[2488852] | 1 | #include <cstdlib>
|
---|
[371ce29] | 2 | #include <cstdio>
|
---|
[e3535b3] | 3 | #include <unistd.h>
|
---|
[2488852] | 4 | #include <string>
|
---|
[e3535b3] | 5 | #include <iostream>
|
---|
[3b1efcc] | 6 | #include <sstream>
|
---|
[edfd1d0] | 7 | #include <cstring>
|
---|
[60017fc] | 8 | #include <cmath>
|
---|
[371ce29] | 9 |
|
---|
[01d0d00] | 10 | #include <vector>
|
---|
| 11 | #include <map>
|
---|
| 12 |
|
---|
[d211210] | 13 | #include <sys/time.h>
|
---|
| 14 |
|
---|
[73f75c1] | 15 | #include <sys/socket.h>
|
---|
[371ce29] | 16 | #include <netdb.h>
|
---|
[73f75c1] | 17 | #include <netinet/in.h>
|
---|
| 18 | #include <arpa/inet.h>
|
---|
| 19 |
|
---|
[b128109] | 20 | #include <crypt.h>
|
---|
| 21 |
|
---|
[edfd1d0] | 22 | /*
|
---|
[e3535b3] | 23 | #include <openssl/bio.h>
|
---|
| 24 | #include <openssl/ssl.h>
|
---|
| 25 | #include <openssl/err.h>
|
---|
[edfd1d0] | 26 | */
|
---|
[e3535b3] | 27 |
|
---|
[b53c6b3] | 28 | #include "../common/Compiler.h"
|
---|
[3b1efcc] | 29 | #include "../common/Common.h"
|
---|
[edfd1d0] | 30 | #include "../common/Message.h"
|
---|
[60017fc] | 31 | #include "../common/WorldMap.h"
|
---|
[edfd1d0] | 32 | #include "../common/Player.h"
|
---|
[b53c6b3] | 33 |
|
---|
[36082e8] | 34 | #include "DataAccess.h"
|
---|
[d2b411a] | 35 |
|
---|
[e3535b3] | 36 | using namespace std;
|
---|
| 37 |
|
---|
[d211210] | 38 | // from used to be const. Removed that so I could take a reference
|
---|
| 39 | // and use it to send messages
|
---|
| 40 | bool processMessage(const NETWORK_MSG &clientMsg, struct sockaddr_in &from, map<unsigned int, Player>& mapPlayers, WorldMap* gameMap, unsigned int& unusedId, NETWORK_MSG &serverMsg, int sock);
|
---|
[01d0d00] | 41 |
|
---|
[1106210] | 42 | void updateUnusedId(unsigned int& id, map<unsigned int, Player>& mapPlayers);
|
---|
[8e540f4] | 43 |
|
---|
[73f75c1] | 44 | // this should probably go somewhere in the common folder
|
---|
[e3535b3] | 45 | void error(const char *msg)
|
---|
| 46 | {
|
---|
| 47 | perror(msg);
|
---|
| 48 | exit(0);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
[01d0d00] | 51 | Player *findPlayerByName(map<unsigned int, Player> &m, string name)
|
---|
[2488852] | 52 | {
|
---|
[01d0d00] | 53 | map<unsigned int, Player>::iterator it;
|
---|
[2488852] | 54 |
|
---|
[01d0d00] | 55 | for (it = m.begin(); it != m.end(); it++)
|
---|
[2488852] | 56 | {
|
---|
[01d0d00] | 57 | if ( it->second.name.compare(name) == 0 )
|
---|
| 58 | return &(it->second);
|
---|
[2488852] | 59 | }
|
---|
| 60 |
|
---|
| 61 | return NULL;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
[01d0d00] | 64 | Player *findPlayerByAddr(map<unsigned int, Player> &m, const sockaddr_in &addr)
|
---|
[73f75c1] | 65 | {
|
---|
[01d0d00] | 66 | map<unsigned int, Player>::iterator it;
|
---|
[73f75c1] | 67 |
|
---|
[01d0d00] | 68 | for (it = m.begin(); it != m.end(); it++)
|
---|
[73f75c1] | 69 | {
|
---|
[01d0d00] | 70 | if ( it->second.addr.sin_addr.s_addr == addr.sin_addr.s_addr &&
|
---|
| 71 | it->second.addr.sin_port == addr.sin_port )
|
---|
| 72 | return &(it->second);
|
---|
[73f75c1] | 73 | }
|
---|
| 74 |
|
---|
| 75 | return NULL;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
[01d0d00] | 78 | void broadcastPlayerPositions(map<unsigned int, Player> &m, int sock)
|
---|
[edfd1d0] | 79 | {
|
---|
[01d0d00] | 80 | map<unsigned int, Player>::iterator it, it2;
|
---|
[edfd1d0] | 81 | NETWORK_MSG serverMsg;
|
---|
| 82 |
|
---|
| 83 | serverMsg.type = MSG_TYPE_PLAYER;
|
---|
| 84 |
|
---|
[01d0d00] | 85 | for (it = m.begin(); it != m.end(); it++)
|
---|
[edfd1d0] | 86 | {
|
---|
[01d0d00] | 87 | it->second.serialize(serverMsg.buffer);
|
---|
[edfd1d0] | 88 |
|
---|
[01d0d00] | 89 | for (it2 = m.begin(); it2 != m.end(); it2++)
|
---|
[edfd1d0] | 90 | {
|
---|
[01d0d00] | 91 | if ( sendMessage(&serverMsg, sock, &(it2->second.addr)) < 0 )
|
---|
[edfd1d0] | 92 | error("sendMessage");
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
| 95 | }
|
---|
| 96 |
|
---|
[e3535b3] | 97 | int main(int argc, char *argv[])
|
---|
| 98 | {
|
---|
| 99 | int sock, length, n;
|
---|
| 100 | struct sockaddr_in server;
|
---|
[3b1efcc] | 101 | struct sockaddr_in from; // info of client sending the message
|
---|
[e084950] | 102 | NETWORK_MSG clientMsg, serverMsg;
|
---|
[01d0d00] | 103 | map<unsigned int, Player> mapPlayers;
|
---|
[1106210] | 104 | unsigned int unusedId = 1;
|
---|
[e084950] | 105 |
|
---|
[edfd1d0] | 106 | //SSL_load_error_strings();
|
---|
| 107 | //ERR_load_BIO_strings();
|
---|
| 108 | //OpenSSL_add_all_algorithms();
|
---|
[e3535b3] | 109 |
|
---|
| 110 | if (argc < 2) {
|
---|
[73f75c1] | 111 | cerr << "ERROR, no port provided" << endl;
|
---|
| 112 | exit(1);
|
---|
[e3535b3] | 113 | }
|
---|
[60017fc] | 114 |
|
---|
[7b43385] | 115 | WorldMap* gameMap = WorldMap::loadMapFromFile("../data/map.txt");
|
---|
[41ad8ed] | 116 |
|
---|
[371ce29] | 117 | sock = socket(AF_INET, SOCK_DGRAM, 0);
|
---|
[e3535b3] | 118 | if (sock < 0) error("Opening socket");
|
---|
| 119 | length = sizeof(server);
|
---|
| 120 | bzero(&server,length);
|
---|
| 121 | server.sin_family=AF_INET;
|
---|
| 122 | server.sin_port=htons(atoi(argv[1]));
|
---|
[2488852] | 123 | server.sin_addr.s_addr=INADDR_ANY;
|
---|
| 124 | if ( bind(sock, (struct sockaddr *)&server, length) < 0 )
|
---|
[e084950] | 125 | error("binding");
|
---|
[73f75c1] | 126 |
|
---|
[371ce29] | 127 | set_nonblock(sock);
|
---|
| 128 |
|
---|
[da692b9] | 129 | bool broadcastResponse;
|
---|
[d211210] | 130 | timespec ts;
|
---|
| 131 | long timeLastUpdated = 0, curTime = 0;
|
---|
[cb1f288] | 132 | while (true) {
|
---|
[371ce29] | 133 |
|
---|
| 134 | usleep(5000);
|
---|
| 135 |
|
---|
[d211210] | 136 | clock_gettime(CLOCK_REALTIME, &ts);
|
---|
| 137 | curTime = ts.tv_sec + ts.tv_nsec*1000000000;
|
---|
| 138 |
|
---|
| 139 | if (timeLastUpdated == 0 || (curTime-timeLastUpdated) >= 50000) {
|
---|
| 140 | timeLastUpdated = curTime;
|
---|
| 141 |
|
---|
| 142 | // maybe put this in a separate method
|
---|
| 143 | map<unsigned int, Player>::iterator it, it2;
|
---|
| 144 | for (it = mapPlayers.begin(); it != mapPlayers.end(); it++) {
|
---|
| 145 | if (!it->second.move(gameMap)) {
|
---|
| 146 | cout << "Cenceling move" << endl;
|
---|
| 147 | //serverMsg.type = MSG_TYPE_PLAYER;
|
---|
| 148 | //it->second.serialize(serverMsg.buffer);
|
---|
| 149 |
|
---|
| 150 | cout << "about to send move cencellation" << endl;
|
---|
| 151 | for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++)
|
---|
| 152 | {
|
---|
| 153 | //if ( sendMessage(&serverMsg, sock, &(it2->second.addr)) < 0 )
|
---|
| 154 | // error("sendMessage");
|
---|
| 155 | }
|
---|
| 156 | }
|
---|
| 157 | }
|
---|
| 158 | }
|
---|
| 159 |
|
---|
[e084950] | 160 | n = receiveMessage(&clientMsg, sock, &from);
|
---|
[8e540f4] | 161 |
|
---|
[371ce29] | 162 | if (n >= 0) {
|
---|
| 163 | cout << "Got a message" << endl;
|
---|
[8e540f4] | 164 |
|
---|
[d211210] | 165 | broadcastResponse = processMessage(clientMsg, from, mapPlayers, gameMap, unusedId, serverMsg, sock);
|
---|
[371ce29] | 166 |
|
---|
[b128109] | 167 | // probably replace this with a function that prints based on the
|
---|
| 168 | // message type
|
---|
[371ce29] | 169 | cout << "msg: " << serverMsg.buffer << endl;
|
---|
[b128109] | 170 | cout << "broadcastResponse: " << broadcastResponse << endl;
|
---|
[da692b9] | 171 | if (broadcastResponse)
|
---|
[3b1efcc] | 172 | {
|
---|
[da692b9] | 173 | cout << "Should be broadcasting the message" << endl;
|
---|
| 174 |
|
---|
[01d0d00] | 175 | map<unsigned int, Player>::iterator it;
|
---|
| 176 | for (it = mapPlayers.begin(); it != mapPlayers.end(); it++)
|
---|
[3b1efcc] | 177 | {
|
---|
[d211210] | 178 | cout << "Sent message back to " << it->second.name << endl;
|
---|
[01d0d00] | 179 | if ( sendMessage(&serverMsg, sock, &(it->second.addr)) < 0 )
|
---|
[3b1efcc] | 180 | error("sendMessage");
|
---|
| 181 | }
|
---|
| 182 | }
|
---|
| 183 | else
|
---|
| 184 | {
|
---|
[da692b9] | 185 | cout << "Should be sending back the message" << endl;
|
---|
| 186 |
|
---|
[3b1efcc] | 187 | if ( sendMessage(&serverMsg, sock, &from) < 0 )
|
---|
| 188 | error("sendMessage");
|
---|
| 189 | }
|
---|
[7b43385] | 190 | }
|
---|
[8e540f4] | 191 |
|
---|
[d211210] | 192 | // we don't want to update and broadcast player positions here
|
---|
| 193 | // when a player sends a position update, we want to check if
|
---|
| 194 | // it's reasonable and send it out to all other players
|
---|
| 195 |
|
---|
[7b43385] | 196 | // update player positions
|
---|
| 197 | map<unsigned int, Player>::iterator it;
|
---|
| 198 | for (it = mapPlayers.begin(); it != mapPlayers.end(); it++)
|
---|
| 199 | {
|
---|
[876add0] | 200 | it->second.move(gameMap);
|
---|
[edfd1d0] | 201 | }
|
---|
[7b43385] | 202 |
|
---|
| 203 | broadcastPlayerPositions(mapPlayers, sock);
|
---|
[8e540f4] | 204 | }
|
---|
[371ce29] | 205 |
|
---|
[8e540f4] | 206 | return 0;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
[d211210] | 209 | bool processMessage(const NETWORK_MSG& clientMsg, struct sockaddr_in& from, map<unsigned int, Player>& mapPlayers, WorldMap* gameMap, unsigned int& unusedId, NETWORK_MSG& serverMsg, int sock)
|
---|
[8e540f4] | 210 | {
|
---|
[41ad8ed] | 211 | DataAccess da;
|
---|
| 212 |
|
---|
[8e540f4] | 213 | cout << "MSG: type: " << clientMsg.type << endl;
|
---|
| 214 | cout << "MSG contents: " << clientMsg.buffer << endl;
|
---|
| 215 |
|
---|
[da692b9] | 216 | // maybe we should make a message class and have this be a member
|
---|
[3b1efcc] | 217 | bool broadcastResponse = false;
|
---|
| 218 |
|
---|
[8e540f4] | 219 | // Check that if an invalid message is sent, the client will correctly
|
---|
| 220 | // receive and display the response. Maybe make a special error msg type
|
---|
| 221 | switch(clientMsg.type)
|
---|
| 222 | {
|
---|
| 223 | case MSG_TYPE_REGISTER:
|
---|
[d2b411a] | 224 | {
|
---|
[8e540f4] | 225 | string username(clientMsg.buffer);
|
---|
| 226 | string password(strchr(clientMsg.buffer, '\0')+1);
|
---|
[d2b411a] | 227 |
|
---|
[8e540f4] | 228 | cout << "username: " << username << endl;
|
---|
| 229 | cout << "password: " << password << endl;
|
---|
[d2b411a] | 230 |
|
---|
[3b1efcc] | 231 | int error = da.insertPlayer(username, password);
|
---|
[41ad8ed] | 232 |
|
---|
[3b1efcc] | 233 | if (!error)
|
---|
| 234 | strcpy(serverMsg.buffer, "Registration successful.");
|
---|
| 235 | else
|
---|
| 236 | strcpy(serverMsg.buffer, "Registration failed. Please try again.");
|
---|
[8e540f4] | 237 |
|
---|
| 238 | serverMsg.type = MSG_TYPE_REGISTER;
|
---|
[d2b411a] | 239 |
|
---|
[8e540f4] | 240 | break;
|
---|
| 241 | }
|
---|
| 242 | case MSG_TYPE_LOGIN:
|
---|
| 243 | {
|
---|
[60017fc] | 244 | cout << "Got login message" << endl;
|
---|
| 245 |
|
---|
[d211210] | 246 | serverMsg.type = MSG_TYPE_LOGIN;
|
---|
| 247 |
|
---|
[8e540f4] | 248 | string username(clientMsg.buffer);
|
---|
[41ad8ed] | 249 | string password(strchr(clientMsg.buffer, '\0')+1);
|
---|
[8e540f4] | 250 |
|
---|
[41ad8ed] | 251 | Player* p = da.getPlayer(username);
|
---|
[d2b411a] | 252 |
|
---|
[b128109] | 253 | if (p == NULL || !da.verifyPassword(password, p->password))
|
---|
[41ad8ed] | 254 | {
|
---|
| 255 | strcpy(serverMsg.buffer, "Incorrect username or password");
|
---|
| 256 | }
|
---|
[01d0d00] | 257 | else if(findPlayerByName(mapPlayers, username) != NULL)
|
---|
[41ad8ed] | 258 | {
|
---|
| 259 | strcpy(serverMsg.buffer, "Player has already logged in.");
|
---|
| 260 | }
|
---|
| 261 | else
|
---|
[8e540f4] | 262 | {
|
---|
[d211210] | 263 | serverMsg.type = MSG_TYPE_PLAYER;
|
---|
| 264 |
|
---|
[01d0d00] | 265 | p->setAddr(from);
|
---|
[1106210] | 266 | updateUnusedId(unusedId, mapPlayers);
|
---|
[01d0d00] | 267 | p->id = unusedId;
|
---|
[d211210] | 268 | cout << "new player id: " << p->id << endl;
|
---|
| 269 |
|
---|
| 270 | // tell the new player about all the existing players
|
---|
| 271 | cout << "Sending other players to new player" << endl;
|
---|
| 272 |
|
---|
| 273 | map<unsigned int, Player>::iterator it;
|
---|
| 274 | for (it = mapPlayers.begin(); it != mapPlayers.end(); it++)
|
---|
| 275 | {
|
---|
| 276 | it->second.serialize(serverMsg.buffer);
|
---|
| 277 |
|
---|
| 278 | cout << "sending info about " << it->second.name << endl;
|
---|
| 279 | cout << "sending ind " << it->second.id << endl;
|
---|
| 280 | if ( sendMessage(&serverMsg, sock, &from) < 0 )
|
---|
| 281 | error("sendMessage");
|
---|
| 282 | }
|
---|
[59061f6] | 283 |
|
---|
[594d2e9] | 284 | p->serialize(serverMsg.buffer);
|
---|
[d211210] | 285 | cout << "Should be broadcasting the message" << endl;
|
---|
| 286 |
|
---|
| 287 | for (it = mapPlayers.begin(); it != mapPlayers.end(); it++)
|
---|
| 288 | {
|
---|
| 289 | cout << "Sent message back to " << it->second.name << endl;
|
---|
| 290 | if ( sendMessage(&serverMsg, sock, &(it->second.addr)) < 0 )
|
---|
| 291 | error("sendMessage");
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 | serverMsg.type = MSG_TYPE_LOGIN;
|
---|
| 295 | mapPlayers[unusedId] = *p;
|
---|
[07028b9] | 296 | }
|
---|
| 297 |
|
---|
[41ad8ed] | 298 | delete(p);
|
---|
[07028b9] | 299 |
|
---|
[8e540f4] | 300 | break;
|
---|
| 301 | }
|
---|
| 302 | case MSG_TYPE_LOGOUT:
|
---|
| 303 | {
|
---|
| 304 | string name(clientMsg.buffer);
|
---|
| 305 | cout << "Player logging out: " << name << endl;
|
---|
| 306 |
|
---|
[01d0d00] | 307 | Player *p = findPlayerByName(mapPlayers, name);
|
---|
[633f42a] | 308 |
|
---|
[8e540f4] | 309 | if (p == NULL)
|
---|
| 310 | {
|
---|
| 311 | strcpy(serverMsg.buffer, "That player is not logged in. This is either a bug, or you're trying to hack the server.");
|
---|
[8a3ef42] | 312 | cout << "Player not logged in" << endl;
|
---|
[07028b9] | 313 | }
|
---|
[01d0d00] | 314 | else if ( p->addr.sin_addr.s_addr != from.sin_addr.s_addr ||
|
---|
| 315 | p->addr.sin_port != from.sin_port )
|
---|
[07028b9] | 316 | {
|
---|
[8e540f4] | 317 | strcpy(serverMsg.buffer, "That player is logged in using a differemt connection. This is either a bug, or you're trying to hack the server.");
|
---|
[8a3ef42] | 318 | cout << "Player logged in using a different connection" << endl;
|
---|
[2488852] | 319 | }
|
---|
[8e540f4] | 320 | else
|
---|
[2488852] | 321 | {
|
---|
[01d0d00] | 322 | if (p->id < unusedId)
|
---|
| 323 | unusedId = p->id;
|
---|
| 324 | mapPlayers.erase(p->id);
|
---|
[41ad8ed] | 325 | strcpy(serverMsg.buffer, "You have successfully logged out.");
|
---|
[8a3ef42] | 326 | cout << "Player logged out successfuly" << endl;
|
---|
[8e540f4] | 327 | }
|
---|
[07028b9] | 328 |
|
---|
[d211210] | 329 | serverMsg.type = MSG_TYPE_LOGOUT;
|
---|
[8a3ef42] | 330 |
|
---|
[8e540f4] | 331 | break;
|
---|
| 332 | }
|
---|
| 333 | case MSG_TYPE_CHAT:
|
---|
| 334 | {
|
---|
[da692b9] | 335 | cout << "Got a chat message" << endl;
|
---|
| 336 |
|
---|
[01d0d00] | 337 | Player *p = findPlayerByAddr(mapPlayers, from);
|
---|
[07028b9] | 338 |
|
---|
[8e540f4] | 339 | if (p == NULL)
|
---|
| 340 | {
|
---|
| 341 | strcpy(serverMsg.buffer, "No player is logged in using this connection. This is either a bug, or you're trying to hack the server.");
|
---|
[2488852] | 342 | }
|
---|
[8e540f4] | 343 | else
|
---|
| 344 | {
|
---|
[3b1efcc] | 345 | broadcastResponse = true;
|
---|
| 346 |
|
---|
[b128109] | 347 | ostringstream oss;
|
---|
| 348 | oss << p->name << ": " << clientMsg.buffer;
|
---|
[3b1efcc] | 349 |
|
---|
[b128109] | 350 | strcpy(serverMsg.buffer, oss.str().c_str());
|
---|
[8e540f4] | 351 | }
|
---|
| 352 |
|
---|
| 353 | serverMsg.type = MSG_TYPE_CHAT;
|
---|
| 354 |
|
---|
| 355 | break;
|
---|
[e084950] | 356 | }
|
---|
[b128109] | 357 | case MSG_TYPE_PLAYER_MOVE:
|
---|
| 358 | {
|
---|
| 359 | istringstream iss;
|
---|
| 360 | iss.str(clientMsg.buffer);
|
---|
| 361 |
|
---|
| 362 | cout << "PLAYER_MOVE" << endl;
|
---|
| 363 |
|
---|
| 364 | int id, x, y;
|
---|
| 365 |
|
---|
| 366 | memcpy(&id, clientMsg.buffer, 4);
|
---|
| 367 | memcpy(&x, clientMsg.buffer+4, 4);
|
---|
| 368 | memcpy(&y, clientMsg.buffer+8, 4);
|
---|
[7b43385] | 369 |
|
---|
[b128109] | 370 | cout << "x: " << x << endl;
|
---|
| 371 | cout << "y: " << y << endl;
|
---|
| 372 | cout << "id: " << id << endl;
|
---|
[7b43385] | 373 |
|
---|
[b128109] | 374 | if ( mapPlayers[id].addr.sin_addr.s_addr == from.sin_addr.s_addr &&
|
---|
| 375 | mapPlayers[id].addr.sin_port == from.sin_port )
|
---|
| 376 | {
|
---|
[60017fc] | 377 | // we need to make sure the player can move here
|
---|
| 378 | if (0 <= x && x < 300 && 0 <= y && y < 300 &&
|
---|
| 379 | gameMap->getElement(x/25, y/25) == WorldMap::TERRAIN_GRASS)
|
---|
| 380 | {
|
---|
[7b43385] | 381 | cout << "valid terrain" << endl;
|
---|
| 382 |
|
---|
[60017fc] | 383 | mapPlayers[id].target.x = x;
|
---|
| 384 | mapPlayers[id].target.y = y;
|
---|
| 385 | int xDiff = mapPlayers[id].target.x - mapPlayers[id].pos.x;
|
---|
| 386 | int yDiff = mapPlayers[id].target.y - mapPlayers[id].pos.y;
|
---|
| 387 |
|
---|
| 388 | serverMsg.type = MSG_TYPE_PLAYER_MOVE;
|
---|
| 389 |
|
---|
| 390 | memcpy(serverMsg.buffer, &id, 4);
|
---|
[d211210] | 391 | memcpy(serverMsg.buffer+4, &mapPlayers[id].target.x, 4);
|
---|
| 392 | memcpy(serverMsg.buffer+8, &mapPlayers[id].target.y, 4);
|
---|
[60017fc] | 393 |
|
---|
| 394 | broadcastResponse = true;
|
---|
| 395 | }
|
---|
| 396 | else
|
---|
| 397 | cout << "Bad terrain detected" << endl;
|
---|
[b128109] | 398 | }
|
---|
| 399 | else // nned to send back a message indicating failure
|
---|
| 400 | cout << "Player id (" << id << ") doesn't match sender" << endl;
|
---|
| 401 |
|
---|
| 402 | break;
|
---|
| 403 | }
|
---|
[8e540f4] | 404 | default:
|
---|
| 405 | {
|
---|
| 406 | strcpy(serverMsg.buffer, "Server error occured. Report this please.");
|
---|
[e084950] | 407 |
|
---|
[8e540f4] | 408 | serverMsg.type = MSG_TYPE_CHAT;
|
---|
[e084950] | 409 |
|
---|
[8e540f4] | 410 | break;
|
---|
| 411 | }
|
---|
[e3535b3] | 412 | }
|
---|
[da692b9] | 413 |
|
---|
[60017fc] | 414 | cout << "Got to the end of the switch" << endl;
|
---|
| 415 |
|
---|
[da692b9] | 416 | return broadcastResponse;
|
---|
[e3535b3] | 417 | }
|
---|
[da692b9] | 418 |
|
---|
[1106210] | 419 | void updateUnusedId(unsigned int& id, map<unsigned int, Player>& mapPlayers)
|
---|
[01d0d00] | 420 | {
|
---|
[1106210] | 421 | while (mapPlayers.find(id) != mapPlayers.end())
|
---|
| 422 | id++;
|
---|
[01d0d00] | 423 | }
|
---|