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

Function MultiProcessData

Descent3/multi.cpp:9518–9951  ·  view source on GitHub ↗

Takes the individual packet types and passes their data to the appropriate routines

Source from the content-addressed store, hash-verified

9516
9517// Takes the individual packet types and passes their data to the appropriate routines
9518void MultiProcessData(uint8_t *data, int len, int slot, network_address *from_addr) {
9519 uint8_t type = data[0];
9520 len = len;
9521 int sequence = -1;
9522
9523 // HEY!!!!! These packets are the only ones that are accepted by non-connected machines
9524 // (ie people on the netgame join screen)
9525 // This will go away once I fill out all the ACCEPT_CONDITION types
9526 if (!(NetPlayers[Player_num].flags & NPF_CONNECTED)) {
9527 if (type != MP_CONNECTION_ACCEPTED && type != MP_JOIN_RESPONSE && type != MP_GAME_INFO &&
9528 type != MP_PLAYERLIST_DATA && type != MP_ASK_FOR_URL && type != MP_CUR_MSN_URLS)
9529 return;
9530 } else {
9531 // Setup our sequences for accept conditions
9532 if (Netgame.local_role == LR_SERVER) {
9533 if (NetPlayers[Player_num].sequence != NETSEQ_PLAYING)
9534 return;
9535 if (slot == -1)
9536 sequence = -1;
9537 else
9538 sequence = NetPlayers[slot].sequence;
9539 } else {
9540 sequence = NetPlayers[Player_num].sequence;
9541 }
9542 }
9543
9544#ifndef RELEASE
9545 Multi_packet_tracking[type]++;
9546#endif
9547
9548 switch (type) {
9549 case MP_CONNECTION_ACCEPTED:
9550 ACCEPT_CONDITION(-1, -1);
9551 MultiDoConnectionAccepted(data);
9552 break;
9553 case MP_REQUEST_PLAYERS:
9554 MultiDoRequestPlayers(data);
9555 break;
9556 case MP_REQUEST_BUILDINGS:
9557 MultiDoRequestBuildings(data);
9558 break;
9559 case MP_REQUEST_OBJECTS:
9560 MultiDoRequestObjects(data);
9561 break;
9562 case MP_REQUEST_WORLD_STATES:
9563 MultiDoRequestWorldStates(data);
9564 break;
9565 case MP_PLAYER_POS:
9566 ACCEPT_CONDITION(NETSEQ_PLAYING, NETSEQ_PLAYING);
9567 NetPlayers[Player_num].total_bytes_rcvd += len;
9568 MultiDoPlayerPos(data);
9569 break;
9570 case MP_DONE_PLAYERS:
9571 MultiDoDonePlayers(data);
9572 break;
9573 case MP_DONE_BUILDINGS:
9574 MultiDoDoneBuildings(data);
9575 break;

Callers 1

MultiProcessBigDataFunction · 0.85

Calls 15

MultiDoRequestPlayersFunction · 0.85
MultiDoRequestBuildingsFunction · 0.85
MultiDoRequestObjectsFunction · 0.85
MultiDoPlayerPosFunction · 0.85
MultiDoDonePlayersFunction · 0.85
MultiDoDoneBuildingsFunction · 0.85
MultiDoDoneObjectsFunction · 0.85
MultiDoDoneWorldStatesFunction · 0.85
MultiDoEnteringGameFunction · 0.85
MultiDoPlayerFunction · 0.85

Tested by

no test coverage detected