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

Function MultiSendHeartbeat

Descent3/multi.cpp:9475–9503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9473
9474#define HEARTBEAT_INTERVAL 10.0f
9475void MultiSendHeartbeat() {
9476 static float last_heartbeat = timer_GetTime();
9477
9478 float time_scalar = 1;
9479
9480 if (Netgame.local_role == LR_SERVER)
9481 time_scalar = .5; // Server sends out twice as fast
9482
9483 if ((timer_GetTime() - last_heartbeat) > (HEARTBEAT_INTERVAL * time_scalar)) {
9484 uint8_t outdata[100];
9485 int count = 0;
9486 int size;
9487
9488 size = START_DATA(MP_HEARTBEAT, outdata, &count);
9489 END_DATA(count, outdata, size);
9490
9491 if (Netgame.local_role == LR_SERVER) {
9492
9493 mprintf(0, "Server sending heartbeat.\n");
9494 MultiSendToAllExcept(Player_num, outdata, count, -1);
9495 } else {
9496 mprintf(0, "Client sending heartbeat.\n");
9497 nw_Send(&Netgame.server_address, outdata, count, 0);
9498 }
9499
9500 // Reset interval
9501 last_heartbeat = timer_GetTime();
9502 }
9503}
9504
9505//-----------------------------------------------
9506void MultiDoMSafeFunction(uint8_t *data);

Callers 1

LoadLevelProgressFunction · 0.85

Calls 4

START_DATAFunction · 0.85
END_DATAFunction · 0.85
MultiSendToAllExceptFunction · 0.85
nw_SendFunction · 0.85

Tested by

no test coverage detected