From 3bb061951dc9d57ed1645ec2ee433ee41d064086 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 10 Feb 2023 10:48:02 -0800 Subject: [PATCH] add name color proxy option --- src/Client.hh | 1 + src/Menu.hh | 7 ++++--- src/ProxyCommands.cc | 38 +++++++++++++++++++++++++------------- src/ReceiveCommands.cc | 5 +++++ 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/Client.hh b/src/Client.hh index cee501e3..184825b3 100644 --- a/src/Client.hh +++ b/src/Client.hh @@ -42,6 +42,7 @@ struct ClientOptions { bool suppress_remote_login; bool zero_remote_guild_card; bool ep3_infinite_meseta; + bool red_name; int64_t function_call_return_value; // -1 = don't block function calls ClientOptions(); diff --git a/src/Menu.hh b/src/Menu.hh index 0e855be1..c3878f3d 100644 --- a/src/Menu.hh +++ b/src/Menu.hh @@ -66,9 +66,10 @@ namespace ProxyOptionsMenuItemID { constexpr uint32_t BLOCK_EVENTS = 0xAA5555AA; constexpr uint32_t BLOCK_PATCHES = 0xAA6666AA; constexpr uint32_t SAVE_FILES = 0xAA7777AA; - constexpr uint32_t SUPPRESS_LOGIN = 0xAA8888AA; - constexpr uint32_t SKIP_CARD = 0xAA9999AA; - constexpr uint32_t EP3_INFINITE_MESETA = 0xAAAAAAAA; + constexpr uint32_t RED_NAME = 0xAA8888AA; + constexpr uint32_t SUPPRESS_LOGIN = 0xAA9999AA; + constexpr uint32_t SKIP_CARD = 0xAAAAAAAA; + constexpr uint32_t EP3_INFINITE_MESETA = 0xAABBBBAA; } diff --git a/src/ProxyCommands.cc b/src/ProxyCommands.cc index fc100320..d83816ea 100644 --- a/src/ProxyCommands.cc +++ b/src/ProxyCommands.cc @@ -989,25 +989,37 @@ static HandlerResult S_6x(shared_ptr, static HandlerResult C_GXB_61(shared_ptr, ProxyServer::LinkedSession& session, uint16_t, uint32_t flag, string& data) { - if (session.options.enable_chat_filter) { - if (session.version == GameVersion::BB) { - auto& pd = check_size_t(data, sizeof(PSOPlayerDataBB), 0xFFFF); - add_color_inplace(pd.info_board.data(), pd.info_board.size()); + bool modified = false; + // TODO: We should check if the info board text was actually modified and + // return MODIFIED if so. + if (session.version == GameVersion::BB) { + auto& pd = check_size_t(data, sizeof(PSOPlayerDataBB), 0xFFFF); + if (session.options.enable_chat_filter) { + add_color_inplace(pd.info_board.data(), pd.info_board.size()); + } + if (session.options.red_name && pd.disp.name_color != 0xFFFF0000) { + pd.disp.name_color = 0xFFFF0000; + modified = true; + } + + } else { + PSOPlayerDataV3* pd; + if (flag == 4) { // Episode 3 + pd = reinterpret_cast(&check_size_t(data)); } else { - PSOPlayerDataV3* pd; - if (flag == 4) { // Episode 3 - pd = reinterpret_cast(&check_size_t(data)); - } else { - pd = &check_size_t(data, sizeof(PSOPlayerDataV3), 0xFFFF); - } + pd = &check_size_t(data, sizeof(PSOPlayerDataV3), 0xFFFF); + } + if (session.options.enable_chat_filter) { add_color_inplace(pd->info_board.data(), pd->info_board.size()); } + if (session.options.red_name && pd->disp.name_color != 0xFFFF0000) { + pd->disp.name_color = 0xFFFF0000; + modified = true; + } } - // TODO: We should check if the info board text was actually modified and - // return MODIFIED if so. - return HandlerResult::Type::FORWARD; + return modified ? HandlerResult::Type::MODIFIED : HandlerResult::Type::FORWARD; } static HandlerResult C_GX_D9(shared_ptr, diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index c3d05b42..a7611325 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -81,6 +81,7 @@ static const unordered_map proxy_options_menu_descrip {ProxyOptionsMenuItemID::BLOCK_EVENTS, u"Disable seasonal\nevents in the lobby\nand in games"}, {ProxyOptionsMenuItemID::BLOCK_PATCHES, u"Disable patches sent\nby the remote server"}, {ProxyOptionsMenuItemID::SAVE_FILES, u"Save local copies of\nfiles from the\nremote server\n(quests, etc.)"}, + {ProxyOptionsMenuItemID::RED_NAME, u"Set your name\ncolor to red"}, {ProxyOptionsMenuItemID::SUPPRESS_LOGIN, u"Use an alternate\nlogin sequence"}, {ProxyOptionsMenuItemID::SKIP_CARD, u"Use an alternate\nvalue for your initial\nGuild Card"}, }); @@ -116,6 +117,7 @@ static vector proxy_options_menu_for_client( add_option(ProxyOptionsMenuItemID::SAVE_FILES, c->options.save_files, u"Save files"); } if (s->proxy_enable_login_options) { + add_option(ProxyOptionsMenuItemID::RED_NAME, c->options.red_name, u"Red name"); add_option(ProxyOptionsMenuItemID::SUPPRESS_LOGIN, c->options.suppress_remote_login, u"Skip login"); add_option(ProxyOptionsMenuItemID::SKIP_CARD, c->options.zero_remote_guild_card, u"Skip card"); } @@ -1823,6 +1825,9 @@ static void on_10(shared_ptr s, shared_ptr c, case ProxyOptionsMenuItemID::SAVE_FILES: c->options.save_files = !c->options.save_files; goto resend_proxy_options_menu; + case ProxyOptionsMenuItemID::RED_NAME: + c->options.red_name = !c->options.red_name; + goto resend_proxy_options_menu; case ProxyOptionsMenuItemID::SUPPRESS_LOGIN: c->options.suppress_remote_login = !c->options.suppress_remote_login; goto resend_proxy_options_menu;