From db099ed2dda03c126863f7c21b7a44940693c065 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Wed, 30 Mar 2022 11:34:01 -0700 Subject: [PATCH] make proxy change ship behavior cleaner --- src/ProxyServer.cc | 20 ++++++++++++++++++++ src/ReceiveCommands.cc | 3 +-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/ProxyServer.cc b/src/ProxyServer.cc index 15ee512e..b03ea6d4 100644 --- a/src/ProxyServer.cc +++ b/src/ProxyServer.cc @@ -234,6 +234,9 @@ void ProxyServer::UnlinkedSession::on_client_input() { log(ERROR, "[ProxyServer/%08" PRIX32 "] Client configuration is invalid; cannot open session", license->serial_number); } else { + // If the client goes back to newserv, we need to set the welcome + // message flag so the server will know what to do + client_config.flags |= ClientFlag::AT_WELCOME_MESSAGE; session.reset(new LinkedSession( this->server, this->local_port, @@ -496,6 +499,23 @@ void ProxyServer::LinkedSession::on_client_input() { // These will take you back to the newserv main menu instead of the // proxied service's menu + // Delete all the other players + for (size_t x = 0; x < this->lobby_players.size(); x++) { + if (this->lobby_players[x].guild_card_number == 0) { + continue; + } + uint8_t leaving_id = x; + uint8_t leader_id = this->lobby_client_id; + struct { + uint8_t client_id; + uint8_t leader_id; + uint16_t unused; + } __attribute__((packed)) cmd = {leaving_id, leader_id, 0}; + send_command(this->client_bev.get(), this->version, + this->client_output_crypt.get(), 0x69, leaving_id, &cmd, + sizeof(cmd), name.c_str()); + } + // Restore the newserv client config, so the client gets its newserv // guild card number back and the login server knows e.g. not to show // the welcome message (if the appropriate flag is set) diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index ad234b56..ba743f30 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -91,7 +91,7 @@ void process_connect(std::shared_ptr s, std::shared_ptr c) break; } - case ServerBehavior::LOGIN_SERVER: { + case ServerBehavior::LOGIN_SERVER: if (!s->welcome_message.empty()) { c->flags |= ClientFlag::AT_WELCOME_MESSAGE; } @@ -100,7 +100,6 @@ void process_connect(std::shared_ptr s, std::shared_ptr c) send_change_event(c, s->pre_lobby_event); } break; - } case ServerBehavior::LOBBY_SERVER: case ServerBehavior::DATA_SERVER_BB: