diff --git a/src/Episode3/Server.cc b/src/Episode3/Server.cc index 1f982a42..dccac493 100644 --- a/src/Episode3/Server.cc +++ b/src/Episode3/Server.cc @@ -2066,6 +2066,12 @@ void Server::handle_CAx21_end_battle(const string& data) { in_cmd.header.subsubcommand, "END BATTLE"); if (this->setup_phase == SetupPhase::BATTLE_ENDED) { this->battle_finished = true; + + // This logic isn't part of the original implementation. + auto l = this->lobby.lock(); + if (l) { + send_ep3_disband_watcher_lobbies(l); + } } } diff --git a/src/SendCommands.cc b/src/SendCommands.cc index 769a0bf1..4e4bfc1f 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -2811,6 +2811,16 @@ void send_ep3_card_auction(shared_ptr s, shared_ptr l) { send_command_t(l, 0xEF, num_cards, cmd); } +void send_ep3_disband_watcher_lobbies(shared_ptr primary_l) { + for (auto watcher_l : primary_l->watcher_lobbies) { + if (!watcher_l->is_ep3()) { + throw logic_error("spectator team is not an Episode 3 lobby"); + } + primary_l->log.info("Disbanding watcher lobby %" PRIX32, watcher_l->lobby_id); + send_command(watcher_l, 0xED, 0x00); + } +} + void send_server_time(shared_ptr c) { uint64_t t = now(); diff --git a/src/SendCommands.hh b/src/SendCommands.hh index 5a5df88a..01bb29a1 100644 --- a/src/SendCommands.hh +++ b/src/SendCommands.hh @@ -366,10 +366,9 @@ void send_ep3_tournament_details( std::shared_ptr t); void send_ep3_game_details( std::shared_ptr c, std::shared_ptr l); - void send_ep3_update_spectator_count(std::shared_ptr l); - void send_ep3_card_auction(std::shared_ptr s, std::shared_ptr l); +void send_ep3_disband_watcher_lobbies(std::shared_ptr primary_l); // Pass mask_key = 0 to unmask the command void set_mask_for_ep3_game_command(void* vdata, size_t size, uint8_t mask_key); diff --git a/src/ServerState.cc b/src/ServerState.cc index 308159b5..1331a1d4 100644 --- a/src/ServerState.cc +++ b/src/ServerState.cc @@ -250,14 +250,7 @@ void ServerState::remove_lobby(uint32_t lobby_id) { } l->watched_lobby.reset(); } else { - // Tell all players in all spectator teams to go back to the lobby - for (auto watcher_l : l->watcher_lobbies) { - if (!watcher_l->is_ep3()) { - throw logic_error("spectator team is not an Episode 3 lobby"); - } - l->log.info("Disbanding watcher lobby %" PRIX32, watcher_l->lobby_id); - send_command(watcher_l, 0xED, 0x00); - } + send_ep3_disband_watcher_lobbies(l); } l->log.info("Deleted lobby");