I don't really understand why it isn't at least behaving consistently.
This is the function called every frame to check for collisions between an entity 'e' and other non-tile entities. At the moment I'm not doing a broadphase check, as there aren't any off screen items.
[source lang="cpp"]void cEntityManager::calculateCollisions(cEntity* e) { std::list<std::string> deletionList; std::list<std::string>::iterator it; std::map<std::string, cEntity*>::iterator itr; for(itr=entityList.begin(); itr != entityList.end(); ++itr){ if(e != itr->second && ( getIntersectionX(getPathRectX(*e), itr->second->getBoundingBox()) || getIntersectionY(getPathRectY(*e), itr->second->getBoundingBox() ))) { if(e->handleCollision(itr->second) == 1) { deletionList.insert(deletionList.end(), itr->first); } } } if(deletionList.size() != 0) { for(it = deletionList.begin(); it != deletionList.end(); ++it) { itr = entityList.find(it->data()); removeItem(itr->first); } }}[/source]
Then the removal function, which will remove the items from the std::map
[source lang="cpp"]void cEntityManager::removeItem(std::string s) { std::map<std::string, cEntity*>::iterator itr; itr = entityList.find(s); delete itr->second; entityList.erase(s);}[/source]
Does anyone have any idea why this is misbehaving?
Edited by Silgen, 30 October 2012 - 03:01 AM.






