mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-05 13:04:54 +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
|
else
|
||||||
{
|
{
|
||||||
cb->setOwner(id, h->tempOwner);
|
cb->setOwner(id, h->tempOwner);
|
||||||
removeCapitols (h->getOwner(), true);
|
removeCapitols (h->getOwner());
|
||||||
cb->heroVisitCastle(id, h->id);
|
cb->heroVisitCastle(id, h->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1706,8 +1706,6 @@ void CGTownInstance::initObj()
|
|||||||
bonusingBuildings.push_back (new CTownBonus(17, this));
|
bonusingBuildings.push_back (new CTownBonus(17, this));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (getOwner() != 255)
|
|
||||||
removeCapitols (getOwner(), false); // destroy other capitols
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGTownInstance::newTurn() const
|
void CGTownInstance::newTurn() const
|
||||||
@ -1752,31 +1750,26 @@ void CGTownInstance::fightOver( const CGHeroInstance *h, BattleResult *result )
|
|||||||
{
|
{
|
||||||
if(result->winner == 0)
|
if(result->winner == 0)
|
||||||
{
|
{
|
||||||
removeCapitols (h->getOwner(), true);
|
removeCapitols (h->getOwner());
|
||||||
cb->setOwner (id, h->tempOwner); //give control after checkout is done
|
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
|
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)
|
for (std::vector<CGTownInstance*>::const_iterator i = state->towns.begin(); i < state->towns.end(); ++i)
|
||||||
{
|
{
|
||||||
if (*i != this && (*i)->hasCapitol())
|
if (*i != this && (*i)->hasCapitol())
|
||||||
{
|
{
|
||||||
if (me)
|
RazeStructures rs;
|
||||||
{
|
rs.tid = id;
|
||||||
RazeStructures rs;
|
rs.bid.insert(13);
|
||||||
rs.tid = id;
|
rs.destroyed = destroyed;
|
||||||
rs.bid.insert(13);
|
cb->sendAndApply(&rs);
|
||||||
rs.destroyed = destroyed;
|
return;
|
||||||
cb->sendAndApply(&rs);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
(*i)->builtBuildings.erase(13); //destroy all other capitols at the beginning of game
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -492,7 +492,7 @@ public:
|
|||||||
bool hasCapitol() const;
|
bool hasCapitol() const;
|
||||||
int dailyIncome() const; //calculates daily income of this town
|
int dailyIncome() const; //calculates daily income of this town
|
||||||
int spellsAtLevel(int level, bool checkGuild) const; //levels are counted from 1 (1 - 5)
|
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
|
int defenceBonus(int type) const;//primary skills bonuses for defending hero
|
||||||
|
|
||||||
CGTownInstance();
|
CGTownInstance();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user