1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

* fix for bug 288 (and maybe other related bugs)

This commit is contained in:
mateuszb 2009-12-20 11:49:43 +00:00
parent d037bec1be
commit 08c7541076
3 changed files with 19 additions and 19 deletions

View File

@ -786,10 +786,10 @@ bool CBattleAttack::checkInitialConditions()
return isEarliest(false); return isEarliest(false);
} }
CBattleAttack::CBattleAttack(CBattleInterface * _owner, int _stackID, int _dest) CBattleAttack::CBattleAttack(CBattleInterface * _owner, int _stackID, int _dest, int _attackedID)
: CBattleStackAnimation(_owner, _stackID), dest(_dest) : CBattleStackAnimation(_owner, _stackID), dest(_dest)
{ {
attackedStack = LOCPLINT->cb->battleGetStackByPos(_dest, false); attackedStack = LOCPLINT->cb->battleGetStackByID(_attackedID, false);
attackingStack = LOCPLINT->cb->battleGetStackByID(_stackID, false); attackingStack = LOCPLINT->cb->battleGetStackByID(_stackID, false);
assert(attackingStack && "attackingStack is NULL in CBattleAttack::CBattleAttack !\n"); assert(attackingStack && "attackingStack is NULL in CBattleAttack::CBattleAttack !\n");
@ -893,8 +893,8 @@ void CMeleeAttack::endAnim()
delete this; delete this;
} }
CMeleeAttack::CMeleeAttack(CBattleInterface * _owner, int attacker, int _dest) CMeleeAttack::CMeleeAttack(CBattleInterface * _owner, int attacker, int _dest, int _attackedID)
: CBattleAttack(_owner, attacker, _dest) : CBattleAttack(_owner, attacker, _dest, _attackedID)
{ {
} }
@ -1014,8 +1014,8 @@ void CShootingAnim::endAnim()
delete this; delete this;
} }
CShootingAnim::CShootingAnim(CBattleInterface * _owner, int attacker, int _dest, bool _catapult, int _catapultDmg) CShootingAnim::CShootingAnim(CBattleInterface * _owner, int attacker, int _dest, int _attackedID, bool _catapult, int _catapultDmg)
: CBattleAttack(_owner, attacker, _dest), catapultDamage(_catapultDmg), catapult(_catapult) : CBattleAttack(_owner, attacker, _dest, _attackedID), catapultDamage(_catapultDmg), catapult(_catapult)
{ {
if(catapult) //catapult attack if(catapult) //catapult attack
{ {
@ -2168,9 +2168,9 @@ void CBattleInterface::stacksAreAttacked(std::vector<SStackAttackedInfo> attacke
} }
} }
void CBattleInterface::stackAttacking(int ID, int dest) void CBattleInterface::stackAttacking(int ID, int dest, int attackedID)
{ {
addNewAnim(new CMeleeAttack(this, ID, dest)); addNewAnim(new CMeleeAttack(this, ID, dest, attackedID));
} }
void CBattleInterface::newRound(int number) void CBattleInterface::newRound(int number)
@ -2489,16 +2489,16 @@ void CBattleInterface::hexLclicked(int whichOne)
} }
} }
void CBattleInterface::stackIsShooting(int ID, int dest) void CBattleInterface::stackIsShooting(int ID, int dest, int attackedID)
{ {
addNewAnim(new CShootingAnim(this, ID, dest)); addNewAnim(new CShootingAnim(this, ID, dest, attackedID));
} }
void CBattleInterface::stackIsCatapulting(const CatapultAttack & ca) void CBattleInterface::stackIsCatapulting(const CatapultAttack & ca)
{ {
for(std::set< std::pair< std::pair< ui8, si16 >, ui8> >::const_iterator it = ca.attackedParts.begin(); it != ca.attackedParts.end(); ++it) for(std::set< std::pair< std::pair< ui8, si16 >, ui8> >::const_iterator it = ca.attackedParts.begin(); it != ca.attackedParts.end(); ++it)
{ {
addNewAnim(new CShootingAnim(this, ca.attacker, it->first.second, true, it->second)); addNewAnim(new CShootingAnim(this, ca.attacker, it->first.second, -1, true, it->second));
SDL_FreeSurface(siegeH->walls[it->first.first + 2]); SDL_FreeSurface(siegeH->walls[it->first.first + 2]);
siegeH->walls[it->first.first + 2] = BitmapHandler::loadBitmap( siegeH->walls[it->first.first + 2] = BitmapHandler::loadBitmap(

View File

@ -188,7 +188,7 @@ public:
bool checkInitialConditions(); bool checkInitialConditions();
CBattleAttack(CBattleInterface * _owner, int _stackID, int _dest); CBattleAttack(CBattleInterface * _owner, int _stackID, int _dest, int _attackedID);
}; };
class CMeleeAttack : public CBattleAttack class CMeleeAttack : public CBattleAttack
@ -198,7 +198,7 @@ public:
void nextFrame(); void nextFrame();
void endAnim(); void endAnim();
CMeleeAttack(CBattleInterface * _owner, int attacker, int _dest); CMeleeAttack(CBattleInterface * _owner, int attacker, int _dest, int _attackedID);
}; };
class CShootingAnim : public CBattleAttack class CShootingAnim : public CBattleAttack
@ -211,7 +211,7 @@ public:
void nextFrame(); void nextFrame();
void endAnim(); void endAnim();
CShootingAnim(CBattleInterface * _owner, int attacker, int _dest, bool _catapult = false, int _catapultDmg = 0); //last param only for catapult attacks CShootingAnim(CBattleInterface * _owner, int attacker, int _dest, int _attackedID, bool _catapult = false, int _catapultDmg = 0); //last param only for catapult attacks
}; };
//end of battle animation handlers //end of battle animation handlers
@ -475,10 +475,10 @@ public:
void stackActivated(int number); //active stack has been changed void stackActivated(int number); //active stack has been changed
void stackMoved(int number, int destHex, bool endMoving, int distance); //stack with id number moved to destHex void stackMoved(int number, int destHex, bool endMoving, int distance); //stack with id number moved to destHex
void stacksAreAttacked(std::vector<SStackAttackedInfo> attackedInfos); //called when a certain amount of stacks has been attacked void stacksAreAttacked(std::vector<SStackAttackedInfo> attackedInfos); //called when a certain amount of stacks has been attacked
void stackAttacking(int ID, int dest); //called when stack with id ID is attacking something on hex dest void stackAttacking(int ID, int dest, int attackedID); //called when stack with id ID is attacking something on hex dest
void newRound(int number); //caled when round is ended; number is the number of round void newRound(int number); //caled when round is ended; number is the number of round
void hexLclicked(int whichOne); //hex only call-in void hexLclicked(int whichOne); //hex only call-in
void stackIsShooting(int ID, int dest); //called when stack with id ID is shooting to hex dest void stackIsShooting(int ID, int dest, int attackedID); //called when stack with id ID is shooting to hex dest
void stackIsCatapulting(const CatapultAttack & ca); //called when a stack is attacking walls void stackIsCatapulting(const CatapultAttack & ca); //called when a stack is attacking walls
void battleFinished(const BattleResult& br); //called when battle is finished - battleresult window should be printed void battleFinished(const BattleResult& br); //called when battle is finished - battleresult window should be printed
const BattleResult * bresult; //result of a battle; if non-zero then display when all animations end const BattleResult * bresult; //result of a battle; if non-zero then display when all animations end

View File

@ -1146,10 +1146,10 @@ void CPlayerInterface::battleAttack(BattleAttack *ba)
if(ba->shot()) if(ba->shot())
{ {
for(std::set<BattleStackAttacked>::iterator i = ba->bsa.begin(); i != ba->bsa.end(); i++) for(std::set<BattleStackAttacked>::iterator i = ba->bsa.begin(); i != ba->bsa.end(); i++)
battleInt->stackIsShooting(ba->stackAttacking,cb->battleGetPos(i->stackAttacked)); battleInt->stackIsShooting(ba->stackAttacking,cb->battleGetPos(i->stackAttacked), i->stackAttacked);
} }
else else
{ {//WARNING: does not support multiple attacked creatures
const CStack * attacker = cb->battleGetStackByID(ba->stackAttacking); const CStack * attacker = cb->battleGetStackByID(ba->stackAttacking);
int shift = 0; int shift = 0;
if(ba->counter() && BattleInfo::mutualPosition(curAction->destinationTile, attacker->position) < 0) if(ba->counter() && BattleInfo::mutualPosition(curAction->destinationTile, attacker->position) < 0)
@ -1159,7 +1159,7 @@ void CPlayerInterface::battleAttack(BattleAttack *ba)
else else
shift = -1; shift = -1;
} }
battleInt->stackAttacking( ba->stackAttacking, ba->counter() ? curAction->destinationTile + shift : curAction->additionalInfo ); battleInt->stackAttacking( ba->stackAttacking, ba->counter() ? curAction->destinationTile + shift : curAction->additionalInfo, ba->bsa.begin()->stackAttacked );
} }
} }