From a9c98d2b8c7a43672a23131231372afbe05fc043 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Tue, 18 Jan 2011 18:54:53 +0000 Subject: [PATCH] #463 and #571 should be fixed now --- client/CBattleInterface.cpp | 2 +- lib/BattleState.cpp | 5 +++-- server/CGameHandler.cpp | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/client/CBattleInterface.cpp b/client/CBattleInterface.cpp index 6e0aa38b2..9feffe7e8 100644 --- a/client/CBattleInterface.cpp +++ b/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); } diff --git a/lib/BattleState.cpp b/lib/BattleState.cpp index 537efda9d..e49912067 100644 --- a/lib/BattleState.cpp +++ b/lib/BattleState.cpp @@ -1345,11 +1345,12 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, int terrain, int terType, const for(unsigned g=0; gposition%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; } diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index dabe154f6..b31d88b81 100644 --- a/server/CGameHandler.cpp +++ b/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; vcurB->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;