From 1c253f12af8d676d95fdaf4c31ec56c3b4a6706f Mon Sep 17 00:00:00 2001 From: Jenny White Date: Sun, 29 Apr 2018 09:29:42 +0300 Subject: [PATCH] working on moving code to new files --- include/MiscTemporary.hpp | 1 + src/hooks/DispatchUserMessage.cpp | 29 +++++-- src/hooks/LevelInit.cpp | 71 ++++++++++++++++++ src/hooks/Paint.cpp | 8 +- src/hooks/PaintTraverse.cpp | 17 ----- src/hooks/SendNetMsg.cpp | 5 +- src/hooks/others.cpp | 104 +------------------------- src/hooks/visual/DrawModelExecute.cpp | 12 +-- src/hooks/visual/FrameStageNotify.cpp | 4 + src/hooks/visual/OverrideView.cpp | 9 +++ src/hooks/visual/PaintTraverse.cpp | 37 ++++++--- src/hooks/visual/RandomInt.cpp | 3 + 12 files changed, 153 insertions(+), 147 deletions(-) diff --git a/include/MiscTemporary.hpp b/include/MiscTemporary.hpp index eeb9786d..72b152fd 100644 --- a/include/MiscTemporary.hpp +++ b/include/MiscTemporary.hpp @@ -14,6 +14,7 @@ extern CatVar no_zoom; extern CatVar clean_screenshots; extern CatVar disable_visuals; extern CatVar disconnect_reason; + #if ENABLE_VISUALS extern int spectator_target; #endif diff --git a/src/hooks/DispatchUserMessage.cpp b/src/hooks/DispatchUserMessage.cpp index 3c52a889..69b1873d 100644 --- a/src/hooks/DispatchUserMessage.cpp +++ b/src/hooks/DispatchUserMessage.cpp @@ -3,13 +3,35 @@ Copyright (c) 2018 nullworks. All rights reserved. */ +#include +#include +#include #include "HookedMethods.hpp" +static bool retrun = false; +static Timer sendmsg{}; +static Timer gitgud{}; +static CatVar clean_chat(CV_SWITCH, "clean_chat", "0", "Clean chat", + "Removes newlines from chat"); +static CatVar dispatch_log(CV_SWITCH, "debug_log_usermessages", "0", + "Log dispatched user messages"); +static CatVar chat_filter(CV_STRING, "chat_censor", "", "Censor words", + "Spam Chat with newlines if the chosen words are " + "said, seperate with commas"); +static CatVar chat_filter_enabled(CV_SWITCH, "chat_censor_enabled", "0", + "Enable censor", "Censor Words in chat"); +static CatVar crypt_chat( + CV_SWITCH, "chat_crypto", "1", "Crypto chat", + "Start message with !! and it will be only visible to cathook users"); +std::string clear = ""; +std::string lastfilter{}; +std::string lastname{}; + namespace hooked_methods { DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, - bf_read &buffer) + bf_read &buf) { if (retrun && gitgud.test_and_set(10000)) { @@ -20,9 +42,6 @@ DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, int loop_index, s, i, j; char *data, c; - static const DispatchUserMessage_t original = - (DispatchUserMessage_t) hooks::client.GetMethod( - offsets::DispatchUserMessage()); if (type == 4) { loop_index = 0; @@ -250,6 +269,6 @@ DEFINE_HOOKED_METHOD(DispatchUserMessage, bool, void *this_, int type, buf.Seek(0); } votelogger::user_message(buf, type); - return original::DispatchUserMessage(this_, type, buffer); + return original::DispatchUserMessage(this_, type, buf); } } \ No newline at end of file diff --git a/src/hooks/LevelInit.cpp b/src/hooks/LevelInit.cpp index c6cd7fe8..43de342f 100644 --- a/src/hooks/LevelInit.cpp +++ b/src/hooks/LevelInit.cpp @@ -5,6 +5,77 @@ #include "HookedMethods.hpp" + + +const char *skynum[] = { "sky_tf2_04", + "sky_upward", + "sky_dustbowl_01", + "sky_goldrush_01", + "sky_granary_01", + "sky_well_01", + "sky_gravel_01", + "sky_badlands_01", + "sky_hydro_01", + "sky_night_01", + "sky_nightfall_01", + "sky_trainyard_01", + "sky_stormfront_01", + "sky_morningsnow_01", + "sky_alpinestorm_01", + "sky_harvest_01", + "sky_harvest_night_01", + "sky_halloween", + "sky_halloween_night_01", + "sky_halloween_night2014_01", + "sky_island_01", + "sky_jungle_01", + "sky_invasion2fort_01", + "sky_well_02", + "sky_outpost_01", + "sky_coastal_01", + "sky_rainbow_01", + "sky_badlands_pyroland_01", + "sky_pyroland_01", + "sky_pyroland_02", + "sky_pyroland_03" }; +CatEnum skys({ "sky_tf2_04", + "sky_upward", + "sky_dustbowl_01", + "sky_goldrush_01", + "sky_granary_01", + "sky_well_01", + "sky_gravel_01", + "sky_badlands_01", + "sky_hydro_01", + "sky_night_01", + "sky_nightfall_01", + "sky_trainyard_01", + "sky_stormfront_01", + "sky_morningsnow_01", + "sky_alpinestorm_01", + "sky_harvest_01", + "sky_harvest_night_01", + "sky_halloween", + "sky_halloween_night_01", + "sky_halloween_night2014_01", + "sky_island_01", + "sky_jungle_01", + "sky_invasion2fort_01", + "sky_well_02", + "sky_outpost_01", + "sky_coastal_01", + "sky_rainbow_01", + "sky_badlands_pyroland_01", + "sky_pyroland_01", + "sky_pyroland_02", + "sky_pyroland_03" }); +static CatVar + skybox_changer(skys, "skybox_changer", "0", "Change Skybox to this skybox", + "Change Skybox to this skybox, only changes on map load"); +static CatVar halloween_mode(CV_SWITCH, "halloween_mode", "0", + "Forced Halloween mode", + "forced tf_forced_holiday 2"); + namespace hooked_methods { diff --git a/src/hooks/Paint.cpp b/src/hooks/Paint.cpp index 8d4decff..beb9d9b8 100644 --- a/src/hooks/Paint.cpp +++ b/src/hooks/Paint.cpp @@ -9,6 +9,9 @@ #include "hitrate.hpp" #include "hack.hpp" +static CatVar cursor_fix_experimental(CV_SWITCH, "experimental_cursor_fix", "1", + "Cursor fix"); + namespace hooked_methods { @@ -87,7 +90,4 @@ DEFINE_HOOKED_METHOD(Paint, void, IEngineVGui *this_, PaintMode_t mode) return original::Paint(this_, mode); } -} - -static CatVar cursor_fix_experimental(CV_SWITCH, "experimental_cursor_fix", "1", - "Cursor fix"); \ No newline at end of file +} \ No newline at end of file diff --git a/src/hooks/PaintTraverse.cpp b/src/hooks/PaintTraverse.cpp index afd12ac8..4cc0a47f 100644 --- a/src/hooks/PaintTraverse.cpp +++ b/src/hooks/PaintTraverse.cpp @@ -11,24 +11,7 @@ #include "GUI.h" #endif -CatVar clean_screenshots(CV_SWITCH, "clean_screenshots", "1", - "Clean screenshots", - "Don't draw visuals while taking a screenshot"); -CatVar disable_visuals(CV_SWITCH, "no_visuals", "0", "Disable ALL drawing", - "Completely hides cathook"); -CatVar no_zoom(CV_SWITCH, "no_zoom", "0", "Disable scope", - "Disables black scope overlay"); -CatVar pure_bypass(CV_SWITCH, "pure_bypass", "0", "Pure Bypass", - "Bypass sv_pure"); -void *pure_orig = nullptr; -void **pure_addr = nullptr; -CatEnum software_cursor_enum({ "KEEP", "ALWAYS", "NEVER", "MENU ON", - "MENU OFF" }); -CatVar - software_cursor_mode(software_cursor_enum, "software_cursor_mode", "0", - "Software cursor", - "Try to change this and see what works best for you"); void PaintTraverse_hook(void *_this, unsigned int vp, bool fr, bool ar) { diff --git a/src/hooks/SendNetMsg.cpp b/src/hooks/SendNetMsg.cpp index 19eaf43b..6bc3ef19 100644 --- a/src/hooks/SendNetMsg.cpp +++ b/src/hooks/SendNetMsg.cpp @@ -3,6 +3,7 @@ Copyright (c) 2018 nullworks. All rights reserved. */ +#include #include "HookedMethods.hpp" namespace hooked_methods @@ -16,10 +17,6 @@ DEFINE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *this_, INetMessage &message, std::string newlines; NET_StringCmd stringcmd; - // This is a INetChannel hook - it SHOULDN'T be static because netchannel - // changes. - const SendNetMsg_t original = - (SendNetMsg_t) hooks::netchannel.GetMethod(offsets::SendNetMsg()); // net_StringCmd if (msg.GetType() == 4 && (newlines_msg || crypt_chat)) { diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index fb33a93e..1f4c4b17 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -15,9 +15,6 @@ #if ENABLE_VISUALS -static CatVar medal_flip(CV_SWITCH, "medal_flip", "0", "Infinite Medal Flip", - ""); - // This hook isn't used yet! /*int C_TFPlayer__DrawModel_hook(IClientEntity *_this, int flags) { @@ -33,20 +30,10 @@ static CatVar medal_flip(CV_SWITCH, "medal_flip", "0", "Infinite Medal Flip", *(float *) ((uintptr_t) _this + 79u) = old_invis; }*/ -static CatVar no_arms(CV_SWITCH, "no_arms", "0", "No Arms", - "Removes arms from first person"); -static CatVar no_hats(CV_SWITCH, "no_hats", "0", "No Hats", - "Removes non-stock hats"); + float last_say = 0.0f; -CatVar override_fov_zoomed(CV_FLOAT, "fov_zoomed", "0", "FOV override (zoomed)", - "Overrides FOV with this value when zoomed in " - "(default FOV when zoomed is 20)"); -CatVar override_fov(CV_FLOAT, "fov", "0", "FOV override", - "Overrides FOV with this value"); -CatVar freecam(CV_KEY, "debug_freecam", "0", "Freecam"); -int spectator_target{ 0 }; CatCommand spectate("spectate", "Spectate", [](const CCommand &args) { if (args.ArgC() < 1) @@ -91,20 +78,11 @@ static CatVar newlines_msg(CV_INT, "chat_newlines", "0", "Prefix newlines", // (without having your msgs eaten by valve cooldown)"); static CatVar airstuck(CV_KEY, "airstuck", "0", "Airstuck", ""); -static CatVar crypt_chat( - CV_SWITCH, "chat_crypto", "1", "Crypto chat", - "Start message with !! and it will be only visible to cathook users"); -static CatVar chat_filter(CV_STRING, "chat_censor", "", "Censor words", - "Spam Chat with newlines if the chosen words are " - "said, seperate with commas"); -static CatVar chat_filter_enabled(CV_SWITCH, "chat_censor_enabled", "0", - "Enable censor", "Censor Words in chat"); static CatVar server_crash_key(CV_KEY, "crash_server", "0", "Server crash key", "hold key and wait..."); static CatVar die_if_vac(CV_SWITCH, "die_if_vac", "0", "Die if VAC banned"); -static CatVar resolver(CV_SWITCH, "resolver", "0", "Resolve angles"); CatEnum namesteal_enum({ "OFF", "PASSIVE", "ACTIVE" }); CatVar namesteal(namesteal_enum, "name_stealer", "0", "Name Stealer", @@ -203,85 +181,5 @@ bool StolenName() static CatVar ipc_name(CV_STRING, "name_ipc", "", "IPC Name"); -CatVar nightmode(CV_SWITCH, "nightmode", "0", "Enable nightmode", ""); -static CatVar clean_chat(CV_SWITCH, "clean_chat", "0", "Clean chat", - "Removes newlines from chat"); -static CatVar dispatch_log(CV_SWITCH, "debug_log_usermessages", "0", - "Log dispatched user messages"); -std::string clear = ""; -std::string lastfilter{}; -std::string lastname{}; -static bool retrun = false; -static Timer sendmsg{}; -static Timer gitgud{}; - -const char *skynum[] = { "sky_tf2_04", - "sky_upward", - "sky_dustbowl_01", - "sky_goldrush_01", - "sky_granary_01", - "sky_well_01", - "sky_gravel_01", - "sky_badlands_01", - "sky_hydro_01", - "sky_night_01", - "sky_nightfall_01", - "sky_trainyard_01", - "sky_stormfront_01", - "sky_morningsnow_01", - "sky_alpinestorm_01", - "sky_harvest_01", - "sky_harvest_night_01", - "sky_halloween", - "sky_halloween_night_01", - "sky_halloween_night2014_01", - "sky_island_01", - "sky_jungle_01", - "sky_invasion2fort_01", - "sky_well_02", - "sky_outpost_01", - "sky_coastal_01", - "sky_rainbow_01", - "sky_badlands_pyroland_01", - "sky_pyroland_01", - "sky_pyroland_02", - "sky_pyroland_03" }; -CatEnum skys({ "sky_tf2_04", - "sky_upward", - "sky_dustbowl_01", - "sky_goldrush_01", - "sky_granary_01", - "sky_well_01", - "sky_gravel_01", - "sky_badlands_01", - "sky_hydro_01", - "sky_night_01", - "sky_nightfall_01", - "sky_trainyard_01", - "sky_stormfront_01", - "sky_morningsnow_01", - "sky_alpinestorm_01", - "sky_harvest_01", - "sky_harvest_night_01", - "sky_halloween", - "sky_halloween_night_01", - "sky_halloween_night2014_01", - "sky_island_01", - "sky_jungle_01", - "sky_invasion2fort_01", - "sky_well_02", - "sky_outpost_01", - "sky_coastal_01", - "sky_rainbow_01", - "sky_badlands_pyroland_01", - "sky_pyroland_01", - "sky_pyroland_02", - "sky_pyroland_03" }); -static CatVar - skybox_changer(skys, "skybox_changer", "0", "Change Skybox to this skybox", - "Change Skybox to this skybox, only changes on map load"); -static CatVar halloween_mode(CV_SWITCH, "halloween_mode", "0", - "Forced Halloween mode", - "forced tf_forced_holiday 2"); diff --git a/src/hooks/visual/DrawModelExecute.cpp b/src/hooks/visual/DrawModelExecute.cpp index c7478749..e8b90e40 100644 --- a/src/hooks/visual/DrawModelExecute.cpp +++ b/src/hooks/visual/DrawModelExecute.cpp @@ -3,8 +3,14 @@ Copyright (c) 2018 nullworks. All rights reserved. */ +#include #include "HookedMethods.hpp" +static CatVar no_arms(CV_SWITCH, "no_arms", "0", "No Arms", + "Removes arms from first person"); +static CatVar no_hats(CV_SWITCH, "no_hats", "0", "No Hats", + "Removes non-stock hats"); + namespace hooked_methods { @@ -12,9 +18,6 @@ DEFINE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *this_, const DrawModelState_t &state, const ModelRenderInfo_t &info, matrix3x4_t *bone) { - static const DrawModelExecute_t original = - (DrawModelExecute_t) hooks::modelrender.GetMethod( - offsets::DrawModelExecute()); static const char *name; static std::string sname; static IClientUnknown *unk; @@ -24,8 +27,7 @@ DEFINE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *this_, !(spectator_target || no_arms || no_hats || (clean_screenshots && g_IEngine->IsTakingScreenshot()))) { - original(_this, state, info, matrix); - return; + return original::DrawModelExecute(this_, state, info, bone); } PROF_SECTION(DrawModelExecute); diff --git a/src/hooks/visual/FrameStageNotify.cpp b/src/hooks/visual/FrameStageNotify.cpp index f15ab294..e3d073f6 100644 --- a/src/hooks/visual/FrameStageNotify.cpp +++ b/src/hooks/visual/FrameStageNotify.cpp @@ -3,8 +3,12 @@ Copyright (c) 2018 nullworks. All rights reserved. */ +#include #include "HookedMethods.hpp" +CatVar resolver(CV_SWITCH, "resolver", "0", "Resolve angles"); +CatVar nightmode(CV_SWITCH, "nightmode", "0", "Enable nightmode", ""); + namespace hooked_methods { diff --git a/src/hooks/visual/OverrideView.cpp b/src/hooks/visual/OverrideView.cpp index ca5dd827..78a27691 100644 --- a/src/hooks/visual/OverrideView.cpp +++ b/src/hooks/visual/OverrideView.cpp @@ -3,8 +3,17 @@ Copyright (c) 2018 nullworks. All rights reserved. */ +#include #include "HookedMethods.hpp" +CatVar override_fov_zoomed(CV_FLOAT, "fov_zoomed", "0", "FOV override (zoomed)", + "Overrides FOV with this value when zoomed in " + "(default FOV when zoomed is 20)"); +CatVar override_fov(CV_FLOAT, "fov", "0", "FOV override", + "Overrides FOV with this value"); + +CatVar freecam(CV_KEY, "debug_freecam", "0", "Freecam"); + namespace hooked_methods { diff --git a/src/hooks/visual/PaintTraverse.cpp b/src/hooks/visual/PaintTraverse.cpp index 73a4e9b2..202fc1bf 100644 --- a/src/hooks/visual/PaintTraverse.cpp +++ b/src/hooks/visual/PaintTraverse.cpp @@ -5,6 +5,25 @@ #include "HookedMethods.hpp" +CatVar clean_screenshots(CV_SWITCH, "clean_screenshots", "1", + "Clean screenshots", + "Don't draw visuals while taking a screenshot"); +CatVar disable_visuals(CV_SWITCH, "no_visuals", "0", "Disable ALL drawing", + "Completely hides cathook"); +CatVar no_zoom(CV_SWITCH, "no_zoom", "0", "Disable scope", + "Disables black scope overlay"); +CatVar pure_bypass(CV_SWITCH, "pure_bypass", "0", "Pure Bypass", + "Bypass sv_pure"); +void *pure_orig = nullptr; +void **pure_addr = nullptr; + +CatEnum software_cursor_enum({ "KEEP", "ALWAYS", "NEVER", "MENU ON", + "MENU OFF" }); +CatVar + software_cursor_mode(software_cursor_enum, "software_cursor_mode", "0", + "Software cursor", + "Try to change this and see what works best for you"); + namespace hooked_methods { @@ -49,7 +68,7 @@ DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_, pure_orig = (void *) 0; } call_default = true; - if (cathook && panel_scope && no_zoom && vp == panel_scope) + if (cathook && panel_scope && no_zoom && panel == panel_scope) call_default = false; if (software_cursor_mode) @@ -87,39 +106,39 @@ DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_, PROF_SECTION(PT_total); - if (vp == panel_top) + if (panel == panel_top) draw_flag = true; if (!cathook) return; if (!panel_top) { - name = g_IPanel->GetName(vp); + name = g_IPanel->GetName(panel); if (strlen(name) > 4) { if (name[0] == 'M' && name[3] == 'S') { - panel_top = vp; + panel_top = panel; } } } if (!panel_focus) { - name = g_IPanel->GetName(vp); + name = g_IPanel->GetName(panel); if (strlen(name) > 5) { if (name[0] == 'F' && name[5] == 'O') { - panel_focus = vp; + panel_focus = panel; } } } if (!panel_scope) { - name = g_IPanel->GetName(vp); + name = g_IPanel->GetName(panel); if (!strcmp(name, "HudScope")) { - panel_scope = vp; + panel_scope = panel; } } if (!g_IEngine->IsInGame()) @@ -127,7 +146,7 @@ DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_, g_Settings.bInvalid = true; } - if (vp != panel_focus) + if (panel != panel_focus) return; g_IPanel->SetTopmostPopup(panel_focus, true); if (!draw_flag) diff --git a/src/hooks/visual/RandomInt.cpp b/src/hooks/visual/RandomInt.cpp index fb47b4cb..0d8264dd 100644 --- a/src/hooks/visual/RandomInt.cpp +++ b/src/hooks/visual/RandomInt.cpp @@ -5,6 +5,9 @@ #include "HookedMethods.hpp" +static CatVar medal_flip(CV_SWITCH, "medal_flip", "0", "Infinite Medal Flip", + ""); + namespace hooked_methods {