Skip to content

Commit a8f4e99

Browse files
committed
Fixed invalid entity lookup for physics body.
1 parent 9d944a5 commit a8f4e99

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

OpenTESArena/src/Entities/EntityChunkManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,10 +745,10 @@ EntityInstanceID EntityChunkManager::getEntityFromPhysicsBodyID(JPH::BodyID body
745745
// @todo: probably want a smarter lookup than this
746746
for (int i = 0; i < this->entities.getTotalCount(); i++)
747747
{
748-
const EntityInstance &entityInst = this->entities.get(i);
749-
if (entityInst.physicsBodyID == bodyID)
748+
const EntityInstance *entityInst = this->entities.tryGet(i);
749+
if (entityInst != nullptr && entityInst->physicsBodyID == bodyID)
750750
{
751-
return entityInst.instanceID;
751+
return entityInst->instanceID;
752752
}
753753
}
754754

0 commit comments

Comments
 (0)