Changeset 7f884ea in network-game for common/Game.cpp
- Timestamp:
- Jan 24, 2014, 12:27:15 AM (11 years ago)
- Branches:
- master
- Children:
- f66d04f
- Parents:
- e70b66b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Game.cpp
re70b66b r7f884ea 102 102 } 103 103 104 void Game::addObjectToMap( WorldMap::ObjectType objectType, int x, int y) {104 void Game::addObjectToMap(ObjectType objectType, int x, int y) { 105 105 NETWORK_MSG serverMsg; 106 106 … … 120 120 if (0 <= x && x < this->worldMap->width*25 && 121 121 0 <= y && y < this->worldMap->height*25 && 122 this->worldMap->getElement(x/25, y/25) == WorldMap::TERRAIN_GRASS)122 this->worldMap->getElement(x/25, y/25) == TERRAIN_GRASS) 123 123 { 124 124 p->target.x = x; … … 140 140 switch(this->worldMap->getElement(p->pos.x/25, p->pos.y/25)) 141 141 { 142 case WorldMap::TERRAIN_NONE:143 case WorldMap::TERRAIN_OCEAN:144 case WorldMap::TERRAIN_ROCK:142 case TERRAIN_NONE: 143 case TERRAIN_OCEAN: 144 case TERRAIN_ROCK: 145 145 { 146 146 p->pos = oldPos; … … 167 167 if (posDistance(p->pos, it->pos.toFloat()) < 10) { 168 168 switch (it->type) { 169 case WorldMap::OBJECT_BLUE_FLAG:169 case OBJECT_BLUE_FLAG: 170 170 if (p->team == 1) { 171 171 p->hasBlueFlag = true; … … 173 173 } 174 174 break; 175 case WorldMap::OBJECT_RED_FLAG:175 case OBJECT_RED_FLAG: 176 176 if (p->team == 0) { 177 177 p->hasRedFlag = true; … … 179 179 } 180 180 break; 181 case WorldMap::OBJECT_NONE:181 case OBJECT_NONE: 182 182 break; 183 183 } … … 198 198 if (p->isDead) 199 199 { 200 WorldMap::ObjectType flagType = WorldMap::OBJECT_NONE;200 ObjectType flagType = OBJECT_NONE; 201 201 if (p->hasBlueFlag) 202 flagType = WorldMap::OBJECT_BLUE_FLAG;202 flagType = OBJECT_BLUE_FLAG; 203 203 else if (p->hasRedFlag) 204 flagType = WorldMap::OBJECT_RED_FLAG;205 206 if (flagType != WorldMap::OBJECT_NONE)204 flagType = OBJECT_RED_FLAG; 205 206 if (flagType != OBJECT_NONE) 207 207 this->addObjectToMap(flagType, p->pos.x, p->pos.y); 208 208 } … … 252 252 cout << "player move processed" << endl; 253 253 254 WorldMap::ObjectType flagType;254 ObjectType flagType; 255 255 POSITION pos; 256 256 bool flagTurnedIn = false; … … 260 260 switch(this->worldMap->getStructure(p->pos.x/25, p->pos.y/25)) 261 261 { 262 case WorldMap::STRUCTURE_BLUE_FLAG:262 case STRUCTURE_BLUE_FLAG: 263 263 { 264 264 if (p->team == 0 && p->hasRedFlag) 265 265 { 266 266 // check that your flag is at your base 267 pos = this->worldMap->getStructureLocation( WorldMap::STRUCTURE_BLUE_FLAG);267 pos = this->worldMap->getStructureLocation(STRUCTURE_BLUE_FLAG); 268 268 269 269 vector<WorldMap::Object>* vctObjects = this->worldMap->getObjects(); … … 272 272 for (itObjects = vctObjects->begin(); itObjects != vctObjects->end(); itObjects++) 273 273 { 274 if (itObjects->type == WorldMap::OBJECT_BLUE_FLAG)274 if (itObjects->type == OBJECT_BLUE_FLAG) 275 275 { 276 276 if (itObjects->pos.x == pos.x*25+12 && itObjects->pos.y == pos.y*25+12) … … 285 285 { 286 286 p->hasRedFlag = false; 287 flagType = WorldMap::OBJECT_RED_FLAG;288 pos = this->worldMap->getStructureLocation( WorldMap::STRUCTURE_RED_FLAG);287 flagType = OBJECT_RED_FLAG; 288 pos = this->worldMap->getStructureLocation(STRUCTURE_RED_FLAG); 289 289 flagTurnedIn = true; 290 290 this->blueScore++; … … 294 294 break; 295 295 } 296 case WorldMap::STRUCTURE_RED_FLAG:296 case STRUCTURE_RED_FLAG: 297 297 { 298 298 if (p->team == 1 && p->hasBlueFlag) 299 299 { 300 300 // check that your flag is at your base 301 pos = this->worldMap->getStructureLocation( WorldMap::STRUCTURE_RED_FLAG);301 pos = this->worldMap->getStructureLocation(STRUCTURE_RED_FLAG); 302 302 303 303 vector<WorldMap::Object>* vctObjects = this->worldMap->getObjects(); … … 306 306 for (itObjects = vctObjects->begin(); itObjects != vctObjects->end(); itObjects++) 307 307 { 308 if (itObjects->type == WorldMap::OBJECT_RED_FLAG)308 if (itObjects->type == OBJECT_RED_FLAG) 309 309 { 310 310 if (itObjects->pos.x == pos.x*25+12 && itObjects->pos.y == pos.y*25+12) … … 319 319 { 320 320 p->hasBlueFlag = false; 321 flagType = WorldMap::OBJECT_BLUE_FLAG;322 pos = this->worldMap->getStructureLocation( WorldMap::STRUCTURE_BLUE_FLAG);321 flagType = OBJECT_BLUE_FLAG; 322 pos = this->worldMap->getStructureLocation(STRUCTURE_BLUE_FLAG); 323 323 flagTurnedIn = true; 324 324 this->redScore++; … … 385 385 { 386 386 if (p->team == 0 && 387 itObjects->type == WorldMap::OBJECT_BLUE_FLAG)387 itObjects->type == OBJECT_BLUE_FLAG) 388 388 { 389 structPos = this->worldMap->getStructureLocation( WorldMap::STRUCTURE_BLUE_FLAG);389 structPos = this->worldMap->getStructureLocation(STRUCTURE_BLUE_FLAG); 390 390 flagReturned = true; 391 391 break; 392 392 } 393 393 else if (p->team == 1 && 394 itObjects->type == WorldMap::OBJECT_RED_FLAG)394 itObjects->type == OBJECT_RED_FLAG) 395 395 { 396 structPos = this->worldMap->getStructureLocation( WorldMap::STRUCTURE_RED_FLAG);396 structPos = this->worldMap->getStructureLocation(STRUCTURE_RED_FLAG); 397 397 flagReturned = true; 398 398 break;
Note:
See TracChangeset
for help on using the changeset viewer.