Add a 15 seconds cooldown between successive gamestate resends

This commit is contained in:
Louis-Antoine 2020-10-27 01:20:05 +01:00
parent 9f5686ef48
commit 7ae53364f2

View file

@ -85,6 +85,7 @@ char playeraddress[MAXPLAYERS][64];
tic_t jointimeout = (10*TICRATE); tic_t jointimeout = (10*TICRATE);
static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame? static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame?
static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame? static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame?
static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can resend again?
static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout? static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout?
// Incremented by cv_joindelay when a client joins, decremented each tic. // Incremented by cv_joindelay when a client joins, decremented each tic.
@ -3149,14 +3150,18 @@ void D_ClientServerInit(void)
static void ResetNode(INT32 node) static void ResetNode(INT32 node)
{ {
nodeingame[node] = false; nodeingame[node] = false;
nodetoplayer[node] = -1; nodewaiting[node] = 0;
nodetoplayer2[node] = -1;
nettics[node] = gametic; nettics[node] = gametic;
supposedtics[node] = gametic; supposedtics[node] = gametic;
nodewaiting[node] = 0;
nodetoplayer[node] = -1;
nodetoplayer2[node] = -1;
playerpernode[node] = 0; playerpernode[node] = 0;
sendingsavegame[node] = false; sendingsavegame[node] = false;
resendingsavegame[node] = false; resendingsavegame[node] = false;
savegameresendcooldown[node] = 0;
} }
void SV_ResetServer(void) void SV_ResetServer(void)
@ -4069,7 +4074,7 @@ static void HandlePacketFromPlayer(SINT8 node)
// Check player consistancy during the level // Check player consistancy during the level
if (realstart <= gametic && realstart + BACKUPTICS - 1 > gametic && gamestate == GS_LEVEL if (realstart <= gametic && realstart + BACKUPTICS - 1 > gametic && gamestate == GS_LEVEL
&& consistancy[realstart%BACKUPTICS] != SHORT(netbuffer->u.clientpak.consistancy) && consistancy[realstart%BACKUPTICS] != SHORT(netbuffer->u.clientpak.consistancy)
&& !resendingsavegame[node]) && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime())
{ {
if (cv_resynchattempts.value) if (cv_resynchattempts.value)
{ {
@ -4237,6 +4242,7 @@ static void HandlePacketFromPlayer(SINT8 node)
case PT_RECEIVEDGAMESTATE: case PT_RECEIVEDGAMESTATE:
sendingsavegame[node] = false; sendingsavegame[node] = false;
resendingsavegame[node] = false; resendingsavegame[node] = false;
savegameresendcooldown[node] = I_GetTime() + 15 * TICRATE;
break; break;
// -------------------------------------------- CLIENT RECEIVE ---------- // -------------------------------------------- CLIENT RECEIVE ----------
case PT_SERVERTICS: case PT_SERVERTICS: