Core/Maps: Fixed invalid iterator usage

Closes #14687
This commit is contained in:
Shauren
2015-05-14 00:04:49 +02:00
parent 5c5cb3e555
commit ee1c1b97be
3 changed files with 36 additions and 15 deletions

View File

@@ -225,8 +225,12 @@ void PoolGroup<Creature>::Despawn1Object(uint64 guid)
if (!map->Instanceable())
{
auto creatureBounds = map->GetCreatureBySpawnIdStore().equal_range(guid);
for (auto itr = creatureBounds.first; itr != creatureBounds.second; ++itr)
itr->second->AddObjectToRemoveList();
for (auto itr = creatureBounds.first; itr != creatureBounds.second;)
{
Creature* creature = itr->second;
++itr;
creature->AddObjectToRemoveList();
}
}
}
}
@@ -243,8 +247,12 @@ void PoolGroup<GameObject>::Despawn1Object(uint64 guid)
if (!map->Instanceable())
{
auto gameobjectBounds = map->GetGameObjectBySpawnIdStore().equal_range(guid);
for (auto itr = gameobjectBounds.first; itr != gameobjectBounds.second; ++itr)
itr->second->AddObjectToRemoveList();
for (auto itr = gameobjectBounds.first; itr != gameobjectBounds.second;)
{
GameObject* go = itr->second;
++itr;
go->AddObjectToRemoveList();
}
}
}
}