mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Fixed #374
This commit is contained in:
parent
dc2a0730e6
commit
76dab23dda
@ -1666,7 +1666,7 @@ void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const
|
||||
else
|
||||
{
|
||||
cb->setOwner(id, h->tempOwner);
|
||||
removeCapitols (h->getOwner(), true);
|
||||
removeCapitols (h->getOwner());
|
||||
cb->heroVisitCastle(id, h->id);
|
||||
}
|
||||
}
|
||||
@ -1706,8 +1706,6 @@ void CGTownInstance::initObj()
|
||||
bonusingBuildings.push_back (new CTownBonus(17, this));
|
||||
break;
|
||||
}
|
||||
if (getOwner() != 255)
|
||||
removeCapitols (getOwner(), false); // destroy other capitols
|
||||
}
|
||||
|
||||
void CGTownInstance::newTurn() const
|
||||
@ -1752,31 +1750,26 @@ void CGTownInstance::fightOver( const CGHeroInstance *h, BattleResult *result )
|
||||
{
|
||||
if(result->winner == 0)
|
||||
{
|
||||
removeCapitols (h->getOwner(), true);
|
||||
removeCapitols (h->getOwner());
|
||||
cb->setOwner (id, h->tempOwner); //give control after checkout is done
|
||||
}
|
||||
}
|
||||
|
||||
void CGTownInstance::removeCapitols (ui8 owner, bool me) const
|
||||
void CGTownInstance::removeCapitols (ui8 owner) const
|
||||
{
|
||||
if (hasCapitol()) // search for older capitol
|
||||
if (hasCapitol()) // search if there's an older capitol
|
||||
{
|
||||
PlayerState* state = cb->gameState()->getPlayer (owner); //get all towns owned by player
|
||||
for (std::vector<CGTownInstance*>::const_iterator i = state->towns.begin(); i < state->towns.end(); ++i)
|
||||
{
|
||||
if (*i != this && (*i)->hasCapitol())
|
||||
{
|
||||
if (me)
|
||||
{
|
||||
RazeStructures rs;
|
||||
rs.tid = id;
|
||||
rs.bid.insert(13);
|
||||
rs.destroyed = destroyed;
|
||||
cb->sendAndApply(&rs);
|
||||
return;
|
||||
}
|
||||
else
|
||||
(*i)->builtBuildings.erase(13); //destroy all other capitols at the beginning of game
|
||||
RazeStructures rs;
|
||||
rs.tid = id;
|
||||
rs.bid.insert(13);
|
||||
rs.destroyed = destroyed;
|
||||
cb->sendAndApply(&rs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ public:
|
||||
bool hasCapitol() const;
|
||||
int dailyIncome() const; //calculates daily income of this town
|
||||
int spellsAtLevel(int level, bool checkGuild) const; //levels are counted from 1 (1 - 5)
|
||||
void removeCapitols (ui8 owner, bool me) const;
|
||||
void removeCapitols (ui8 owner) const;
|
||||
int defenceBonus(int type) const;//primary skills bonuses for defending hero
|
||||
|
||||
CGTownInstance();
|
||||
|
Loading…
x
Reference in New Issue
Block a user