1
0

cMonster::m_Target safety across worlds

This commit is contained in:
LogicParrot
2016-02-01 22:49:34 +02:00
parent a5403c8976
commit 4aade202e0
17 changed files with 294 additions and 83 deletions

View File

@@ -1959,6 +1959,10 @@ bool cChunk::ForEachEntity(cEntityCallback & a_Callback)
for (cEntityList::iterator itr = m_Entities.begin(), itr2 = itr; itr != m_Entities.end(); itr = itr2)
{
++itr2;
if ((*itr)->IsDestroyed())
{
continue;
}
if (a_Callback.Item(*itr))
{
return false;
@@ -1977,6 +1981,10 @@ bool cChunk::ForEachEntityInBox(const cBoundingBox & a_Box, cEntityCallback & a_
for (cEntityList::iterator itr = m_Entities.begin(), itr2 = itr; itr != m_Entities.end(); itr = itr2)
{
++itr2;
if ((*itr)->IsDestroyed())
{
continue;
}
cBoundingBox EntBox((*itr)->GetPosition(), (*itr)->GetWidth() / 2, (*itr)->GetHeight());
if (!EntBox.DoesIntersect(a_Box))
{
@@ -2000,7 +2008,7 @@ bool cChunk::DoWithEntityByID(UInt32 a_EntityID, cEntityCallback & a_Callback, b
// The entity list is locked by the parent chunkmap's CS
for (cEntityList::iterator itr = m_Entities.begin(), end = m_Entities.end(); itr != end; ++itr)
{
if ((*itr)->GetUniqueID() == a_EntityID)
if (((*itr)->GetUniqueID() == a_EntityID) && (!(*itr)->IsDestroyed()))
{
a_CallbackResult = a_Callback.Item(*itr);
return true;