- Timestamp:
- Dec 30, 2012, 6:33:03 PM (12 years ago)
- Branches:
- master
- Children:
- 3535088
- Parents:
- 092817a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
r092817a r1106210 32 32 bool processMessage(const NETWORK_MSG &clientMsg, const struct sockaddr_in &from, map<unsigned int, Player>& mapPlayers, unsigned int& unusedId, NETWORK_MSG &serverMsg); 33 33 34 void updateUnusedId(unsigned int& id );34 void updateUnusedId(unsigned int& id, map<unsigned int, Player>& mapPlayers); 35 35 36 36 // this should probably go somewhere in the common folder … … 94 94 NETWORK_MSG clientMsg, serverMsg; 95 95 map<unsigned int, Player> mapPlayers; 96 unsigned int unusedId = 0;96 unsigned int unusedId = 1; 97 97 98 98 //SSL_load_error_strings(); … … 212 212 { 213 213 p->setAddr(from); 214 updateUnusedId(unusedId, mapPlayers); 214 215 p->id = unusedId; 215 216 mapPlayers[unusedId] = *p; 216 updateUnusedId(unusedId);217 217 218 218 strcpy(serverMsg.buffer, "Login successful. Enjoy chatting with other players."); … … 288 288 } 289 289 290 void updateUnusedId(unsigned int& id) 291 { 292 id = 5; 293 } 290 void updateUnusedId(unsigned int& id, map<unsigned int, Player>& mapPlayers) 291 { 292 while (mapPlayers.find(id) != mapPlayers.end()) 293 id++; 294 }
Note:
See TracChangeset
for help on using the changeset viewer.