Browse Source

Allow town portal to ally town.
fixes mantiss 0002064

AlexVinS 10 years ago
parent
commit
d564520f04
2 changed files with 13 additions and 3 deletions
  1. 8 1
      client/windows/CSpellWindow.cpp
  2. 5 2
      lib/spells/AdventureSpellMechanics.cpp

+ 8 - 1
client/windows/CSpellWindow.cpp

@@ -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]);

+ 5 - 2
lib/spells/AdventureSpellMechanics.cpp

@@ -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;
 	}