From e5e03959d2486dfb79f822fdc0ea641ba78a9f30 Mon Sep 17 00:00:00 2001 From: LightCat Date: Sun, 19 Aug 2018 22:06:09 +0200 Subject: [PATCH 1/6] test commit --- include/EventLogging.hpp | 10 +++ src/EventLogging.cpp | 168 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+) create mode 100755 include/EventLogging.hpp create mode 100755 src/EventLogging.cpp diff --git a/include/EventLogging.hpp b/include/EventLogging.hpp new file mode 100755 index 00000000..3cb4f5ef --- /dev/null +++ b/include/EventLogging.hpp @@ -0,0 +1,10 @@ +/* + Created on 29.07.18. +*/ + +#pragma once + +namespace event_logging +{ +bool isEnabled(); +} \ No newline at end of file diff --git a/src/EventLogging.cpp b/src/EventLogging.cpp new file mode 100755 index 00000000..54043513 --- /dev/null +++ b/src/EventLogging.cpp @@ -0,0 +1,168 @@ +/* + Created on 29.07.18. +*/ + +#include +#include +#include +#include +#include + +static settings::Bool enable{ "chat.log-events", "false" }; + +static void handlePlayerConnectClient(KeyValues *kv) +{ + PrintChat("\x07%06X%s\x01 \x07%06X%s\x01 joining", 0xa06ba0, + kv->GetString("name"), 0x914e65, kv->GetString("networkid")); +} + +static void handlePlayerActivate(KeyValues *kv) +{ + int uid = kv->GetInt("userid"); + int entity = g_IEngine->GetPlayerForUserID(uid); + player_info_s info{}; + if (g_IEngine->GetPlayerInfo(entity, &info)) + PrintChat("\x07%06X%s\x01 connected", 0xa06ba0, info.name); +} + +static void handlePlayerDisconnect(KeyValues *kv) +{ + CachedEntity *player = + ENTITY(g_IEngine->GetPlayerForUserID(kv->GetInt("userid"))); + if (player == nullptr) + return; + PrintChat("\x07%06X%s\x01 \x07%06X%s\x01 disconnected", + colors::chat::team(player->m_iTeam()), kv->GetString("name"), + 0x914e65, kv->GetString("networkid")); +} + +static void handlePlayerTeam(KeyValues *kv) +{ + if (kv->GetBool("disconnect")) + return; + + int oteam = kv->GetInt("oldteam"); + int nteam = kv->GetInt("team"); + const char *oteam_s = teamname(oteam); + const char *nteam_s = teamname(nteam); + PrintChat("\x07%06X%s\x01 changed team (\x07%06X%s\x01 -> " + "\x07%06X%s\x01)", + 0xa06ba0, kv->GetString("name"), colors::chat::team(oteam), + oteam_s, colors::chat::team(nteam), nteam_s); +} + +static void handlePlayerHurt(KeyValues *kv) +{ + int victim = kv->GetInt("userid"); + int attacker = kv->GetInt("attacker"); + int health = kv->GetInt("health"); + player_info_s kinfo{}; + player_info_s vinfo{}; + g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(victim), &vinfo); + g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(attacker), &kinfo); + CachedEntity *vic = ENTITY(g_IEngine->GetPlayerForUserID(victim)); + CachedEntity *att = ENTITY(g_IEngine->GetPlayerForUserID(attacker)); + + if (vic == nullptr || att == nullptr) + return; + + PrintChat("\x07%06X%s\x01 hurt \x07%06X%s\x01 down to \x07%06X%d\x01hp", + colors::chat::team(att->m_iTeam()), kinfo.name, + colors::chat::team(vic->m_iTeam()), vinfo.name, 0x2aaf18, health); +} + +static void handlePlayerDeath(KeyValues *kv) +{ + int victim = kv->GetInt("userid"); + int attacker = kv->GetInt("attacker"); + player_info_s kinfo{}; + player_info_s vinfo{}; + g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(victim), &vinfo); + g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(attacker), &kinfo); + CachedEntity *vic = ENTITY(g_IEngine->GetPlayerForUserID(victim)); + CachedEntity *att = ENTITY(g_IEngine->GetPlayerForUserID(attacker)); + + if (vic == nullptr || att == nullptr) + return; + + PrintChat("\x07%06X%s\x01 killed \x07%06X%s\x01", + colors::chat::team(att->m_iTeam()), kinfo.name, + colors::chat::team(vic->m_iTeam()), vinfo.name); +} + +static void handlePlayerSpawn(KeyValues *kv) +{ + int id = kv->GetInt("userid"); + player_info_s info{}; + g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(id), &info); + CachedEntity *player = ENTITY(g_IEngine->GetPlayerForUserID(id)); + if (player == nullptr) + return; + PrintChat("\x07%06X%s\x01 (re)spawned", + colors::chat::team(player->m_iTeam()), info.name); +} + +static void handlePlayerChangeClass(KeyValues *kv) +{ + int id = kv->GetInt("userid"); + player_info_s info{}; + g_IEngine->GetPlayerInfo(g_IEngine->GetPlayerForUserID(id), &info); + CachedEntity *player = ENTITY(g_IEngine->GetPlayerForUserID(id)); + if (player == nullptr) + return; + PrintChat("\x07%06X%s\x01 changed to \x07%06X%s\x01", + colors::chat::team(player->m_iTeam()), info.name, 0xa06ba0, + classname(kv->GetInt("class"))); +} + +static void handleVoteCast(KeyValues *kv) +{ + int vote_option = kv->GetInt("vote_option"); + int team = kv->GetInt("team"); + int idx = kv->GetInt("entityid"); + player_info_s info{}; + const char *team_s = teamname(team); + if (g_IEngine->GetPlayerInfo(idx, &info)) + PrintChat("\x07%06X%s\x01 Voted \x07%06X%d\x01 on team \x07%06X%s\x01", + colors::chat::team(team), info.name, colors::chat::team(team), + vote_option, colors::chat::team(team), team_s); +} + +class LoggingEventListener : public IGameEventListener +{ +public: + void FireGameEvent(KeyValues *event) override + { + if (!enable) + return; + + const char *name = event->GetName(); + if (!strcmp(name, "player_connect_client")) + handlePlayerConnectClient(event); + else if (!strcmp(name, "player_activate")) + handlePlayerActivate(event); + else if (!strcmp(name, "player_disconnect")) + handlePlayerDisconnect(event); + else if (!strcmp(name, "player_team")) + handlePlayerTeam(event); + else if (!strcmp(name, "player_hurt")) + handlePlayerHurt(event); + else if (!strcmp(name, "player_death")) + handlePlayerDeath(event); + else if (!strcmp(name, "player_spawn")) + handlePlayerSpawn(event); + else if (!strcmp(name, "player_changeclass")) + handlePlayerChangeClass(event); + else if (!strcmp(name, "vote_cast")) + handleVoteCast(event); + } +}; + +static LoggingEventListener listener{}; + +InitRoutine init([]() { g_IGameEventManager->AddListener(&listener, false); }); + +bool event_logging::isEnabled() +{ + return *enable; +} From 558bf0dcbf52d28c3062e0e42b0ffbe75e98efc8 Mon Sep 17 00:00:00 2001 From: LightCat Date: Sun, 19 Aug 2018 22:32:22 +0200 Subject: [PATCH 2/6] oof --- include/angles.hpp | 3 +-- include/backpacktf.hpp | 1 + include/chatlog.hpp | 1 + include/chatstack.hpp | 1 + include/common.hpp | 3 +-- include/entitycache.hpp | 1 + include/entityhitboxcache.hpp | 1 + include/hacks/ESP.hpp | 3 ++- include/hacks/LightESP.hpp | 2 ++ include/online/Online.hpp | 4 ++++ include/playerlist.hpp | 8 ++++++-- include/visual/CMakeLists.txt | 2 +- include/visual/colors.hpp | 3 ++- src/EventLogging.cpp | 4 +++- src/angles.cpp | 1 - src/backpacktf.cpp | 5 ++--- src/hacks/Aimbot.cpp | 2 ++ src/hacks/AntiAim.cpp | 1 - src/hacks/AntiCheat.cpp | 2 ++ src/hacks/AutoReflect.cpp | 2 ++ src/hacks/Backtrack.cpp | 2 ++ src/hacks/FollowBot.cpp | 2 ++ src/hacks/LightESP.cpp | 5 ++++- src/hacks/Misc.cpp | 2 ++ src/hacks/NavBot.cpp | 2 -- src/hacks/Radar.cpp | 3 ++- src/hacks/Walkbot.cpp | 2 ++ src/hooks/LevelInit.cpp | 7 ++++--- src/playerlist.cpp | 18 ++++++++++++------ src/prediction.cpp | 3 ++- src/visual/CMakeLists.txt | 4 ++-- src/visual/EventLogging.cpp | 4 +++- 32 files changed, 72 insertions(+), 32 deletions(-) diff --git a/include/angles.hpp b/include/angles.hpp index 5d1e2369..305b9828 100644 --- a/include/angles.hpp +++ b/include/angles.hpp @@ -7,9 +7,8 @@ #pragma once -#include #include "common.hpp" - +#include namespace angles { diff --git a/include/backpacktf.hpp b/include/backpacktf.hpp index bd869318..7b230d36 100644 --- a/include/backpacktf.hpp +++ b/include/backpacktf.hpp @@ -6,6 +6,7 @@ */ #pragma once +#include "config.h" namespace backpacktf { diff --git a/include/chatlog.hpp b/include/chatlog.hpp index d39c7e8d..2e207ba8 100755 --- a/include/chatlog.hpp +++ b/include/chatlog.hpp @@ -7,6 +7,7 @@ #pragma once +#include "config.h" #include namespace chatlog diff --git a/include/chatstack.hpp b/include/chatstack.hpp index ba0472ae..a1f48ef2 100644 --- a/include/chatstack.hpp +++ b/include/chatstack.hpp @@ -9,6 +9,7 @@ #define CHATSTACK_INTERVAL 0.8f +#include "config.h" #include #include #include diff --git a/include/common.hpp b/include/common.hpp index e3d92d42..928b1e85 100755 --- a/include/common.hpp +++ b/include/common.hpp @@ -47,9 +47,8 @@ #include "averager.hpp" #include "core/macros.hpp" -#include - #if ENABLE_VISUALS +#include #include #include "visual/fidgetspinner.hpp" #include diff --git a/include/entitycache.hpp b/include/entitycache.hpp index 6ba396b6..1fa3922b 100644 --- a/include/entitycache.hpp +++ b/include/entitycache.hpp @@ -64,6 +64,7 @@ bool IsProjectileACrit(CachedEntity *ent); class CachedEntity { public: + typedef CachedEntity ThisClass; CachedEntity(); ~CachedEntity(); diff --git a/include/entityhitboxcache.hpp b/include/entityhitboxcache.hpp index 0e30cab5..358d0d1f 100644 --- a/include/entityhitboxcache.hpp +++ b/include/entityhitboxcache.hpp @@ -14,6 +14,7 @@ #include #include +class CachedEntity; #define CACHE_MAX_HITBOXES 64 namespace hitbox_cache diff --git a/include/hacks/ESP.hpp b/include/hacks/ESP.hpp index 5f02a774..2f42f43c 100644 --- a/include/hacks/ESP.hpp +++ b/include/hacks/ESP.hpp @@ -8,7 +8,7 @@ #pragma once #include "common.hpp" - +#if ENABLE_VISUALS namespace hacks::shared::esp { @@ -59,3 +59,4 @@ void AddEntityString(CachedEntity *entity, const std::string &string, void SetEntityColor(CachedEntity *entity, const rgba_t &color); void ResetEntityStrings(); } // namespace hacks::shared::esp +#endif \ No newline at end of file diff --git a/include/hacks/LightESP.hpp b/include/hacks/LightESP.hpp index 2e1ec2aa..80f54b32 100644 --- a/include/hacks/LightESP.hpp +++ b/include/hacks/LightESP.hpp @@ -2,7 +2,9 @@ #include namespace hacks::shared::lightesp { +#if ENABLE_VISUALS void run(); void draw(); rgba_t LightESPColor(CachedEntity *ent); +#endif } // namespace hacks::shared::lightesp diff --git a/include/online/Online.hpp b/include/online/Online.hpp index e1db6908..bf1281f0 100644 --- a/include/online/Online.hpp +++ b/include/online/Online.hpp @@ -5,7 +5,9 @@ #pragma once #include +#if ENABLE_VISUALS #include +#endif #include #include @@ -24,7 +26,9 @@ struct user_data bool no_target{ false }; bool is_developer{}; bool has_color{ false }; +#if ENABLE_VISUALS colors::rgba_t color{}; +#endif bool rainbow{ false }; }; diff --git a/include/playerlist.hpp b/include/playerlist.hpp index 96783c81..9568e1d0 100644 --- a/include/playerlist.hpp +++ b/include/playerlist.hpp @@ -24,8 +24,9 @@ enum class k_EState CAT, STATE_LAST = CAT }; - +#if ENABLE_VISUALS extern rgba_t k_Colors[]; +#endif const std::string k_Names[] = { "DEFAULT", "FRIEND", "RAGE", "IPC", "DEVELOPER" }; const char *const k_pszNames[] = { "DEFAULT", "FRIEND", "RAGE", "IPC", @@ -34,7 +35,9 @@ const char *const k_pszNames[] = { "DEFAULT", "FRIEND", "RAGE", "IPC", struct userdata { k_EState state{ k_EState::DEFAULT }; +#if ENABLE_VISUALS rgba_t color{ 0, 0, 0, 0 }; +#endif float inventory_value{ 0 }; unsigned deaths_to{ 0 }; unsigned kills{ 0 }; @@ -50,9 +53,10 @@ constexpr bool IsFriendly(k_EState state) return state == k_EState::DEVELOPER || state == k_EState::FRIEND || state == k_EState::IPC; } - +#if ENABLE_VISUALS rgba_t Color(unsigned steamid); rgba_t Color(CachedEntity *player); +#endif userdata &AccessData(unsigned steamid); userdata &AccessData(CachedEntity *player); bool IsDefault(unsigned steamid); diff --git a/include/visual/CMakeLists.txt b/include/visual/CMakeLists.txt index eeaa9175..0a48c8c6 100755 --- a/include/visual/CMakeLists.txt +++ b/include/visual/CMakeLists.txt @@ -5,8 +5,8 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/drawmgr.hpp" "${CMAKE_CURRENT_LIST_DIR}/EffectChams.hpp" "${CMAKE_CURRENT_LIST_DIR}/EffectGlow.hpp" + "${CMAKE_CURRENT_LIST_DIR}/EventLogging.hpp" "${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.hpp" - "${CMAKE_CURRENT_LIST_DIR}/EventLogging.hpp" "${CMAKE_CURRENT_LIST_DIR}/SDLHooks.hpp") if(EnableGUI) diff --git a/include/visual/colors.hpp b/include/visual/colors.hpp index 8d95028b..e6c0683a 100644 --- a/include/visual/colors.hpp +++ b/include/visual/colors.hpp @@ -10,7 +10,7 @@ #include class CachedEntity; - +#if ENABLE_VISUALS namespace colors { namespace chat @@ -165,3 +165,4 @@ rgba_t EntityF(CachedEntity *ent); } // namespace colors using rgba_t = colors::rgba_t; +#endif \ No newline at end of file diff --git a/src/EventLogging.cpp b/src/EventLogging.cpp index 54043513..a170bb23 100755 --- a/src/EventLogging.cpp +++ b/src/EventLogging.cpp @@ -1,10 +1,11 @@ /* Created on 29.07.18. */ - +#include "config.h" #include #include #include +#if ENABLE_VISUALS #include #include @@ -166,3 +167,4 @@ bool event_logging::isEnabled() { return *enable; } +#endif \ No newline at end of file diff --git a/src/angles.cpp b/src/angles.cpp index 51453216..a97322a3 100644 --- a/src/angles.cpp +++ b/src/angles.cpp @@ -4,7 +4,6 @@ * Created on: Jun 5, 2017 * Author: nullifiedcat */ - #include "angles.hpp" namespace angles diff --git a/src/backpacktf.cpp b/src/backpacktf.cpp index 5b33d6e7..4f1cf2f6 100644 --- a/src/backpacktf.cpp +++ b/src/backpacktf.cpp @@ -4,13 +4,12 @@ * Created on: Jul 23, 2017 * Author: nullifiedcat */ - +#include "config.h" +#include "common.hpp" #include "backpacktf.hpp" #include "json.hpp" #include "https_request.hpp" -#include "common.hpp" - #include #include #include diff --git a/src/hacks/Aimbot.cpp b/src/hacks/Aimbot.cpp index f71e99c1..ae4e89aa 100644 --- a/src/hacks/Aimbot.cpp +++ b/src/hacks/Aimbot.cpp @@ -10,7 +10,9 @@ #include #include #include +#if ENABLE_VISUALS #include +#endif #include #include #include "common.hpp" diff --git a/src/hacks/AntiAim.cpp b/src/hacks/AntiAim.cpp index 2cadeec9..657240ed 100644 --- a/src/hacks/AntiAim.cpp +++ b/src/hacks/AntiAim.cpp @@ -6,7 +6,6 @@ */ #include -#include #include #include diff --git a/src/hacks/AntiCheat.cpp b/src/hacks/AntiCheat.cpp index 3830cb10..10607bb3 100644 --- a/src/hacks/AntiCheat.cpp +++ b/src/hacks/AntiCheat.cpp @@ -35,10 +35,12 @@ void Accuse(int eid, const std::string &hack, const std::string &details) } else { +#if ENABLE_VISUALS PrintChat("\x07%06X%s\x01 (%s) suspected \x07%06X%s\x01: %s", colors::chat::team(ENTITY(eid)->m_iTeam()), info.name, classname(CE_INT(ent, netvar.iClass)), 0xe05938, hack.c_str(), details.c_str()); +#endif } } } diff --git a/src/hacks/AutoReflect.cpp b/src/hacks/AutoReflect.cpp index ff941ee3..66371cd0 100644 --- a/src/hacks/AutoReflect.cpp +++ b/src/hacks/AutoReflect.cpp @@ -7,7 +7,9 @@ #include "common.hpp" #include +#if ENABLE_VISUALS #include +#endif #include static settings::Bool enable{ "autoreflect.enable", "false" }; diff --git a/src/hacks/Backtrack.cpp b/src/hacks/Backtrack.cpp index 5d735d0f..3621bc1c 100644 --- a/src/hacks/Backtrack.cpp +++ b/src/hacks/Backtrack.cpp @@ -9,7 +9,9 @@ #include "hacks/Aimbot.hpp" #include "hacks/Backtrack.hpp" #include +#if ENABLE_VISUALS #include +#endif #include #include diff --git a/src/hacks/FollowBot.cpp b/src/hacks/FollowBot.cpp index 7c621b9a..0664ebd3 100644 --- a/src/hacks/FollowBot.cpp +++ b/src/hacks/FollowBot.cpp @@ -8,7 +8,9 @@ #include "common.hpp" #include +#if ENABLE_VISUALS #include +#endif #include static settings::Bool enable{ "follow-bot.enable", "false" }; diff --git a/src/hacks/LightESP.cpp b/src/hacks/LightESP.cpp index d5e8a03f..f1f034a4 100644 --- a/src/hacks/LightESP.cpp +++ b/src/hacks/LightESP.cpp @@ -1,4 +1,6 @@ +#if ENABLE_VISUALS #include +#endif #include #include "hacks/LightESP.hpp" @@ -71,7 +73,7 @@ void draw() } #endif } - +#if ENABLE_VISUALS rgba_t LightESPColor(CachedEntity *ent) { if (!playerlist::IsDefault(ent)) @@ -80,4 +82,5 @@ rgba_t LightESPColor(CachedEntity *ent) } return colors::green; } +#endif } // namespace hacks::shared::lightesp diff --git a/src/hacks/Misc.cpp b/src/hacks/Misc.cpp index be1c4efc..e507cd2c 100644 --- a/src/hacks/Misc.cpp +++ b/src/hacks/Misc.cpp @@ -12,7 +12,9 @@ #include #include #include +#if ENABLE_VISUALS #include +#endif #include #include "core/sharedobj.hpp" diff --git a/src/hacks/NavBot.cpp b/src/hacks/NavBot.cpp index 1b89fc44..78792fdd 100644 --- a/src/hacks/NavBot.cpp +++ b/src/hacks/NavBot.cpp @@ -2,8 +2,6 @@ // Created by bencat07 on 17.08.18. // #include "common.hpp" -#include -#include #include "navparser.hpp" #include "FollowBot.hpp" #include "NavBot.hpp" diff --git a/src/hacks/Radar.cpp b/src/hacks/Radar.cpp index 9899ffa2..1f546ec4 100644 --- a/src/hacks/Radar.cpp +++ b/src/hacks/Radar.cpp @@ -4,8 +4,9 @@ * Created on: Mar 28, 2017 * Author: nullifiedcat */ - +#if ENABLE_VISUALS #include +#endif #include #include "common.hpp" #include "hacks/Radar.hpp" diff --git a/src/hacks/Walkbot.cpp b/src/hacks/Walkbot.cpp index 4810a814..053beba4 100644 --- a/src/hacks/Walkbot.cpp +++ b/src/hacks/Walkbot.cpp @@ -12,7 +12,9 @@ #include #include #include +#if ENABLE_VISUALS #include +#endif #include static settings::Button recording_key{ "walkbot.recording-key", "" }; diff --git a/src/hooks/LevelInit.cpp b/src/hooks/LevelInit.cpp index 39b7178f..978b7a01 100644 --- a/src/hooks/LevelInit.cpp +++ b/src/hooks/LevelInit.cpp @@ -5,7 +5,9 @@ #include #include +#if ENABLE_VISUALS #include +#endif #include "HookedMethods.hpp" #include "MiscTemporary.hpp" #include "navparser.hpp" @@ -78,14 +80,13 @@ DEFINE_HOOKED_METHOD(LevelInit, void, void *this_, const char *name) logging::Info("Loaded Skybox: %s", succ ? "true" : "false"); ConVar *holiday = g_ICvar->FindVar("tf_forced_holiday"); - for (int i = 0; i < 32; i++) - g_Settings.brute.brutenum[i] = 0; if (halloween_mode) holiday->SetValue(2); else if (holiday->m_nValue == 2) holiday->SetValue(0); #endif - + for (int i = 0; i < 32; i++) + g_Settings.brute.brutenum[i] = 0; g_IEngine->ClientCmd_Unrestricted("exec cat_matchexec"); #if !LAGBOT_MODE hacks::shared::aimbot::Reset(); diff --git a/src/playerlist.cpp b/src/playerlist.cpp index 00211ed8..928822ea 100644 --- a/src/playerlist.cpp +++ b/src/playerlist.cpp @@ -18,14 +18,17 @@ namespace playerlist std::unordered_map data{}; const userdata null_data{}; - +#if ENABLE_VISUALS rgba_t k_Colors[] = { colors::empty, colors::FromRGBA8(99, 226, 161, 255), colors::FromRGBA8(226, 204, 99, 255), colors::FromRGBA8(232, 134, 6, 255), colors::empty }; - +#endif bool ShouldSave(const userdata &data) { +#if ENABLE_VISUALS return data.color || (data.state != k_EState::DEFAULT); +#endif + return (data.state != k_EState::DEFAULT); } void Save() @@ -114,7 +117,7 @@ void Load() logging::Info("Reading unsuccessful: %s", e.what()); } } - +#if ENABLE_VISUALS rgba_t Color(unsigned steamid) { if (AccessData(steamid).state == k_EState::DEVELOPER) @@ -137,7 +140,7 @@ rgba_t Color(CachedEntity *player) return Color(player->player_info.friendsID); return colors::empty; } - +#endif userdata &AccessData(unsigned steamid) { return data[steamid]; @@ -154,7 +157,10 @@ userdata &AccessData(CachedEntity *player) bool IsDefault(unsigned steamid) { const userdata &data = AccessData(steamid); +#if ENABLE_VISUALS return data.state == k_EState::DEFAULT && !data.color.a; +#endif + return data.state == k_EState ::DEFAULT; } bool IsDefault(CachedEntity *entity) @@ -184,7 +190,7 @@ CatCommand pl_set_state( AccessData(steamid).state = state; logging::Info("Set %d to %d", steamid, state); }); - +#if ENABLE_VISUALS CatCommand pl_set_color("pl_set_color", "pl_set_color uniqueid r g b", [](const CCommand &args) { if (args.ArgC() < 5) @@ -201,7 +207,7 @@ CatCommand pl_set_color("pl_set_color", "pl_set_color uniqueid r g b", AccessData(steamid).color = color; logging::Info("Changed %d's color", steamid); }); - +#endif CatCommand pl_info("pl_info", "pl_info uniqueid", [](const CCommand &args) { if (args.ArgC() < 2) { diff --git a/src/prediction.cpp b/src/prediction.cpp index 100ead10..8d9f1cd4 100644 --- a/src/prediction.cpp +++ b/src/prediction.cpp @@ -4,8 +4,9 @@ * Created on: Dec 5, 2016 * Author: nullifiedcat */ - +#if ENABLE_VISUALS #include +#endif #include #include "common.hpp" diff --git a/src/visual/CMakeLists.txt b/src/visual/CMakeLists.txt index cc633bc2..3795c4e0 100755 --- a/src/visual/CMakeLists.txt +++ b/src/visual/CMakeLists.txt @@ -5,10 +5,10 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/drawmgr.cpp" "${CMAKE_CURRENT_LIST_DIR}/EffectChams.cpp" "${CMAKE_CURRENT_LIST_DIR}/EffectGlow.cpp" + "${CMAKE_CURRENT_LIST_DIR}/EventLogging.cpp" "${CMAKE_CURRENT_LIST_DIR}/fidgetspinner.cpp" - "${CMAKE_CURRENT_LIST_DIR}/EventLogging.cpp" "${CMAKE_CURRENT_LIST_DIR}/SDLHooks.cpp") if(EnableGUI) add_subdirectory(menu) -endif() \ No newline at end of file +endif() diff --git a/src/visual/EventLogging.cpp b/src/visual/EventLogging.cpp index 54043513..a170bb23 100755 --- a/src/visual/EventLogging.cpp +++ b/src/visual/EventLogging.cpp @@ -1,10 +1,11 @@ /* Created on 29.07.18. */ - +#include "config.h" #include #include #include +#if ENABLE_VISUALS #include #include @@ -166,3 +167,4 @@ bool event_logging::isEnabled() { return *enable; } +#endif \ No newline at end of file From 94382b8ffddff2369dfa21ec67ebbef8ea787f7a Mon Sep 17 00:00:00 2001 From: LightCat Date: Sun, 19 Aug 2018 22:53:59 +0200 Subject: [PATCH 3/6] how needs backpacktf anyways --- include/CMakeLists.txt | 1 - include/backpacktf.hpp | 36 ------- include/common.hpp | 1 - src/CMakeLists.txt | 1 - src/backpacktf.cpp | 238 ----------------------------------------- src/hack.cpp | 2 - 6 files changed, 279 deletions(-) delete mode 100644 include/backpacktf.hpp delete mode 100644 src/backpacktf.cpp diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 1d2601d5..e8dd5d4b 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,7 +1,6 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/angles.hpp" "${CMAKE_CURRENT_LIST_DIR}/averager.hpp" - "${CMAKE_CURRENT_LIST_DIR}/backpacktf.hpp" "${CMAKE_CURRENT_LIST_DIR}/base64.hpp" "${CMAKE_CURRENT_LIST_DIR}/chatlog.hpp" "${CMAKE_CURRENT_LIST_DIR}/chatstack.hpp" diff --git a/include/backpacktf.hpp b/include/backpacktf.hpp deleted file mode 100644 index 7b230d36..00000000 --- a/include/backpacktf.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * backpacktf.hpp - * - * Created on: Jul 23, 2017 - * Author: nullifiedcat - */ - -#pragma once -#include "config.h" - -namespace backpacktf -{ - -constexpr float REFINED_METAL_PRICE = 0.075f; // $ -constexpr unsigned REQUEST_INTERVAL = - 10; // Make a backpack.tf request every 30 seconds -constexpr unsigned MAX_CACHE_AGE = 60 * 30; -constexpr unsigned OUTDATED_AGE = - 60 * 60 * 24 * 3; // After how many seconds backpack is marked "outdated" - // (possibly private) - -struct backpack_data_s -{ - bool pending{ false }; - bool bad{ true }; - bool no_value{ false }; // No recorded value - bool outdated_value{ false }; // Outdated value. Private inventory? - unsigned last_request{ 0 }; - float value{ 0 }; - unsigned id{ 0 }; -}; - -const backpack_data_s &get_data(unsigned id); -void init(); -bool enabled(); -} // namespace backpacktf diff --git a/include/common.hpp b/include/common.hpp index 928b1e85..f6514b37 100755 --- a/include/common.hpp +++ b/include/common.hpp @@ -93,7 +93,6 @@ #include "votelogger.hpp" #include "crits.hpp" #include "textmode.hpp" -#include "backpacktf.hpp" #include "core/sharedobj.hpp" #include "init.hpp" #include "reclasses/reclasses.hpp" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 97b8202a..963d3daa 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,5 @@ target_sources(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}/angles.cpp" - "${CMAKE_CURRENT_LIST_DIR}/backpacktf.cpp" "${CMAKE_CURRENT_LIST_DIR}/chatlog.cpp" "${CMAKE_CURRENT_LIST_DIR}/chatstack.cpp" "${CMAKE_CURRENT_LIST_DIR}/conditions.cpp" diff --git a/src/backpacktf.cpp b/src/backpacktf.cpp deleted file mode 100644 index 4f1cf2f6..00000000 --- a/src/backpacktf.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * backpacktf.cpp - * - * Created on: Jul 23, 2017 - * Author: nullifiedcat - */ -#include "config.h" -#include "common.hpp" -#include "backpacktf.hpp" -#include "json.hpp" -#include "https_request.hpp" - -#include -#include -#include - -static settings::Bool bptf_enable{ "backpack-tf.enable", "false" }; - -namespace backpacktf -{ - -std::unordered_map cache{}; -std::queue pending_queue{}; -std::mutex queue_mutex{}; -std::mutex cache_mutex{}; -bool thread_running{ true }; - -std::string api_key_s = ""; -bool valid_api_key = false; - -CatCommand api_key("bptf_key", "Set API Key", [](const CCommand &args) { - api_key_s = args.ArgS(); - logging::Info("API key changed!"); - valid_api_key = false; - if (api_key_s.length() != 24) - { - logging::Info("API key must be exactly 24 characters long"); - valid_api_key = false; - } - else - { - valid_api_key = true; - } -}); - -void store_data(unsigned id, float value, bool no_value, bool outdated_value); - -void processing_thread() -{ - logging::Info("[bp.tf] Starting the thread"); - while (thread_running) - { - if (enabled()) - { - try - { - std::vector batch{}; - int count = 0; - { - std::lock_guard lock(queue_mutex); - while (not pending_queue.empty() && ++count < 100) - { - batch.push_back(pending_queue.front()); - pending_queue.pop(); - } - } - if (count) - { - logging::Info("[bp.tf] Requesting data for %d users", - count); - std::string id_list = ""; - for (const auto &x : batch) - { - x->pending = false; - id_list += format("[U:1:", x->id, "],"); - } - // Remove trailing ',' - id_list = id_list.substr(0, id_list.length() - 1); - std::string query = - format("steamids=", id_list, "&key=", api_key_s); - try - { - auto sock = https::RAII_HTTPS_Socket("backpack.tf"); - std::string response = - sock.get("/api/users/info/v1?" + query); - if (response.compare("HTTP/1.1 200 OK\r\n") != 0) - { - size_t status = response.find("\r\n"); - throw std::runtime_error( - "Response isn't 200 OK! It's " + - response.substr(0, status)); - } - - std::string body = - response.substr(response.find("\r\n\r\n") + 4); - - try - { - nlohmann::json data = nlohmann::json::parse(body); - nlohmann::json users = data["users"]; - std::lock_guard lock(cache_mutex); - for (auto it = users.begin(); it != users.end(); - ++it) - { - unsigned userid = strtoul( - it.key().substr(5).c_str(), nullptr, 10); - try - { - unsigned userid = - strtoul(it.key().substr(5).c_str(), - nullptr, 10); - const auto &v = it.value(); - if (not v.is_object()) - { - logging::Info("Data for %u (%s) is not " - "an object!", - userid, it.key().c_str()); - continue; - } - std::string name = v.at("name"); - logging::Info( - "Parsing data for user %u (%s)", userid, - name.c_str()); - if (v.find("inventory") == v.end()) - { - store_data(userid, 0, true, false); - continue; - } - const auto &inv = - v.at("inventory").at("440"); - if (inv.find("value") == inv.end()) - { - store_data(userid, 0, true, false); - } - else - { - float value = float(inv["value"]); - unsigned updated = - unsigned(inv["updated"]); - store_data( - userid, value * REFINED_METAL_PRICE, - false, - (unsigned(time(0)) - updated > - OUTDATED_AGE)); - } - } - catch (std::exception &ex) - { - logging::Info( - "Error while parsing user %s: %s", - it.key().c_str(), ex.what()); - } - } - } - catch (std::exception &e) - { - logging::Info( - "[bp.tf] Exception while parsing response: %s", - e.what()); - } - } - catch (std::exception &e) - { - logging::Info("[bp.tf] HTTPS exception: %s", e.what()); - } - } - } - catch (std::exception &e) - { - logging::Info("[bp.tf] Thread exception: %s", e.what()); - } - } - sleep(REQUEST_INTERVAL); - } -} - -void request_data(unsigned id) -{ - if (cache[id].pending) - return; - cache[id].pending = true; - { - std::lock_guard lock(queue_mutex); - pending_queue.push(&cache[id]); - } -} - -bool enabled() -{ - return bptf_enable && valid_api_key; -} - -backpack_data_s &access_data(unsigned id) -{ - try - { - return cache.at(id); - } - catch (std::out_of_range &oor) - { - cache.emplace(id, backpack_data_s{}); - cache.at(id).id = id; - return cache.at(id); - } -} - -void store_data(unsigned id, float value, bool none, bool outdated) -{ - auto &d = access_data(id); - d.last_request = unsigned(time(0)); - d.bad = false; - d.value = value; - d.no_value = none; - d.outdated_value = outdated; - d.pending = false; -} - -const backpack_data_s &get_data(unsigned id) -{ - auto &d = access_data(id); - if (d.bad || ((unsigned) time(0) - MAX_CACHE_AGE > cache[id].last_request)) - { - request_data(id); - } - return d; -} - -std::thread &GetBackpackTFThread() -{ - static std::thread thread(processing_thread); - return thread; -} - -void init() -{ - GetBackpackTFThread(); -} -} // namespace backpacktf diff --git a/src/hack.cpp b/src/hack.cpp index b683a3a5..988edbc2 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -380,8 +380,6 @@ free(logname);*/ logging::Info("Initialized Fidget Spinner"); #endif hacks::shared::spam::init(); - backpacktf::init(); - logging::Info("Initialized Backpack.TF integration"); #endif #if not LAGBOT_MODE hacks::shared::walkbot::Initialize(); From 2fcf568123582304a1e9d143cda133d0c741fb19 Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Sun, 19 Aug 2018 23:03:51 +0200 Subject: [PATCH 4/6] Some more precompiler things --- include/config.h.in | 3 ++- include/online/Online.hpp | 4 +++- src/PlayerTools.cpp | 10 +++++----- src/hooks/Paint.cpp | 2 ++ src/online/Online.cpp | 7 +++++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/config.h.in b/include/config.h.in index 48ab0479..ae03b13e 100755 --- a/include/config.h.in +++ b/include/config.h.in @@ -15,4 +15,5 @@ #define ENABLE_TEXTMODE_STDIN @EnableTextmodeStdin@ #define ENABLE_NULL_GRAPHICS @EnableNullGraphics@ #define TEXTMODE @Textmode@ -#define ENABLE_PROFILER @EnableProfiler@ \ No newline at end of file +#define ENABLE_PROFILER @EnableProfiler@ +#define ENABLE_ONLINE @EnableOnlineFeatures@ diff --git a/include/online/Online.hpp b/include/online/Online.hpp index bf1281f0..c6d60008 100644 --- a/include/online/Online.hpp +++ b/include/online/Online.hpp @@ -3,7 +3,8 @@ */ #pragma once - +#include "config.h" +#if ENABLE_ONLINE #include #if ENABLE_VISUALS #include @@ -39,3 +40,4 @@ void update(); user_data *getUserData(unsigned steamId); } // namespace online +#endif diff --git a/src/PlayerTools.cpp b/src/PlayerTools.cpp index ccbf994c..d09c1b1e 100644 --- a/src/PlayerTools.cpp +++ b/src/PlayerTools.cpp @@ -49,7 +49,7 @@ IgnoreReason shouldTargetSteamId(unsigned id) auto &pl = playerlist::AccessData(id); if (playerlist::IsFriendly(pl.state)) return IgnoreReason::LOCAL_PLAYER_LIST; - +#if ENABLE_ONLINE auto *co = online::getUserData(id); if (co) { @@ -67,7 +67,7 @@ IgnoreReason shouldTargetSteamId(unsigned id) if (co->is_developer) return IgnoreReason::DEVELOPER; } - +#endif return IgnoreReason::DO_NOT_IGNORE; } IgnoreReason shouldTarget(CachedEntity *entity) @@ -93,11 +93,11 @@ bool shouldAlwaysRenderEspSteamId(unsigned id) auto &pl = playerlist::AccessData(id); if (pl.state != playerlist::k_EState::DEFAULT) return true; - +#if ENABLE_ONLINE auto *co = online::getUserData(id); if (co) return true; - +#endif return false; } bool shouldAlwaysRenderEsp(CachedEntity *entity) @@ -158,4 +158,4 @@ void onKilledBy(CachedEntity *entity) { onKilledBy(entity->player_info.friendsID); } -} // namespace player_tools \ No newline at end of file +} // namespace player_tools diff --git a/src/hooks/Paint.cpp b/src/hooks/Paint.cpp index eb4ef9c8..9883ce24 100644 --- a/src/hooks/Paint.cpp +++ b/src/hooks/Paint.cpp @@ -29,7 +29,9 @@ DEFINE_HOOKED_METHOD(Paint, void, IEngineVGui *this_, PaintMode_t mode) #endif hacks::shared::catbot::update(); hitrate::Update(); +#if ENABLE_ONLINE online::update(); +#endif #if ENABLE_IPC static Timer nametimer{}; if (nametimer.test_and_set(1000 * 10)) diff --git a/src/online/Online.cpp b/src/online/Online.cpp index de490928..a9080929 100644 --- a/src/online/Online.cpp +++ b/src/online/Online.cpp @@ -1,7 +1,8 @@ /* Created on 23.06.18. */ - +#include "config.h" +#if ENABLE_ONLINE #include #include @@ -12,6 +13,7 @@ #undef null + #include #include #include @@ -332,4 +334,5 @@ user_data *getUserData(unsigned steamId) // SteamID does not belong to online user return nullptr; } -} // namespace online \ No newline at end of file +} // namespace online +#endif From e678e9895811646fadbbf576a6c4394c5a7e04ee Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Sun, 19 Aug 2018 23:10:36 +0200 Subject: [PATCH 5/6] Ouf --- src/prediction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prediction.cpp b/src/prediction.cpp index 8d9f1cd4..06ef1818 100644 --- a/src/prediction.cpp +++ b/src/prediction.cpp @@ -4,11 +4,11 @@ * Created on: Dec 5, 2016 * Author: nullifiedcat */ +#include "common.hpp" #if ENABLE_VISUALS #include #endif #include -#include "common.hpp" static settings::Bool debug_enginepred{ "debug.engine-pred-others", "false" }; static settings::Bool debug_pp_extrapolate{ "debug.pp-extrapolate", "false" }; From bcb0c2f229287466edb5ef406ad6a4905a4b7834 Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Sun, 19 Aug 2018 23:23:23 +0200 Subject: [PATCH 6/6] Ouf 2 --- src/hacks/LightESP.cpp | 2 +- src/hacks/Misc.cpp | 2 +- src/hacks/Radar.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hacks/LightESP.cpp b/src/hacks/LightESP.cpp index f1f034a4..c05b16bd 100644 --- a/src/hacks/LightESP.cpp +++ b/src/hacks/LightESP.cpp @@ -1,8 +1,8 @@ +#include "hacks/LightESP.hpp" #if ENABLE_VISUALS #include #endif #include -#include "hacks/LightESP.hpp" static settings::Bool enable{ "lightesp.enable", "false" }; diff --git a/src/hacks/Misc.cpp b/src/hacks/Misc.cpp index e507cd2c..99b82b0b 100644 --- a/src/hacks/Misc.cpp +++ b/src/hacks/Misc.cpp @@ -5,6 +5,7 @@ * Author: nullifiedcat */ +#include "common.hpp" #include #include #include @@ -20,7 +21,6 @@ #include "core/sharedobj.hpp" #include "hack.hpp" -#include "common.hpp" static settings::Bool render_zoomed{ "visuals.render-local-zoomed", "false" }; static settings::Bool anti_afk{ "misc.anti-afk", "false" }; diff --git a/src/hacks/Radar.cpp b/src/hacks/Radar.cpp index 1f546ec4..5fb9168d 100644 --- a/src/hacks/Radar.cpp +++ b/src/hacks/Radar.cpp @@ -4,11 +4,11 @@ * Created on: Mar 28, 2017 * Author: nullifiedcat */ +#include "common.hpp" #if ENABLE_VISUALS #include #endif #include -#include "common.hpp" #include "hacks/Radar.hpp" #ifndef FEATURE_RADAR_DISABLED