Skip to content

Commit

Permalink
Merge pull request #734 from openmultiplayer/amir/fix-object-crash
Browse files Browse the repository at this point in the history
fix obj crash,  deleted objects being delayed processed
  • Loading branch information
AmyrAhmady authored Oct 10, 2023
2 parents 7b22bb0 + f35b0f6 commit 441a63a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Server/Components/Objects/objects_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,13 @@ class ObjectComponent final : public IObjectsComponent, public CoreEventHandler,

void release(int index) override
{
auto ptr = storage.get(index);
if (ptr)
auto obj = storage.get(index);
if (obj)
{
static_cast<Object*>(ptr)->destream();
obj->destream();
storage.release(index, false);
processedObjects.erase(obj);
attachedToPlayer.erase(obj);
}
}

Expand Down Expand Up @@ -599,6 +601,7 @@ class PlayerObjectData final : public IPlayerObjectData
obj->destream();
storage.release(index, false);
attachedToPlayer_.erase(obj);
component_.getPlayerProcessedObjects().erase(obj);
}
}

Expand Down

0 comments on commit 441a63a

Please sign in to comment.