fix glow, chams and various other issues

This commit is contained in:
TotallyNotElite 2019-04-17 20:09:14 +02:00
parent c086775131
commit 7cd5a6414d
6 changed files with 28 additions and 20 deletions

View File

@ -17,20 +17,7 @@ class EffectGlow : public IScreenSpaceEffect
{ {
public: public:
virtual void Init(); virtual void Init();
virtual void Shutdown() 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;
}
}
inline virtual void SetParameters(KeyValues *params) inline virtual void SetParameters(KeyValues *params)
{ {

View File

@ -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 TICKS_TO_TIME(t) (TICK_INTERVAL * (t))
#define ROUND_TO_TICKS(t) (TICK_INTERVAL * TIME_TO_TICKS(t)) #define ROUND_TO_TICKS(t) (TICK_INTERVAL * TIME_TO_TICKS(t))
uintptr_t **fp; uintptr_t **fp;
__asm__("mov %%ebp, %0" : "=r"(fp)); __asm__ volatile("mov %%ebp, %0" : "=r"(fp));
bSendPackets = reinterpret_cast<bool *>(**fp - 8); bSendPackets = reinterpret_cast<bool *>(**fp - 8);
g_Settings.is_create_move = true; g_Settings.is_create_move = true;

View File

@ -44,7 +44,7 @@ DEFINE_HOOKED_METHOD(LevelInit, void, void *this_, const char *name)
logging::Info("Loaded Skybox: %s", succ ? "true" : "false"); logging::Info("Loaded Skybox: %s", succ ? "true" : "false");
} }
ConVar *holiday = g_ICvar->FindVar("tf_forced_holiday"); ConVar *holiday = g_ICvar->FindVar("tf_forced_holiday");
effect_chams::g_EffectChams.Init();
if (halloween_mode) if (halloween_mode)
holiday->SetValue(2); holiday->SetValue(2);
else if (holiday->m_nValue == 2) else if (holiday->m_nValue == 2)

View File

@ -43,6 +43,8 @@ DEFINE_HOOKED_METHOD(Shutdown, void, INetChannel *this_, const char *reason)
if (autoabandon) if (autoabandon)
tfmm::disconnectAndAbandon(); tfmm::disconnectAndAbandon();
hacks::shared::autojoin::onShutdown(); hacks::shared::autojoin::onShutdown();
effect_glow::g_EffectGlow.Shutdown();
effect_chams::g_EffectChams.Shutdown();
if (*random_name) if (*random_name)
{ {
static TextFile file; static TextFile file;

View File

@ -344,7 +344,7 @@ void EffectChams::Render(int x, int y, int w, int h)
{ {
IClientEntity *entity = g_IEntityList->GetClientEntity(i); IClientEntity *entity = g_IEntityList->GetClientEntity(i);
if (!entity || entity->IsDormant() || CE_BAD(ENTITY(i))) if (!entity || entity->IsDormant() || CE_BAD(ENTITY(i)))
return; continue;
RenderChams(entity); RenderChams(entity);
} }
EndRenderChams(); EndRenderChams();

View File

@ -204,6 +204,25 @@ void EffectGlow::Init()
init = true; 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) rgba_t EffectGlow::GlowColor(IClientEntity *entity)
{ {
static CachedEntity *ent; static CachedEntity *ent;
@ -415,13 +434,13 @@ void EffectGlow::Render(int x, int y, int w, int h)
{ {
if (!enable) if (!enable)
return; return;
if (!isHackActive() || (clean_screenshots && g_IEngine->IsTakingScreenshot()) || g_Settings.bInvalid)
return;
static ITexture *orig; static ITexture *orig;
static IClientEntity *ent; static IClientEntity *ent;
static IMaterialVar *blury_bloomamount; static IMaterialVar *blury_bloomamount;
if (!init) if (!init)
Init(); Init();
if (!isHackActive() || (g_IEngine->IsTakingScreenshot() && clean_screenshots) || g_Settings.bInvalid)
return;
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT); CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
orig = ptr->GetRenderTarget(); orig = ptr->GetRenderTarget();
BeginRenderGlow(); 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->DrawScreenSpaceRectangle(mat_blur_x, x, y, w, h, 0, 0, w - 1, h - 1, w, h);
ptr->SetRenderTarget(GetBuffer(1)); ptr->SetRenderTarget(GetBuffer(1));
blury_bloomamount = mat_blur_y->FindVar("$bloomamount", nullptr); 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->DrawScreenSpaceRectangle(mat_blur_y, x, y, w, h, 0, 0, w - 1, h - 1, w, h);
ptr->Viewport(x, y, w, h); ptr->Viewport(x, y, w, h);
ptr->SetRenderTarget(orig); ptr->SetRenderTarget(orig);