1
0

Add cWorld::RemoveEntity and use in cEntity (#4003)

* Add cWorld::RemoveEntity and use in cEntity

* cEntity: Remove uneeded asserts from Destroy and DoMoveToWorld
This commit is contained in:
peterbell10
2017-09-05 15:11:35 +01:00
committed by Alexander Harkness
parent 028a35ef0d
commit ef1f371dab
3 changed files with 44 additions and 11 deletions

View File

@@ -3709,6 +3709,36 @@ bool cWorld::HasEntity(UInt32 a_UniqueID)
OwnedEntity cWorld::RemoveEntity(cEntity & a_Entity)
{
// Check if the entity is in the chunkmap:
auto Entity = m_ChunkMap->RemoveEntity(a_Entity);
if (Entity != nullptr)
{
return Entity;
}
// Check if the entity is in the queue to be added to the world:
cCSLock Lock(m_CSEntitiesToAdd);
auto itr = std::find_if(m_EntitiesToAdd.begin(), m_EntitiesToAdd.end(),
[&a_Entity](const OwnedEntity & a_OwnedEntity)
{
return (a_OwnedEntity.get() == &a_Entity);
}
);
if (itr != m_EntitiesToAdd.end())
{
Entity = std::move(*itr);
m_EntitiesToAdd.erase(itr);
}
return Entity;
}
/*
unsigned int cWorld::GetNumPlayers(void)
{