From a8298496194e8c8279074b5f3e2e2378ab29e860 Mon Sep 17 00:00:00 2001 From: LightCat Date: Sun, 27 Jan 2019 10:51:42 +0100 Subject: [PATCH] Fix anti auto balance issues and clang format --- src/hacks/ac/aimbot.cpp | 4 ++-- src/helpers.cpp | 3 ++- src/hooks/DispatchUserMessage.cpp | 4 ++-- src/reclasses/CTFGCClientSystem.cpp | 2 +- src/reclasses/CTFPartyClient.cpp | 33 +++++++++++++++-------------- src/votelogger.cpp | 11 ++++------ 6 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/hacks/ac/aimbot.cpp b/src/hacks/ac/aimbot.cpp index 22c0b614..ec93a36e 100644 --- a/src/hacks/ac/aimbot.cpp +++ b/src/hacks/ac/aimbot.cpp @@ -111,8 +111,8 @@ void Event(KeyValues *event) { CachedEntity *victim = ENTITY(vid); CachedEntity *attacker = ENTITY(eid); - auto &Po_v = Player_origs[vid]; - auto &Po_e = Player_origs[eid]; + auto &Po_v = Player_origs[vid]; + auto &Po_e = Player_origs[eid]; if (Po_v.z != 0 && Po_e.z != 0) if (Po_v.DistTo(Po_e) > 250) { diff --git a/src/helpers.cpp b/src/helpers.cpp index feb74332..345632ec 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -815,7 +815,8 @@ int UniformRandomInt(int min, int max) while (len) { bound = (1U + RAND_MAX) % len; - while ((r = rand()) < bound); + while ((r = rand()) < bound) + ; result *= 1U + RAND_MAX; result += r % len; len -= len > RAND_MAX ? RAND_MAX : len; diff --git a/src/hooks/DispatchUserMessage.cpp b/src/hooks/DispatchUserMessage.cpp index 5a2d67ae..4a219718 100644 --- a/src/hooks/DispatchUserMessage.cpp +++ b/src/hooks/DispatchUserMessage.cpp @@ -113,7 +113,7 @@ DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, bf_read & logging::Info("%s", data.c_str()); if (data.find("TeamChangeP") != data.npos && CE_GOOD(LOCAL_E)) { - std::string server_name = server->GetName(); + std::string server_name(server->GetAddress()); if (server_name != previous_name) { previous_name = server_name; @@ -161,7 +161,7 @@ DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, bf_read & { player_info_s info{}; g_IEngine->GetPlayerInfo(LOCAL_E->m_IDX, &info); - const char *claz = nullptr; + const char *claz = nullptr; std::string name1 = info.name; switch (g_pLocalPlayer->clazz) diff --git a/src/reclasses/CTFGCClientSystem.cpp b/src/reclasses/CTFGCClientSystem.cpp index 6f5487a6..d27aef0c 100644 --- a/src/reclasses/CTFGCClientSystem.cpp +++ b/src/reclasses/CTFGCClientSystem.cpp @@ -13,7 +13,7 @@ using namespace re; CTFGCClientSystem *CTFGCClientSystem::GTFGCClientSystem() { typedef CTFGCClientSystem *(*GTFGCClientSystem_t)(); - static uintptr_t addr1 = gSignatures.GetClientSignature("55 B8 ? ? ? ? 89 E5 5D C3 8D B6 00 00 00 00 55 A1 ? ? ? ? 89 E5 5D C3 " + static uintptr_t addr1 = gSignatures.GetClientSignature("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(addr1); diff --git a/src/reclasses/CTFPartyClient.cpp b/src/reclasses/CTFPartyClient.cpp index d750add0..9736ba08 100644 --- a/src/reclasses/CTFPartyClient.cpp +++ b/src/reclasses/CTFPartyClient.cpp @@ -11,7 +11,7 @@ re::CTFPartyClient *re::CTFPartyClient::GTFPartyClient() { typedef re::CTFPartyClient *(*GTFPartyClient_t)(void); - static uintptr_t addr = gSignatures.GetClientSignature("55 A1 ? ? ? ? 89 E5 5D C3 8D B6 00 00 00 00 A1 ? ? ? ? 85 C0"); + static uintptr_t addr = gSignatures.GetClientSignature("55 A1 ? ? ? ? 89 E5 5D C3 8D B6 00 00 00 00 A1 ? ? ? ? 85 C0"); static GTFPartyClient_t GTFPartyClient_fn = GTFPartyClient_t(addr); return GTFPartyClient_fn(); @@ -24,7 +24,7 @@ bool re::CTFPartyClient::BInQueue(re::CTFPartyClient *this_) int re::CTFPartyClient::GetNumOnlineMembers() { typedef int (*GetNumOnlineMembers_t)(re::CTFPartyClient *); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC ? 8B 7D ? 8B 77 ? 85 F6 0F 84"); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC ? 8B 7D ? 8B 77 ? 85 F6 0F 84"); static GetNumOnlineMembers_t GetNumOnlineMembers_fn = GetNumOnlineMembers_t(addr); return GetNumOnlineMembers_fn(this); @@ -32,7 +32,7 @@ int re::CTFPartyClient::GetNumOnlineMembers() int re::CTFPartyClient::GetNumMembers() { typedef int (*GetNumMembers_t)(re::CTFPartyClient *); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 8B 45 ? 8B 50 ? C6 80") + 0x30; + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 8B 45 ? 8B 50 ? C6 80") + 0x30; static GetNumMembers_t GetNumMembers_fn = GetNumMembers_t(addr); return GetNumMembers_fn(this); @@ -40,7 +40,7 @@ int re::CTFPartyClient::GetNumMembers() void re::CTFPartyClient::SendPartyChat(const char *message) { typedef void (*SendPartyChat_t)(re::CTFPartyClient *, const char *); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC ? ? ? ? 8B 5D 0C 89 1C 24"); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC ? ? ? ? 8B 5D 0C 89 1C 24"); static SendPartyChat_t SendPartyChat_fn = SendPartyChat_t(addr); SendPartyChat_fn(this, message); @@ -49,7 +49,7 @@ void re::CTFPartyClient::SendPartyChat(const char *message) 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 " + 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); @@ -59,7 +59,7 @@ bool re::CTFPartyClient::BCanQueueForStandby(re::CTFPartyClient *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 ? 8B 50 ? C6 80"); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 8B 45 ? 8B 50 ? C6 80"); static MutLocalGroupCriteria_t MutLocalGroupCriteria_fn = MutLocalGroupCriteria_t(addr); return MutLocalGroupCriteria_fn(client); @@ -69,7 +69,8 @@ int re::CTFPartyClient::LoadSavedCasualCriteria() { typedef int (*LoadSavedCasualCriteria_t)(re::CTFPartyClient *); static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 8B 45 ? 5D 8B 80 ? ? ? ? C3 66 90 55 89 E5 " - "8B 45 ? 5D 0F B6 80 ? ? ? ? C3 90 55 89 E5 56") - 0x40; + "8B 45 ? 5D 0F B6 80 ? ? ? ? C3 90 55 89 E5 56") - + 0x40; static LoadSavedCasualCriteria_t LoadSavedCasualCriteria_fn = LoadSavedCasualCriteria_t(addr); return LoadSavedCasualCriteria_fn(this); @@ -77,7 +78,7 @@ int re::CTFPartyClient::LoadSavedCasualCriteria() void re::CTFPartyClient::RequestQueueForStandby() { typedef void (*RequestStandby_t)(re::CTFPartyClient *); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC ? 8B 7D ? 8B 4F ? 85 C9 74"); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC ? 8B 7D ? 8B 4F ? 85 C9 74"); static RequestStandby_t RequestStandby_fn = RequestStandby_t(addr); RequestStandby_fn(this); return; @@ -85,7 +86,7 @@ void re::CTFPartyClient::RequestQueueForStandby() char re::CTFPartyClient::RequestQueueForMatch(int type) { typedef char (*RequestQueueForMatch_t)(re::CTFPartyClient *, int); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC ? ? ? ? 8B 45 ? E8"); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC ? ? ? ? 8B 45 ? E8"); static RequestQueueForMatch_t RequestQueueForMatch_fn = RequestQueueForMatch_t(addr); return RequestQueueForMatch_fn(this, type); @@ -93,7 +94,7 @@ char re::CTFPartyClient::RequestQueueForMatch(int type) bool re::CTFPartyClient::BInQueueForMatchGroup(int type) { typedef bool (*BInQueueForMatchGroup_t)(re::CTFPartyClient *, int); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 56 53 8B 5D ? 8B 75 ? 89 D8 E8 ? ? ? ? 84 C0 74 ? 8B 4E"); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 56 53 8B 5D ? 8B 75 ? 89 D8 E8 ? ? ? ? 84 C0 74 ? 8B 4E"); static BInQueueForMatchGroup_t BInQueueForMatchGroup_fn = BInQueueForMatchGroup_t(addr); return BInQueueForMatchGroup_fn(this, type); @@ -105,7 +106,7 @@ bool re::CTFPartyClient::BInQueueForStandby() char re::CTFPartyClient::RequestLeaveForMatch(int type) { typedef char (*RequestLeaveForMatch_t)(re::CTFPartyClient *, int); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC ? 8B 45 ? 89 44 24 ? 8B 45 ? 89 04 24 E8 ? ? " + static 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"); static RequestLeaveForMatch_t RequestLeaveForMatch_fn = RequestLeaveForMatch_t(addr); @@ -114,7 +115,7 @@ char re::CTFPartyClient::RequestLeaveForMatch(int type) int re::CTFPartyClient::BInvitePlayerToParty(CSteamID steamid) { typedef int (*BInvitePlayerToParty_t)(re::CTFPartyClient *, CSteamID, bool); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC ? ? ? ? 8B 45 ? 8B 5D ? 8B 55 ? 89 85 ? ? ? ? " + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC ? ? ? ? 8B 45 ? 8B 5D ? 8B 55 ? 89 85 ? ? ? ? " "65 A1 ? ? ? ? 89 45 ? 31 C0 8B 45"); static BInvitePlayerToParty_t BInvitePlayerToParty_fn = BInvitePlayerToParty_t(addr); return BInvitePlayerToParty_fn(this, steamid, false); @@ -123,14 +124,14 @@ int re::CTFPartyClient::BRequestJoinPlayer(CSteamID steamid) { // 55 89 E5 57 56 53 81 EC 8C 00 00 00 8B 45 14 8B 55 10 89 45 A4 8B 45 0C typedef int (*BRequestJoinPlayer_t)(re::CTFPartyClient *, CSteamID, bool); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC ? ? ? ? 8B 45 14 8B 55 ? 89 45 ? 8B"); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 57 56 53 81 EC ? ? ? ? 8B 45 14 8B 55 ? 89 45 ? 8B"); static BRequestJoinPlayer_t BRequestJoinPlayer_fn = BRequestJoinPlayer_t(addr); return BRequestJoinPlayer_fn(this, steamid, false); } int re::CTFPartyClient::PromotePlayerToLeader(CSteamID steamid) { typedef int (*PromotePlayerToLeader_t)(re::CTFPartyClient *, CSteamID); - static uintptr_t addr = gSignatures.GetClientSignature("8B 55 08 8B 8A A0 01 00 00 8B 92 9C 01 00 00 89 04 24 89 4C 24 08 89 54 24 04 E8") + 27; + static uintptr_t addr = gSignatures.GetClientSignature("8B 55 08 8B 8A A0 01 00 00 8B 92 9C 01 00 00 89 04 24 89 4C 24 08 89 54 24 04 E8") + 27; static PromotePlayerToLeader_t PromotePlayerToLeader_fn = PromotePlayerToLeader_t(e8call(reinterpret_cast(addr))); return PromotePlayerToLeader_fn(this, steamid); @@ -138,7 +139,7 @@ int re::CTFPartyClient::PromotePlayerToLeader(CSteamID steamid) int re::CTFPartyClient::KickPlayer(CSteamID steamid) { typedef int (*KickPlayer_t)(re::CTFPartyClient *, CSteamID); - static uintptr_t addr = gSignatures.GetClientSignature("8B 93 9C 01 00 00 8B 8B A0 01 00 00 89 04 24 89 54 24 04 89 4C 24 08 E8") + 24; + static uintptr_t addr = gSignatures.GetClientSignature("8B 93 9C 01 00 00 8B 8B A0 01 00 00 89 04 24 89 54 24 04 89 4C 24 08 E8") + 24; static KickPlayer_t KickPlayer_fn = KickPlayer_t(e8call(reinterpret_cast(addr))); return KickPlayer_fn(this, steamid); @@ -155,7 +156,7 @@ bool re::CTFPartyClient::GetCurrentPartyLeader(CSteamID &id) re::ITFMatchGroupDescription *re::GetMatchGroupDescription(int &idx) { typedef re::ITFMatchGroupDescription *(*GetMatchGroupDescription_t)(int &); - static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 8B 45 ? 8B 00 83 F8 ? 77"); + static uintptr_t addr = gSignatures.GetClientSignature("55 89 E5 8B 45 ? 8B 00 83 F8 ? 77"); static GetMatchGroupDescription_t GetMatchGroupDescription_fn = GetMatchGroupDescription_t(addr); return GetMatchGroupDescription_fn(idx); diff --git a/src/votelogger.cpp b/src/votelogger.cpp index 298d9a5a..c5f9bdbe 100644 --- a/src/votelogger.cpp +++ b/src/votelogger.cpp @@ -77,8 +77,7 @@ void dispatchUserMessage(bf_read &buffer, int type) if (!g_IEngine->GetPlayerInfo(eid, &info) || !g_IEngine->GetPlayerInfo(caller, &info2)) break; - logging::Info("Vote called to kick %s [U:1:%u] for %s by %s [U:1:%u]", - info.name, info.friendsID, reason, info2.name, info2.friendsID); + logging::Info("Vote called to kick %s [U:1:%u] for %s by %s [U:1:%u]", info.name, info.friendsID, reason, info2.name, info2.friendsID); if (eid == LOCAL_E->m_IDX) was_local_player = true; @@ -86,8 +85,8 @@ void dispatchUserMessage(bf_read &buffer, int type) { using namespace playerlist; - auto &pl = AccessData(info.friendsID); - auto &pl_caller = AccessData(info2.friendsID); + auto &pl = AccessData(info.friendsID); + auto &pl_caller = AccessData(info2.friendsID); bool friendly_kicked = pl.state != k_EState::RAGE && pl.state != k_EState::DEFAULT; bool friendly_caller = pl_caller.state != k_EState::RAGE && pl_caller.state != k_EState::DEFAULT; @@ -103,9 +102,7 @@ void dispatchUserMessage(bf_read &buffer, int type) if (*party_say) { char formated_string[256]; - std::snprintf(formated_string, sizeof(formated_string), - "[CAT] votekick called: %s => %s (%s)", - info2.name, info.name, reason); + std::snprintf(formated_string, sizeof(formated_string), "[CAT] votekick called: %s => %s (%s)", info2.name, info.name, reason); re::CTFPartyClient::GTFPartyClient()->SendPartyChat(formated_string); } break;