- Timestamp:
- Dec 23, 2013, 5:26:01 PM (11 years ago)
- Branches:
- master
- Children:
- 3b6f46b
- Parents:
- ad1e2fc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
rad1e2fc re5b96e2 230 230 Game* game = NULL; 231 231 WorldMap* gameMap = NULL; 232 233 for (itGames = mapGames.begin(); itGames != mapGames.end(); itGames++) { 232 bool gameFinished; 233 234 for (itGames = mapGames.begin(); itGames != mapGames.end();) { 234 235 game = itGames->second; 235 236 gameMap = game->getMap(); 236 237 map<unsigned int, Player*>& playersInGame = game->getPlayers(); 238 gameFinished = false; 237 239 238 240 for (it = game->getPlayers().begin(); it != game->getPlayers().end(); it++) … … 363 365 } 364 366 365 /* 367 // check to see if the game should end 368 // move to its own method 366 369 if (scoreBlue == 3 || scoreRed == 3) { 367 game Over= true;370 gameFinished = true; 368 371 369 372 unsigned int winningTeam; … … 377 380 memcpy(serverMsg.buffer+4, &scoreBlue, 4); 378 381 memcpy(serverMsg.buffer+8, &scoreRed, 4); 379 380 for (it2 = playersInGame.begin(); it2 != playersInGame.end(); it2++)381 {382 if ( msgProcessor.sendMessage(&serverMsg, sock, &(it2->second->addr), &outputLog) < 0 )383 error("sendMessage");384 }385 386 // send a GAME_INFO message with 0 players to force clients to delete the game387 int numPlayers = 0;388 serverMsg.type = MSG_TYPE_GAME_INFO;389 memcpy(serverMsg.buffer, &numPlayers, 4);390 382 391 383 for (it2 = playersInGame.begin(); it2 != playersInGame.end(); it2++) … … 395 387 } 396 388 } 397 */398 389 399 390 // this means a PLAYER message will be sent … … 539 530 } 540 531 } 532 533 if (gameFinished) { 534 // send a GAME_INFO message with 0 players to force clients to delete the game 535 int numPlayers = 0; 536 serverMsg.type = MSG_TYPE_GAME_INFO; 537 memcpy(serverMsg.buffer, &numPlayers, 4); 538 539 map<unsigned int, Player*>::iterator it2; 540 for (it2 = mapPLayers.begin(); it2 != mapPLayers.end(); it2++) 541 { 542 if ( msgProcessor.sendMessage(&serverMsg, sock, &(it2->second->addr), &outputLog) < 0 ) 543 error("sendMessage"); 544 } 545 546 // erase game from server 547 mapGames.erase(itGames); 548 }else 549 itGames++; 541 550 } 542 551
Note:
See TracChangeset
for help on using the changeset viewer.