diff options
-rw-r--r-- | inc/creature.hpp | 4 | ||||
-rw-r--r-- | inc/list.hpp | 3 | ||||
-rw-r--r-- | inc/quadtree.hpp | 5 | ||||
-rw-r--r-- | src/list.cpp | 6 | ||||
-rw-r--r-- | src/quadtree.cpp | 10 |
5 files changed, 13 insertions, 15 deletions
diff --git a/inc/creature.hpp b/inc/creature.hpp index f9cb979..8174cf6 100644 --- a/inc/creature.hpp +++ b/inc/creature.hpp @@ -1,9 +1,7 @@ #ifndef creature_h #define creature_h -#include <cstdlib> #include <vector> -#include <list> #include <algorithm> #include "entity.hpp" @@ -21,7 +19,7 @@ class Creature: public Entity void checkTarget(); void moveTowards(Rectangle r); void impregnate(DNA d); - void giveNearMe(std::list<Entity*> n){nearMe = {std::begin(n),std::end(n)};}; + void giveNearMe(std::vector<Entity*> n){nearMe = n;}; DNA getDNA(){return myDNA;}; DNA getChildsDNA(){return childsDNA;}; diff --git a/inc/list.hpp b/inc/list.hpp index 872d5fa..f62112c 100644 --- a/inc/list.hpp +++ b/inc/list.hpp @@ -17,7 +17,8 @@ class List void Place(); void Remove(); - std::list<Entity*> getNear(Creature c); + std::vector<Entity*> getNear(Creature c); + std::list<Resource> resources; std::list<Creature> creatures; diff --git a/inc/quadtree.hpp b/inc/quadtree.hpp index 2b07103..bf308f8 100644 --- a/inc/quadtree.hpp +++ b/inc/quadtree.hpp @@ -1,7 +1,6 @@ #ifndef quadtree_h
#define quadtree_h
-#include <list>
#include <vector>
#include "constants.hpp"
@@ -21,8 +20,8 @@ class Quadtree { void clear();
void insert(Entity* iter);
- std::list<Entity*> retrieve(std::list<Entity*> returnObject, GraphicsData obj);
- std::list<Entity*> objects;
+ std::vector<Entity*> retrieve(std::vector<Entity*> returnObject, GraphicsData obj);
+ std::vector<Entity*> objects;
Quadtree* nodes;
diff --git a/src/list.cpp b/src/list.cpp index 2daed25..ca69a4d 100644 --- a/src/list.cpp +++ b/src/list.cpp @@ -36,7 +36,7 @@ void List::Remove() void List::Behavior() { for(std::list<Creature>::iterator it = creatures.begin(); it!= creatures.end(); it++){ - std::list<Entity*> N = getNear(*it); + std::vector<Entity*> N = getNear(*it); it->giveNearMe(N); it->Behavior(); @@ -74,9 +74,9 @@ void List::Place() } } -std::list<Entity*> List::getNear(Creature nC) +std::vector<Entity*> List::getNear(Creature nC) { - std::list<Entity*> N; + std::vector<Entity*> N; N = tree.retrieve(N, nC.getGFXD()); return N; diff --git a/src/quadtree.cpp b/src/quadtree.cpp index 54a16c6..909c875 100644 --- a/src/quadtree.cpp +++ b/src/quadtree.cpp @@ -92,7 +92,7 @@ void Quadtree::insert(Entity* iter){ split();
int index;
- for(std::list <Entity*>::iterator it = objects.begin(); it!=objects.end();it++){
+ for(std::vector<Entity*>::iterator it = objects.begin(); it!=objects.end();it++){
index = getIndex((*it)->getGFXD());
if (index != -1) {
nodes[index].insert(*it);
@@ -104,8 +104,8 @@ void Quadtree::insert(Entity* iter){ std::vector<GraphicsData> Quadtree::Draw(){
std::vector<GraphicsData> retdat;
-
- for (int i = 0; i < 4; i++) {
+ int i;
+ for (i = 0; i < 4; i++) {
if (!nodes[i].isNull) {
std::vector<GraphicsData> temp = nodes[i].Draw();
retdat.insert(retdat.end(), temp.begin(), temp.end());
@@ -126,12 +126,12 @@ std::vector<GraphicsData> Quadtree::Draw(){ return retdat;
}
-std::list<Entity*> Quadtree::retrieve(std::list<Entity*> returnObjects, GraphicsData obj) {
+std::vector<Entity*> Quadtree::retrieve(std::vector<Entity*> returnObjects, GraphicsData obj) {
int index = getIndex(obj);
if (index != -1 && !nodes[0].isNull)
returnObjects = nodes[index].retrieve(returnObjects, obj);
- for(std::list <Entity*>::iterator it = objects.begin(); it!=objects.end(); it++)
+ for(std::vector<Entity*>::iterator it = objects.begin(); it!=objects.end(); it++)
returnObjects.emplace_back(*it);
return returnObjects;
|