MCPcopy Create free account
hub / github.com/ZDoom/Raze / NetbufferSize

Function NetbufferSize

source/core/d_net.cpp:358–412  ·  view source on GitHub ↗

[RH] Rewritten to properly calculate the packet size with our variable length commands.

Source from the content-addressed store, hash-verified

356// with our variable length commands.
357//
358int NetbufferSize ()
359{
360 if (netbuffer[0] & (NCMD_EXIT | NCMD_SETUP))
361 {
362 return doomcom.datalength;
363 }
364
365 int k = 2, count, numtics;
366
367 if (netbuffer[0] & NCMD_RETRANSMIT)
368 k++;
369
370 if (NetMode == NET_PacketServer && doomcom.remotenode == nodeforplayer[Net_Arbitrator])
371 k++;
372
373 numtics = netbuffer[0] & NCMD_XTICS;
374 if (numtics == 3)
375 {
376 numtics += netbuffer[k++];
377 }
378
379 if (netbuffer[0] & NCMD_QUITTERS)
380 {
381 k += netbuffer[k] + 1;
382 }
383
384 // Network delay byte
385 k++;
386
387 if (netbuffer[0] & NCMD_MULTI)
388 {
389 count = netbuffer[k];
390 k += count;
391 }
392 else
393 {
394 count = 1;
395 }
396
397 // Need at least 3 bytes per tic per player
398 if (doomcom.datalength < k + 3 * count * numtics)
399 {
400 return k + 3 * count * numtics;
401 }
402
403 uint8_t *skipper = &netbuffer[k];
404 if ((netbuffer[0] & NCMD_EXIT) == 0)
405 {
406 while (count-- > 0)
407 {
408 SkipTicCmd (&skipper, numtics);
409 }
410 }
411 return int(skipper - netbuffer);
412}
413
414//
415//

Callers 1

HGetPacketFunction · 0.85

Calls 1

SkipTicCmdFunction · 0.85

Tested by

no test coverage detected