Skip to content

Commit

Permalink
fix flash_window_on_name_ping(why did we have an extra hook in GameSe…
Browse files Browse the repository at this point in the history
…ttings that was never referenced?)
  • Loading branch information
DubbleClick committed May 3, 2024
1 parent 5fd9af9 commit 6b2f13d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 50 deletions.
2 changes: 1 addition & 1 deletion GWToolboxdll/Modules/ChatSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
46 changes: 0 additions & 46 deletions GWToolboxdll/Modules/GameSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"<a=1>");
message.insert(end_idx + 5, L"</a>");
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*)
{
Expand Down
1 change: 0 additions & 1 deletion GWToolboxdll/Modules/GameSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand Down
4 changes: 2 additions & 2 deletions GWToolboxdll/Windows/InfoWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
}
Expand Down

0 comments on commit 6b2f13d

Please sign in to comment.