fix chams crash

This commit is contained in:
TotallyNotElite 2019-04-18 15:21:31 +02:00
parent 2bc7606b56
commit 674e77e78f

View File

@ -85,10 +85,10 @@ void EffectChams::EndRenderChams()
CMatRenderContextPtr ptr(GET_RENDER_CONTEXT); CMatRenderContextPtr ptr(GET_RENDER_CONTEXT);
g_IVModelRender->ForcedMaterialOverride(nullptr); g_IVModelRender->ForcedMaterialOverride(nullptr);
} }
static rgba_t data[32] = { colors::empty }; static rgba_t data[33] = { colors::empty };
void EffectChams::SetEntityColor(CachedEntity *ent, rgba_t color) void EffectChams::SetEntityColor(CachedEntity *ent, rgba_t color)
{ {
if (ent->m_IDX > 31 || ent->m_IDX < 0) if (ent->m_IDX > 32 || ent->m_IDX < 0)
return; return;
data[ent->m_IDX] = color; data[ent->m_IDX] = color;
} }
@ -98,7 +98,7 @@ rgba_t EffectChams::ChamsColor(IClientEntity *entity)
{ {
if (!isHackActive() || !*effect_chams::enable) if (!isHackActive() || !*effect_chams::enable)
return colors::empty; return colors::empty;
;
CachedEntity *ent = ENTITY(entity->entindex()); CachedEntity *ent = ENTITY(entity->entindex());
if (disco_chams) if (disco_chams)
{ {
@ -157,11 +157,14 @@ rgba_t EffectChams::ChamsColor(IClientEntity *entity)
} }
return disco; return disco;
} }
if (data[entity->entindex()] != colors::empty) if (ent->m_IDX <= 32 && ent->m_IDX >= 0)
{ {
auto toret = data[entity->entindex()]; if (data[entity->entindex()] != colors::empty)
data[entity->entindex()] = colors::empty; {
return toret; auto toret = data[entity->entindex()];
data[entity->entindex()] = colors::empty;
return toret;
}
} }
if (CE_BAD(ent)) if (CE_BAD(ent))
return colors::white; return colors::white;