From: Daniel Karbach Date: Sun, 3 Feb 2013 14:51:42 +0000 (+0100) Subject: less pointer chasing in battle::PerformAttacks X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=b7b7078d04007d5b86ab160288f88b57d76ea408;p=l2e.git less pointer chasing in battle::PerformAttacks --- diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 2274cfc..960eb6c 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -77,15 +77,16 @@ void PerformAttacks::HandleEvents(const Input &input) { } battle->CalculateDamage(); + const Battle::Order &attack = battle->CurrentAttack(); - if (battle->CurrentAttack().IsMonster()) { - Monster &monster(battle->MonsterAt(battle->CurrentAttack().index)); + if (attack.IsMonster()) { + Monster &monster(battle->MonsterAt(attack.index)); titleBarText = monster.Name(); targetAnimation = AnimationRunner(monster.MeleeAnimation()); moveAnimation = AnimationRunner(monster.AttackAnimation()); monster.SetAnimation(moveAnimation); - AddNumberAnimations(battle->MonsterAt(battle->CurrentAttack().index).GetAttackChoice().Selection()); - } else if (battle->CurrentAttack().IsCapsule()) { + AddNumberAnimations(monster.GetAttackChoice().Selection()); + } else if (attack.IsCapsule()) { Capsule &capsule(battle->GetCapsule()); titleBarText = capsule.Name(); targetAnimation = AnimationRunner(capsule.MeleeAnimation()); @@ -93,8 +94,8 @@ void PerformAttacks::HandleEvents(const Input &input) { capsule.SetAnimation(moveAnimation); AddNumberAnimations(capsule.GetAttackChoice().Selection()); } else { - Hero &hero(battle->HeroAt(battle->CurrentAttack().index)); - const AttackChoice &ac(battle->CurrentAttackAttackChoice()); + Hero &hero(battle->HeroAt(attack.index)); + const AttackChoice &ac(hero.GetAttackChoice()); switch (ac.GetType()) { case AttackChoice::SWORD: @@ -145,10 +146,10 @@ void PerformAttacks::HandleEvents(const Input &input) { } if (moveAnimation.Valid()) { moveAnimation.Start(*this); - if (battle->CurrentAttack().IsMonster()) { - battle->MonsterAt(battle->CurrentAttack().index).SetAnimation(moveAnimation); - } else if (battle->CurrentAttack().IsHero()) { - battle->HeroAt(battle->CurrentAttack().index).SetAnimation(moveAnimation); + if (attack.IsMonster()) { + battle->MonsterAt(attack.index).SetAnimation(moveAnimation); + } else if (attack.IsHero()) { + battle->HeroAt(attack.index).SetAnimation(moveAnimation); } else { battle->GetCapsule().SetAnimation(moveAnimation); }