mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Fix removal of towns from map via event
This commit is contained in:
@@ -418,6 +418,18 @@ void GameStatePackVisitor::visitRemoveObject(RemoveObject & pack)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(obj->ID == Obj::TOWN)
|
||||||
|
{
|
||||||
|
auto * town = dynamic_cast<CGTownInstance *>(obj);
|
||||||
|
town->setVisitingHero(nullptr);
|
||||||
|
|
||||||
|
if (town->getGarrisonHero())
|
||||||
|
{
|
||||||
|
town->setGarrisonedHero(nullptr);
|
||||||
|
gs.getMap().showObject(gs.getHero(town->getGarrisonHero()->id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const auto * quest = dynamic_cast<const IQuestObject *>(obj);
|
const auto * quest = dynamic_cast<const IQuestObject *>(obj);
|
||||||
if (quest)
|
if (quest)
|
||||||
{
|
{
|
||||||
@@ -429,6 +441,7 @@ void GameStatePackVisitor::visitRemoveObject(RemoveObject & pack)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
obj->detachFromBonusSystem(gs);
|
||||||
gs.getMap().eraseObject(pack.objectID);
|
gs.getMap().eraseObject(pack.objectID);
|
||||||
gs.getMap().calculateGuardingGreaturePositions();//FIXME: excessive, update only affected tiles
|
gs.getMap().calculateGuardingGreaturePositions();//FIXME: excessive, update only affected tiles
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user