Use deque instead of vector for cPopulation
This means that saved references to elements will be preserved if a new monster is added onto the end. Thanks to @fosnola for noticing that this is an issue.
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#define BOE_DATA_CREATLIST_H
|
#define BOE_DATA_CREATLIST_H
|
||||||
|
|
||||||
#include "scenario/monster.hpp"
|
#include "scenario/monster.hpp"
|
||||||
|
#include <deque>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include "creature.hpp"
|
#include "creature.hpp"
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ namespace legacy {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class cPopulation {
|
class cPopulation {
|
||||||
std::vector<cCreature> dudes;
|
std::deque<cCreature> dudes;
|
||||||
public:
|
public:
|
||||||
short which_town;
|
short which_town;
|
||||||
bool hostile;
|
bool hostile;
|
||||||
@@ -32,8 +33,8 @@ public:
|
|||||||
cCreature& operator[](size_t n);
|
cCreature& operator[](size_t n);
|
||||||
const cCreature& operator[](size_t n) const;
|
const cCreature& operator[](size_t n) const;
|
||||||
cPopulation() : which_town(200), hostile(false) {}
|
cPopulation() : which_town(200), hostile(false) {}
|
||||||
std::vector<cCreature>::iterator begin() {return dudes.begin();}
|
std::deque<cCreature>::iterator begin() {return dudes.begin();}
|
||||||
std::vector<cCreature>::iterator end() {return dudes.end();}
|
std::deque<cCreature>::iterator end() {return dudes.end();}
|
||||||
// Apparently Visual Studio needs this to work
|
// Apparently Visual Studio needs this to work
|
||||||
cPopulation& operator=(const cPopulation& other) = default;
|
cPopulation& operator=(const cPopulation& other) = default;
|
||||||
void swap(cPopulation& other);
|
void swap(cPopulation& other);
|
||||||
|
Reference in New Issue
Block a user