Original Post
//--------------------------------------------------------------------
// Animate entities
//--------------------------------------------------------------------
for(int iLayerNr = 0; iLayerNr < MAX_ENTITY_LAYERS;iLayerNr++)
{
map<uint,CEntity*> ::iterator next = mEntities[iLayerNr].begin();
while(next != mEntities[iLayerNr].end())
{
int retval = 0;
if(next->second->hasAttribute(CEntity::ATTRIBUTE_ANIMATED))
{
retval = next->second->update(newtime, lasttime);
}
if(retval == -1)
{
//--------------------------------------------------------------
//Returned -1, entity wants us to delete it...
//--------------------------------------------------------------------
delete next->second;
map<uint,CEntity*> ::iterator curr = next++;
mEntities[iLayerNr].erase(curr);
}
else
{
next++;
}
}
}
the question i have is about this part. It seems like he is erasing the next entity and not the one that requested to be erased?
delete next->second;
map<uint,CEntity*> ::iterator curr = next++;
mEntities[iLayerNr].erase(curr);
should it not be like this or is there something i missed?
delete next->second;
mEntities[iLayerNr].erase(curr);
map<uint,CEntity*> ::iterator curr = next++;
// edit - added a title [Edited by - LessBread on August 23, 2005 7:01:22 PM]