]> git.localhorst.tv Git - l2e.git/commitdiff
removed direct access to battle's monsters vector
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 11 Aug 2012 14:40:21 +0000 (16:40 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 11 Aug 2012 14:40:21 +0000 (16:40 +0200)
src/battle/BattleState.h
src/battle/states/PerformAttacks.cpp

index cfec6129a8cb0f47e81589e689a5182280f6a34e..f5bf9cb1b915ee9e60de2a3516104adac9842052 100644 (file)
@@ -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<Monster>::size_type index) { return monsters[index]; }
-       const Monster &MonsterAt(std::vector<Monster>::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<int> &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<geometry::Point<int> > &MonsterPositions() const { return monsterPositions; }
        bool MonsterPositionOccupied(int index) { return index >= 0 && index < int(monsters.size()) && monsters[index].Health() > 0; }
        const std::vector<geometry::Point<int> > &HeroesPositions() const { return heroesPositions; }
        bool HeroPositionOccupied(int index) { return index >= 0 && index < numHeroes; }
-       int NumHeroes() const { return numHeroes; }
-       std::vector<Monster> &Monsters() { return monsters; }
-       const std::vector<Monster> &Monsters() const { return monsters; }
 
        void SetRunaway() { ranAway = true; }
        void ClearAllAttacks();
index e5bd7c98207da2c9b5bbc76f2a0713e01eca57b4..f5a8c87334af8e064170b6b7771cfb7aca47703e 100644 (file)
@@ -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();
                                }