add $exit on game server
This commit is contained in:
+28
-2
@@ -295,11 +295,37 @@ static void server_command_persist(shared_ptr<ServerState>, shared_ptr<Lobby> l,
|
||||
}
|
||||
}
|
||||
|
||||
static void server_command_exit(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
|
||||
shared_ptr<Client> c, const std::u16string&) {
|
||||
if (l->is_game()) {
|
||||
if (c->flags & Client::Flag::IS_EPISODE_3) {
|
||||
c->channel.send(0xED, 0x00);
|
||||
} else {
|
||||
send_text_message(c, u"$C6You must return to\nthe lobby first");
|
||||
}
|
||||
} else {
|
||||
send_self_leave_notification(c);
|
||||
if (!(c->flags & Client::Flag::NO_D6)) {
|
||||
send_message_box(c, u"");
|
||||
}
|
||||
|
||||
const auto& port_name = version_to_login_port_name.at(
|
||||
static_cast<size_t>(c->version()));
|
||||
send_reconnect(c, s->connect_address_for_client(c),
|
||||
s->name_to_port_config.at(port_name)->port);
|
||||
}
|
||||
}
|
||||
|
||||
static void proxy_command_exit(shared_ptr<ServerState>,
|
||||
ProxyServer::LinkedSession& session, const std::u16string&) {
|
||||
if (session.is_in_game) {
|
||||
send_text_message(session.client_channel, u"$C6You must return to\nthe lobby first");
|
||||
if (session.newserv_client_config.cfg.flags & Client::Flag::IS_EPISODE_3) {
|
||||
session.client_channel.send(0xED, 0x00);
|
||||
} else {
|
||||
send_text_message(session.client_channel, u"$C6You must return to\nthe lobby first");
|
||||
}
|
||||
} else {
|
||||
session.close_on_disconnect = true;
|
||||
session.send_to_game_server();
|
||||
}
|
||||
}
|
||||
@@ -1154,7 +1180,7 @@ static const unordered_map<u16string, ChatCommandDefinition> chat_commands({
|
||||
{u"$dbgid", {server_command_dbgid, nullptr, u"Usage:\ndbgid"}},
|
||||
{u"$edit", {server_command_edit, nullptr , u"Usage:\nedit <stat> <value>"}},
|
||||
{u"$event", {server_command_lobby_event, proxy_command_lobby_event, u"Usage:\nevent <name>"}},
|
||||
{u"$exit", {nullptr, proxy_command_exit, u"Usage:\nexit"}},
|
||||
{u"$exit", {server_command_exit, proxy_command_exit, u"Usage:\nexit"}},
|
||||
{u"$gc", {server_command_get_self_card, proxy_command_get_player_card, u"Usage:\ngc"}},
|
||||
{u"$infhp", {server_command_infinite_hp, proxy_command_infinite_hp, u"Usage:\ninfhp"}},
|
||||
{u"$inftp", {server_command_infinite_tp, proxy_command_infinite_tp, u"Usage:\ninftp"}},
|
||||
|
||||
+1
-3
@@ -715,9 +715,7 @@ void ProxyServer::LinkedSession::send_to_game_server(const char* error_message)
|
||||
update_client_config_cmd.cfg = this->newserv_client_config.cfg;
|
||||
this->client_channel.send(0x04, 0x00, &update_client_config_cmd, sizeof(update_client_config_cmd));
|
||||
|
||||
static const vector<string> version_to_port_name({
|
||||
"bb-patch", "console-login", "pc-login", "console-login", "console-login", "bb-init"});
|
||||
const auto& port_name = version_to_port_name.at(static_cast<size_t>(
|
||||
const auto& port_name = version_to_login_port_name.at(static_cast<size_t>(
|
||||
this->version));
|
||||
|
||||
S_Reconnect_19 reconnect_cmd = {{
|
||||
|
||||
@@ -126,17 +126,13 @@ static vector<MenuItem> proxy_options_menu_for_client(
|
||||
|
||||
|
||||
static void send_client_to_lobby_server(shared_ptr<ServerState> s, shared_ptr<Client> c) {
|
||||
static const vector<string> version_to_port_name({
|
||||
"bb-lobby", "console-lobby", "pc-lobby", "console-lobby", "console-lobby", "bb-lobby"});
|
||||
const auto& port_name = version_to_port_name.at(static_cast<size_t>(c->version()));
|
||||
const auto& port_name = version_to_lobby_port_name.at(static_cast<size_t>(c->version()));
|
||||
send_reconnect(c, s->connect_address_for_client(c),
|
||||
s->name_to_port_config.at(port_name)->port);
|
||||
}
|
||||
|
||||
static void send_client_to_proxy_server(shared_ptr<ServerState> s, shared_ptr<Client> c) {
|
||||
static const vector<string> version_to_port_name({
|
||||
"", "dc-proxy", "pc-proxy", "gc-proxy", "xb-proxy", "bb-proxy"});
|
||||
const auto& port_name = version_to_port_name.at(static_cast<size_t>(c->version()));
|
||||
const auto& port_name = version_to_proxy_port_name.at(static_cast<size_t>(c->version()));
|
||||
uint16_t local_port = s->name_to_port_config.at(port_name)->port;
|
||||
|
||||
s->proxy_server->delete_session(c->license->serial_number);
|
||||
@@ -2215,9 +2211,7 @@ static void on_A0(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||
send_message_box(c, u"");
|
||||
}
|
||||
|
||||
static const vector<string> version_to_port_name({
|
||||
"bb-patch", "console-login", "pc-login", "console-login", "console-login", "bb-init"});
|
||||
const auto& port_name = version_to_port_name.at(static_cast<size_t>(c->version()));
|
||||
const auto& port_name = version_to_login_port_name.at(static_cast<size_t>(c->version()));
|
||||
|
||||
send_reconnect(c, s->connect_address_for_client(c),
|
||||
s->name_to_port_config.at(port_name)->port);
|
||||
|
||||
+1
-3
@@ -875,9 +875,7 @@ void send_card_search_result_t(
|
||||
shared_ptr<Client> c,
|
||||
shared_ptr<Client> result,
|
||||
shared_ptr<Lobby> result_lobby) {
|
||||
static const vector<string> version_to_port_name({
|
||||
"bb-lobby", "console-lobby", "pc-lobby", "console-lobby", "console-lobby", "bb-lobby"});
|
||||
const auto& port_name = version_to_port_name.at(static_cast<size_t>(c->version()));
|
||||
const auto& port_name = version_to_lobby_port_name.at(static_cast<size_t>(c->version()));
|
||||
|
||||
S_GuildCardSearchResult<CommandHeaderT, CharT> cmd;
|
||||
cmd.player_tag = 0x00010000;
|
||||
|
||||
@@ -10,6 +10,13 @@ using namespace std;
|
||||
|
||||
|
||||
|
||||
const vector<string> version_to_login_port_name({
|
||||
"bb-patch", "console-login", "pc-login", "console-login", "console-login", "bb-init"});
|
||||
const vector<string> version_to_lobby_port_name({
|
||||
"bb-patch", "console-lobby", "pc-lobby", "console-lobby", "console-lobby", "bb-lobby"});
|
||||
const vector<string> version_to_proxy_port_name({
|
||||
"", "dc-proxy", "pc-proxy", "gc-proxy", "xb-proxy", "bb-proxy"});
|
||||
|
||||
uint16_t flags_for_version(GameVersion version, int64_t sub_version) {
|
||||
switch (sub_version) {
|
||||
case -1: // Initial check (before sub_version recognition)
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
|
||||
enum class GameVersion {
|
||||
@@ -23,6 +26,10 @@ enum class ServerBehavior {
|
||||
PROXY_SERVER,
|
||||
};
|
||||
|
||||
extern const std::vector<std::string> version_to_login_port_name;
|
||||
extern const std::vector<std::string> version_to_lobby_port_name;
|
||||
extern const std::vector<std::string> version_to_proxy_port_name;
|
||||
|
||||
uint16_t flags_for_version(GameVersion version, int64_t sub_version);
|
||||
const char* name_for_version(GameVersion version);
|
||||
GameVersion version_for_name(const char* name);
|
||||
|
||||
Reference in New Issue
Block a user