From 10f374a7dadbd3f239fc0abc76094e3e45889f95 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 21 Aug 2012 21:06:29 +0200 Subject: [PATCH] added some assertions concerning BattleState::activeHero --- src/battle/BattleState.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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]; } -- 2.39.2