Browse Source

#463 and #571 should be fixed now

mateuszb 14 years ago
parent
commit
a9c98d2b8c
3 changed files with 16 additions and 7 deletions
  1. 1 1
      client/CBattleInterface.cpp
  2. 3 2
      lib/BattleState.cpp
  3. 12 4
      server/CGameHandler.cpp

+ 1 - 1
client/CBattleInterface.cpp

@@ -893,7 +893,7 @@ bool CMeleeAttack::init()
 	int revShiftattacker = (attackingStack->attackerOwned ? -1 : 1);
 
 	int mutPos = THex::mutualPosition(attackingStackPosBeforeReturn, dest);
-	if(mutPos == -1 && attackedStack->doubleWide())
+	if(mutPos == -1 && attackingStack->doubleWide())
 	{
 		mutPos = THex::mutualPosition(attackingStackPosBeforeReturn + revShiftattacker, attackedStack->position);
 	}

+ 3 - 2
lib/BattleState.cpp

@@ -1345,11 +1345,12 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const
 
 	for(unsigned g=0; g<stacks.size(); ++g) //shifting positions of two-hex creatures
 	{
-		if((stacks[g]->position%17)==1 && stacks[g]->doubleWide() && stacks[g]->attackerOwned)
+		//we should do that for creature bank too
+		if(stacks[g]->doubleWide() && stacks[g]->attackerOwned)
 		{
 			stacks[g]->position += THex::RIGHT;
 		}
-		else if((stacks[g]->position%17)==15 && stacks[g]->doubleWide() && !stacks[g]->attackerOwned)
+		else if(stacks[g]->doubleWide() && !stacks[g]->attackerOwned)
 		{
 			stacks[g]->position += THex::LEFT;
 		}

+ 12 - 4
server/CGameHandler.cpp

@@ -4897,17 +4897,20 @@ void CGameHandler::runBattle()
 			{
 				BattleAction heal;
 
-				std::vector< const CStack * > possibleStacks;
+				std::vector< const CStack * > possibleStacks, secondPriority;
 				for (int v=0; v<gs->curB->stacks.size(); ++v)
 				{
 					const CStack * cstack = gs->curB->stacks[v];
 					if (cstack->owner == next->owner && cstack->firstHPleft < cstack->MaxHealth() && cstack->alive()) //it's friendly and not fully healthy
 					{
-						possibleStacks.push_back(cstack);
+						if (cstack->hasBonusOfType(Bonus::SIEGE_WEAPON))
+							secondPriority.push_back(cstack);
+						else
+							possibleStacks.push_back(cstack);
 					}
 				}
 
-				if(possibleStacks.size() == 0)
+				if(possibleStacks.size() == 0 && secondPriority.size() == 0)
 				{
 					//nothing to heal
 					makeStackDoNothing(next);
@@ -4917,7 +4920,12 @@ void CGameHandler::runBattle()
 				else
 				{
 					//heal random creature
-					const CStack * toBeHealed = possibleStacks[ rand()%possibleStacks.size() ];
+					const CStack * toBeHealed = NULL;
+					if (possibleStacks.size() > 0)
+						toBeHealed = possibleStacks[ rand()%possibleStacks.size() ];
+					else
+						toBeHealed = secondPriority[ rand()%secondPriority.size() ];
+					
 					heal.actionType = BattleAction::STACK_HEAL;
 					heal.additionalInfo = 0;
 					heal.destinationTile = toBeHealed->position;