From ce09da783aec4c9f5e6a81e0930424a3c4fde0e3 Mon Sep 17 00:00:00 2001 From: FeniksFire Date: Sat, 8 Jul 2017 21:35:29 +0200 Subject: [PATCH] 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. --- server/CGameHandler.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 0262e0bef..0abba0378 100644 --- a/server/CGameHandler.cpp +++ b/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); - for(auto & i : theLastObstacle) - if(curStack->alive()) - handleDamageFromObstacle(*i, curStack); - } - - if (curStack->alive() && curStack->doubleWide()) - { - BattleHex otherHex = curStack->occupiedHex(curStack->position); - if (otherHex.isValid()) + if(curStack->doubleWide()) { - //two hex creature hit obstacle by backside - auto theLastObstacle = battleGetAllObstaclesOnPos(otherHex, false); - for(auto & i : theLastObstacle) - if(curStack->alive()) + 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()) + if(i->obstacleType != CObstacleInstance::MOAT || !containDamageFromMoat) handleDamageFromObstacle(*i, curStack); + if(i->obstacleType == CObstacleInstance::MOAT) + containDamageFromMoat = true; } } return ret;