From 6b2f13d4ce8b06254e4b69e078b0ff32d7b7e06f Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 3 May 2024 17:22:51 +0200 Subject: [PATCH] fix flash_window_on_name_ping(why did we have an extra hook in GameSettings that was never referenced?) --- GWToolboxdll/Modules/ChatSettings.cpp | 2 +- GWToolboxdll/Modules/GameSettings.cpp | 46 --------------------------- GWToolboxdll/Modules/GameSettings.h | 1 - GWToolboxdll/Windows/InfoWindow.cpp | 4 +-- 4 files changed, 3 insertions(+), 50 deletions(-) diff --git a/GWToolboxdll/Modules/ChatSettings.cpp b/GWToolboxdll/Modules/ChatSettings.cpp index 47d3917ca..ff0a6e466 100644 --- a/GWToolboxdll/Modules/ChatSettings.cpp +++ b/GWToolboxdll/Modules/ChatSettings.cpp @@ -170,7 +170,7 @@ namespace { if (end_idx == std::wstring::npos) { return; // Not a player name, this should never happen. } - const std::wstring player_pinged = GuiUtils::SanitizePlayerName(message.substr(start_idx, end_idx)); + const std::wstring player_pinged = GuiUtils::SanitizePlayerName(message.substr(start_idx, end_idx - start_idx)); if (player_pinged.empty()) { return; // No recipient } diff --git a/GWToolboxdll/Modules/GameSettings.cpp b/GWToolboxdll/Modules/GameSettings.cpp index 14a86bc9f..07c08582a 100644 --- a/GWToolboxdll/Modules/GameSettings.cpp +++ b/GWToolboxdll/Modules/GameSettings.cpp @@ -2316,52 +2316,6 @@ void GameSettings::OnServerMessage(const GW::HookStatus*, GW::Packet::StoC::Mess } } - -// Allow clickable name when a player pings "I'm following X" or "I'm targeting X" -void GameSettings::OnLocalChatMessage(GW::HookStatus* status, const GW::Packet::StoC::MessageLocal* pak) -{ - if (status->blocked) { - return; // Sender blocked, packet handled. - } - if (pak->channel != std::to_underlying(GW::Chat::Channel::CHANNEL_GROUP) || !pak->player_number) { - return; // Not team chat or no sender - } - const auto core = GetMessageCore(); - if (core[0] != 0x778 && core[0] != 0x781) { - return; // Not "I'm Following X" or "I'm Targeting X" message. - } - std::wstring message(core); - size_t start_idx = message.find(L"\xba9\x107"); - if (start_idx == std::wstring::npos) { - return; // Not a player name. - } - start_idx += 2; - const size_t end_idx = message.find(L'\x1', start_idx); - if (end_idx == std::wstring::npos) { - return; // Not a player name, this should never happen. - } - const auto player_pinged = SanitizePlayerName(message.substr(start_idx, end_idx)); - if (player_pinged.empty()) { - return; // No recipient - } - const auto sender = GW::PlayerMgr::GetPlayerByID(pak->player_number); - if (!sender) { - return; // No sender - } - if (flash_window_on_name_ping && GetPlayerName() == player_pinged) { - FlashWindow(); // Flash window - we've been followed! - } - // Allow clickable player name - message.insert(start_idx, L""); - message.insert(end_idx + 5, L""); - PendingChatMessage* m = PendingChatMessage::queuePrint(GW::Chat::Channel::CHANNEL_GROUP, message.c_str(), sender->name_enc); - if (m) { - ChatSettings::AddPendingMessage(m); - } - ClearMessageCore(); - status->blocked = true; // consume original packet. -} - // Automatic /age on vanquish void GameSettings::OnVanquishComplete(const GW::HookStatus*, GW::Packet::StoC::VanquishComplete*) { diff --git a/GWToolboxdll/Modules/GameSettings.h b/GWToolboxdll/Modules/GameSettings.h index 2f3f249f5..e29e6fc59 100644 --- a/GWToolboxdll/Modules/GameSettings.h +++ b/GWToolboxdll/Modules/GameSettings.h @@ -79,7 +79,6 @@ class GameSettings : public ToolboxModule { static void OnPlayerJoinInstance(GW::HookStatus*, GW::Packet::StoC::PlayerJoinInstance*); static void OnPartyInviteReceived(const GW::HookStatus*, const GW::Packet::StoC::PartyInviteReceived_Create*); void OnPartyPlayerJoined(const GW::HookStatus*, const GW::Packet::StoC::PartyPlayerAdd*); - static void OnLocalChatMessage(GW::HookStatus*, const GW::Packet::StoC::MessageLocal*); static void OnServerMessage(const GW::HookStatus*, GW::Packet::StoC::MessageServer*); void OnScreenShake(GW::HookStatus*, const void* packet) const; static void OnWriteChat(GW::HookStatus* status, GW::UI::UIMessage msgid, void* wParam, void*); diff --git a/GWToolboxdll/Windows/InfoWindow.cpp b/GWToolboxdll/Windows/InfoWindow.cpp index d38da4c39..c0ad28d76 100644 --- a/GWToolboxdll/Windows/InfoWindow.cpp +++ b/GWToolboxdll/Windows/InfoWindow.cpp @@ -762,7 +762,7 @@ namespace { record_textures = ImGui::CollapsingHeader("Loaded Textures"); if (record_textures) { ImGui::PushID(&textures_created); - const ImVec2 scaled_size = { 64.f,64.f }; + constexpr ImVec2 scaled_size = { 64.f,64.f }; constexpr ImVec4 tint(1, 1, 1, 1); const auto normal_bg = ImColor(IM_COL32(0, 0, 0, 0)); constexpr auto uv0 = ImVec2(0, 0); @@ -790,7 +790,7 @@ namespace { ImGui::NextSpacedElement(); ImGui::ImageButton(*texture, scaled_size, uv0, uv1, -1, normal_bg, tint); if (ImGui::IsItemHovered()) { - static wchar_t out[3] = { 0 }; + static wchar_t out[3]; FileIdToFileHash(texture_file_ids[texture], out); ImGui::SetTooltip("File ID: 0x%08x\nFile Hash: 0x%04x 0x%04x", texture_file_ids[texture], out[0], out[1]); }