clang-format

This commit is contained in:
nullifiedcat 2017-12-07 23:36:06 +03:00
parent 8fbff54fe3
commit cf7e4ec91f
14 changed files with 105 additions and 93 deletions

View File

@ -11,7 +11,5 @@
inline void *e8call(void *address) inline void *e8call(void *address)
{ {
return (void *)uintptr_t(*(uintptr_t *)address + uintptr_t(address) + 4); return (void *) uintptr_t(*(uintptr_t *) address + uintptr_t(address) + 4);
} }

View File

@ -47,7 +47,8 @@ struct offsets
break; break;
} }
// pCompileError. // pCompileError.
// static_assert(result != undefined, "No offset defined for this platform!"); // static_assert(result != undefined, "No offset defined for this
// platform!");
return result; return result;
} }
static constexpr uint32_t GetUserCmd() static constexpr uint32_t GetUserCmd()

View File

@ -15,8 +15,6 @@ public:
inline static int state_(CTFParty *party) inline static int state_(CTFParty *party)
{ {
return *((int *)party + 19); return *((int *) party + 19);
} }
}; };

View File

@ -14,6 +14,7 @@ public:
{ {
CASUAL = 7 CASUAL = 7
}; };
public: public:
static int SetMatchGroup(ITFGroupMatchCriteria *this_, int group); static int SetMatchGroup(ITFGroupMatchCriteria *this_, int group);
}; };

View File

@ -24,5 +24,4 @@ namespace re
#include "CTFParty.hpp" #include "CTFParty.hpp"
#include "ITFGroupMatchCriteria.hpp" #include "ITFGroupMatchCriteria.hpp"
#include "CTFPartyClient.hpp" #include "CTFPartyClient.hpp"
} }

View File

@ -12,7 +12,4 @@ namespace tfmm
void queue_start(); void queue_start();
void abandon(); void abandon();
} }

View File

@ -45,8 +45,10 @@ bool UnassignedClass()
void UpdateSearch() void UpdateSearch()
{ {
if (!auto_queue) return; if (!auto_queue)
if (g_IEngine->IsInGame()) return; return;
if (g_IEngine->IsInGame())
return;
static Timer autoqueue_timer{}; static Timer autoqueue_timer{};
if (autoqueue_timer.test_and_set(5000)) if (autoqueue_timer.test_and_set(5000))
@ -62,29 +64,22 @@ void UpdateSearch()
void Update() void Update()
{ {
static auto last_check = std::chrono::system_clock::now(); static Timer timer;
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now() - last_check)
.count();
if (ms < 500) if (timer.test_and_set(500))
{ {
return; if (autojoin_team and UnassignedTeam())
{
hack::ExecuteCommand("jointeam auto");
}
else if (preferred_class and UnassignedClass())
{
if (int(preferred_class) < 10)
g_IEngine->ExecuteClientCmd(
format("join_class ", classnames[int(preferred_class) - 1])
.c_str());
}
} }
if (autojoin_team and UnassignedTeam())
{
hack::ExecuteCommand("jointeam auto");
}
else if (preferred_class and UnassignedClass())
{
if (int(preferred_class) < 10)
g_IEngine->ExecuteClientCmd(
format("join_class ", classnames[int(preferred_class) - 1])
.c_str());
}
last_check = std::chrono::system_clock::now();
} }
} }
} }

View File

@ -59,7 +59,7 @@ void SDL_GL_SwapWindow_hook(SDL_Window *window)
static bool init{ false }; static bool init{ false };
static GLXContext tf2 = glXGetCurrentContext(); static GLXContext tf2 = glXGetCurrentContext();
static SDL_GLContext tf2_sdl = SDL_GL_GetCurrentContext(); static SDL_GLContext tf2_sdl = SDL_GL_GetCurrentContext();
if (cathook && !disable_visuals) if (cathook && !disable_visuals)
@ -76,9 +76,10 @@ void SDL_GL_SwapWindow_hook(SDL_Window *window)
PROF_SECTION(SWAPWINDOW_tf2); PROF_SECTION(SWAPWINDOW_tf2);
SDL_GL_MakeCurrent(window, tf2_sdl); SDL_GL_MakeCurrent(window, tf2_sdl);
SDL_GL_SwapWindow_o(window); SDL_GL_SwapWindow_o(window);
//glXMakeContextCurrent(wminfo.info.x11.display, wminfo.info.x11.window, // glXMakeContextCurrent(wminfo.info.x11.display,
// wminfo.info.x11.window,
// wminfo.info.x11.window, tf2); // wminfo.info.x11.window, tf2);
//glXSwapBuffers(wminfo.info.x11.display, wminfo.info.x11.window); // glXSwapBuffers(wminfo.info.x11.display, wminfo.info.x11.window);
} }
} }

View File

@ -11,8 +11,11 @@
re::CTFGCClientSystem *re::CTFGCClientSystem::GTFGCClientSystem() re::CTFGCClientSystem *re::CTFGCClientSystem::GTFGCClientSystem()
{ {
typedef re::CTFGCClientSystem *(*GTFGCClientSystem_t)(); 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 uintptr_t addr1 = gSignatures.GetClientSignature(
static GTFGCClientSystem_t GTFGCClientSystem_fn = GTFGCClientSystem_t(e8call((void *)(addr1 + 14))); "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(); return GTFGCClientSystem_fn();
} }
@ -20,10 +23,12 @@ re::CTFGCClientSystem *re::CTFGCClientSystem::GTFGCClientSystem()
void re::CTFGCClientSystem::AbandonCurrentMatch(re::CTFGCClientSystem *this_) void re::CTFGCClientSystem::AbandonCurrentMatch(re::CTFGCClientSystem *this_)
{ {
typedef void *(*AbandonCurrentMatch_t)(re::CTFGCClientSystem *); 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 uintptr_t addr1 = gSignatures.GetClientSignature(
static AbandonCurrentMatch_t AbandonCurrentMatch_fn = AbandonCurrentMatch_t(addr1); "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_); AbandonCurrentMatch_fn(this_);
} }

View File

@ -13,11 +13,13 @@ re::CTFParty *re::CTFParty::GetParty()
typedef re::CTFParty *(*GetParty_t)(void *); typedef re::CTFParty *(*GetParty_t)(void *);
typedef void *(*GTFGCClientSystem_t)(); 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 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 GTFGCClientSystem_t GTFGCClientSystem_fn =
static GetParty_t GetParty_fn = GetParty_t(e8call((void *)(addr1 + 27))); GTFGCClientSystem_t(e8call((void *) (addr1 + 14)));
static GetParty_t GetParty_fn = GetParty_t(e8call((void *) (addr1 + 27)));
return GetParty_fn(GTFGCClientSystem_fn()); return GetParty_fn(GTFGCClientSystem_fn());
} }

View File

@ -11,49 +11,69 @@
re::CTFPartyClient *re::CTFPartyClient::GTFPartyClient() re::CTFPartyClient *re::CTFPartyClient::GTFPartyClient()
{ {
typedef re::CTFPartyClient *(*GTFPartyClient_t)(void); 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 uintptr_t addr = gSignatures.GetClientSignature(
static GTFPartyClient_t GTFPartyClient_fn = GTFPartyClient_t(e8call((void *)addr)); "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(); return GTFPartyClient_fn();
} }
int re::CTFPartyClient::SendPartyChat(re::CTFPartyClient *client, const char *message) int re::CTFPartyClient::SendPartyChat(re::CTFPartyClient *client,
const char *message)
{ {
// todo // todo
} }
bool re::CTFPartyClient::BCanQueueForStandby(re::CTFPartyClient *this_) bool re::CTFPartyClient::BCanQueueForStandby(re::CTFPartyClient *this_)
{ {
typedef bool(*BCanQueueForStandby_t)(re::CTFPartyClient *); 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 uintptr_t addr = gSignatures.GetClientSignature(
static BCanQueueForStandby_t BCanQueueForStandby_fn = BCanQueueForStandby_t(addr); "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_); return BCanQueueForStandby_fn(this_);
} }
re::ITFGroupMatchCriteria *re::CTFPartyClient::MutLocalGroupCriteria(re::CTFPartyClient *client) re::ITFGroupMatchCriteria *
re::CTFPartyClient::MutLocalGroupCriteria(re::CTFPartyClient *client)
{ {
typedef re::ITFGroupMatchCriteria *(*MutLocalGroupCriteria_t)(re::CTFPartyClient *); typedef re::ITFGroupMatchCriteria *(*MutLocalGroupCriteria_t)(
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"); re::CTFPartyClient *);
static MutLocalGroupCriteria_t MutLocalGroupCriteria_fn = MutLocalGroupCriteria_t(addr); 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); return MutLocalGroupCriteria_fn(client);
} }
int re::CTFPartyClient::LoadSavedCasualCriteria(re::CTFPartyClient *client) int re::CTFPartyClient::LoadSavedCasualCriteria(re::CTFPartyClient *client)
{ {
typedef int(*LoadSavedCasualCriteria_t)(re::CTFPartyClient *); 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 uintptr_t addr = gSignatures.GetClientSignature(
static LoadSavedCasualCriteria_t LoadSavedCasualCriteria_fn = LoadSavedCasualCriteria_t(e8call((void *)addr)); "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); return LoadSavedCasualCriteria_fn(client);
} }
void re::CTFPartyClient::RequestQueueForMatch(re::CTFPartyClient *client) void re::CTFPartyClient::RequestQueueForMatch(re::CTFPartyClient *client)
{ {
typedef void(*RequestQueueForMatch_t)(re::CTFPartyClient *); 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 uintptr_t addr = gSignatures.GetClientSignature(
static RequestQueueForMatch_t RequestQueueForMatch_fn = RequestQueueForMatch_t(addr); "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); return RequestQueueForMatch_fn(client);
} }

View File

@ -7,10 +7,13 @@
#include "common.hpp" #include "common.hpp"
int re::ITFGroupMatchCriteria::SetMatchGroup(re::ITFGroupMatchCriteria *this_, int group) int re::ITFGroupMatchCriteria::SetMatchGroup(re::ITFGroupMatchCriteria *this_,
int group)
{ {
typedef int(*SetMatchGroup_t)(re::ITFGroupMatchCriteria *, int); 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"); 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); SetMatchGroup_t SetMatchGroup_fn = SetMatchGroup_t(addr);
return SetMatchGroup_fn(this_, group); return SetMatchGroup_fn(this_, group);

View File

@ -7,18 +7,13 @@
#include "common.hpp" #include "common.hpp"
CatCommand cmd_queue_start("mm_queue_casual", "Start casual queue", []() CatCommand cmd_queue_start("mm_queue_casual", "Start casual queue",
{ []() { tfmm::queue_start(); });
tfmm::queue_start();
});
CatCommand cmd_abandon("mm_abandon", "Abandon match", []() CatCommand cmd_abandon("mm_abandon", "Abandon match",
{ []() { tfmm::abandon(); });
tfmm::abandon();
});
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();
if (!party) if (!party)
{ {
@ -36,7 +31,9 @@ void queue_start()
re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient(); re::CTFPartyClient *client = re::CTFPartyClient::GTFPartyClient();
if (client) if (client)
{ {
re::ITFGroupMatchCriteria::SetMatchGroup(re::CTFPartyClient::MutLocalGroupCriteria(client), re::ITFGroupMatchCriteria::group::CASUAL); re::ITFGroupMatchCriteria::SetMatchGroup(
re::CTFPartyClient::MutLocalGroupCriteria(client),
re::ITFGroupMatchCriteria::group::CASUAL);
re::CTFPartyClient::LoadSavedCasualCriteria(client); re::CTFPartyClient::LoadSavedCasualCriteria(client);
re::CTFPartyClient::RequestQueueForMatch(client); re::CTFPartyClient::RequestQueueForMatch(client);
} }
@ -48,5 +45,4 @@ void abandon()
if (gc != nullptr) if (gc != nullptr)
re::CTFGCClientSystem::AbandonCurrentMatch(gc); re::CTFGCClientSystem::AbandonCurrentMatch(gc);
} }
} }

View File

@ -87,41 +87,37 @@ void initialize()
void draw_rect(float x, float y, float w, float h, const rgba_t &rgba) void draw_rect(float x, float y, float w, float h, const rgba_t &rgba)
{ {
glez_rect(x, y, w, h, glez_rect(x, y, w, h, *reinterpret_cast<const glez_rgba_t *>(&rgba));
*reinterpret_cast<const glez_rgba_t *>(&rgba));
} }
void draw_rect_outlined(float x, float y, float w, float h, const rgba_t &rgba, void draw_rect_outlined(float x, float y, float w, float h, const rgba_t &rgba,
float thickness) float thickness)
{ {
glez_rect_outline( glez_rect_outline(x, y, w, h, *reinterpret_cast<const glez_rgba_t *>(&rgba),
x, y, w, h, *reinterpret_cast<const glez_rgba_t *>(&rgba), thickness);
thickness);
} }
void draw_line(float x, float y, float dx, float dy, const rgba_t &rgba, void draw_line(float x, float y, float dx, float dy, const rgba_t &rgba,
float thickness) float thickness)
{ {
glez_line(x, y, dx, dy, glez_line(x, y, dx, dy, *reinterpret_cast<const glez_rgba_t *>(&rgba),
*reinterpret_cast<const glez_rgba_t *>(&rgba), thickness);
thickness);
} }
void draw_rect_textured(float x, float y, float w, float h, const rgba_t &rgba, void draw_rect_textured(float x, float y, float w, float h, const rgba_t &rgba,
texture_handle_t texture, float u, float v, float s, texture_handle_t texture, float u, float v, float s,
float t) float t)
{ {
glez_rect_textured( glez_rect_textured(x, y, w, h,
x, y, w, h, *reinterpret_cast<const glez_rgba_t *>(&rgba), *reinterpret_cast<const glez_rgba_t *>(&rgba),
texture.handle, u, v, s, t); texture.handle, u, v, s, t);
} }
void draw_circle(float x, float y, float radius, const rgba_t &rgba, void draw_circle(float x, float y, float radius, const rgba_t &rgba,
float thickness, int steps) float thickness, int steps)
{ {
glez_circle(x, y, radius, glez_circle(x, y, radius, *reinterpret_cast<const glez_rgba_t *>(&rgba),
*reinterpret_cast<const glez_rgba_t *>(&rgba), thickness, steps);
thickness, steps);
} }
void draw_string(float x, float y, const char *string, font_handle_t &font, void draw_string(float x, float y, const char *string, font_handle_t &font,
@ -130,8 +126,8 @@ void draw_string(float x, float y, const char *string, font_handle_t &font,
if (!font.handle) if (!font.handle)
font.handle = glez_font_load(font.filename.c_str(), font.size); font.handle = glez_font_load(font.filename.c_str(), font.size);
glez_string(x, y, string, font.handle, glez_string(x, y, string, font.handle,
*reinterpret_cast<const glez_rgba_t *>(&rgba), *reinterpret_cast<const glez_rgba_t *>(&rgba), nullptr,
nullptr, nullptr); nullptr);
} }
void draw_string_with_outline(float x, float y, const char *string, void draw_string_with_outline(float x, float y, const char *string,