MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / PrePacket

Function PrePacket

Source/msg.cpp:374–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372}
373
374void PrePacket()
375{
376 uint8_t playerId = std::numeric_limits<uint8_t>::max();
377 for (TMegaPkt &pkt : MegaPktList) {
378 byte *data = pkt.data;
379 size_t spaceLeft = sizeof(pkt.data);
380 while (spaceLeft != pkt.spaceLeft) {
381 auto cmdId = static_cast<_cmd_id>(*data);
382
383 if (cmdId == FAKE_CMD_SETID) {
384 auto *cmd = (TFakeCmdPlr *)data;
385 data += sizeof(*cmd);
386 spaceLeft -= sizeof(*cmd);
387 playerId = cmd->bPlr;
388 continue;
389 }
390
391 if (cmdId == FAKE_CMD_DROPID) {
392 auto *cmd = (TFakeDropPlr *)data;
393 data += sizeof(*cmd);
394 spaceLeft -= sizeof(*cmd);
395 multi_player_left(cmd->bPlr, SDL_SwapLE32(cmd->dwReason));
396 continue;
397 }
398
399 if (playerId >= Players.size()) {
400 Log("Missing source of network message");
401 return;
402 }
403
404 size_t size = ParseCmd(playerId, (TCmd *)data);
405 if (size == 0) {
406 Log("Discarding bad network message");
407 return;
408 }
409 data += size;
410 spaceLeft -= size;
411 }
412 }
413}
414
415void SendPacket(int pnum, const void *packet, size_t dwSize)
416{

Callers 1

run_delta_infoFunction · 0.85

Calls 4

multi_player_leftFunction · 0.85
LogFunction · 0.85
ParseCmdFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected