1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

Allow town portal to ally town.

fixes mantiss 0002064
This commit is contained in:
AlexVinS
2015-04-01 04:04:02 +03:00
parent fb707a6576
commit d564520f04
2 changed files with 13 additions and 3 deletions

View File

@@ -707,7 +707,14 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
//todo: move to mechanics
std::vector <int> availableTowns;
std::vector <const CGTownInstance*> Towns = LOCPLINT->cb->getTownsInfo(true);
std::vector <const CGTownInstance*> Towns = LOCPLINT->cb->getTownsInfo(false);
vstd::erase_if(Towns, [](const CGTownInstance * t)
{
const auto relations = LOCPLINT->cb->getPlayerRelations(t->tempOwner, LOCPLINT->playerID);
return relations == PlayerRelations::ENEMIES;
});
if (Towns.empty())
{
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[124]);

View File

@@ -203,9 +203,12 @@ bool TownPortalMechanics::applyAdventureEffects(const SpellCastEnvironment * env
}
CGTownInstance * town = static_cast<CGTownInstance*>(tile.visitableObjects.back());
if (town->tempOwner != parameters.caster->tempOwner)
const auto relations = env->getCb()->getPlayerRelations(town->tempOwner, parameters.caster->tempOwner);
if(relations == PlayerRelations::ENEMIES)
{
env->complain("Can't teleport to another player!");
env->complain("Can't teleport to enemy!");
return false;
}