From 35f8a25fc914f10a8e987357bab94584af0992fb Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sat, 11 Aug 2012 16:40:21 +0200 Subject: [PATCH] removed direct access to battle's monsters vector --- src/battle/BattleState.h | 10 +++++----- src/battle/states/PerformAttacks.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index cfec612..f5bf9cb 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -93,8 +93,8 @@ public: Hero &HeroAt(int index) { return heroes[index]; } const Hero &HeroAt(int index) const { return heroes[index]; } - Monster &MonsterAt(std::vector::size_type index) { return monsters[index]; } - const Monster &MonsterAt(std::vector::size_type index) const { return monsters[index]; } + Monster &MonsterAt(int index) { return monsters[index]; } + const Monster &MonsterAt(int index) const { return monsters[index]; } const HeroTag &HeroTagAt(int index) const { return heroTags[index]; } const geometry::Point &HeroTagPositionAt(int index) const { return heroTagPositions[index]; } @@ -105,13 +105,13 @@ public: const AttackChoice &AttackChoiceAt(int index) const { return attackChoices[index]; } bool AttackSelectionDone() const { return activeHero >= numHeroes; } + int NumHeroes() const { return numHeroes; } + int MaxMonsters() const { return monsters.size(); } + const std::vector > &MonsterPositions() const { return monsterPositions; } bool MonsterPositionOccupied(int index) { return index >= 0 && index < int(monsters.size()) && monsters[index].Health() > 0; } const std::vector > &HeroesPositions() const { return heroesPositions; } bool HeroPositionOccupied(int index) { return index >= 0 && index < numHeroes; } - int NumHeroes() const { return numHeroes; } - std::vector &Monsters() { return monsters; } - const std::vector &Monsters() const { return monsters; } void SetRunaway() { ranAway = true; } void ClearAllAttacks(); diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index e5bd7c9..f5a8c87 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -58,10 +58,10 @@ void PerformAttacks::HandleEvents(const Input &input) { if (titleBarText) { titleBarText = 0; ++cursor; - while (cursor < (int)battle->Monsters().size() && !battle->MonsterPositionOccupied(cursor)) { + while (cursor < battle->MaxMonsters() && !battle->MonsterPositionOccupied(cursor)) { ++cursor; } - if (cursor >= (int)battle->Monsters().size()) { + if (cursor >= battle->MaxMonsters()) { battle->ClearAllAttacks(); ctrl->PopState(); } -- 2.39.2