]> git.localhorst.tv Git - l2e.git/commitdiff
fixed a bug in BattleState::PreviousHero()
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 21 Aug 2012 19:02:58 +0000 (21:02 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 21 Aug 2012 19:02:58 +0000 (21:02 +0200)
didn't account for dead heroes; now does

src/battle/BattleState.cpp
src/battle/BattleState.h

index 65bdb9180b56e86dbff54a64a5f21f356f06f4e7..50121049651fc4b0a4deacb7c40554dcdc21400a 100644 (file)
@@ -59,6 +59,13 @@ void BattleState::NextHero() {
        }
 }
 
+void BattleState::PreviousHero() {
+       --activeHero;
+       while (activeHero >= 0 && heroes[activeHero].Health() == 0) {
+               --activeHero;
+       }
+}
+
 void BattleState::SwapHeroes(int lhs, int rhs) {
        if (lhs < 0 || lhs >= numHeroes || rhs < 0 || rhs >= numHeroes || lhs == rhs) return;
        std::swap(heroes[lhs], heroes[rhs]);
index 3561609e91c105a34413a8b29d042d7d1a0c50ce..0143fe0fac21cefd940e2e9a48fb50dfa7df2321 100644 (file)
@@ -93,7 +93,7 @@ public:
 
        void NextHero();
        bool BeforeFirstHero() const { return activeHero < 0; }
-       void PreviousHero() { --activeHero; }
+       void PreviousHero();
        void SwapHeroes(int lhs, int rhs);
        Hero &ActiveHero() { return heroes[activeHero]; }
        const Hero &ActiveHero() const { return heroes[activeHero]; }