- Timestamp:
- May 25, 2013, 6:49:14 PM (12 years ago)
- Branches:
- master
- Children:
- b8cb03f
- Parents:
- e487381
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/WorldMap.cpp
re487381 r7511a2b 68 68 return vctObjects; 69 69 } 70 70 71 vector<WorldMap::Object> WorldMap::getObjects(int x, int y) { 71 72 vector<WorldMap::Object> vctObjectsInRegion; 72 73 73 74 vector<WorldMap::Object>::iterator it; 74 for (it = vctObjects->begin(); it != vctObjects->end(); it++) {75 for (it = vctObjects->begin(); it != vctObjects->end(); it++) { 75 76 if (it->pos.x/25 == x && it->pos.y/25 == y) 76 77 vctObjectsInRegion.push_back(*it); … … 82 83 // used by the server to create new objects 83 84 void WorldMap::addObject(WorldMap::ObjectType t, int x, int y) { 84 WorldMap::Object o(vctObjects->size(), t, x, y); 85 int id; 86 vector<WorldMap::Object>::iterator it; 87 88 for (id = 0; id < vctObjects->size(); id++) { 89 for (it = vctObjects->begin(); it != vctObjects->end(); it++) { 90 if (id == it->id) 91 break; 92 } 93 94 if (it == vctObjects->end()) // if no objects with this id exists 95 break; 96 } 97 98 WorldMap::Object o(id, t, x, y); 85 99 vctObjects->push_back(o); 86 100 } … … 91 105 bool foundObject = false; 92 106 107 cout << "Searching for obbject to update" << endl; 108 switch (t) { 109 case WorldMap::OBJECT_BLUE_FLAG: 110 cout << "BLUE_FLAG" << endl; 111 break; 112 case WorldMap::OBJECT_RED_FLAG: 113 cout << "RED_FLAG" << endl; 114 break; 115 } 116 93 117 for (it = vctObjects->begin(); it != vctObjects->end(); it++) { 94 118 if (it->id == id) { 95 119 foundObject = true; 120 cout << "Found object with id " << id << endl; 121 switch (it->type) { 122 case WorldMap::OBJECT_BLUE_FLAG: 123 cout << "BLUE_FLAG" << endl; 124 break; 125 case WorldMap::OBJECT_RED_FLAG: 126 cout << "RED_FLAG" << endl; 127 break; 128 } 96 129 it->pos.x = x; 97 130 it->pos.y = y;
Note:
See TracChangeset
for help on using the changeset viewer.