From 224e0df87e5bc34233e373213e7df220ed257ab5 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Thu, 15 Dec 2022 12:54:29 -0800 Subject: [PATCH] handle stray server data commands --- src/ReceiveCommands.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index dd8854cf..3890efb7 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -1259,8 +1259,16 @@ static void on_tournament_bracket_updated( static void on_ep3_server_data_request(shared_ptr s, shared_ptr c, uint16_t, uint32_t, const string& data) { // CA - auto l = s->find_lobby(c->lobby_id); - if (!l || !(l->flags & Lobby::Flag::EPISODE_3_ONLY) || !l->is_game()) { + shared_ptr l; + try { + l = s->find_lobby(c->lobby_id); + } catch (const out_of_range&) { + // In rare cases (e.g. when two players end a tournament's match results + // screens at exactly the same time), the client can send a server data + // command when it's not in any lobby at all. We just ignore such commands. + return; + } + if (!(l->flags & Lobby::Flag::EPISODE_3_ONLY) || !l->is_game()) { throw runtime_error("Episode 3 server data request sent outside of Episode 3 game"); }