From d7bb3b3576e31f703dfde80f597f50d4aef6b582 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sun, 18 Jun 2023 22:56:43 -0700 Subject: [PATCH] implement Ep3 spectator sound forwarding --- src/ReceiveSubcommands.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index a1ca1aa5..5be9d700 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -205,6 +205,26 @@ static void on_forward_check_size_ep3_game(shared_ptr, //////////////////////////////////////////////////////////////////////////////// // Ep3 subcommands +static void on_ep3_sound_chat(shared_ptr, + shared_ptr l, shared_ptr c, uint8_t command, uint8_t flag, + const void* data, size_t size) { + // Unlike the 6x and C9 commands, subcommands sent with the CB command are + // forwarded from spectator teams to the primary team. The client only uses this + // behavior for the 6xBE command (sound chat), and newserv enforces this rule. + if (!(c->flags & Client::Flag::IS_EPISODE_3)) { + throw runtime_error("non-Episode 3 client sent sound chat command"); + } + + if ((command == 0xCB) && (l->flags & Lobby::Flag::IS_SPECTATOR_TEAM)) { + auto watched_lobby = l->watched_lobby.lock(); + if (watched_lobby) { + forward_subcommand(watched_lobby, c, command, flag, data, size); + } + } + + forward_subcommand(l, c, command, flag, data, size); +} + static void on_ep3_battle_subs(shared_ptr s, shared_ptr l, shared_ptr c, uint8_t command, uint8_t flag, const void* orig_data, size_t size) {