Browse Source

Prevent crash when opening stack's info window in fort

Michał Zaremba 3 weeks ago
parent
commit
6ee1e7a5c7
1 changed files with 2 additions and 9 deletions
  1. 2 9
      lib/bonuses/Limiters.cpp

+ 2 - 9
lib/bonuses/Limiters.cpp

@@ -287,16 +287,9 @@ ILimiter::EDecision CreatureTerrainLimiter::limit(const BonusLimitationContext &
 	}
 	else
 	{
-		if (context.node.getNodeType() == BonusNodeType::STACK_BATTLE)
-		{
-			const auto * unit = dynamic_cast<const CStack *>(&context.node);
-			if (unit->getCurrentTerrain() == terrainType)
-				return ILimiter::EDecision::ACCEPT;
-		}
-		else
+		if(const auto * unit = retrieveStackInstance(&context.node))
 		{
-			const auto * unit = dynamic_cast<const CStackInstance*>(&context.node);
-			if (unit->getCurrentTerrain() == terrainType)
+			if (unit->getArmy() && unit->getCurrentTerrain() == terrainType)
 				return ILimiter::EDecision::ACCEPT;
 		}
 	}