UTIL_ResetEntities: Crash fixed, sometimes returns NULL for 1 index

This commit is contained in:
s1lentq 2022-06-14 19:31:34 +07:00
parent 21dab90571
commit 10813019c8

View File

@ -1502,10 +1502,10 @@ void UTIL_RestartOther(const char *szClassname)
void UTIL_ResetEntities() void UTIL_ResetEntities()
{ {
edict_t *pEdict = INDEXENT(1); for (int i = 1; i < gpGlobals->maxEntities; i++)
for (int i = 1; i < gpGlobals->maxEntities; i++, pEdict++)
{ {
if (pEdict->free) edict_t *pEdict = INDEXENT(i);
if (!pEdict || pEdict->free)
continue; continue;
CBaseEntity *pEntity = CBaseEntity::Instance(pEdict); CBaseEntity *pEntity = CBaseEntity::Instance(pEdict);