From 2a5f063aba18d30174fa53a0053ebbe4368466f0 Mon Sep 17 00:00:00 2001 From: BenCat07 Date: Thu, 5 Apr 2018 20:38:15 +0200 Subject: [PATCH] Fully fix autoqueue:tm: --- include/reclasses/CTFPartyClient.hpp | 1 + include/tfmm.hpp | 1 + src/hacks/AutoJoin.cpp | 4 +++- src/reclasses/CTFGCClientSystem.cpp | 6 +++--- src/reclasses/CTFPartyClient.cpp | 10 ++++++++++ src/tfmm.cpp | 15 ++++++++++----- 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/include/reclasses/CTFPartyClient.hpp b/include/reclasses/CTFPartyClient.hpp index 46d9079a..f54731a7 100755 --- a/include/reclasses/CTFPartyClient.hpp +++ b/include/reclasses/CTFPartyClient.hpp @@ -20,6 +20,7 @@ public: static ITFGroupMatchCriteria *MutLocalGroupCriteria(CTFPartyClient *client); static bool BCanQueueForStandby(CTFPartyClient *this_); char RequestQueueForMatch(int type); + char RequestLeaveForMatch(int type); static bool BInQueue(CTFPartyClient *this_); }; } diff --git a/include/tfmm.hpp b/include/tfmm.hpp index 93471f05..2d289d3f 100755 --- a/include/tfmm.hpp +++ b/include/tfmm.hpp @@ -11,5 +11,6 @@ namespace tfmm { void queue_start(); +void queue_leave(); void abandon(); } diff --git a/src/hacks/AutoJoin.cpp b/src/hacks/AutoJoin.cpp index ac16bb05..bfe4c194 100755 --- a/src/hacks/AutoJoin.cpp +++ b/src/hacks/AutoJoin.cpp @@ -52,7 +52,9 @@ void UpdateSearch() if (g_IEngine->IsInGame()) return; - if (autoqueue_timer.test_and_set(10000)) + if (g_pUserCmd) + tfmm::queue_leave(); + if (autoqueue_timer.test_and_set(30000)) { re::CTFGCClientSystem *gc = re::CTFGCClientSystem::GTFGCClientSystem(); if (gc && !gc->BConnectedToMatchServer(false) && CE_BAD(LOCAL_E)) diff --git a/src/reclasses/CTFGCClientSystem.cpp b/src/reclasses/CTFGCClientSystem.cpp index 1ec1e503..3ea95a7f 100755 --- a/src/reclasses/CTFGCClientSystem.cpp +++ b/src/reclasses/CTFGCClientSystem.cpp @@ -14,9 +14,9 @@ CTFGCClientSystem *CTFGCClientSystem::GTFGCClientSystem() { typedef CTFGCClientSystem *(*GTFGCClientSystem_t)(); static uintptr_t addr1 = gSignatures.GetClientSignature( - "E8 ? ? ? ? 84 C0 0F 85 ? ? ? ? E8 ? ? ? ? 89 04 24 E8 ? ? ? ? 85 C0"); + "55 B8 ? ? ? ? 89 E5 5D C3 8D B6 00 00 00 00 55 A1 ? ? ? ? 89 E5 5D C3 8D B6 00 00 00 00 A1 ? ? ? ?"); static GTFGCClientSystem_t GTFGCClientSystem_fn = - GTFGCClientSystem_t(e8call((void *) (addr1 + 14))); + GTFGCClientSystem_t(addr1); return GTFGCClientSystem_fn(); } @@ -25,7 +25,7 @@ void CTFGCClientSystem::AbandonCurrentMatch() { 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"); + "55 89 E5 57 56 8D 75 ? 53 81 EC ? ? ? ? C7 04 24 ? ? ? ?"); static AbandonCurrentMatch_t AbandonCurrentMatch_fn = AbandonCurrentMatch_t(addr1); if (AbandonCurrentMatch_fn == nullptr) diff --git a/src/reclasses/CTFPartyClient.cpp b/src/reclasses/CTFPartyClient.cpp index 7487c396..777a09a5 100644 --- a/src/reclasses/CTFPartyClient.cpp +++ b/src/reclasses/CTFPartyClient.cpp @@ -76,3 +76,13 @@ char re::CTFPartyClient::RequestQueueForMatch(int type) return RequestQueueForMatch_fn(this, type); } +char re::CTFPartyClient::RequestLeaveForMatch(int type) +{ + typedef char (*RequestLeaveForMatch_t)(re::CTFPartyClient *, int); + uintptr_t addr = gSignatures.GetClientSignature( + "55 89 E5 57 56 53 83 EC ? 8B 45 ? 89 44 24 ? 8B 45 ? 89 04 24 E8 ? ? ? ? 84 C0 89 C6 75 ?"); + RequestLeaveForMatch_t RequestLeaveForMatch_fn = + RequestLeaveForMatch_t(addr); + + return RequestLeaveForMatch_fn(this, type); +} diff --git a/src/tfmm.cpp b/src/tfmm.cpp index 60d01712..8362d6e5 100755 --- a/src/tfmm.cpp +++ b/src/tfmm.cpp @@ -12,6 +12,8 @@ CatCommand cmd_queue_start("mm_queue_casual", "Start casual queue", CatCommand cmd_abandon("mm_abandon", "Abandon match", []() { tfmm::abandon(); }); +static CatEnum queue_mode({ "MvmPractice", "MvmMannup", "LadderMatch6v6", "LadderMatch9v9", "LadderMatch12v12", "CasualMatch6v6", "CasualMatch9v9", "CasualMatch12v12", "CompetitiveEventMatch12v12"}); +static CatVar queue(queue_mode, "autoqueue_mode", "7", "Autoqueue for this mode", ""); CatCommand get_state("mm_state", "Get party state", []() { re::CTFParty *party = re::CTFParty::GetParty(); @@ -30,15 +32,18 @@ void queue_start() { re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient(); if (client) { - logging::Info("test1"); client->LoadSavedCasualCriteria(); - logging::Info("test2"); - client->RequestQueueForMatch(re::ITFGroupMatchCriteria::CasualMatch12v12); + client->RequestQueueForMatch((int)queue); } else - { logging::Info("queue_start: CTFPartyClient == null!"); - } +} +void queue_leave() { + re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient(); + if (client) + client->RequestLeaveForMatch((int)queue); + else + logging::Info("queue_start: CTFPartyClient == null!"); } void abandon()