From d4bc116a5796386c71bfba6b9ebbb080eea98337 Mon Sep 17 00:00:00 2001 From: LightCat Date: Sat, 15 Sep 2018 12:13:42 +0200 Subject: [PATCH] clang --- include/hooks/HookTools.hpp | 15 ++++++++++----- src/crits.cpp | 15 ++++++++------- src/hacks/CatBot.cpp | 27 +++++++++++++++------------ src/hacks/LightESP.cpp | 2 +- src/hacks/NavBot.cpp | 5 +++-- src/hacks/Spam.cpp | 3 ++- src/hacks/Trigger.cpp | 2 +- src/hooks/CreateMove.cpp | 15 ++++++++------- src/hooks/DispatchUserMessage.cpp | 18 +++++++++++------- src/hooks/HookTools.cpp | 10 +++++----- src/hooks/Shutdown.cpp | 22 +++++++++++++--------- src/settings/Settings.cpp | 2 +- src/tfmm.cpp | 2 +- src/visual/EffectChams.cpp | 3 ++- src/visual/drawmgr.cpp | 5 ++--- src/visual/menu/GuiInterface.cpp | 3 ++- 16 files changed, 85 insertions(+), 64 deletions(-) mode change 100755 => 100644 src/settings/Settings.cpp mode change 100755 => 100644 src/visual/menu/GuiInterface.cpp diff --git a/include/hooks/HookTools.hpp b/include/hooks/HookTools.hpp index a122df9e..79e59072 100644 --- a/include/hooks/HookTools.hpp +++ b/include/hooks/HookTools.hpp @@ -11,7 +11,7 @@ class HookedFunction; namespace HookTools { -std::vector &GetHookedFunctions(); +std::vector &GetHookedFunctions(); void CM(); } // namespace HookTools @@ -27,7 +27,8 @@ class HookedFunction std::string m_name; std::function m_func; HookedFunctions_types m_type; - void init(HookedFunctions_types type, std::string name, int priority, std::function func) + void init(HookedFunctions_types type, std::string name, int priority, + std::function func) { switch (type) { @@ -44,6 +45,7 @@ class HookedFunction m_type = type; HookTools::GetHookedFunctions().push_back(this); } + public: int m_priority; void run(HookedFunctions_types type) @@ -57,16 +59,19 @@ public: m_func(); } } - HookedFunction(HookedFunctions_types type, std::string name, int priority, std::function func) + HookedFunction(HookedFunctions_types type, std::string name, int priority, + std::function func) { init(type, name, priority, func); } - HookedFunction(HookedFunctions_types type, int priority, std::function func) + HookedFunction(HookedFunctions_types type, int priority, + std::function func) { static const std::string name("UNNAMED_FUNCTIONS"); init(type, name, priority, func); } - HookedFunction(HookedFunctions_types type, std::string name, std::function func) + HookedFunction(HookedFunctions_types type, std::string name, + std::function func) { int priority = 5; init(type, name, priority, func); diff --git a/src/crits.cpp b/src/crits.cpp index 7d98af73..0a92f0aa 100644 --- a/src/crits.cpp +++ b/src/crits.cpp @@ -25,13 +25,14 @@ CatCommand test("crit_debug_print", "debug", []() { return; if (CE_BAD(LOCAL_W)) return; - unsigned unk1 = *(unsigned *)(RAW_ENT(LOCAL_W) + 2832); - unsigned unk2 = *(unsigned *)(RAW_ENT(LOCAL_W) + 2820); - unsigned char CritSlots = *(unsigned char *)(unk1 + (unk2 << 6) + 1844); - int CritSlots2 = *(unsigned *)(unk1 + (unk2 << 6) + 1788); - unsigned CritSlots3 = *(unsigned *)(unk1 + (unk2 << 6) + 1788); - int CritSlots4 = *(int *)(unk1 + (unk2 << 6) + 1788); - logging::Info("%u %d %d %u %d", unk1, int(CritSlots), CritSlots2, CritSlots3, CritSlots4); + unsigned unk1 = *(unsigned *) (RAW_ENT(LOCAL_W) + 2832); + unsigned unk2 = *(unsigned *) (RAW_ENT(LOCAL_W) + 2820); + unsigned char CritSlots = *(unsigned char *) (unk1 + (unk2 << 6) + 1844); + int CritSlots2 = *(unsigned *) (unk1 + (unk2 << 6) + 1788); + unsigned CritSlots3 = *(unsigned *) (unk1 + (unk2 << 6) + 1788); + int CritSlots4 = *(int *) (unk1 + (unk2 << 6) + 1788); + logging::Info("%u %d %d %u %d", unk1, int(CritSlots), CritSlots2, + CritSlots3, CritSlots4); }); int find_next_random_crit_for_weapon(IClientEntity *weapon) { diff --git a/src/hacks/CatBot.cpp b/src/hacks/CatBot.cpp index 3eadfb8a..4f53b0bf 100644 --- a/src/hacks/CatBot.cpp +++ b/src/hacks/CatBot.cpp @@ -219,13 +219,14 @@ void reportall() player_info_s info; if (g_IEngine->GetPlayerInfo(i, &info)) { -// if (info.friendsID == local.friendsID || -// playerlist::AccessData(info.friendsID).state == -// playerlist::k_EState::FRIEND || -// playerlist::AccessData(info.friendsID).state == -// playerlist::k_EState::IPC) -// continue; - if (player_tools::shouldTargetSteamId(info.friendsID) != player_tools::IgnoreReason::DO_NOT_IGNORE) + // if (info.friendsID == local.friendsID || + // playerlist::AccessData(info.friendsID).state == + // playerlist::k_EState::FRIEND || + // playerlist::AccessData(info.friendsID).state == + // playerlist::k_EState::IPC) + // continue; + if (player_tools::shouldTargetSteamId(info.friendsID) != + player_tools::IgnoreReason::DO_NOT_IGNORE) continue; CSteamID id(info.friendsID, EUniverse::k_EUniversePublic, EAccountType::k_EAccountTypeIndividual); @@ -251,14 +252,17 @@ void smart_crouch() for (int i = 0; i < g_IEngine->GetMaxClients(); i++) { auto ent = ENTITY(i); - if (CE_BAD(ent) || ent->m_Type() != ENTITY_PLAYER || ent->m_iTeam() == LOCAL_E->m_iTeam() || + if (CE_BAD(ent) || ent->m_Type() != ENTITY_PLAYER || + ent->m_iTeam() == LOCAL_E->m_iTeam() || !(ent->hitboxes.GetHitbox(0)) || !(ent->m_bAlivePlayer()) || - player_tools::shouldTargetSteamId(ent->player_info.friendsID) != player_tools::IgnoreReason::DO_NOT_IGNORE || + player_tools::shouldTargetSteamId(ent->player_info.friendsID) != + player_tools::IgnoreReason::DO_NOT_IGNORE || should_ignore_player(ent)) continue; bool failedvis = false; for (int j = 0; j < 18; j++) - if (IsVectorVisible(g_pLocalPlayer->v_Eye, ent->hitboxes.GetHitbox(j)->center)) + if (IsVectorVisible(g_pLocalPlayer->v_Eye, + ent->hitboxes.GetHitbox(j)->center)) failedvis = true; if (failedvis) continue; @@ -286,8 +290,7 @@ void smart_crouch() } // TODO: add more stuffs -static HookedFunction cm(HF_CreateMove, "catbot", 5, []() -{ +static HookedFunction cm(HF_CreateMove, "catbot", 5, []() { if (!*enable) return; diff --git a/src/hacks/LightESP.cpp b/src/hacks/LightESP.cpp index 82519d26..c2b8f8ec 100644 --- a/src/hacks/LightESP.cpp +++ b/src/hacks/LightESP.cpp @@ -15,7 +15,7 @@ Vector maxp[32]; bool drawEsp[32]; #if ENABLE_VISUALS -static HookedFunction cm(HF_CreateMove, "lightesp", 5, [](){ +static HookedFunction cm(HF_CreateMove, "lightesp", 5, []() { if (!*enable) return; for (int i = 1; i < g_IEngine->GetMaxClients(); i++) diff --git a/src/hacks/NavBot.cpp b/src/hacks/NavBot.cpp index ba6f9ba7..1be325d0 100644 --- a/src/hacks/NavBot.cpp +++ b/src/hacks/NavBot.cpp @@ -363,7 +363,7 @@ bool NavToEnemy() if (CE_GOOD(ent)) { int nearestvalid = - nav::FindNearestValidbyDist(ent->m_vecOrigin(), 1000, 4000); + nav::FindNearestValidbyDist(ent->m_vecOrigin(), 1000, 4000); if (nearestvalid != -1) { auto area = nav::areas[nearestvalid]; @@ -445,7 +445,8 @@ void CreateMove() return; if (primary_only && enable) UpdateSlot(); - if (*stay_near && nav_enemy_cd.test_and_set(1000) && (!HasLowAmmo()) & (!HasLowHealth())) + if (*stay_near && nav_enemy_cd.test_and_set(1000) && + (!HasLowAmmo()) & (!HasLowHealth())) NavToEnemy(); if (HasLowHealth() && cdr.test_and_set(5000)) { diff --git a/src/hacks/Spam.cpp b/src/hacks/Spam.cpp index 5c85385d..c29c2a83 100644 --- a/src/hacks/Spam.cpp +++ b/src/hacks/Spam.cpp @@ -392,7 +392,8 @@ bool isActive() const std::vector builtin_default = { "Cathook - more fun than a ball of yarn!", "GNU/Linux is the best OS!", "Visit https://github.com/nullworks/cathook for more information!", - "Cathook - Free and Open-Source tf2 cheat!", "Cathook - ca(n)t stop me meow!" + "Cathook - Free and Open-Source tf2 cheat!", + "Cathook - ca(n)t stop me meow!" }; const std::vector builtin_lennyfaces = { "( ͡° ͜ʖ ͡°)", "( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°) ͡°)", diff --git a/src/hacks/Trigger.cpp b/src/hacks/Trigger.cpp index 48a826f0..62b9d47b 100644 --- a/src/hacks/Trigger.cpp +++ b/src/hacks/Trigger.cpp @@ -330,7 +330,7 @@ bool IsTargetStateGood(CachedEntity *entity) // return false Vector hit; if (!CheckLineBox(minz, maxz, g_pLocalPlayer->v_Eye, forward, - hit)) + hit)) return false; } } diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index 40823aa8..268eb3bd 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -452,27 +452,28 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, if (roll_speedhack && cmd->buttons & IN_DUCK && !(cmd->buttons & IN_ATTACK)) { - speed = Vector{cmd->forwardmove, cmd->sidemove, 0.0f}.Length(); + speed = Vector{ cmd->forwardmove, cmd->sidemove, 0.0f }.Length(); static float prevspeedang = 0.0f; if (fabs(speed) > 0.0f) { - Vector vecMove( cmd->forwardmove, cmd->sidemove, 0.0f ); + Vector vecMove(cmd->forwardmove, cmd->sidemove, 0.0f); vecMove *= -1; float flLength = vecMove.Length(); Vector angMoveReverse{}; - VectorAngles( vecMove, angMoveReverse ); + VectorAngles(vecMove, angMoveReverse); cmd->forwardmove = -flLength; - cmd->sidemove = 0.0f; // Move only backwards, no sidemove - float res = g_pLocalPlayer->v_OrigViewangles.y - angMoveReverse.y; + cmd->sidemove = 0.0f; // Move only backwards, no sidemove + float res = + g_pLocalPlayer->v_OrigViewangles.y - angMoveReverse.y; while (res > 180) res -= 360; while (res < -180) res += 360; if (res - prevspeedang > 90.0f) res = (res + prevspeedang) / 2; - prevspeedang = res; - cmd->viewangles.y = res; + prevspeedang = res; + cmd->viewangles.y = res; cmd->viewangles.z = 90.0f; g_pLocalPlayer->bUseSilentAngles = true; speedapplied = true; diff --git a/src/hooks/DispatchUserMessage.cpp b/src/hooks/DispatchUserMessage.cpp index 72105e6b..a53e2ec1 100644 --- a/src/hooks/DispatchUserMessage.cpp +++ b/src/hooks/DispatchUserMessage.cpp @@ -53,12 +53,14 @@ DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, for (int i = 0; i < buf.GetNumBytesLeft(); i++) { int byte = buf.ReadByte(); - if ( byte == 0) + if (byte == 0) break; message_name.push_back(byte); } - if (message_name.find("TF_Autobalance_TeamChangePending") != std::string::npos) - logging::Info("test, %d %d", int(message_name[0]), (CE_GOOD(LOCAL_E) ? LOCAL_E->m_IDX : -1)); + if (message_name.find("TF_Autobalance_TeamChangePending") != + std::string::npos) + logging::Info("test, %d %d", int(message_name[0]), + (CE_GOOD(LOCAL_E) ? LOCAL_E->m_IDX : -1)); } if (type == 4) { @@ -133,8 +135,9 @@ DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, } for (char i : name1) { - if (i == ' '); - continue; + if (i == ' ') + ; + continue; if (iii == 2) { iii = 0; @@ -151,8 +154,9 @@ DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, iii = 0; for (char i : name1) { - if (i == ' '); - continue; + if (i == ' ') + ; + continue; if (iii == 3) { iii = 0; diff --git a/src/hooks/HookTools.cpp b/src/hooks/HookTools.cpp index 3bd9da96..327d0c4a 100644 --- a/src/hooks/HookTools.cpp +++ b/src/hooks/HookTools.cpp @@ -1,8 +1,8 @@ #include "HookTools.hpp" -std::vector &HookTools::GetHookedFunctions() +std::vector &HookTools::GetHookedFunctions() { - static std::vector CreateMoves{}; + static std::vector CreateMoves{}; return CreateMoves; } @@ -19,8 +19,8 @@ void HookTools::CM() static InitRoutine init([]() { auto &HookedFunctions = HookTools::GetHookedFunctions(); std::sort(HookedFunctions.begin(), HookedFunctions.end(), - [](HookedFunction *a, HookedFunction *b){ - return a->m_priority > b->m_priority; - }); + [](HookedFunction *a, HookedFunction *b) { + return a->m_priority > b->m_priority; + }); logging::Info("Sorted Hooked Functions: %i", HookedFunctions.size()); }); diff --git a/src/hooks/Shutdown.cpp b/src/hooks/Shutdown.cpp index 78f402e7..db69d946 100644 --- a/src/hooks/Shutdown.cpp +++ b/src/hooks/Shutdown.cpp @@ -23,21 +23,25 @@ DEFINE_HOOKED_METHOD(Shutdown, void, INetChannel *this_, const char *reason) logging::Info("Disconnect: %s", reason); if (strstr(reason, "Generic_Kicked")) { - if (*die_if_vac) { - static uintptr_t addr = - gSignatures.GetClientSignature("C7 04 24 ? ? ? ? 8D 7D ? 31 F6"); + if (*die_if_vac) + { + static uintptr_t addr = gSignatures.GetClientSignature( + "C7 04 24 ? ? ? ? 8D 7D ? 31 F6"); static uintptr_t offset0 = uintptr_t(*(uintptr_t *) (addr + 0x3)); static uintptr_t offset1 = gSignatures.GetClientSignature( - "55 89 E5 83 EC ? 8B 45 ? 8B 80 ? ? ? ? 85 C0 74 ? C7 44 24 ? ? ? ? ? " - "89 04 24 E8 ? ? ? ? 85 C0 74 ? 8B 40"); + "55 89 E5 83 EC ? 8B 45 ? 8B 80 ? ? ? ? 85 C0 74 ? C7 44 24 ? " + "? ? ? ? " + "89 04 24 E8 ? ? ? ? 85 C0 74 ? 8B 40"); typedef int (*GetPendingInvites_t)(uintptr_t); - GetPendingInvites_t GetPendingInvites = GetPendingInvites_t(offset1); + GetPendingInvites_t GetPendingInvites = + GetPendingInvites_t(offset1); int invites = GetPendingInvites(offset0); - re::CTFGCClientSystem *gc = re::CTFGCClientSystem::GTFGCClientSystem(); + re::CTFGCClientSystem *gc = + re::CTFGCClientSystem::GTFGCClientSystem(); re::CTFPartyClient *pc = re::CTFPartyClient::GTFPartyClient(); - if (gc && !gc->BConnectedToMatchServer(false) && !gc->BHaveLiveMatch() && - !invites) + if (gc && !gc->BConnectedToMatchServer(false) && + !gc->BHaveLiveMatch() && !invites) if (!(pc && pc->BInQueueForMatchGroup(tfmm::getQueue()))) { logging::Info("VAC/Matchmaking banned"); diff --git a/src/settings/Settings.cpp b/src/settings/Settings.cpp old mode 100755 new mode 100644 index 6659adbc..7c74610e --- a/src/settings/Settings.cpp +++ b/src/settings/Settings.cpp @@ -6,5 +6,5 @@ namespace settings { -std::atomic RVarLock{false}; +std::atomic RVarLock{ false }; } diff --git a/src/tfmm.cpp b/src/tfmm.cpp index 225d729e..5ec6c505 100644 --- a/src/tfmm.cpp +++ b/src/tfmm.cpp @@ -59,7 +59,7 @@ void startQueue() if (*queue == 7) client->LoadSavedCasualCriteria(); client->RequestQueueForMatch((int) queue); - //client->RequestQueueForStandby(); + // client->RequestQueueForStandby(); queuecount++; } else diff --git a/src/visual/EffectChams.cpp b/src/visual/EffectChams.cpp index 5ea77e4d..c6eff8f7 100644 --- a/src/visual/EffectChams.cpp +++ b/src/visual/EffectChams.cpp @@ -89,7 +89,8 @@ int prevcolor = -1; rgba_t EffectChams::ChamsColor(IClientEntity *entity) { if (!isHackActive() || !*enable) - return colors::empty;; + return colors::empty; + ; CachedEntity *ent = ENTITY(entity->entindex()); if (disco_chams) { diff --git a/src/visual/drawmgr.cpp b/src/visual/drawmgr.cpp index e6f9b659..aa58b6c0 100644 --- a/src/visual/drawmgr.cpp +++ b/src/visual/drawmgr.cpp @@ -72,9 +72,8 @@ void DrawCheatVisuals() GUIColor()); // github commit and date AddSideString(hack::GetType(), GUIColor()); // Compile type #if ENABLE_GUI - AddSideString( - "Press 'INSERT' key to open/close cheat menu.", - GUIColor()); + AddSideString("Press 'INSERT' key to open/close cheat menu.", + GUIColor()); AddSideString("Use mouse to navigate in menu.", GUIColor()); #endif if (!g_IEngine->IsInGame() diff --git a/src/visual/menu/GuiInterface.cpp b/src/visual/menu/GuiInterface.cpp old mode 100755 new mode 100644 index 223fcb85..62042e50 --- a/src/visual/menu/GuiInterface.cpp +++ b/src/visual/menu/GuiInterface.cpp @@ -98,7 +98,8 @@ static void initPlayerlist() }); controller->setOpenSteamCallback([](unsigned steam) { CSteamID id{}; - id.Set(steam, EUniverse::k_EUniversePublic, EAccountType::k_EAccountTypeIndividual); + id.Set(steam, EUniverse::k_EUniversePublic, + EAccountType::k_EAccountTypeIndividual); g_ISteamFriends->ActivateGameOverlayToUser("steamid", id); }); }