diff --git a/.cproject b/.cproject index 886f4f9a..ce07ed67 100644 --- a/.cproject +++ b/.cproject @@ -128,11 +128,12 @@ - + + diff --git a/include/common.hpp b/include/common.hpp index 68404de6..dfac75ee 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -99,6 +99,7 @@ #include #include "textfile.hpp" #include "ipc.hpp" +#include "tfmm.hpp" #include "hooks/hookedmethods.hpp" #include "classinfo/classinfo.hpp" #include "crits.hpp" diff --git a/include/e8call.hpp b/include/e8call.hpp new file mode 100644 index 00000000..9dace5da --- /dev/null +++ b/include/e8call.hpp @@ -0,0 +1,17 @@ +/* + * e8call.hpp + * + * Created on: Dec 7, 2017 + * Author: nullifiedcat + */ + +#pragma once + +#include + +inline void *e8call(void *address) +{ + return (void *)uintptr_t(*(uintptr_t *)address + uintptr_t(address) + 4); +} + + diff --git a/include/reclasses/CTFGCClientSystem.hpp b/include/reclasses/CTFGCClientSystem.hpp new file mode 100644 index 00000000..d2804b57 --- /dev/null +++ b/include/reclasses/CTFGCClientSystem.hpp @@ -0,0 +1,15 @@ +/* + * CTFGCClientSystem.hpp + * + * Created on: Dec 7, 2017 + * Author: nullifiedcat + */ + +#pragma once + +class CTFGCClientSystem +{ +public: + static CTFGCClientSystem *GTFGCClientSystem(); + static void AbandonCurrentMatch(CTFGCClientSystem *); +}; diff --git a/include/reclasses/CTFParty.hpp b/include/reclasses/CTFParty.hpp new file mode 100644 index 00000000..840c60d3 --- /dev/null +++ b/include/reclasses/CTFParty.hpp @@ -0,0 +1,22 @@ +/* + * CTFParty.hpp + * + * Created on: Dec 7, 2017 + * Author: nullifiedcat + */ + +#pragma once + +class CTFParty +{ +public: + // 7 Dec client.so:sub_B986E0 + static CTFParty *GetParty(); + + inline static int state_(CTFParty *party) + { + return *((int *)party + 19); + } +}; + + diff --git a/include/reclasses/CTFPartyClient.hpp b/include/reclasses/CTFPartyClient.hpp new file mode 100644 index 00000000..9004baa5 --- /dev/null +++ b/include/reclasses/CTFPartyClient.hpp @@ -0,0 +1,20 @@ +/* + * CTFPartyClient.hpp + * + * Created on: Dec 7, 2017 + * Author: nullifiedcat + */ + +#pragma once + +class CTFPartyClient +{ +public: + static CTFPartyClient *GTFPartyClient(); + + static int SendPartyChat(CTFPartyClient *client, const char *message); + static int LoadSavedCasualCriteria(CTFPartyClient *client); + static ITFGroupMatchCriteria *MutLocalGroupCriteria(CTFPartyClient *client); + static bool BCanQueueForStandby(CTFPartyClient *this_); + static void RequestQueueForMatch(CTFPartyClient *client); +}; diff --git a/include/reclasses/ITFGroupMatchCriteria.hpp b/include/reclasses/ITFGroupMatchCriteria.hpp new file mode 100644 index 00000000..02918737 --- /dev/null +++ b/include/reclasses/ITFGroupMatchCriteria.hpp @@ -0,0 +1,19 @@ +/* + * ITFGroupMatchCriteria.hpp + * + * Created on: Dec 7, 2017 + * Author: nullifiedcat + */ + +#pragma once + +class ITFGroupMatchCriteria +{ +public: + enum group + { + CASUAL = 7 + }; +public: + static int SetMatchGroup(ITFGroupMatchCriteria *this_, int group); +}; diff --git a/include/reclasses/reclasses.hpp b/include/reclasses/reclasses.hpp index 2d272c04..1e35cbbf 100644 --- a/include/reclasses/reclasses.hpp +++ b/include/reclasses/reclasses.hpp @@ -19,4 +19,10 @@ namespace re #include "C_TFWeaponBase.hpp" #include "C_TFWeaponBaseMelee.hpp" #include "C_TFWeaponBaseGun.hpp" + +#include "CTFGCClientSystem.hpp" +#include "CTFParty.hpp" +#include "ITFGroupMatchCriteria.hpp" +#include "CTFPartyClient.hpp" + } diff --git a/include/sdk.hpp b/include/sdk.hpp index 9c64b393..972a5c24 100644 --- a/include/sdk.hpp +++ b/include/sdk.hpp @@ -57,7 +57,6 @@ #include #include -#include "sdk/TFGCClientSystem.hpp" #include "sdk/in_buttons.h" #include "sdk/imaterialsystemfixed.h" #include "sdk/ScreenSpaceEffects.h" diff --git a/include/sdk/TFGCClientSystem.hpp b/include/sdk/TFGCClientSystem.hpp deleted file mode 100644 index 947a1803..00000000 --- a/include/sdk/TFGCClientSystem.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * TFGCClientSystem.hpp - * - * Created on: Jul 28, 2017 - * Author: nullifiedcat - */ - -#pragma once - -class TFGCClientSystem -{ -public: - int RequestSelectWizardStep(int type); - int GetState(); - /* 55 89 E5 57 56 8D 75 C8 53 81 EC 8C 00 00 00 8B 45 0C C7 04 24 ? ? ? ? 8B - * 5D 08 89 45 A4 0F B6 C0 89 44 24 04 E8 ? ? ? ? C7 44 24 04 91 18 00 00 89 - * 34 24 E8 ? ? ? ? A1 ? ? ? ? */ - int SendExitMatchmaking(bool abandon); - int LoadSearchCriteria(); -}; diff --git a/include/tfmm.hpp b/include/tfmm.hpp new file mode 100644 index 00000000..fc13f13e --- /dev/null +++ b/include/tfmm.hpp @@ -0,0 +1,18 @@ +/* + * tfmm.hpp + * + * Created on: Dec 7, 2017 + * Author: nullifiedcat + */ + +#pragma once + +namespace tfmm +{ + +void queue_start(); +void abandon(); + +} + + diff --git a/src/hacks/AutoJoin.cpp b/src/hacks/AutoJoin.cpp index 8cf3719b..64eb5166 100644 --- a/src/hacks/AutoJoin.cpp +++ b/src/hacks/AutoJoin.cpp @@ -33,20 +33,6 @@ const std::string classnames[] = { "scout", "sniper", "soldier", "demoman", "medic", "heavyweapons", "pyro", "spy", "engineer" }; -/*CatCommand debug_startsearch("debug_startsearch", "DEBUG StartSearch", []() { - logging::Info("%d", g_TFGCClientSystem->RequestSelectWizardStep(4)); -}); -CatCommand debug_casual("debug_casual", "DEBUG Casual", []() { - g_IEngine->ExecuteClientCmd("OpenMatchmakingLobby casual"); - g_TFGCClientSystem->LoadSearchCriteria(); - //logging::Info("%d", g_TFGCClientSystem->RequestSelectWizardStep(6)); -}); -CatCommand debug_readytosearch("debug_gcstate", "DEBUG GCState", []() { - logging::Info("%d", g_TFGCClientSystem->GetState()); -}); -CatCommand debug_abandon("debug_abandon", "DEBUG Abandon", []() { - g_TFGCClientSystem->SendExitMatchmaking(true); -});*/ bool UnassignedTeam() { return !g_pLocalPlayer->team or (g_pLocalPlayer->team == TEAM_SPEC); @@ -59,23 +45,19 @@ bool UnassignedClass() void UpdateSearch() { - /*if (!auto_queue) return; + if (!auto_queue) return; if (g_IEngine->IsInGame()) return; - static auto last_check = std::chrono::system_clock::now(); - auto s = - std::chrono::duration_cast(std::chrono::system_clock::now() - - last_check).count(); if (s < 4) return; + static Timer autoqueue_timer{}; - if (g_TFGCClientSystem->GetState() == 6) { - logging::Info("Sending MM request"); - g_TFGCClientSystem->RequestSelectWizardStep(4); - } else if (g_TFGCClientSystem->GetState() == 5) { - g_IEngine->ExecuteClientCmd("OpenMatchmakingLobby casual"); - g_TFGCClientSystem->LoadSearchCriteria(); - //logging::Info("%d", g_TFGCClientSystem->RequestSelectWizardStep(6)); + if (autoqueue_timer.test_and_set(5000)) + { + re::CTFParty *party = re::CTFParty::GetParty(); + if (!party || re::CTFParty::state_(party) == 0) + { + logging::Info("Starting queue"); + tfmm::queue_start(); + } } - - last_check = std::chrono::system_clock::now();*/ } void Update() diff --git a/src/reclasses/CTFGCClientSystem.cpp b/src/reclasses/CTFGCClientSystem.cpp new file mode 100644 index 00000000..eb1b202b --- /dev/null +++ b/src/reclasses/CTFGCClientSystem.cpp @@ -0,0 +1,29 @@ +/* + * CTFGCClientSystem.cpp + * + * Created on: Dec 7, 2017 + * Author: nullifiedcat + */ + +#include "common.hpp" +#include "e8call.hpp" + +re::CTFGCClientSystem *re::CTFGCClientSystem::GTFGCClientSystem() +{ + typedef re::CTFGCClientSystem *(*GTFGCClientSystem_t)(); + static uintptr_t addr1 = gSignatures.GetClientSignature("E8 ? ? ? ? 84 C0 0F 85 7B 02 00 00 E8 ? ? ? ? BE 01 00 00 00 89 04 24 E8 ? ? ? ? 85 C0 0F 84 E5 02 00 00"); + static GTFGCClientSystem_t GTFGCClientSystem_fn = GTFGCClientSystem_t(e8call((void *)(addr1 + 14))); + + return GTFGCClientSystem_fn(); +} + +void re::CTFGCClientSystem::AbandonCurrentMatch(re::CTFGCClientSystem *this_) +{ + typedef void *(*AbandonCurrentMatch_t)(re::CTFGCClientSystem *); + static uintptr_t addr1 = gSignatures.GetClientSignature("55 89 E5 57 56 8D 75 C8 53 81 EC 8C 00 00 00 C7 04 24 ? ? ? ? 8B 5D 08 E8 ? ? ? ? C7 44 24 04 91 18 00 00 89 34 24 E8 ? ? ? ? A1 ? ? ? ? C7 45 C8 ? ? ? ?"); + static AbandonCurrentMatch_t AbandonCurrentMatch_fn = AbandonCurrentMatch_t(addr1); + + AbandonCurrentMatch_fn(this_); +} + + diff --git a/src/reclasses/CTFParty.cpp b/src/reclasses/CTFParty.cpp new file mode 100644 index 00000000..86e0ee3a --- /dev/null +++ b/src/reclasses/CTFParty.cpp @@ -0,0 +1,23 @@ +/* + * CTFParty.cpp + * + * Created on: Dec 7, 2017 + * Author: nullifiedcat + */ + +#include "common.hpp" +#include "e8call.hpp" + +re::CTFParty *re::CTFParty::GetParty() +{ + typedef re::CTFParty *(*GetParty_t)(void *); + typedef void *(*GTFGCClientSystem_t)(); + + static uintptr_t addr1 = gSignatures.GetClientSignature("E8 ? ? ? ? 84 C0 0F 85 7B 02 00 00 E8 ? ? ? ? BE 01 00 00 00 89 04 24 E8 ? ? ? ? 85 C0 0F 84 E5 02 00 00"); + + static GTFGCClientSystem_t GTFGCClientSystem_fn = GTFGCClientSystem_t(e8call((void *)(addr1 + 14))); + static GetParty_t GetParty_fn = GetParty_t(e8call((void *)(addr1 + 27))); + + return GetParty_fn(GTFGCClientSystem_fn()); +} + diff --git a/src/reclasses/CTFPartyClient.cpp b/src/reclasses/CTFPartyClient.cpp new file mode 100644 index 00000000..2d3da835 --- /dev/null +++ b/src/reclasses/CTFPartyClient.cpp @@ -0,0 +1,59 @@ +/* + * CTFPartyClient.cpp + * + * Created on: Dec 7, 2017 + * Author: nullifiedcat + */ + +#include "common.hpp" +#include "e8call.hpp" + +re::CTFPartyClient *re::CTFPartyClient::GTFPartyClient() +{ + typedef re::CTFPartyClient *(*GTFPartyClient_t)(void); + static uintptr_t addr = gSignatures.GetClientSignature("83 04 02 00 00 00 00 00 00 ? 83 08 02 00 00 01 E8 ? ? ? ? 89 04 24 E8 ? ? ? ?") + 17; + static GTFPartyClient_t GTFPartyClient_fn = GTFPartyClient_t(e8call((void *)addr)); + + return GTFPartyClient_fn(); +} + +int re::CTFPartyClient::SendPartyChat(re::CTFPartyClient *client, const char *message) +{ + // todo +} + +bool re::CTFPartyClient::BCanQueueForStandby(re::CTFPartyClient *this_) +{ + typedef bool(*BCanQueueForStandby_t)(re::CTFPartyClient *); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 53 83 EC 24 8B 5D 08 80 7B 46 00 75 40 8B 4B 38 85 C9 74 39 E8 ? ? ? ? 89 04 24 E8 ? ? ? ? 84 C0 75 28"); + static BCanQueueForStandby_t BCanQueueForStandby_fn = BCanQueueForStandby_t(addr); + + return BCanQueueForStandby_fn(this_); +} + +re::ITFGroupMatchCriteria *re::CTFPartyClient::MutLocalGroupCriteria(re::CTFPartyClient *client) +{ + typedef re::ITFGroupMatchCriteria *(*MutLocalGroupCriteria_t)(re::CTFPartyClient *); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 8B 45 08 8B 50 38 C6 80 BC 01 00 00 01 85 D2 74 06 80 78 44 00 74 07"); + static MutLocalGroupCriteria_t MutLocalGroupCriteria_fn = MutLocalGroupCriteria_t(addr); + + return MutLocalGroupCriteria_fn(client); +} + +int re::CTFPartyClient::LoadSavedCasualCriteria(re::CTFPartyClient *client) +{ + typedef int(*LoadSavedCasualCriteria_t)(re::CTFPartyClient *); + static uintptr_t addr = gSignatures.GetClientSignature("83 04 02 00 00 00 00 00 00 ? 83 08 02 00 00 01 E8 ? ? ? ? 89 04 24 E8 ? ? ? ?") + 25; + static LoadSavedCasualCriteria_t LoadSavedCasualCriteria_fn = LoadSavedCasualCriteria_t(e8call((void *)addr)); + + return LoadSavedCasualCriteria_fn(client); +} + +void re::CTFPartyClient::RequestQueueForMatch(re::CTFPartyClient *client) +{ + typedef void(*RequestQueueForMatch_t)(re::CTFPartyClient *); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC 8C 00 00 00 8B 7D 08 80 BF C1 01 00 00 00 0F 85 4F 04 00 00 80 7F 45 00 0F 85 45 04 00 00"); + static RequestQueueForMatch_t RequestQueueForMatch_fn = RequestQueueForMatch_t(addr); + + return RequestQueueForMatch_fn(client); +} diff --git a/src/reclasses/ITFGroupMatchCriteria.cpp b/src/reclasses/ITFGroupMatchCriteria.cpp new file mode 100644 index 00000000..681e4fd9 --- /dev/null +++ b/src/reclasses/ITFGroupMatchCriteria.cpp @@ -0,0 +1,17 @@ +/* + * ITFGroupMatchCriteria.cpp + * + * Created on: Dec 7, 2017 + * Author: nullifiedcat + */ + +#include "common.hpp" + +int re::ITFGroupMatchCriteria::SetMatchGroup(re::ITFGroupMatchCriteria *this_, int group) +{ + typedef int(*SetMatchGroup_t)(re::ITFGroupMatchCriteria *, int); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 56 53 83 EC 10 8B 5D 08 8B 75 0C 8B 03 89 1C 24 FF 50 08 3B 70 30 74 0F 8B 03 89 1C 24 FF 50 0C 83 48 08 04 89 70 30"); + SetMatchGroup_t SetMatchGroup_fn = SetMatchGroup_t(addr); + + return SetMatchGroup_fn(this_, group); +} diff --git a/src/sdk/TFGCClientSystem.cpp b/src/sdk/TFGCClientSystem.cpp deleted file mode 100644 index 51af254c..00000000 --- a/src/sdk/TFGCClientSystem.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * TFGCClientSystem.cpp - * - * Created on: Jul 28, 2017 - * Author: nullifiedcat - */ - -#include "copypasted/CSignature.h" -#include "sdk/TFGCClientSystem.hpp" - -#include - -int TFGCClientSystem::RequestSelectWizardStep(int type) -{ - static uintptr_t RequestSelectWizardStep_loc = - gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC 1C 8B 5D 08 8B " - "75 0C 89 1C 24 E8 ? ? ? ? 84 C0 75 0D " - "83 C4 1C 5B 5E 5F 5D C3 90 8D 74 26 00 " - "89 1C 24 E8 ? ? ? ? 85 C0"); - typedef int (*RequestSelectWizardStep_t)(TFGCClientSystem *, int); - static RequestSelectWizardStep_t RequestSelectWizardStep_fn = - (RequestSelectWizardStep_t) RequestSelectWizardStep_loc; - return RequestSelectWizardStep_fn(this, 4); -} - -int TFGCClientSystem::GetState() -{ - return *(int *) ((uintptr_t) this + 1136); -} - -/* 55 89 E5 57 56 8D 75 C8 53 81 EC 8C 00 00 00 8B 45 0C C7 04 24 ? ? ? ? 8B 5D - * 08 89 45 A4 0F B6 C0 89 44 24 04 E8 ? ? ? ? C7 44 24 04 91 18 00 00 89 34 24 - * E8 ? ? ? ? A1 ? ? ? ? */ -int TFGCClientSystem::SendExitMatchmaking(bool abandon) -{ - static uintptr_t SendExitMatchmaking_loc = gSignatures.GetClientSignature( - "55 89 E5 57 56 8D 75 C8 53 81 EC 8C 00 00 00 8B 45 0C C7 04 24 ? ? ? " - "? 8B 5D 08 89 45 A4 0F B6 C0 89 44"); - typedef int (*SendExitMatchmaking_t)(TFGCClientSystem *, char); - static SendExitMatchmaking_t SendExitMatchmaking_fn = - (SendExitMatchmaking_t) SendExitMatchmaking_loc; - logging::Info("Calling 0x%08x", SendExitMatchmaking_fn); - return SendExitMatchmaking_fn(this, abandon); -} - -int TFGCClientSystem::LoadSearchCriteria() -{ - static uintptr_t LoadSearchCriteria_loc = gSignatures.GetClientSignature( - "55 89 E5 57 56 53 8D 5D A8 81 EC DC 00 00 00 C7 44 24 0C 00 00 00 00 " - "C7 44 24 08 00 00 00 00 C7 44 24 04 00 00 00 00 89 1C 24 E8 ? ? ? ? " - "C7 44 24 08 01 00 00 00 C7 44 24 04 01 00 00 00 89 1C 24 E8 ? ? ? ? " - "A1 ? ? ? ? 8D 50 04"); - typedef int (*LoadSearchCriteria_t)(TFGCClientSystem *); - static LoadSearchCriteria_t LoadSearchCriteria_fn = - (LoadSearchCriteria_t) LoadSearchCriteria_loc; - logging::Info("Calling 0x%08x", LoadSearchCriteria_fn); - return LoadSearchCriteria_fn(this); -} diff --git a/src/tfmm.cpp b/src/tfmm.cpp new file mode 100644 index 00000000..d35b3d42 --- /dev/null +++ b/src/tfmm.cpp @@ -0,0 +1,52 @@ +/* + * tfmm.cpp + * + * Created on: Dec 7, 2017 + * Author: nullifiedcat + */ + +#include "common.hpp" + +CatCommand cmd_queue_start("mm_queue_casual", "Start casual queue", []() +{ + tfmm::queue_start(); +}); + +CatCommand cmd_abandon("mm_abandon", "Abandon match", []() +{ + tfmm::abandon(); +}); + +CatCommand get_state("mm_state", "Get party state", []() +{ + re::CTFParty *party = re::CTFParty::GetParty(); + if (!party) + { + logging::Info("Party == NULL"); + return; + } + logging::Info("State: %d", re::CTFParty::state_(party)); +}); + +namespace tfmm +{ + +void queue_start() +{ + re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient(); + if (client) + { + re::ITFGroupMatchCriteria::SetMatchGroup(re::CTFPartyClient::MutLocalGroupCriteria(client), re::ITFGroupMatchCriteria::group::CASUAL); + re::CTFPartyClient::LoadSavedCasualCriteria(client); + re::CTFPartyClient::RequestQueueForMatch(client); + } +} + +void abandon() +{ + re::CTFGCClientSystem *gc = re::CTFGCClientSystem::GTFGCClientSystem(); + if (gc != nullptr) + re::CTFGCClientSystem::AbandonCurrentMatch(gc); +} + +} diff --git a/src/visual/drawex.cpp b/src/visual/drawex.cpp index d5913b07..1b3e366f 100644 --- a/src/visual/drawex.cpp +++ b/src/visual/drawex.cpp @@ -17,7 +17,7 @@ extern "C" { #include "xoverlay.h" } -#define DRAW_XOVERLAY 1 +#define DRAW_XOVERLAY 0 SDL_GLContext context = nullptr;