From f5ed347734dab08d3cad4417aab6b5bf05236586 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 29 Nov 2024 22:19:05 -0800 Subject: [PATCH] convert private word select messages to text chat messages --- src/CommandFormats.hh | 3 ++- src/ReceiveSubcommands.cc | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/CommandFormats.hh b/src/CommandFormats.hh index 60eb47f7..0d9874f8 100644 --- a/src/CommandFormats.hh +++ b/src/CommandFormats.hh @@ -502,7 +502,8 @@ struct S_UpdateClientConfig_BB_04 { // used, but are often nonzero and set to the value 4. (This is probably done so // that the field is always a valid ASCII character and also never terminates // the chat string accidentally.) We call this byte private_flags in the places -// where newserv uses it. +// where newserv uses it; there is a similar byte in the 6xBD (private word +// select) command. // 07 (S->C): Ship or block select menu // Internal name: RcvDirList diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index 0d54656f..7ad47862 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -2506,16 +2506,15 @@ static void on_ep3_private_word_select_bb_bank_action(shared_ptr c, uint const auto& cmd = check_size_t(data, size); s->word_select_table->validate(cmd.message, c->version()); - G_PrivateWordSelect_Ep3_6xBD masked_cmd = { - {0xBD, sizeof(G_PrivateWordSelect_Ep3_6xBD) >> 2, cmd.header.client_id}, - // "Please use the Whispers function." - {0x0001, 0x0001, {0x00C1, 0x02C7, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF}, 0x0000, 0x0000}, - cmd.private_flags, - {0, 0, 0}}; - + string from_name = c->character()->disp.name.decode(c->language()); + static const string whisper_text = "(whisper)"; auto send_to_client = [&](shared_ptr lc) -> void { if (cmd.private_flags & (1 << lc->lobby_client_id)) { - send_command_t(lc, command, flag, masked_cmd); + try { + send_chat_message(lc, c->login->account->account_id, from_name, whisper_text, cmd.private_flags); + } catch (const runtime_error& e) { + lc->log.warning("Failed to encode chat message: %s", e.what()); + } } else { send_command_t(lc, command, flag, cmd); }