Changeset df74597 in network-game for server/server.cpp
- Timestamp:
- Dec 25, 2013, 4:44:20 PM (11 years ago)
- Branches:
- master
- Children:
- 257de75
- Parents:
- e0fd377
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
re0fd377 rdf74597 216 216 for (itGames = mapGames.begin(); itGames != mapGames.end();) { 217 217 if (handleGameEvents(itGames->second, mapPlayers, msgProcessor)) { 218 delete itGames->second; 218 219 mapGames.erase(itGames++); 219 delete itGames->second;220 220 }else 221 221 itGames++; … … 831 831 NETWORK_MSG serverMsg; 832 832 map<unsigned int, Player*>::iterator it; 833 bool gameFinished = false; 833 834 834 835 for (it = game->getPlayers().begin(); it != game->getPlayers().end(); it++) 835 836 { 836 if (handlePlayerEvents(it->second, game, msgProcessor)) { 837 // send a GAME_INFO message with 0 players to force clients to delete the game 838 int numPlayers = 0; 839 serverMsg.type = MSG_TYPE_GAME_INFO; 840 memcpy(serverMsg.buffer, &numPlayers, 4); 841 broadcastMessage(msgProcessor, serverMsg, mapPlayers); 842 843 return true; 844 }else 845 return false; 846 } 837 gameFinished = gameFinished || 838 handlePlayerEvents(it->second, game, msgProcessor); 839 } 840 841 // set each player's current game to null 842 if (gameFinished) { 843 // send a GAME_INFO message with 0 players to force clients to delete the game 844 int numPlayers = 0; 845 serverMsg.type = MSG_TYPE_GAME_INFO; 846 memcpy(serverMsg.buffer, &numPlayers, 4); 847 broadcastMessage(msgProcessor, serverMsg, mapPlayers); 848 849 for (it = game->getPlayers().begin(); it != game->getPlayers().end(); it++) 850 { 851 it->second->currentGame = NULL; 852 } 853 } 854 855 return gameFinished; 847 856 } 848 857 … … 1097 1106 broadcastMessage(msgProcessor, serverMsg, playersInGame); 1098 1107 } 1108 1109 return gameFinished; 1099 1110 } 1100 1111
Note:
See TracChangeset
for help on using the changeset viewer.