From 245ebd92c660613c91a12b8c27a04c3ae901bbce Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 8 Sep 2023 10:47:13 -0700 Subject: [PATCH] don't send Ep3 lobby banners again after ending a proxy session --- README.md | 1 + src/Client.hh | 5 ++++- src/ReceiveCommands.cc | 28 ++++++++++++++++++++-------- src/SendCommands.cc | 3 --- tests/GC-Episode3Battle.test.txt | 8 ++++---- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 2f2f871d..3e4e980e 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,7 @@ The following Episode 3 features work well: * Participating in card auctions. (The auction contents must be configured in config.json.) The following Episode 3 features are implemented, but are only partially tested: +* Decorations in lobbies. Currently only images are supported; the game also supports loading custom 3D models in lobbies, but newserv does not implement this (yet). * Spectator teams. There is a known issue that prevents viewing battles unless you're in the spectator team when the battle begins, and spectating clients sometimes crash for an unknown reason. * Battle replays also sometimes cause the client to crash during the replay. Using the $playrec command is therefore not recommended. diff --git a/src/Client.hh b/src/Client.hh index bfa043b3..5e67bc83 100644 --- a/src/Client.hh +++ b/src/Client.hh @@ -106,8 +106,11 @@ struct Client { // Client has received newserv's Episode 3 card definitions, so don't send // them again HAS_EP3_CARD_DEFS = 0x00004000, + // Client has received newserv's Episode 3 media updates, so don't send them + // again + HAS_EP3_MEDIA_UPDATES = 0x00800000, - UNUSED_FLAG_BITS = 0xFF800000, + UNUSED_FLAG_BITS = 0xFF010000, }; uint64_t id; diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index caa29a0d..8fd3683e 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -2479,15 +2479,27 @@ static void on_61_98(shared_ptr s, shared_ptr c, // update and the current tournament entry depend on this flag, we have // to delay sending them until now, instead of sending them during the // login sequence. - if ((c->flags & Client::Flag::IS_EPISODE_3) && !(c->flags & Client::Flag::HAS_EP3_CARD_DEFS)) { - send_ep3_card_list_update(s, c); - for (const auto& banner : s->ep3_lobby_banners) { - send_ep3_media_update(c, banner.type, banner.which, banner.data); + if (c->flags & Client::Flag::IS_EPISODE_3) { + bool flags_changed = false; + if (!(c->flags & Client::Flag::HAS_EP3_CARD_DEFS)) { + send_ep3_card_list_update(s, c); + auto team = c->ep3_tournament_team.lock(); + auto tourn = team ? team->tournament.lock() : nullptr; + if (!(c->flags & Client::Flag::IS_EP3_TRIAL_EDITION)) { + send_ep3_confirm_tournament_entry(s, c, tourn); + } + c->flags |= Client::Flag::HAS_EP3_CARD_DEFS; + flags_changed = true; } - auto team = c->ep3_tournament_team.lock(); - auto tourn = team ? team->tournament.lock() : nullptr; - if (!(c->flags & Client::Flag::IS_EP3_TRIAL_EDITION)) { - send_ep3_confirm_tournament_entry(s, c, tourn); + if (!(c->flags & Client::Flag::HAS_EP3_MEDIA_UPDATES)) { + for (const auto& banner : s->ep3_lobby_banners) { + send_ep3_media_update(c, banner.type, banner.which, banner.data); + c->flags |= Client::Flag::HAS_EP3_MEDIA_UPDATES; + flags_changed = true; + } + } + if (flags_changed) { + send_update_client_config(c); } } diff --git a/src/SendCommands.cc b/src/SendCommands.cc index aa24d8c8..1d246d09 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -2190,9 +2190,6 @@ void send_ep3_card_list_update(shared_ptr s, shared_ptr c) w.write(data); send_command(c, 0xB8, 0x00, w.str()); - - c->flags |= Client::Flag::HAS_EP3_CARD_DEFS; - send_update_client_config(c); } } diff --git a/tests/GC-Episode3Battle.test.txt b/tests/GC-Episode3Battle.test.txt index f96332c3..78b88e22 100644 --- a/tests/GC-Episode3Battle.test.txt +++ b/tests/GC-Episode3Battle.test.txt @@ -2532,10 +2532,6 @@ I 2784 2023-09-05 22:29:00 - [Commands] Sending to C-3 (version=GC command=B8 fl 6EB0 | 3A 30 70 FD E8 3A 2E FF 00 D7 F8 FF E3 02 BD C6 | :0p :. 6EC0 | FF 50 FF 0B CA 5D A3 F8 F4 1F 2A A0 43 F0 E6 FC | P ] * C 6ED0 | F0 8C 0A 08 FF 0B 00 00 | -I 2784 2023-09-05 22:29:00 - [Commands] Sending to C-3 (version=GC command=04 flag=00) -0000 | 04 00 2C 00 00 00 01 00 11 11 11 11 39 98 AC 82 | , 9 -0010 | 0E 89 2A 49 0A 43 02 00 30 45 53 33 00 00 00 00 | *I 0ES3 -0020 | 00 00 FF FF FF FF FF FF FF FF FF FF | I 2784 2023-09-05 22:29:00 - [Commands] Sending to C-3 (version=GC command=CC flag=00) 0000 | CC 00 0C 05 00 00 00 00 00 00 00 00 00 00 00 00 | 0010 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | @@ -2618,6 +2614,10 @@ I 2784 2023-09-05 22:29:00 - [Commands] Sending to C-3 (version=GC command=CC fl 04E0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | 04F0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | 0500 | 00 00 00 00 00 00 00 00 00 00 00 00 | +I 2784 2023-09-05 22:29:00 - [Commands] Sending to C-3 (version=GC command=04 flag=00) +0000 | 04 00 2C 00 00 00 01 00 11 11 11 11 39 98 AC 82 | , 9 +0010 | 0E 89 2A 49 0A 43 02 00 30 45 53 33 00 00 00 00 | *I 0ES3 +0020 | 00 00 FF FF FF FF FF FF FF FF FF FF | I 2784 2023-09-05 22:29:00 - [Commands] Received from C-3 (Tali) (version=GC command=99 flag=00) 0000 | 99 00 04 00 | I 2784 2023-09-05 22:29:00 - [Commands] Received from C-3 (Tali) (version=GC command=B8 flag=00)