From 3558bbb4e5ecd8d72a6dc8c3791f6d470431a718 Mon Sep 17 00:00:00 2001 From: nullifiedcat Date: Tue, 2 May 2017 23:31:18 +0300 Subject: [PATCH] fix? hoovy crash + trying to improve fake name --- src/EffectGlow.cpp | 2 +- src/hooks/others.cpp | 12 +++++++++--- src/hoovy.cpp | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/EffectGlow.cpp b/src/EffectGlow.cpp index 2899cf05..d0850b25 100644 --- a/src/EffectGlow.cpp +++ b/src/EffectGlow.cpp @@ -34,7 +34,7 @@ static CatVar ammobox(CV_SWITCH, "glow_ammo", "0", "Ammoboxes", "Render glow on static CatVar buildings(CV_SWITCH, "glow_buildings", "0", "Buildings", "Render glow on buildings"); static CatVar stickies(CV_SWITCH, "glow_stickies", "0", "Stickies", "Render glow on stickybombs"); static CatVar teammate_buildings(CV_SWITCH, "glow_teammate_buildings", "0", "Teammate Buildings", "Render glow on teammates buildings"); - +//static CatVar weapons_white(CV_SWITCH, "glow_weapons_white", "1", "White Weapon Glow", "Weapons will glow white"); struct ShaderStencilState_t { diff --git a/src/hooks/others.cpp b/src/hooks/others.cpp index 64ce6c4d..e15df73b 100644 --- a/src/hooks/others.cpp +++ b/src/hooks/others.cpp @@ -184,6 +184,10 @@ void FrameStageNotify_hook(void* thisptr, int stage) { } } if (stage == FRAME_NET_UPDATE_START) { + static int next_name_change = 0; + if (next_name_change == 0) { + need_name_change = true; + } else next_name_change--; if (force_name.convar->m_StringLength > 2 && need_name_change) { INetChannel* ch = (INetChannel*)g_IEngine->GetNetChannelInfo(); if (ch) { @@ -194,10 +198,12 @@ void FrameStageNotify_hook(void* thisptr, int stage) { ch->SendNetMsg(setname, false); need_name_change = false; } + next_name_change = 60 * 100; } static ConVar* name_cv = g_ICvar->FindVar("name"); - name_cv->SetValue(force_name.GetString()); + //name_cv->SetValue(force_name.GetString()); name_cv->m_pszString = (char*)strfmt("%s", force_name.GetString()); + name_cv->m_StringLength = strlen(force_name.GetString()) + 1; } if (TF && cathook && !g_Settings.bInvalid && stage == FRAME_RENDER_START) { if (glow_enabled) { @@ -334,8 +340,8 @@ void LevelInit_hook(void* thisptr, const char* newmap) { //name_cv->m_pszString = strfmt("%s", force_name.GetString()); } static ConVar* name_cv = g_ICvar->FindVar("name"); - name_cv->SetValue(force_name.GetString()); name_cv->m_pszString = (char*)strfmt("%s", force_name.GetString()); + name_cv->m_StringLength = strlen(force_name.GetString()) + 1; } } @@ -361,8 +367,8 @@ void LevelShutdown_hook(void* thisptr) { //name_cv->m_pszString = strfmt("%s", force_name.GetString()); } static ConVar* name_cv = g_ICvar->FindVar("name"); - name_cv->SetValue(force_name.GetString()); name_cv->m_pszString = (char*)strfmt("%s", force_name.GetString()); + name_cv->m_StringLength = strlen(force_name.GetString()) + 1; } } diff --git a/src/hoovy.cpp b/src/hoovy.cpp index 7987bcc3..4af55ce5 100644 --- a/src/hoovy.cpp +++ b/src/hoovy.cpp @@ -10,7 +10,9 @@ static bool hoovy_list[32] = { 0 }; bool HasSandvichOut(CachedEntity* entity) { - CachedEntity* weapon = ENTITY(CE_INT(entity, netvar.hActiveWeapon) & 0xFFF); + int weapon_idx = CE_INT(entity, netvar.hActiveWeapon) & 0xFFF; + if (!(weapon_idx > 0 && weapon_idx < HIGHEST_ENTITY)) return false; + CachedEntity* weapon = ENTITY(weapon_idx); if (CE_GOOD(weapon)) { if (weapon->m_iClassID == g_pClassID->CTFLunchBox && CE_INT(entity, netvar.iClass) == tf_heavy) { return true;