MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / MultiDoConnectionAccepted

Function MultiDoConnectionAccepted

Descent3/multi_connect.cpp:424–496  ·  view source on GitHub ↗

The server says we can join! Client only

Source from the content-addressed store, hash-verified

422// The server says we can join!
423// Client only
424void MultiDoConnectionAccepted(uint8_t *data) {
425 int count = 0;
426 uint16_t server_version;
427
428 // Skip header
429 SKIP_HEADER(data, &count);
430
431 server_version = MultiGetShort(data, &count);
432
433 if (server_version != MULTI_VERSION) {
434 mprintf(0, "Client and server code versions don't match. Do an update!\n");
435 return;
436 } else {
437 // Versions match, get info about the game and then connect!
438 mprintf(0, "Client/server versions match.\n");
439
440 // Check if we have the mission needed
441 uint8_t len = MultiGetByte(data, &count);
442 memcpy(Netgame.mission, &data[count], len);
443 count += len;
444
445 if (!LoadMission(Netgame.mission)) {
446 mprintf(0, "We don't have this mission: %s!\n", Netgame.mission);
447 } else
448 mprintf(0, "Using mission %s...\n", Netgame.mission);
449
450 len = MultiGetByte(data, &count);
451 memcpy(Netgame.name, &data[count], len);
452 count += len;
453
454 // Do script name stuff
455 len = MultiGetByte(data, &count);
456 memcpy(Netgame.scriptname, &data[count], len);
457 count += len;
458
459 SetGamemodeScript(Netgame.scriptname);
460
461 // Get my player num and copy my name over
462 uint8_t player_num = MultiGetByte(data, &count);
463 char name[CALLSIGN_LEN];
464 netplayer tempplayer;
465 strcpy(name, Players[Player_num].callsign);
466 memcpy(&tempplayer, &NetPlayers[Player_num], sizeof(netplayer));
467
468 Player_num = player_num;
469 mprintf(0, "Server tells me that my player num is %d!\n", Player_num);
470 strcpy(Players[Player_num].callsign, name);
471 memcpy(&NetPlayers[Player_num], &tempplayer, sizeof(netplayer));
472 NetPlayers[Player_num].flags = NPF_CONNECTED; // Hurray! We're connected
473
474 // Get packets per second
475 Netgame.packets_per_second = MultiGetByte(data, &count);
476 mprintf(0, "Server is sending %d packets per second\n", Netgame.packets_per_second);
477
478 // Get the secret code we will use to identify ourselves to the server
479 uint32_t secret_code = MultiGetUint(data, &count);
480
481 // Get the peer-peer flag

Callers 1

MultiProcessDataFunction · 0.85

Calls 9

SKIP_HEADERFunction · 0.85
MultiGetShortFunction · 0.85
MultiGetByteFunction · 0.85
LoadMissionFunction · 0.85
SetGamemodeScriptFunction · 0.85
MultiGetUintFunction · 0.85
MultiGetIntFunction · 0.85
MultiSendGreetingsFunction · 0.85
FindArgFunction · 0.70

Tested by

no test coverage detected