1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

CGTownInstance: erase all stacks when town is captured by enemy

This commit is contained in:
Arseniy Shestakov
2016-02-22 03:33:15 +03:00
parent d15106bf63
commit 9428f865d3
2 changed files with 10 additions and 0 deletions

View File

@@ -802,6 +802,14 @@ void CGTownInstance::removeCapitols (PlayerColor owner) const
} }
} }
void CGTownInstance::clearArmy() const
{
while(!stacks.empty())
{
cb->eraseStack(StackLocation(this, stacks.begin()->first));
}
}
int CGTownInstance::getBoatType() const int CGTownInstance::getBoatType() const
{ {
switch (town->faction->alignment) switch (town->faction->alignment)
@@ -1162,6 +1170,7 @@ void CGTownInstance::battleFinished(const CGHeroInstance *hero, const BattleResu
{ {
if(result.winner == 0) if(result.winner == 0)
{ {
clearArmy();
removeCapitols(hero->getOwner()); removeCapitols(hero->getOwner());
cb->setOwner (this, hero->tempOwner); //give control after checkout is done cb->setOwner (this, hero->tempOwner); //give control after checkout is done
FoWChange fw; FoWChange fw;

View File

@@ -239,6 +239,7 @@ public:
void mergeGarrisonOnSiege() const; // merge garrison into army of visiting hero void mergeGarrisonOnSiege() const; // merge garrison into army of visiting hero
void removeCapitols (PlayerColor owner) const; void removeCapitols (PlayerColor owner) const;
void clearArmy() const;
void addHeroToStructureVisitors(const CGHeroInstance *h, si32 structureInstanceID) const; //hero must be visiting or garrisoned in town void addHeroToStructureVisitors(const CGHeroInstance *h, si32 structureInstanceID) const; //hero must be visiting or garrisoned in town
CGTownInstance(); CGTownInstance();