diff --git a/lib/mapping/CMap.cpp b/lib/mapping/CMap.cpp index b3cff891a..1c43f32e9 100644 --- a/lib/mapping/CMap.cpp +++ b/lib/mapping/CMap.cpp @@ -641,6 +641,19 @@ void CMap::removeObject(CGObjectInstance * obj) { (*iter)->id = ObjectInstanceID(i); } + + auto iterTown = std::find(towns.begin(), towns.end(), obj); + if(iterTown != towns.end()) + towns.erase(iterTown); + auto iterArt = std::find(artInstances.begin(), artInstances.end(), obj); + if(iterArt != artInstances.end()) + artInstances.erase(iterArt); + auto iterHero = std::find(allHeroes.begin(), allHeroes.end(), obj); + if(iterHero != allHeroes.end()) + allHeroes.erase(iterHero); + iterHero = std::find(heroesOnMap.begin(), heroesOnMap.end(), obj); + if(iterHero != heroesOnMap.end()) + heroesOnMap.erase(iterHero); } void CMap::initTerrain()