Bladeren bron

Fixed http://bugs.vcmi.eu/view.php?id=2506

AlexVinS 9 jaren geleden
bovenliggende
commit
849e3fc04e
3 gewijzigde bestanden met toevoegingen van 13 en 3 verwijderingen
  1. 1 0
      client/battle/CBattleInterface.cpp
  2. 6 2
      lib/CBattleCallback.cpp
  3. 6 1
      lib/spells/BattleSpellMechanics.cpp

+ 1 - 0
client/battle/CBattleInterface.cpp

@@ -2073,6 +2073,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
 				break;
 			case TELEPORT:
 			{
+				//todo: move to mechanics
 				ui8 skill = 0;
 				if (creatureCasting)
 					skill = sactive->getEffectLevel(SpellID(SpellID::TELEPORT).toSpell());

+ 6 - 2
lib/CBattleCallback.cpp

@@ -52,7 +52,7 @@ namespace SiegeStuffThatShouldBeMovedToHandlers //  <=== TODO
 		const bool stackLeft = pos1 < wallInStackLine;
 		const bool destLeft = pos2 < wallInDestLine;
 
-		return stackLeft != destLeft;
+		return stackLeft == destLeft;
 	}
 
 	// parts of wall
@@ -500,7 +500,11 @@ si8 CBattleInfoCallback::battleCanTeleportTo(const CStack * stack, BattleHex des
 	if (!getAccesibility(stack).accessible(destHex, stack))
 		return false;
 
-	if (battleGetSiegeLevel() && telportLevel < 2) //check for wall
+	const ui8 siegeLevel = battleGetSiegeLevel();
+
+	//check for wall
+	//advanced teleport can pass wall of fort|citadel, expert - of castle
+	if ((siegeLevel > CGTownInstance::NONE && telportLevel < 2) || (siegeLevel >= CGTownInstance::CASTLE && telportLevel < 3))
 		return sameSideOfWall(stack->position, destHex);
 
 	return true;

+ 6 - 1
lib/spells/BattleSpellMechanics.cpp

@@ -856,7 +856,6 @@ bool SummonMechanics::requiresCreatureTarget() const
 ///TeleportMechanics
 void TeleportMechanics::applyBattleEffects(const SpellCastEnvironment * env, const BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
 {
-	//todo: check legal teleport
 	if(parameters.destinations.size() == 2)
 	{
 		//first destination hex to move to
@@ -875,6 +874,12 @@ void TeleportMechanics::applyBattleEffects(const SpellCastEnvironment * env, con
 			return;
 		}
 
+		if(!parameters.cb->battleCanTeleportTo(target, destination, parameters.effectLevel))
+		{
+			env->complain("TeleportMechanics: forbidden teleport");
+			return;
+		}
+
 		BattleStackMoved bsm;
 		bsm.distance = -1;
 		bsm.stack = target->ID;