add proxy commands to override lobby params

This commit is contained in:
Martin Michelsen
2022-03-31 23:33:43 -07:00
parent 8a9e1a2049
commit edd9f4ea8f
3 changed files with 58 additions and 2 deletions
+19 -2
View File
@@ -304,6 +304,9 @@ ProxyServer::LinkedSession::LinkedSession(
newserv_client_config(newserv_client_config),
suppress_newserv_commands(true),
enable_chat_filter(true),
override_section_id(-1),
override_lobby_event(-1),
override_lobby_number(-1),
lobby_players(12),
lobby_client_id(0) {
memset(&this->next_destination, 0, sizeof(this->next_destination));
@@ -912,7 +915,7 @@ void ProxyServer::LinkedSession::on_server_input() {
log(WARNING, "[ProxyServer/%08" PRIX32 "] Lobby join command is incorrect size (expected 0x%zX bytes, received 0x%zX bytes)",
this->license->serial_number, expected_size, data.size());
} else {
const auto* cmd = reinterpret_cast<const S_JoinLobby_GC_65_67_68*>(data.data());
auto* cmd = reinterpret_cast<S_JoinLobby_GC_65_67_68*>(data.data());
this->lobby_client_id = cmd->client_id;
@@ -930,6 +933,13 @@ void ProxyServer::LinkedSession::on_server_input() {
this->lobby_players[index].name.c_str());
}
}
if (this->override_lobby_event >= 0) {
cmd->event = this->override_lobby_event;
}
if (this->override_lobby_event >= 0) {
cmd->lobby_number = this->override_lobby_number;
}
}
break;
}
@@ -947,7 +957,7 @@ void ProxyServer::LinkedSession::on_server_input() {
log(WARNING, "[ProxyServer/%08" PRIX32 "] Game join command is incorrect size (expected 0x%zX bytes, received 0x%zX bytes)",
this->license->serial_number, expected_size, data.size());
} else {
const auto* cmd = reinterpret_cast<const S_JoinGame_GC_64*>(data.data());
auto* cmd = reinterpret_cast<S_JoinGame_GC_64*>(data.data());
this->lobby_client_id = cmd->client_id;
@@ -963,6 +973,13 @@ void ProxyServer::LinkedSession::on_server_input() {
this->lobby_players[x].guild_card_number,
this->lobby_players[x].name.c_str());
}
if (this->override_section_id >= 0) {
cmd->section_id = this->override_section_id;
}
if (this->override_lobby_event >= 0) {
cmd->event = this->override_lobby_event;
}
}
break;
}
+3
View File
@@ -50,6 +50,9 @@ public:
ClientConfig newserv_client_config;
bool suppress_newserv_commands;
bool enable_chat_filter;
int16_t override_section_id;
int16_t override_lobby_event;
int16_t override_lobby_number;
struct LobbyPlayer {
uint32_t guild_card_number;
+36
View File
@@ -97,6 +97,18 @@ Proxy commands (these will only work when exactly one client is connected):\n\
Send a lobby event update to yourself.\n\
warp <area-id>\n\
Send yourself to a specific area.\n\
set-section-id [section-id]\n\
Override the section ID for games you create or join. This affects the\n\
active drop chart if you are the leader of the game and the server doesn't\n\
override drops entirely. If no argument is given, clears the override.\n\
set-event [event]\n\
Override the lobby event for all lobbies and games you join. This applies\n\
only to you; other players do not see this override. If no argument is\n\
given, clears the override.\n\
set-lobby-number [number]\n\
Override the lobby type for all lobbies you join. This applies only to you;\n\
other players do not see this override. If no argument is given, clears the\n\
override.\n\
set-chat-filter <on|off>\n\
Enable or disable chat filtering (enabled by default). Chat filtering\n\
applies newserv\'s standard character replacements to chat messages (for\n\
@@ -323,6 +335,30 @@ Proxy commands (these will only work when exactly one client is connected):\n\
session->send_to_end(data, true);
} else if (command_name == "set-section-id") {
auto session = this->get_proxy_session();
if (command_args.empty()) {
session->override_section_id = -1;
} else {
session->override_section_id = section_id_for_name(command_args);
}
} else if (command_name == "set-event") {
auto session = this->get_proxy_session();
if (command_args.empty()) {
session->override_lobby_event = -1;
} else {
session->override_lobby_event = event_for_name(command_args);
}
} else if (command_name == "set-lobby-number") {
auto session = this->get_proxy_session();
if (command_args.empty()) {
session->override_lobby_number = -1;
} else {
session->override_lobby_number = lobby_type_for_name(command_args);
}
} else if (command_name == "set-chat-filter") {
auto session = this->get_proxy_session();