From: Daniel Karbach Date: Tue, 21 Aug 2012 19:06:29 +0000 (+0200) Subject: added some assertions concerning BattleState::activeHero X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=10f374a7dadbd3f239fc0abc76094e3e45889f95;p=l2e.git added some assertions concerning BattleState::activeHero --- diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index 0143fe0..e9eca69 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -84,10 +84,10 @@ public: AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; } MoveMenu &GetMoveMenu() { return moveMenu; } - graphics::Menu &GetSpellMenu() { return heroes[activeHero].SpellMenu(); } - const graphics::Menu &GetSpellMenu() const { return heroes[activeHero].SpellMenu(); } - graphics::Menu &GetIkariMenu() { return heroes[activeHero].IkariMenu(); } - const graphics::Menu &GetIkariMenu() const { return heroes[activeHero].IkariMenu(); } + graphics::Menu &GetSpellMenu() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].SpellMenu(); } + const graphics::Menu &GetSpellMenu() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].SpellMenu(); } + graphics::Menu &GetIkariMenu() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].IkariMenu(); } + const graphics::Menu &GetIkariMenu() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero].IkariMenu(); } graphics::Menu &GetItemMenu() { return itemMenu; } const graphics::Menu &GetItemMenu() const { return itemMenu; } @@ -95,8 +95,8 @@ public: bool BeforeFirstHero() const { return activeHero < 0; } void PreviousHero(); void SwapHeroes(int lhs, int rhs); - Hero &ActiveHero() { return heroes[activeHero]; } - const Hero &ActiveHero() const { return heroes[activeHero]; } + Hero &ActiveHero() { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero]; } + const Hero &ActiveHero() const { assert(activeHero >= 0 && activeHero < NumHeroes()); return heroes[activeHero]; } Hero &HeroAt(int index) { assert(index >= 0 && index < NumHeroes()); return heroes[index]; } const Hero &HeroAt(int index) const { assert(index >= 0 && index < NumHeroes()); return heroes[index]; }