From f45623336f82449a66cabae81dcb66ec3e731bf5 Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 2 Dec 2024 08:42:54 +0000 Subject: [PATCH] Fixed bugs around chat filter/settings --- GWToolboxdll/Modules/ChatFilter.cpp | 2 +- GWToolboxdll/Modules/ChatSettings.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/GWToolboxdll/Modules/ChatFilter.cpp b/GWToolboxdll/Modules/ChatFilter.cpp index b4d502780..834909ef9 100644 --- a/GWToolboxdll/Modules/ChatFilter.cpp +++ b/GWToolboxdll/Modules/ChatFilter.cpp @@ -808,7 +808,7 @@ void ChatFilter::Initialize() GW::UI::UIMessage::kPlayerChatMessage }; for (auto message_id : message_ids) { - GW::UI::RegisterUIMessageCallback(&BlockIfApplicable_Entry, message_id, OnUIMessage, -0x8000); + GW::UI::RegisterUIMessageCallback(&BlockIfApplicable_Entry, message_id, OnUIMessage, -0x8001); } } diff --git a/GWToolboxdll/Modules/ChatSettings.cpp b/GWToolboxdll/Modules/ChatSettings.cpp index 8fe3f2782..b1daeee23 100644 --- a/GWToolboxdll/Modules/ChatSettings.cpp +++ b/GWToolboxdll/Modules/ChatSettings.cpp @@ -109,8 +109,6 @@ namespace { } - std::wstring rewritten_message; - // Allow clickable name when a player pings "I'm following X" or "I'm targeting X" void OnLocalChatMessage(GW::HookStatus* status, GW::UI::UIMessage, void* wParam, void*) { @@ -121,8 +119,7 @@ namespace { return; if (*packet->message != 0x778 && *packet->message != 0x781) return; // Not "I'm Following X" or "I'm Targeting X" message. - - rewritten_message = packet->message; + std::wstring rewritten_message = packet->message; size_t start_idx = rewritten_message.find(L"\xba9\x107"); if (start_idx == std::wstring::npos) { return; // Not a player name. @@ -146,6 +143,9 @@ namespace { rewritten_message.insert(start_idx, L""); rewritten_message.insert(end_idx + 5, L""); + status->blocked = true; + GW::Chat::WriteChatEnc(packet->channel, rewritten_message.c_str(), sender->name_enc); + packet->message = rewritten_message.data(); } @@ -298,6 +298,8 @@ namespace { } break; case GW::UI::UIMessage::kPlayerChatMessage: { OnLocalChatMessage(status, message_id, wParam, lParam); + if (status->blocked) + return; // Hide player chat message speech bubbles by redirecting from 0x10000081 to 0x1000007E if (hide_player_speech_bubbles) return;