Fully fix autoqueue™️

This commit is contained in:
BenCat07 2018-04-05 20:38:15 +02:00
parent abee301f7d
commit 2a5f063aba
6 changed files with 28 additions and 9 deletions

View File

@ -20,6 +20,7 @@ public:
static ITFGroupMatchCriteria *MutLocalGroupCriteria(CTFPartyClient *client); static ITFGroupMatchCriteria *MutLocalGroupCriteria(CTFPartyClient *client);
static bool BCanQueueForStandby(CTFPartyClient *this_); static bool BCanQueueForStandby(CTFPartyClient *this_);
char RequestQueueForMatch(int type); char RequestQueueForMatch(int type);
char RequestLeaveForMatch(int type);
static bool BInQueue(CTFPartyClient *this_); static bool BInQueue(CTFPartyClient *this_);
}; };
} }

View File

@ -11,5 +11,6 @@ namespace tfmm
{ {
void queue_start(); void queue_start();
void queue_leave();
void abandon(); void abandon();
} }

View File

@ -52,7 +52,9 @@ void UpdateSearch()
if (g_IEngine->IsInGame()) if (g_IEngine->IsInGame())
return; 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(); re::CTFGCClientSystem *gc = re::CTFGCClientSystem::GTFGCClientSystem();
if (gc && !gc->BConnectedToMatchServer(false) && CE_BAD(LOCAL_E)) if (gc && !gc->BConnectedToMatchServer(false) && CE_BAD(LOCAL_E))

View File

@ -14,9 +14,9 @@ CTFGCClientSystem *CTFGCClientSystem::GTFGCClientSystem()
{ {
typedef CTFGCClientSystem *(*GTFGCClientSystem_t)(); typedef CTFGCClientSystem *(*GTFGCClientSystem_t)();
static uintptr_t addr1 = gSignatures.GetClientSignature( 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 = static GTFGCClientSystem_t GTFGCClientSystem_fn =
GTFGCClientSystem_t(e8call((void *) (addr1 + 14))); GTFGCClientSystem_t(addr1);
return GTFGCClientSystem_fn(); return GTFGCClientSystem_fn();
} }
@ -25,7 +25,7 @@ void CTFGCClientSystem::AbandonCurrentMatch()
{ {
typedef void *(*AbandonCurrentMatch_t)(CTFGCClientSystem *); typedef void *(*AbandonCurrentMatch_t)(CTFGCClientSystem *);
static uintptr_t addr1 = gSignatures.GetClientSignature( 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 = static AbandonCurrentMatch_t AbandonCurrentMatch_fn =
AbandonCurrentMatch_t(addr1); AbandonCurrentMatch_t(addr1);
if (AbandonCurrentMatch_fn == nullptr) if (AbandonCurrentMatch_fn == nullptr)

View File

@ -76,3 +76,13 @@ char re::CTFPartyClient::RequestQueueForMatch(int type)
return RequestQueueForMatch_fn(this, 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);
}

View File

@ -12,6 +12,8 @@ CatCommand cmd_queue_start("mm_queue_casual", "Start casual queue",
CatCommand cmd_abandon("mm_abandon", "Abandon match", CatCommand cmd_abandon("mm_abandon", "Abandon match",
[]() { tfmm::abandon(); }); []() { 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", []() { CatCommand get_state("mm_state", "Get party state", []() {
re::CTFParty *party = re::CTFParty::GetParty(); re::CTFParty *party = re::CTFParty::GetParty();
@ -30,15 +32,18 @@ void queue_start() {
re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient(); re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient();
if (client) if (client)
{ {
logging::Info("test1");
client->LoadSavedCasualCriteria(); client->LoadSavedCasualCriteria();
logging::Info("test2"); client->RequestQueueForMatch((int)queue);
client->RequestQueueForMatch(re::ITFGroupMatchCriteria::CasualMatch12v12);
} }
else else
{
logging::Info("queue_start: CTFPartyClient == null!"); 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() void abandon()