| 9473 | |
| 9474 | #define HEARTBEAT_INTERVAL 10.0f |
| 9475 | void 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 | //----------------------------------------------- |
| 9506 | void MultiDoMSafeFunction(uint8_t *data); |
no test coverage detected