Small adjustments to entitycache

This commit is contained in:
BenCat07 2023-02-28 23:15:11 +01:00
parent 0531439d3c
commit 038da8c96f

View File

@ -87,18 +87,23 @@ void Update()
for (auto &[key, val] : array) for (auto &[key, val] : array)
{ {
val.Update(); val.Update();
if (val.InternalEntity() && !val.InternalEntity()->IsDormant()) if (val.InternalEntity())
{
// Non-dormant entities that need bone updates
if (!val.InternalEntity()->IsDormant())
{ {
valid_ents.emplace_back(&val); valid_ents.emplace_back(&val);
if (val.m_Type() == ENTITY_PLAYER) if (val.m_Type() == ENTITY_PLAYER || val.m_Type() == ENTITY_BUILDING || val.m_Type() == ENTITY_NPC)
{
GetPlayerInfo(val.m_IDX, val.player_info);
if (val.m_bAlivePlayer()) [[likely]] if (val.m_bAlivePlayer()) [[likely]]
{ {
val.hitboxes.UpdateBones(); val.hitboxes.UpdateBones();
if (val.m_Type() == ENTITY_PLAYER)
player_cache.emplace_back(&val); player_cache.emplace_back(&val);
} }
} }
if (val.m_Type() == ENTITY_PLAYER)
GetPlayerInfo(val.m_IDX, val.player_info);
} }
} }
previous_max = max; previous_max = max;
@ -122,11 +127,13 @@ void Update()
if (ent.m_Type() == ENTITY_PLAYER || ent.m_Type() == ENTITY_BUILDING || ent.m_Type() == ENTITY_NPC) if (ent.m_Type() == ENTITY_PLAYER || ent.m_Type() == ENTITY_BUILDING || ent.m_Type() == ENTITY_NPC)
{ {
if (ent.m_bAlivePlayer()) [[likely]] if (ent.m_bAlivePlayer()) [[likely]]
{
ent.hitboxes.UpdateBones(); ent.hitboxes.UpdateBones();
if (ent.m_Type() == ENTITY_PLAYER) if (ent.m_Type() == ENTITY_PLAYER)
player_cache.emplace_back(&ent); player_cache.emplace_back(&ent);
} }
} }
}
// Even dormant players have player info // Even dormant players have player info
if (ent.m_Type() == ENTITY_PLAYER) if (ent.m_Type() == ENTITY_PLAYER)