From cc6a171f32a82e45ceca7e32049cb736f27924c2 Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Tue, 11 Sep 2018 20:06:00 +0200 Subject: [PATCH] This is sad tbh --- src/hooks/visual/DrawModelExecute.cpp | 2 +- src/settings/SettingCommands.cpp | 4 +++- src/settings/SettingsIO.cpp | 18 +++++++++++++----- src/visual/EffectChams.cpp | 10 ++++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/hooks/visual/DrawModelExecute.cpp b/src/hooks/visual/DrawModelExecute.cpp index 87a4f738..3e7ea0fa 100644 --- a/src/hooks/visual/DrawModelExecute.cpp +++ b/src/hooks/visual/DrawModelExecute.cpp @@ -21,7 +21,7 @@ DEFINE_HOOKED_METHOD(DrawModelExecute, void, IVModelRender *this_, return original::DrawModelExecute(this_, state, info, bone); if (!(spectator_target || no_arms || no_hats || - (clean_screenshots && g_IEngine->IsTakingScreenshot()) || + (*clean_screenshots && g_IEngine->IsTakingScreenshot()) || CE_BAD(LOCAL_E) || !LOCAL_E->m_bAlivePlayer())) { return original::DrawModelExecute(this_, state, info, bone); diff --git a/src/settings/SettingCommands.cpp b/src/settings/SettingCommands.cpp index 0fe34acb..0bfe4a1c 100755 --- a/src/settings/SettingCommands.cpp +++ b/src/settings/SettingCommands.cpp @@ -74,8 +74,11 @@ void save_thread(const CCommand &args) writer.saveTo( std::string(DATA_PATH "/configs/") + args.Arg(1) + ".conf", false); } + logging::Info("cat_save: Sorting configs..."); getAndSortAllConfigs(); + logging::Info("cat_save: Closing dir..."); closedir(config_directory); + logging::Info("cat_save: Enabeling cathook..."); settings::RVarLock.store(false); } @@ -142,7 +145,6 @@ static void getAndSortAllConfigs() { std::string s(ent->d_name); s = s.substr(0, s.find_last_of(".")); - logging::Info(s.c_str()); sortedConfigs.push_back(s); } std::sort(sortedConfigs.begin(), sortedConfigs.end()); diff --git a/src/settings/SettingsIO.cpp b/src/settings/SettingsIO.cpp index 3d1322cf..ad42a301 100755 --- a/src/settings/SettingsIO.cpp +++ b/src/settings/SettingsIO.cpp @@ -19,9 +19,9 @@ bool settings::SettingsWriter::saveTo(std::string path, bool only_changed) stream.open(path, std::ios::out); - if (stream.bad() || !stream.is_open() || stream.fail() || !stream) + if (!stream || stream.bad() || !stream.is_open() || stream.fail()) { - logging::Info("FATAL: cat_save FAILED!"); + logging::Info("cat_save: FATAL! FAILED to create stream!"); return false; } @@ -46,9 +46,12 @@ bool settings::SettingsWriter::saveTo(std::string path, bool only_changed) write(v.first, v.second); stream.flush(); } - if (stream.bad() || stream.fail() || !stream) + if (!stream || stream.bad() || stream.fail()) logging::Info("cat_save: FATAL! Stream bad!"); + logging::Info("cat_save: Finished"); stream.close(); + if (stream.fail()) + logging::Info("cat_save: FATAL! Stream bad (2)!"); return true; } @@ -56,8 +59,13 @@ void settings::SettingsWriter::write(std::string name, IVariable *variable) { writeEscaped(name); stream << "="; - writeEscaped(variable->toString()); - stream << '\n'; + if (variable) + writeEscaped(variable->toString()); + else + { + logging::Info("cat_save: FATAL! Variable invalid! %s", name.c_str()); + } + stream << std::endl; } void settings::SettingsWriter::writeEscaped(std::string str) diff --git a/src/visual/EffectChams.cpp b/src/visual/EffectChams.cpp index 7b5aeac6..7f46abc3 100644 --- a/src/visual/EffectChams.cpp +++ b/src/visual/EffectChams.cpp @@ -88,6 +88,8 @@ Timer t{}; int prevcolor = -1; rgba_t EffectChams::ChamsColor(IClientEntity *entity) { + if (!isHackActive() || !*enable) + return colors::empty;; CachedEntity *ent = ENTITY(entity->entindex()); if (disco_chams) { @@ -188,6 +190,8 @@ rgba_t EffectChams::ChamsColor(IClientEntity *entity) bool EffectChams::ShouldRenderChams(IClientEntity *entity) { + if (!isHackActive() || !*enable) + return false; if (!enable) return false; if (entity->entindex() < 0) @@ -245,6 +249,8 @@ bool EffectChams::ShouldRenderChams(IClientEntity *entity) void EffectChams::RenderChamsRecursive(IClientEntity *entity) { + if (!isHackActive() || !*enable) + return; entity->DrawModel(1); if (!recursive) @@ -285,6 +291,8 @@ void EffectChams::RenderChamsRecursive(IClientEntity *entity) void EffectChams::RenderChams(IClientEntity *entity) { + if (!isHackActive() || !*enable) + return; CMatRenderContextPtr ptr(GET_RENDER_CONTEXT); if (ShouldRenderChams(entity)) { @@ -315,6 +323,8 @@ void EffectChams::RenderChams(IClientEntity *entity) void EffectChams::Render(int x, int y, int w, int h) { PROF_SECTION(DRAW_chams); + if (!isHackActive()) + return; if (!enable) return; if (!init)