Browse Source

avoid assertions in stack position checks

AlexVinS 8 years ago
parent
commit
e4c14c4cc2
2 changed files with 4 additions and 4 deletions
  1. 2 2
      client/battle/CBattleInterface.cpp
  2. 2 2
      server/CGameHandler.cpp

+ 2 - 2
client/battle/CBattleInterface.cpp

@@ -2036,7 +2036,7 @@ std::string formatDmgRange(std::pair<ui32, ui32> dmgRange)
 bool CBattleInterface::canStackMoveHere(const CStack * activeStack, BattleHex myNumber)
 {
 	std::vector<BattleHex> acc = curInt->cb->battleGetAvailableHexes (activeStack, false);
-	BattleHex shiftedDest = myNumber + activeStack->destShiftDir();
+	BattleHex shiftedDest = myNumber.cloneInDirection(activeStack->destShiftDir(), false);
 
 	if (vstd::contains(acc, myNumber))
 		return true;
@@ -2265,7 +2265,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
 					if(activeStack->doubleWide())
 					{
 						std::vector<BattleHex> acc = curInt->cb->battleGetAvailableHexes(activeStack, false);
-						BattleHex shiftedDest = myNumber + activeStack->destShiftDir();
+						BattleHex shiftedDest = myNumber.cloneInDirection(activeStack->destShiftDir(), false);
 						if(vstd::contains(acc, myNumber))
 							giveCommand(Battle::WALK, myNumber, activeStack->ID);
 						else if(vstd::contains(acc, shiftedDest))

+ 2 - 2
server/CGameHandler.cpp

@@ -1164,7 +1164,7 @@ int CGameHandler::moveStack(int stack, BattleHex dest)
 	//shifting destination (if we have double wide stack and we can occupy dest but not be exactly there)
 	if(!stackAtEnd && curStack->doubleWide() && !accessibility.accessible(dest, curStack))
 	{
-		BattleHex shifted = dest.cloneInDirection(curStack->destShiftDir());
+		BattleHex shifted = dest.cloneInDirection(curStack->destShiftDir(), false);
 
 		if(accessibility.accessible(shifted, curStack))
 			dest = shifted;
@@ -3948,7 +3948,7 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
 			logGlobal->trace("%s will attack %s", stack->nodeName(), destinationStack->nodeName());
 
 			if(stack->position != ba.destinationTile //we wasn't able to reach destination tile
-				&& !(stack->doubleWide() && (stack->position == ba.destinationTile.cloneInDirection(stack->destShiftDir()))) //nor occupy specified hex
+				&& !(stack->doubleWide() && (stack->position == ba.destinationTile.cloneInDirection(stack->destShiftDir(), false))) //nor occupy specified hex
 				)
 			{
 				complain("We cannot move this stack to its destination " + stack->getCreature()->namePl);