From c79e5017ad1c2069c4ea71dd4cff906d63abab8f Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sat, 10 Feb 2024 09:37:47 -0800 Subject: [PATCH] clear ep3 server state on 6F --- src/CommandFormats.hh | 13 ++++++------- src/ReceiveCommands.cc | 27 +++++++++++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/CommandFormats.hh b/src/CommandFormats.hh index a6826c0e..d7ca29be 100644 --- a/src/CommandFormats.hh +++ b/src/CommandFormats.hh @@ -2743,13 +2743,12 @@ struct C_VerifyLicense_BB_DB { pstring game_tag; // "psopc2" } __packed__; -// DC: Player menu state (Episode 3) -// No arguments. It seems the client expects the server to respond with another -// DC command, the contents and flag of which are ignored entirely - all it does -// is set a global flag on the client. This could be the mechanism for waiting -// until all players are at the counter, like how AC (quest barrier) works. I -// haven't spent any time investigating what this actually does; newserv just -// immediately responds to any DC from an Episode 3 client. +// DC: Set battle in progress flag (Episode 3) +// No arguments except header.flag when sent by the client. When header.flag is +// 1, the game should be locked - no players should be allowed to join. In this +// case, the client waits for the server to respond with another DC command +// before proceeding with battle setup. When header.flag is 0, the game should +// be unlocked, and the client does not wait for a response from the server. // DC: Guild card data (BB) diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 154f6469..71dc9805 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -1643,13 +1643,6 @@ static void on_CA_Ep3(shared_ptr c, uint16_t, uint32_t, string& data) { } if (s->ep3_behavior_flags & Episode3::BehaviorFlag::ENABLE_RECORDING) { - if (l->battle_record) { - for (const auto& c : l->clients) { - if (c) { - c->ep3_prev_battle_record = l->battle_record; - } - } - } l->battle_record = make_shared(s->ep3_behavior_flags); for (auto existing_c : l->clients) { if (existing_c) { @@ -1666,9 +1659,6 @@ static void on_CA_Ep3(shared_ptr c, uint16_t, uint32_t, string& data) { } } if (s->ep3_behavior_flags & Episode3::BehaviorFlag::ENABLE_STATUS_MESSAGES) { - if (c->ep3_prev_battle_record) { - send_text_message(l, "$C6Recording complete"); - } send_text_message(l, "$C6Recording enabled"); } } @@ -4433,6 +4423,23 @@ static void on_6F(shared_ptr c, uint16_t command, uint32_t, string& data } } + if (l->ep3_server && l->ep3_server->battle_finished) { + auto s = l->require_server_state(); + l->log.info("Deleting Episode 3 server state"); + l->ep3_server.reset(); + if (l->battle_record) { + for (const auto& c : l->clients) { + if (c) { + c->ep3_prev_battle_record = l->battle_record; + if ((s->ep3_behavior_flags & Episode3::BehaviorFlag::ENABLE_STATUS_MESSAGES)) { + send_text_message(l, "$C6Recording complete"); + } + } + } + l->battle_record.reset(); + } + } + send_server_time(c); if (c->config.check_flag(Client::Flag::DEBUG_ENABLED)) { string variations_str;