Changeset 0678d60 in network-game
- Timestamp:
- Jan 22, 2014, 1:31:27 AM (11 years ago)
- Branches:
- master
- Children:
- 06fc7f7
- Parents:
- 204edcf
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Game.cpp
r204edcf r0678d60 162 162 vector<WorldMap::Object>* vctObjects = this->worldMap->getObjects(); 163 163 vector<WorldMap::Object>::iterator it; 164 int playerId = -1;164 int itemId = -1; 165 165 166 166 for (it = vctObjects->begin(); it != vctObjects->end(); it++) { … … 170 170 if (p->team == 1) { 171 171 p->hasBlueFlag = true; 172 playerId = it->id;172 itemId = it->id; 173 173 } 174 174 break; … … 176 176 if (p->team == 0) { 177 177 p->hasRedFlag = true; 178 playerId = it->id;178 itemId = it->id; 179 179 } 180 180 break; 181 } 182 183 if (playerId > -1) { 181 case WorldMap::OBJECT_NONE: 182 break; 183 } 184 185 if (itemId > -1) { 184 186 vctObjects->erase(it); 185 return playerId;186 } 187 } 188 } 189 190 return playerId;187 return itemId; 188 } 189 } 190 } 191 192 return itemId; 191 193 } 192 194 … … 214 216 215 217 bool Game::handleGameEvents() { 216 NETWORK_MSG serverMsg;217 218 map<unsigned int, Player*>::iterator it; 218 219 bool gameFinished = false; … … 325 326 } 326 327 328 break; 329 } 330 default: 331 { 327 332 break; 328 333 } -
common/MessageProcessor.cpp
r204edcf r0678d60 42 42 if (ret < 0) 43 43 error("sendMessage"); 44 else 45 44 45 return ret; 46 46 } 47 47 -
common/Player.cpp
r204edcf r0678d60 150 150 cout << "No class" << endl; 151 151 break; 152 dafault:153 cout << "nvalid class" << endl;154 break;155 152 } 156 153 } -
common/WorldMap.cpp
r204edcf r0678d60 45 45 } 46 46 47 void WorldMap::createObjectsFromStructures() { 48 for (int y=0; y<this->height; y++) { 49 for (int x=0; x<this->width; x++) { 50 switch (this->getStructure(x, y)) { 51 case WorldMap::STRUCTURE_BLUE_FLAG: 52 this->addObject(WorldMap::OBJECT_BLUE_FLAG, x*25+12, y*25+12); 53 break; 54 case WorldMap::STRUCTURE_RED_FLAG: 55 this->addObject(WorldMap::OBJECT_RED_FLAG, x*25+12, y*25+12); 56 break; 57 case WorldMap::STRUCTURE_NONE: 58 break; 59 } 60 } 61 } 62 } 63 47 64 WorldMap::TerrainType WorldMap::getElement(int x, int y) 48 65 { … … 71 88 pos.y = 0; 72 89 73 for ( int x=0; x<vctStructures->size(); x++) {74 for ( int y=0; y<(*vctStructures)[x]->size(); y++) {90 for (unsigned int x=0; x<vctStructures->size(); x++) { 91 for (unsigned int y=0; y<(*vctStructures)[x]->size(); y++) { 75 92 if ((*(*vctStructures)[x])[y] == t) { 76 93 pos.x = x; … … 131 148 case WorldMap::OBJECT_RED_FLAG: 132 149 cout << "RED_FLAG" << endl; 150 break; 151 case WorldMap::OBJECT_NONE: 152 cout << "OBJECY_NONE" << endl; 133 153 break; 134 154 } … … 145 165 cout << "RED_FLAG" << endl; 146 166 break; 167 case WorldMap::OBJECT_NONE: 168 cout << "OBJECY_NONE" << endl; 169 break; 147 170 } 148 171 it->pos.x = x; -
common/WorldMap.h
r204edcf r0678d60 54 54 ~WorldMap(); 55 55 56 void createObjectsFromStructures(); 57 56 58 TerrainType getElement(int x, int y); 57 59 void setElement(int x, int y, TerrainType type); -
server/DataAccess.cpp
r204edcf r0678d60 177 177 MYSQL_RES *DataAccess::select(string table, string filter) 178 178 { 179 MYSQL_RES *result;180 179 int query_state; 181 180 ostringstream oss; -
server/server.cpp
r204edcf r0678d60 589 589 // add flag objects to the map 590 590 WorldMap* m = g->getMap(); 591 for (int y=0; y<m->height; y++) { 592 for (int x=0; x<m->width; x++) { 593 switch (m->getStructure(x, y)) { 594 case WorldMap::STRUCTURE_BLUE_FLAG: 595 m->addObject(WorldMap::OBJECT_BLUE_FLAG, x*25+12, y*25+12); 596 break; 597 case WorldMap::STRUCTURE_RED_FLAG: 598 m->addObject(WorldMap::OBJECT_RED_FLAG, x*25+12, y*25+12); 599 break; 600 case WorldMap::STRUCTURE_NONE: 601 break; 602 } 603 } 604 } 591 m->createObjectsFromStructures(); 605 592 606 593 serverMsg.type = MSG_TYPE_JOIN_GAME_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.