Просмотр исходного кода

Fix taking double damage from the same moat.

When stack move to the double moat in the fortress, he will be damaged
twice. I fixed it like in original h3, now stack will be damaged once a
time.
FeniksFire 8 лет назад
Родитель
Сommit
ce09da783a
1 измененных файлов с 13 добавлено и 13 удалено
  1. 13 13
      server/CGameHandler.cpp

+ 13 - 13
server/CGameHandler.cpp

@@ -1409,24 +1409,24 @@ int CGameHandler::moveStack(int stack, BattleHex dest)
 	}
 
 	//handling obstacle on the final field (separate, because it affects both flying and walking stacks)
-	if (curStack->alive())
+	if(curStack->alive())
 	{
 		auto theLastObstacle = battleGetAllObstaclesOnPos(curStack->position, false);
+		if(curStack->doubleWide())
+		{
+			BattleHex otherHex = curStack->occupiedHex(curStack->position);
+			if(otherHex.isValid())
+				for(auto & i : battleGetAllObstaclesOnPos(otherHex, false))
+					theLastObstacle.push_back(i);
+		}
+		bool containDamageFromMoat = false;
 		for(auto & i : theLastObstacle)
-			if(curStack->alive())
-				handleDamageFromObstacle(*i, curStack);
-	}
-
-	if (curStack->alive() && curStack->doubleWide())
-	{
-		BattleHex otherHex = curStack->occupiedHex(curStack->position);
-		if (otherHex.isValid())
 		{
-			//two hex creature hit obstacle by backside
-			auto theLastObstacle = battleGetAllObstaclesOnPos(otherHex, false);
-			for(auto & i : theLastObstacle)
-				if(curStack->alive())
+			if(curStack->alive())
+				if(i->obstacleType != CObstacleInstance::MOAT || !containDamageFromMoat)
 					handleDamageFromObstacle(*i, curStack);
+			if(i->obstacleType == CObstacleInstance::MOAT)
+				containDamageFromMoat = true;
 		}
 	}
 	return ret;