]> git.localhorst.tv Git - l2e.git/commitdiff
less pointer chasing in battle::PerformAttacks
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 3 Feb 2013 14:51:42 +0000 (15:51 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 3 Feb 2013 14:51:42 +0000 (15:51 +0100)
src/battle/states/PerformAttacks.cpp

index 2274cfc10a390a15f3dca0f9f4c3fca936528b85..960eb6cf51fc5a0e8d12672844047f09f650e13b 100644 (file)
@@ -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);
                }