diff options
author | majortom6 <tombarrett@siu.edu> | 2017-02-26 07:39:15 -0600 |
---|---|---|
committer | Tom Barrett <tombarrett@siu.edu> | 2017-03-07 13:23:42 -0600 |
commit | 2e4d19ba21347cc370d1aae7a57298328b94ca4e (patch) | |
tree | 715f970ec2aa97eeb42a1144a3361df15b599df7 /src | |
parent | 72b40aec2addc7b28170ba9364bc0429149b3299 (diff) |
-comepletly removed use of lists in quadtree and creature, using vectors now
Diffstat (limited to 'src')
-rw-r--r-- | src/list.cpp | 6 | ||||
-rw-r--r-- | src/quadtree.cpp | 10 |
2 files changed, 8 insertions, 8 deletions
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;
|