Skip to content

Commit f129051

Browse files
committed
Remove the IsBeingDeleted guard that skipped spatial database cleanup in ~CClientEntity, leaving dangling pointers in the R-tree when entities were freed between resource stop iterations. Also reorder the IsBeingDeleted check in the GetElementsWithinRange lambda to filter zombie entities before accessing their members.
1 parent 3b8f42a commit f129051

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

Client/mods/deathmatch/logic/CClientEntity.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ CClientEntity::~CClientEntity()
146146
}
147147

148148
// Remove from spatial database
149-
if (!g_pClientGame->IsBeingDeleted())
150-
GetClientSpatialDatabase()->RemoveEntity(this);
149+
GetClientSpatialDatabase()->RemoveEntity(this);
151150

152151
// Ensure not referenced in the disabled collisions list
153152
assert(!MapContains(g_pClientGame->m_AllDisabledCollisions, this));

Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,9 @@ CClientEntityResult CLuaElementDefs::GetElementsWithinRange(CVector pos, float r
980980
result.erase(std::remove_if(result.begin(), result.end(),
981981
[&, radiusSq = radius * radius](CElement* pElement)
982982
{
983+
if (pElement->IsBeingDeleted())
984+
return true;
985+
983986
if (typeHash && typeHash != pElement->GetTypeHash())
984987
return true;
985988

@@ -995,7 +998,7 @@ CClientEntityResult CLuaElementDefs::GetElementsWithinRange(CVector pos, float r
995998
if ((elementPos - pos).LengthSquared() > radiusSq)
996999
return true;
9971000

998-
return pElement->IsBeingDeleted();
1001+
return false;
9991002
}),
10001003
result.end());
10011004
}

0 commit comments

Comments
 (0)