diff --git a/include/reclasses/CTFGCClientSystem.hpp b/include/reclasses/CTFGCClientSystem.hpp index d2804b57..3284b842 100644 --- a/include/reclasses/CTFGCClientSystem.hpp +++ b/include/reclasses/CTFGCClientSystem.hpp @@ -7,9 +7,23 @@ #pragma once +#include "reclasses.hpp" + +namespace re +{ + class CTFGCClientSystem { public: + CTFGCClientSystem() = delete; static CTFGCClientSystem *GTFGCClientSystem(); - static void AbandonCurrentMatch(CTFGCClientSystem *); + +public: + void AbandonCurrentMatch(); + bool BConnectedToMatchServer(bool flag); + bool BHaveLiveMatch(); + CTFParty *GetParty(); + int JoinMMMatch(); }; + +} diff --git a/include/reclasses/CTFParty.hpp b/include/reclasses/CTFParty.hpp index f0972c1a..58606513 100644 --- a/include/reclasses/CTFParty.hpp +++ b/include/reclasses/CTFParty.hpp @@ -7,6 +7,11 @@ #pragma once +#include "reclasses.hpp" + +namespace re +{ + class CTFParty { public: @@ -18,3 +23,5 @@ public: return *((int *) party + 19); } }; + +} diff --git a/include/reclasses/CTFPartyClient.hpp b/include/reclasses/CTFPartyClient.hpp index 9004baa5..3b3f90a1 100644 --- a/include/reclasses/CTFPartyClient.hpp +++ b/include/reclasses/CTFPartyClient.hpp @@ -7,6 +7,9 @@ #pragma once +namespace re +{ + class CTFPartyClient { public: @@ -17,4 +20,7 @@ public: static ITFGroupMatchCriteria *MutLocalGroupCriteria(CTFPartyClient *client); static bool BCanQueueForStandby(CTFPartyClient *this_); static void RequestQueueForMatch(CTFPartyClient *client); + static bool BInQueue(CTFPartyClient *this_); }; + +} diff --git a/include/reclasses/CTFPlayerShared.hpp b/include/reclasses/CTFPlayerShared.hpp index 7f14e35d..e179b36d 100644 --- a/include/reclasses/CTFPlayerShared.hpp +++ b/include/reclasses/CTFPlayerShared.hpp @@ -1,3 +1,8 @@ +#include "reclasses.hpp" + +namespace re +{ + class CTFPlayerShared { public: @@ -15,3 +20,5 @@ public: return false; } }; + +} diff --git a/include/reclasses/C_BaseCombatWeapon.hpp b/include/reclasses/C_BaseCombatWeapon.hpp index 0e0040a9..34b498a5 100644 --- a/include/reclasses/C_BaseCombatWeapon.hpp +++ b/include/reclasses/C_BaseCombatWeapon.hpp @@ -7,6 +7,11 @@ #pragma once +#include "reclasses.hpp" + +namespace re +{ + class C_BaseCombatWeapon : public C_BaseEntity { public: @@ -32,3 +37,5 @@ public: 0)(self); } }; + +} diff --git a/include/reclasses/C_BaseEntity.hpp b/include/reclasses/C_BaseEntity.hpp index c53a8e0c..9ce98cad 100644 --- a/include/reclasses/C_BaseEntity.hpp +++ b/include/reclasses/C_BaseEntity.hpp @@ -7,6 +7,11 @@ #pragma once +#include "reclasses.hpp" + +namespace re +{ + class C_BaseEntity { public: @@ -23,3 +28,5 @@ public: return placeholder; } }; + +} diff --git a/include/reclasses/C_BasePlayer.hpp b/include/reclasses/C_BasePlayer.hpp index 2dc39a44..7815f476 100644 --- a/include/reclasses/C_BasePlayer.hpp +++ b/include/reclasses/C_BasePlayer.hpp @@ -1,3 +1,10 @@ +#pragma once + +#include "reclasses.hpp" + +namespace re +{ + class C_BasePlayer : public C_BaseEntity { public: @@ -6,3 +13,5 @@ public: return *((CTFPlayerShared *) (unsigned(self) + 6092)); } }; + +} diff --git a/include/reclasses/C_TFWeaponBase.hpp b/include/reclasses/C_TFWeaponBase.hpp index 941e2b1c..c39142de 100644 --- a/include/reclasses/C_TFWeaponBase.hpp +++ b/include/reclasses/C_TFWeaponBase.hpp @@ -7,6 +7,11 @@ #pragma once +#include + +namespace re +{ + class C_TFWeaponBase : public re::C_BaseCombatWeapon { public: @@ -181,3 +186,5 @@ public: return *(float *) (unsigned(self) + 2616u); } }; + +} diff --git a/include/reclasses/C_TFWeaponBaseGun.hpp b/include/reclasses/C_TFWeaponBaseGun.hpp index 19a9f9ec..ebf560e6 100644 --- a/include/reclasses/C_TFWeaponBaseGun.hpp +++ b/include/reclasses/C_TFWeaponBaseGun.hpp @@ -7,6 +7,11 @@ #pragma once +#include "reclasses.hpp" + +namespace re +{ + class C_TFWeaponBaseGun : public C_TFWeaponBase { public: @@ -25,3 +30,5 @@ public: 0)(self); } }; + +} diff --git a/include/reclasses/C_TFWeaponBaseMelee.hpp b/include/reclasses/C_TFWeaponBaseMelee.hpp index e541e054..96061ba9 100644 --- a/include/reclasses/C_TFWeaponBaseMelee.hpp +++ b/include/reclasses/C_TFWeaponBaseMelee.hpp @@ -7,6 +7,11 @@ #pragma once +#include "reclasses.hpp" + +namespace re +{ + class C_TFWeaponBaseMelee : public C_TFWeaponBase { public: @@ -18,3 +23,5 @@ public: 0)(self, trace); } }; + +} diff --git a/include/reclasses/ITFGroupMatchCriteria.hpp b/include/reclasses/ITFGroupMatchCriteria.hpp index e28709ac..e5d0c2d5 100644 --- a/include/reclasses/ITFGroupMatchCriteria.hpp +++ b/include/reclasses/ITFGroupMatchCriteria.hpp @@ -7,6 +7,11 @@ #pragma once +#include "reclasses.hpp" + +namespace re +{ + class ITFGroupMatchCriteria { public: @@ -18,3 +23,5 @@ public: public: static int SetMatchGroup(ITFGroupMatchCriteria *this_, int group); }; + +} diff --git a/include/reclasses/reclasses.hpp b/include/reclasses/reclasses.hpp index dc08a55c..5d9f3e70 100644 --- a/include/reclasses/reclasses.hpp +++ b/include/reclasses/reclasses.hpp @@ -9,9 +9,6 @@ #include "common.hpp" -namespace re -{ - #include "C_BaseEntity.hpp" #include "CTFPlayerShared.hpp" #include "C_BasePlayer.hpp" @@ -20,8 +17,7 @@ namespace re #include "C_TFWeaponBaseMelee.hpp" #include "C_TFWeaponBaseGun.hpp" -#include "CTFGCClientSystem.hpp" #include "CTFParty.hpp" +#include "CTFGCClientSystem.hpp" #include "ITFGroupMatchCriteria.hpp" #include "CTFPartyClient.hpp" -} diff --git a/makefile b/makefile index 345d943a..17ce2096 100644 --- a/makefile +++ b/makefile @@ -57,6 +57,7 @@ LIBXOVERLAY=libxoverlay/bin32/libxoverlay.so INCLUDES=-I. -Iinclude -Iucccccp -isystem/usr/include/c++/6.3.1 -isystem$(SSDK_DIR)/public -isystem$(SSDK_DIR)/mathlib -isystem$(SSDK_DIR)/common -isystem$(SSDK_DIR)/public/tier1 -isystem$(SSDK_DIR)/public/tier0 -isystem$(SSDK_DIR) LDLIBS=-static -l:libc.so.6 -l:libstdc++.so.6 -l:libtier0.so -l:libvstdlib.so LDFLAGS=-shared -L$(realpath $(LIB_DIR)) +#LDFLAGS+=-Wl,--no-undefined SOURCES=$(shell find $(SRC_DIR) -name "*.c*" -print) ifndef CLANG diff --git a/src/hacks/AutoJoin.cpp b/src/hacks/AutoJoin.cpp index 9b10c13f..b16801f2 100644 --- a/src/hacks/AutoJoin.cpp +++ b/src/hacks/AutoJoin.cpp @@ -43,19 +43,21 @@ bool UnassignedClass() return g_pLocalPlayer->clazz != int(preferred_class); } +Timer autoqueue_timer{}; + void UpdateSearch() { if (!auto_queue) return; if (g_IEngine->IsInGame()) return; - static Timer autoqueue_timer{}; if (autoqueue_timer.test_and_set(5000)) { - re::CTFParty *party = re::CTFParty::GetParty(); - if (!party || re::CTFParty::state_(party) == 0) - { + re::CTFGCClientSystem *gc = re::CTFGCClientSystem::GTFGCClientSystem(); + + if (gc && !gc->BConnectedToMatchServer(false) && !gc->BHaveLiveMatch()) + { logging::Info("Starting queue"); tfmm::queue_start(); } diff --git a/src/reclasses/CTFGCClientSystem.cpp b/src/reclasses/CTFGCClientSystem.cpp index cab0f74a..773bc69e 100644 --- a/src/reclasses/CTFGCClientSystem.cpp +++ b/src/reclasses/CTFGCClientSystem.cpp @@ -8,9 +8,11 @@ #include "common.hpp" #include "e8call.hpp" -re::CTFGCClientSystem *re::CTFGCClientSystem::GTFGCClientSystem() +using namespace re; + +CTFGCClientSystem *CTFGCClientSystem::GTFGCClientSystem() { - typedef re::CTFGCClientSystem *(*GTFGCClientSystem_t)(); + typedef 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"); @@ -20,9 +22,9 @@ re::CTFGCClientSystem *re::CTFGCClientSystem::GTFGCClientSystem() return GTFGCClientSystem_fn(); } -void re::CTFGCClientSystem::AbandonCurrentMatch(re::CTFGCClientSystem *this_) +void CTFGCClientSystem::AbandonCurrentMatch() { - typedef void *(*AbandonCurrentMatch_t)(re::CTFGCClientSystem *); + typedef void *(*AbandonCurrentMatch_t)(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 ? ? ? ? " @@ -30,5 +32,35 @@ void re::CTFGCClientSystem::AbandonCurrentMatch(re::CTFGCClientSystem *this_) static AbandonCurrentMatch_t AbandonCurrentMatch_fn = AbandonCurrentMatch_t(addr1); - AbandonCurrentMatch_fn(this_); + AbandonCurrentMatch_fn(this); +} + +bool CTFGCClientSystem::BConnectedToMatchServer(bool flag) +{ + typedef bool(*BConnectedToMatchServer_t)(CTFGCClientSystem *, bool); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 53 80 7D 0C 00 8B 55 08 75 1B 8B 82 F8 04 00 00 83 E8 01 83 F8 01 0F 96 C0 8D 74 26 00 5B 5D C3"); + static BConnectedToMatchServer_t BConnectedToMatchServer_fn = BConnectedToMatchServer_t(addr); + + return BConnectedToMatchServer_fn(this, flag); +} + +bool CTFGCClientSystem::BHaveLiveMatch() +{ + typedef bool(*BHaveLiveMatch_t)(CTFGCClientSystem *); + static uintptr_t addr = gSignatures.GetClientSignature("55 31 C0 89 E5 53 8B 4D 08 0F B6 91 0F 05 00 00 89 D3 81 E3 F0 00 00 00 74 36 80 FA AF"); + static BHaveLiveMatch_t BHaveLiveMatch_fn = BHaveLiveMatch_t(addr); + + return BHaveLiveMatch_fn(this); +} + +CTFParty *CTFGCClientSystem::GetParty() +{ + // TODO + return nullptr; +} + +int CTFGCClientSystem::JoinMMMatch() +{ + // TODO + return 0; } diff --git a/src/reclasses/CTFPartyClient.cpp b/src/reclasses/CTFPartyClient.cpp index fb005f89..526fad7b 100644 --- a/src/reclasses/CTFPartyClient.cpp +++ b/src/reclasses/CTFPartyClient.cpp @@ -21,6 +21,11 @@ re::CTFPartyClient *re::CTFPartyClient::GTFPartyClient() return GTFPartyClient_fn(); } +bool re::CTFPartyClient::BInQueue(re::CTFPartyClient *this_) +{ + return *(uint8_t *)((uint8_t *)this_ + 69); +} + int re::CTFPartyClient::SendPartyChat(re::CTFPartyClient *client, const char *message) { diff --git a/src/tfmm.cpp b/src/tfmm.cpp index 4fa5bb0a..1c4b0ad6 100644 --- a/src/tfmm.cpp +++ b/src/tfmm.cpp @@ -43,6 +43,6 @@ void abandon() { re::CTFGCClientSystem *gc = re::CTFGCClientSystem::GTFGCClientSystem(); if (gc != nullptr) - re::CTFGCClientSystem::AbandonCurrentMatch(gc); + gc->AbandonCurrentMatch(); } }