Spawn::~Spawn() { for (const auto& it : spawnedMap) { Monster* monster = it.second; monster->setSpawn(nullptr); monster->decrementReferenceCounter(); } }
void Spawn::cleanup() { auto it = spawnedMap.begin(); while (it != spawnedMap.end()) { uint32_t spawnId = it->first; Monster* monster = it->second; if (monster->isRemoved()) { if (spawnId != 0) { spawnMap[spawnId].lastSpawn = OTSYS_TIME(); } monster->decrementReferenceCounter(); it = spawnedMap.erase(it); } else if (!isInSpawnZone(monster->getPosition()) && spawnId != 0) { spawnedMap.insert(spawned_pair(0, monster)); it = spawnedMap.erase(it); } else { ++it; } } }