Kaynağa Gözat

#1083 should be fixed.
To be released as dev build 0.89d.

Michał W. Urbańczyk 13 yıl önce
ebeveyn
işleme
dec3f9afd9
1 değiştirilmiş dosya ile 11 ekleme ve 8 silme
  1. 11 8
      lib/CBattleCallback.cpp

+ 11 - 8
lib/CBattleCallback.cpp

@@ -1054,6 +1054,12 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
 		ret[BattleHex(0, y)] = EAccessibility::SIDE_COLUMN;
 	}
 
+	//gate -> should be before stacks
+	if(battleGetSiegeLevel() > 0 && battleGetWallState(EWallParts::GATE) < 3) //gate is not destroyed
+	{
+		ret[95] = ret[96] = EAccessibility::GATE; //block gate's hexes
+	}
+
 	//tiles occupied by standing stacks
 	BOOST_FOREACH(auto stack, battleAliveStacks())
 	{
@@ -1086,12 +1092,6 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
 			if(battleGetWallState(lockedIfNotDestroyed[b].first) < 3)
 				ret[lockedIfNotDestroyed[b].second] = EAccessibility::DESTRUCTIBLE_WALL;
 		}
-
-		//gate
-		if(battleGetWallState(7) < 3) //if it attacker's unit and gate is not destroyed
-		{
-			ret[95] = ret[96] = EAccessibility::GATE; //block gate's hexes
-		}
 	}
 
 	return ret;
@@ -2196,9 +2196,12 @@ bool AccessibilityInfo::accessible(BattleHex tile, bool doubleWide, bool attacke
 {
 	// All hexes that stack would cover if standing on tile have to be accessible.
 	BOOST_FOREACH(auto hex, CStack::getHexes(tile, doubleWide, attackerOwned))
-		if(!hex.isValid() || at(hex) != EAccessibility::ACCESSIBLE)
+	{
+		const bool markedAccessible = at(hex) == EAccessibility::ACCESSIBLE;
+		const bool gateAccessible = (at(hex) == EAccessibility::GATE) && !attackerOwned; //defender can always step on gate 
+		if(!hex.isValid() || (!markedAccessible && !gateAccessible))
 			return false;
-
+	}
 	return true;
 }