From 7cd5a6414da1a0056f3a478c4ce4adab7af04326 Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Wed, 17 Apr 2019 20:09:14 +0200 Subject: [PATCH] fix glow, chams and various other issues --- include/visual/EffectGlow.hpp | 15 +-------------- src/hooks/CreateMove.cpp | 2 +- src/hooks/LevelInit.cpp | 2 +- src/hooks/Shutdown.cpp | 2 ++ src/visual/EffectChams.cpp | 2 +- src/visual/EffectGlow.cpp | 25 ++++++++++++++++++++++--- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/include/visual/EffectGlow.hpp b/include/visual/EffectGlow.hpp index 15817717..c0c536cd 100644 --- a/include/visual/EffectGlow.hpp +++ b/include/visual/EffectGlow.hpp @@ -17,20 +17,7 @@ class EffectGlow : public IScreenSpaceEffect { public: virtual void Init(); - virtual void Shutdown() - { - if (init) - { - mat_unlit.Shutdown(); - mat_unlit_z.Shutdown(); - mat_blit.Shutdown(); - mat_unlit.Shutdown(); - mat_unlit_z.Shutdown(); - mat_blur_x.Shutdown(); - mat_blur_y.Shutdown(); - init = false; - } - } + virtual void Shutdown(); inline virtual void SetParameters(KeyValues *params) { diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index 0f0ca9cd..81d95202 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -130,7 +130,7 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time, CUs #define TICKS_TO_TIME(t) (TICK_INTERVAL * (t)) #define ROUND_TO_TICKS(t) (TICK_INTERVAL * TIME_TO_TICKS(t)) uintptr_t **fp; - __asm__("mov %%ebp, %0" : "=r"(fp)); + __asm__ volatile("mov %%ebp, %0" : "=r"(fp)); bSendPackets = reinterpret_cast(**fp - 8); g_Settings.is_create_move = true; diff --git a/src/hooks/LevelInit.cpp b/src/hooks/LevelInit.cpp index 968b2da7..44fbc133 100644 --- a/src/hooks/LevelInit.cpp +++ b/src/hooks/LevelInit.cpp @@ -44,7 +44,7 @@ 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"); - + effect_chams::g_EffectChams.Init(); if (halloween_mode) holiday->SetValue(2); else if (holiday->m_nValue == 2) diff --git a/src/hooks/Shutdown.cpp b/src/hooks/Shutdown.cpp index ca560348..d9fbcb13 100644 --- a/src/hooks/Shutdown.cpp +++ b/src/hooks/Shutdown.cpp @@ -43,6 +43,8 @@ DEFINE_HOOKED_METHOD(Shutdown, void, INetChannel *this_, const char *reason) if (autoabandon) tfmm::disconnectAndAbandon(); hacks::shared::autojoin::onShutdown(); + effect_glow::g_EffectGlow.Shutdown(); + effect_chams::g_EffectChams.Shutdown(); if (*random_name) { static TextFile file; diff --git a/src/visual/EffectChams.cpp b/src/visual/EffectChams.cpp index f5b2ee24..f4049df7 100644 --- a/src/visual/EffectChams.cpp +++ b/src/visual/EffectChams.cpp @@ -344,7 +344,7 @@ void EffectChams::Render(int x, int y, int w, int h) { IClientEntity *entity = g_IEntityList->GetClientEntity(i); if (!entity || entity->IsDormant() || CE_BAD(ENTITY(i))) - return; + continue; RenderChams(entity); } EndRenderChams(); diff --git a/src/visual/EffectGlow.cpp b/src/visual/EffectGlow.cpp index f5d7c342..e09e0221 100644 --- a/src/visual/EffectGlow.cpp +++ b/src/visual/EffectGlow.cpp @@ -204,6 +204,25 @@ void EffectGlow::Init() init = true; } +void EffectGlow::Shutdown() +{ + if (init) + { + mat_unlit.Shutdown(); + mat_unlit_z.Shutdown(); + mat_blit.Shutdown(); + mat_blur_x.Shutdown(); + mat_blur_y.Shutdown(); + SS_NeverSolid.Reset(); + SS_SolidInvisible.Reset(); + SS_Drawing.Reset(); + GetBuffer(1)->Release(); + GetBuffer(2)->Release(); + init = false; + logging::Info("Shutdown glow"); + } +} + rgba_t EffectGlow::GlowColor(IClientEntity *entity) { static CachedEntity *ent; @@ -415,13 +434,13 @@ void EffectGlow::Render(int x, int y, int w, int h) { if (!enable) return; + if (!isHackActive() || (clean_screenshots && g_IEngine->IsTakingScreenshot()) || g_Settings.bInvalid) + return; static ITexture *orig; static IClientEntity *ent; static IMaterialVar *blury_bloomamount; if (!init) Init(); - if (!isHackActive() || (g_IEngine->IsTakingScreenshot() && clean_screenshots) || g_Settings.bInvalid) - return; CMatRenderContextPtr ptr(GET_RENDER_CONTEXT); orig = ptr->GetRenderTarget(); BeginRenderGlow(); @@ -454,7 +473,7 @@ void EffectGlow::Render(int x, int y, int w, int h) ptr->DrawScreenSpaceRectangle(mat_blur_x, x, y, w, h, 0, 0, w - 1, h - 1, w, h); ptr->SetRenderTarget(GetBuffer(1)); blury_bloomamount = mat_blur_y->FindVar("$bloomamount", nullptr); - blury_bloomamount->SetIntValue((int) blur_scale); + blury_bloomamount->SetIntValue(*blur_scale); ptr->DrawScreenSpaceRectangle(mat_blur_y, x, y, w, h, 0, 0, w - 1, h - 1, w, h); ptr->Viewport(x, y, w, h); ptr->SetRenderTarget(orig);