a lot of MM stuff, fixed autoqueue

This commit is contained in:
nullifiedcat 2017-12-07 23:25:27 +03:00
parent 36a6447adb
commit 8fbff54fe3
19 changed files with 311 additions and 109 deletions

View File

@ -128,11 +128,12 @@
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="include/reclasses"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="include/sdk"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="include/visual"/>
<entry excluding="autogen|segvcatch|targeting|visual|classinfo|vtables|gui|ipc|mem|memory|imgui|hacks/ac" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry excluding="reclasses|autogen|segvcatch|targeting|visual|classinfo|vtables|gui|ipc|mem|memory|imgui|hacks/ac" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/classinfo"/>
<entry excluding="cmdui|im|depr|ncc" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/gui"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/gui/cmdui"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/hacks/ac"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/reclasses"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src/visual"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="xoverlay"/>
</sourceEntries>

View File

@ -99,6 +99,7 @@
#include <chatstack.hpp>
#include "textfile.hpp"
#include "ipc.hpp"
#include "tfmm.hpp"
#include "hooks/hookedmethods.hpp"
#include "classinfo/classinfo.hpp"
#include "crits.hpp"

17
include/e8call.hpp Normal file
View File

@ -0,0 +1,17 @@
/*
* e8call.hpp
*
* Created on: Dec 7, 2017
* Author: nullifiedcat
*/
#pragma once
#include <stdint.h>
inline void *e8call(void *address)
{
return (void *)uintptr_t(*(uintptr_t *)address + uintptr_t(address) + 4);
}

View File

@ -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 *);
};

View File

@ -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);
}
};

View File

@ -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);
};

View File

@ -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);
};

View File

@ -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"
}

View File

@ -57,7 +57,6 @@
#include <netmessage.hpp>
#include <dbg.h>
#include "sdk/TFGCClientSystem.hpp"
#include "sdk/in_buttons.h"
#include "sdk/imaterialsystemfixed.h"
#include "sdk/ScreenSpaceEffects.h"

View File

@ -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();
};

18
include/tfmm.hpp Normal file
View File

@ -0,0 +1,18 @@
/*
* tfmm.hpp
*
* Created on: Dec 7, 2017
* Author: nullifiedcat
*/
#pragma once
namespace tfmm
{
void queue_start();
void abandon();
}

View File

@ -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::seconds>(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()

View File

@ -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_);
}

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -1,58 +0,0 @@
/*
* TFGCClientSystem.cpp
*
* Created on: Jul 28, 2017
* Author: nullifiedcat
*/
#include "copypasted/CSignature.h"
#include "sdk/TFGCClientSystem.hpp"
#include <logging.hpp>
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);
}

52
src/tfmm.cpp Normal file
View File

@ -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);
}
}

View File

@ -17,7 +17,7 @@ extern "C" {
#include "xoverlay.h"
}
#define DRAW_XOVERLAY 1
#define DRAW_XOVERLAY 0
SDL_GLContext context = nullptr;