1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-29 21:56:54 +02:00

hopefully fixes . Still too much magic in this code :(

This commit is contained in:
Ivan Savenko 2013-08-09 17:37:41 +00:00
parent 8beee29482
commit 45c2bd7511
5 changed files with 17 additions and 11 deletions

@ -866,8 +866,13 @@ void CPlayerInterface::battleStacksAttacked(const std::vector<BattleStackAttacke
if (defender && !elem.isSecondary()) if (defender && !elem.isSecondary())
battleInt->displayEffect(elem.effect, defender->position); battleInt->displayEffect(elem.effect, defender->position);
} }
bool shooting = (LOCPLINT->curAction ? LOCPLINT->curAction->actionType != Battle::WALK_AND_ATTACK : false); //FIXME: why action is deleted during enchanter cast? //FIXME: why action is deleted during enchanter cast?
StackAttackedInfo to_put = {defender, elem.damageAmount, elem.killedAmount, attacker, shooting, elem.killed(), elem.willRebirth(), elem.cloneKilled()}; bool remoteAttack = false;
if (LOCPLINT->curAction)
remoteAttack |= LOCPLINT->curAction->actionType != Battle::WALK_AND_ATTACK;
StackAttackedInfo to_put = {defender, elem.damageAmount, elem.killedAmount, attacker, remoteAttack, elem.killed(), elem.willRebirth(), elem.cloneKilled()};
arg.push_back(to_put); arg.push_back(to_put);
} }

@ -61,8 +61,6 @@ bool CBattleAnimation::isEarliest(bool perStackConcurrency)
for(auto & elem : owner->pendingAnims) for(auto & elem : owner->pendingAnims)
{ {
if (elem.first == this)
continue;
CBattleStackAnimation * stAnim = dynamic_cast<CBattleStackAnimation *>(elem.first); CBattleStackAnimation * stAnim = dynamic_cast<CBattleStackAnimation *>(elem.first);
CSpellEffectAnimation * sen = dynamic_cast<CSpellEffectAnimation *>(elem.first); CSpellEffectAnimation * sen = dynamic_cast<CSpellEffectAnimation *>(elem.first);
@ -146,7 +144,7 @@ CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attac
CDefenceAnimation::CDefenceAnimation(StackAttackedInfo _attackedInfo, CBattleInterface * _owner) CDefenceAnimation::CDefenceAnimation(StackAttackedInfo _attackedInfo, CBattleInterface * _owner)
: CBattleStackAnimation(_owner, _attackedInfo.defender), : CBattleStackAnimation(_owner, _attackedInfo.defender),
attacker(_attackedInfo.attacker), rangedAttack(_attackedInfo.rangedAttack), attacker(_attackedInfo.attacker), rangedAttack(_attackedInfo.indirectAttack),
killed(_attackedInfo.killed) killed(_attackedInfo.killed)
{} {}
@ -158,8 +156,6 @@ bool CDefenceAnimation::init()
ui32 lowestMoveID = owner->animIDhelper + 5; ui32 lowestMoveID = owner->animIDhelper + 5;
for(auto & elem : owner->pendingAnims) for(auto & elem : owner->pendingAnims)
{ {
if (elem.first == this)
continue;
CDefenceAnimation * defAnim = dynamic_cast<CDefenceAnimation *>(elem.first); CDefenceAnimation * defAnim = dynamic_cast<CDefenceAnimation *>(elem.first);
if(defAnim && defAnim->stack->ID != stack->ID) if(defAnim && defAnim->stack->ID != stack->ID)
@ -169,6 +165,10 @@ bool CDefenceAnimation::init()
if(attAnim && attAnim->stack->ID != stack->ID) if(attAnim && attAnim->stack->ID != stack->ID)
continue; continue;
CSpellEffectAnimation * sen = dynamic_cast<CSpellEffectAnimation *>(elem.first);
if (sen)
continue;
CReverseAnimation * animAsRev = dynamic_cast<CReverseAnimation *>(elem.first); CReverseAnimation * animAsRev = dynamic_cast<CReverseAnimation *>(elem.first);
if(animAsRev) if(animAsRev)

@ -57,7 +57,7 @@ struct StackAttackedInfo
unsigned int dmg; //damage dealt unsigned int dmg; //damage dealt
unsigned int amountKilled; //how many creatures in stack has been killed unsigned int amountKilled; //how many creatures in stack has been killed
const CStack * attacker; //attacking stack const CStack * attacker; //attacking stack
bool rangedAttack; //if true, stack has been attacked by shooting bool indirectAttack; //if true, stack was attacked indirectly - spell or ranged attack
bool killed; //if true, stack has been killed bool killed; //if true, stack has been killed
bool rebirth; //if true, play rebirth animation after all bool rebirth; //if true, play rebirth animation after all
bool cloneKilled; bool cloneKilled;

@ -525,7 +525,8 @@ void CFramerateManager::framerateDelay()
fps = ceil(1000.0 / timeElapsed); fps = ceil(1000.0 / timeElapsed);
//recalculate timeElapsed for external calls via getElapsed() // recalculate timeElapsed for external calls via getElapsed()
timeElapsed = currentTicks - lastticks; // limit it to 1000 ms to avoid breaking animation in case of huge lag (e.g. triggered breakpoint)
timeElapsed = std::min<ui32>(currentTicks - lastticks, 1000);
lastticks = SDL_GetTicks(); lastticks = SDL_GetTicks();
} }

@ -1494,7 +1494,7 @@ struct BattleStackAttacked : public CPackForClient//3005
{ {
return flags & SECONDARY; return flags & SECONDARY;
} }
bool willRebirth() const//if stack was not a primary target (receives no spell effects) bool willRebirth() const//resurrection, e.g. Phoenix
{ {
return flags & REBIRTH; return flags & REBIRTH;
} }