diff --git a/CBattleInterface.cpp b/CBattleInterface.cpp index c7b545d65..67f560ede 100644 --- a/CBattleInterface.cpp +++ b/CBattleInterface.cpp @@ -41,8 +41,9 @@ public: } cmpst2 ; CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, CGHeroInstance *hero1, CGHeroInstance *hero2) -: printCellBorders(true), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0), activeStack(-1), givenCommand(NULL), attackingInfo(NULL), myTurn(false), resWindow(NULL), showStackQueue(false), animSpeed(2), printStackRange(true) +: printCellBorders(true), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0), activeStack(-1), givenCommand(NULL), attackingInfo(NULL), myTurn(false), resWindow(NULL), showStackQueue(false), animSpeed(2), printStackRange(true), printMouseShadow(true) { + strongInterest = true; givenCommand = new CondSh(NULL); //initializing armies this->army1 = army1; @@ -585,7 +586,7 @@ bool CBattleInterface::reverseCreature(int number, int hex, bool wideTrick) void CBattleInterface::bOptionsf() { CGI->curh->changeGraphic(0,0); - LOCPLINT->curint->deactivate(); + deactivate(); SDL_Rect temp_rect = genRect(431, 481, 160, 84); CBattleOptionsWindow * optionsWin = new CBattleOptionsWindow(temp_rect, this); @@ -617,7 +618,7 @@ void CBattleInterface::bAutofightf() void CBattleInterface::bSpellf() { CGI->curh->changeGraphic(0,0); - LOCPLINT->curint->deactivate(); + deactivate(); const CGHeroInstance * chi = NULL; if(attackingHeroInstance->tempOwner == LOCPLINT->playerID) @@ -811,9 +812,9 @@ void CBattleInterface::stackMoved(int number, int destHex, bool endMoving) if((animCount+1)%(4/animSpeed)==0) creAnims[number]->incrementFrame(); } + activate(); } creAnims[number]->setType(2); //resetting to default - activate(); CGI->curh->show(); } diff --git a/CPlayerInterface.cpp b/CPlayerInterface.cpp index d4436d050..6ac2f11d5 100644 --- a/CPlayerInterface.cpp +++ b/CPlayerInterface.cpp @@ -1616,7 +1616,8 @@ void CPlayerInterface::handleMouseMotion(SDL_Event *sEvent) } for(int i=0; ihover(true); - for(std::list::iterator i=motioninterested.begin(); i != motioninterested.end();i++) + std::list miCopy = motioninterested; + for(std::list::iterator i=miCopy.begin(); i != miCopy.end();i++) { if ((*i)->strongInterest || isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y)) { @@ -2073,7 +2074,7 @@ void CPlayerInterface::battleResultQuited() void CPlayerInterface::battleStackMoved(int ID, int dest) { boost::unique_lock un(*pim); - dynamic_cast(curint)->stackMoved(ID, dest,dest==curAction->destinationTile); + dynamic_cast(curint)->stackMoved(ID, dest, dest==curAction->destinationTile); } void CPlayerInterface::battleAttack(BattleAttack *ba) { @@ -2081,7 +2082,7 @@ void CPlayerInterface::battleAttack(BattleAttack *ba) if(ba->shot()) dynamic_cast(curint)->stackIsShooting(ba->stackAttacking,cb->battleGetPos(ba->bsa.stackAttacked)); else - dynamic_cast(curint)->stackAttacking( ba->stackAttacking, cb->battleGetPos(ba->bsa.stackAttacked) ); + dynamic_cast(curint)->stackAttacking( ba->stackAttacking, curAction->additionalInfo ); if(ba->killed()) dynamic_cast(curint)->stackKilled(ba->bsa.stackAttacked, ba->bsa.damageAmount, ba->bsa.killedAmount, ba->stackAttacking, ba->shot()); else diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 643119719..237ec84da 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -349,11 +349,11 @@ void CGameHandler::startBattle(CCreatureSet army1, CCreatureSet army2, int3 tile delete battleResult.data; } -void CGameHandler::prepareAttack(BattleAttack &bat, CStack *att, CStack *def, bool shooting) +void CGameHandler::prepareAttack(BattleAttack &bat, CStack *att, CStack *def) { bat.stackAttacking = att->ID; bat.bsa.stackAttacked = def->ID; - bat.bsa.damageAmount = BattleInfo::calculateDmg(att, def, gs->getHero(att->attackerOwned ? gs->curB->hero1 : gs->curB->hero2), gs->getHero(def->attackerOwned ? gs->curB->hero1 : gs->curB->hero2), shooting);//counting dealt damage + bat.bsa.damageAmount = BattleInfo::calculateDmg(att, def, gs->getHero(att->attackerOwned ? gs->curB->hero1 : gs->curB->hero2), gs->getHero(def->attackerOwned ? gs->curB->hero1 : gs->curB->hero2), bat.shot());//counting dealt damage //applying damages bat.bsa.killedAmount = bat.bsa.damageAmount / def->creature->hitPoints; @@ -948,14 +948,14 @@ upgend: return; BattleAttack bat; - prepareAttack(bat,curStack,stackAtEnd,false); + prepareAttack(bat,curStack,stackAtEnd); sendAndApply(&bat); //counterattack if(!vstd::contains(curStack->abilities,NO_ENEMY_RETALIATION) && stackAtEnd->alive() && stackAtEnd->counterAttacks ) //TODO: support for multiple retaliatons per turn { - prepareAttack(bat,stackAtEnd,curStack,false); + prepareAttack(bat,stackAtEnd,curStack); bat.flags |= 2; sendAndApply(&bat); } @@ -965,7 +965,7 @@ upgend: && stackAtEnd->alive() ) { bat.flags = 0; - prepareAttack(bat,curStack,stackAtEnd,false); + prepareAttack(bat,curStack,stackAtEnd); sendAndApply(&bat); } sendDataToClients(ui16(3008)); //end movement and attack @@ -981,13 +981,13 @@ upgend: *destStack= gs->curB->getStackT(ba.destinationTile); BattleAttack bat; - prepareAttack(bat,curStack,destStack,true); + prepareAttack(bat,curStack,destStack); bat.flags |= 1; if(vstd::contains(curStack->abilities,TWICE_ATTACK) && curStack->alive()) { - prepareAttack(bat,curStack,destStack,true); + prepareAttack(bat,curStack,destStack); sendAndApply(&bat); } diff --git a/server/CGameHandler.h b/server/CGameHandler.h index f9e041188..fead03736 100644 --- a/server/CGameHandler.h +++ b/server/CGameHandler.h @@ -57,7 +57,7 @@ class CGameHandler void giveSpells(const CGTownInstance *t, const CGHeroInstance *h); void moveStack(int stack, int dest); void startBattle(CCreatureSet army1, CCreatureSet army2, int3 tile, CGHeroInstance *hero1, CGHeroInstance *hero2, boost::function cb); //use hero=NULL for no hero - void prepareAttack(BattleAttack &bat, CStack *att, CStack *def, bool shooting); //if last parameter is true, attack is by shooting, if false it's a melee attack + void prepareAttack(BattleAttack &bat, CStack *att, CStack *def); //if last parameter is true, attack is by shooting, if false it's a melee attack void checkForBattleEnd( std::vector &stacks ); void setupBattle( BattleInfo * curB, int3 tile, CCreatureSet &army1, CCreatureSet &army2, CGHeroInstance * hero1, CGHeroInstance * hero2 );