From c5061ee2fc7ff11da28e2661056b24b5e74dc9f4 Mon Sep 17 00:00:00 2001 From: rei-2 <174158077+rei-2@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:51:13 -0400 Subject: [PATCH] fix region selector --- Amalgam/Amalgam.vcxproj | 3 ++- Amalgam/Amalgam.vcxproj.filters | 3 ++- ...amNetworkingUtils_GetPingToDataCenter.cpp} | 21 ++++++++++++++----- Amalgam/src/SDK/Definitions/Interfaces.h | 1 + .../Interfaces/CTFGCClientSystem.h | 5 +++++ 5 files changed, 26 insertions(+), 7 deletions(-) rename Amalgam/src/Hooks/{ISteamNetworkingUtils_GetDirectPingToPOP.cpp => ISteamNetworkingUtils_GetPingToDataCenter.cpp} (82%) create mode 100644 Amalgam/src/SDK/Definitions/Interfaces/CTFGCClientSystem.h diff --git a/Amalgam/Amalgam.vcxproj b/Amalgam/Amalgam.vcxproj index 6bf5a364..ff72cc5c 100644 --- a/Amalgam/Amalgam.vcxproj +++ b/Amalgam/Amalgam.vcxproj @@ -529,7 +529,7 @@ - + @@ -629,6 +629,7 @@ + diff --git a/Amalgam/Amalgam.vcxproj.filters b/Amalgam/Amalgam.vcxproj.filters index 2e5c8bb5..e2686880 100644 --- a/Amalgam/Amalgam.vcxproj.filters +++ b/Amalgam/Amalgam.vcxproj.filters @@ -154,7 +154,7 @@ - + @@ -437,6 +437,7 @@ + diff --git a/Amalgam/src/Hooks/ISteamNetworkingUtils_GetDirectPingToPOP.cpp b/Amalgam/src/Hooks/ISteamNetworkingUtils_GetPingToDataCenter.cpp similarity index 82% rename from Amalgam/src/Hooks/ISteamNetworkingUtils_GetDirectPingToPOP.cpp rename to Amalgam/src/Hooks/ISteamNetworkingUtils_GetPingToDataCenter.cpp index e6747786..eadcb659 100644 --- a/Amalgam/src/Hooks/ISteamNetworkingUtils_GetDirectPingToPOP.cpp +++ b/Amalgam/src/Hooks/ISteamNetworkingUtils_GetPingToDataCenter.cpp @@ -1,5 +1,7 @@ #include "../SDK/SDK.h" +MAKE_SIGNATURE(CTFGCClientSystem_PingThink, "client.dll", "48 89 4C 24 ? 55 41 54 41 55 48 8D AC 24 ? ? ? ? 48 81 EC", 0x0); + void POPID_ToString(SteamNetworkingPOPID popID, char* out) { out[0] = static_cast(popID >> 16); @@ -50,17 +52,26 @@ unsigned int GetDatacenter(uint32_t uHash) return 0; } -MAKE_HOOK(ISteamNetworkingUtils_GetDirectPingToPOP, U::Memory.GetVFunc(I::SteamNetworkingUtils, 9), int, __fastcall, - void* rcx, SteamNetworkingPOPID popID) +MAKE_HOOK(ISteamNetworkingUtils_GetPingToDataCenter, U::Memory.GetVFunc(I::SteamNetworkingUtils, 8), int, __fastcall, + void* rcx, SteamNetworkingPOPID popID, SteamNetworkingPOPID* pViaRelayPoP) { - int iOriginal = CALL_ORIGINAL(rcx, popID); + int iReturn = CALL_ORIGINAL(rcx, popID, pViaRelayPoP); if (!Vars::Misc::Queueing::ForceRegions.Value) - return iOriginal; + return iReturn; char popIDName[5]; POPID_ToString(popID, popIDName); if (auto uDatacenter = GetDatacenter(FNV1A::Hash32(popIDName))) return Vars::Misc::Queueing::ForceRegions.Value & uDatacenter ? 1 : 999999; - return iOriginal; + return iReturn; +} + +MAKE_HOOK(CTFPartyClient_RequestQueueForMatch, S::CTFPartyClient_RequestQueueForMatch(), void, __fastcall, + void* rcx, int eMatchGroup) +{ + *reinterpret_cast(uintptr_t(I::TFGCClientSystem) + 1116) = true; + S::CTFGCClientSystem_PingThink.As()(I::TFGCClientSystem); + + return CALL_ORIGINAL(rcx, eMatchGroup); } \ No newline at end of file diff --git a/Amalgam/src/SDK/Definitions/Interfaces.h b/Amalgam/src/SDK/Definitions/Interfaces.h index dc8a7f02..19d0532a 100644 --- a/Amalgam/src/SDK/Definitions/Interfaces.h +++ b/Amalgam/src/SDK/Definitions/Interfaces.h @@ -6,6 +6,7 @@ #include "Interfaces/CClientState.h" #include "Interfaces/CGlobalVarsBase.h" #include "Interfaces/CTFGameRules.h" +#include "Interfaces/CTFGCClientSystem.h" #include "Interfaces/CTFPartyClient.h" #include "Interfaces/IClientEntityList.h" #include "Interfaces/ICVar.h" diff --git a/Amalgam/src/SDK/Definitions/Interfaces/CTFGCClientSystem.h b/Amalgam/src/SDK/Definitions/Interfaces/CTFGCClientSystem.h new file mode 100644 index 00000000..ad3310ac --- /dev/null +++ b/Amalgam/src/SDK/Definitions/Interfaces/CTFGCClientSystem.h @@ -0,0 +1,5 @@ +#include "Interface.h" + +class CTFGCClientSystem; + +MAKE_INTERFACE_SIGNATURE(CTFGCClientSystem, TFGCClientSystem, "client.dll", "48 8D 05 ? ? ? ? C3 CC CC CC CC CC CC CC CC 48 8B 05 ? ? ? ? C3 CC CC CC CC CC CC CC CC 48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24", 0x0, 0); \ No newline at end of file