From: Daniel Karbach Date: Tue, 21 Aug 2012 19:02:58 +0000 (+0200) Subject: fixed a bug in BattleState::PreviousHero() X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=68510cd21025741773b6746376a24602be791829;hp=5121f4215d725f492bea084fb94900d7e5972743;p=l2e.git fixed a bug in BattleState::PreviousHero() didn't account for dead heroes; now does --- diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 65bdb91..5012104 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -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]); diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 3561609..0143fe0 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -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]; }