1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

First part of object instance API cleanup

- removed passability() method in favour of passableFor(PlayerColor)
- moved operator < code to map handler
- updated class documentation
This commit is contained in:
Ivan Savenko
2014-06-24 02:26:36 +03:00
parent c7dc4c05b8
commit 5ebc0e8614
13 changed files with 151 additions and 157 deletions

View File

@ -1250,19 +1250,18 @@ void CGGarrison::onHeroVisit (const CGHeroInstance *h) const
cb->showGarrisonDialog(id, h->id, removableUnits);
}
ui8 CGGarrison::getPassableness() const
bool CGGarrison::passableFor(PlayerColor player) const
{
//FIXME: identical to same method in CGTownInstance
if ( !stacksCount() )//empty - anyone can visit
return GameConstants::ALL_PLAYERS;
return true;
if ( tempOwner == PlayerColor::NEUTRAL )//neutral guarded - no one can visit
return 0;
return false;
ui8 mask = 0;
TeamState * ts = cb->gameState()->getPlayerTeam(tempOwner);
for(PlayerColor it : ts->players)
mask |= 1<<it.getNum(); //allies - add to possible visitors
return mask;
if (cb->getPlayerRelations(tempOwner, player) != PlayerRelations::ENEMIES)
return true;
return false;
}
void CGGarrison::battleFinished(const CGHeroInstance *hero, const BattleResult &result) const