diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 81162708..7e9dcf8e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -151,12 +151,6 @@ static consvar_t cv_showjoinaddress = {"showjoinaddress", "On", 0, CV_OnOff, NUL static CV_PossibleValue_t playbackspeed_cons_t[] = {{1, "MIN"}, {10, "MAX"}, {0, NULL}}; consvar_t cv_playbackspeed = {"playbackspeed", "1", 0, playbackspeed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -void D_ResetTiccmds(void) -{ - memset(&localcmds, 0, sizeof(ticcmd_t)); - memset(&localcmds2, 0, sizeof(ticcmd_t)); -} - static inline void *G_DcpyTiccmd(void* dest, const ticcmd_t* src, const size_t n) { const size_t d = n / sizeof(ticcmd_t); @@ -406,6 +400,12 @@ static void ExtraDataTicker(void) } } } + + // If you are a client, you can safely forget the net commands for this tic + // If you are the server, you need to remember them until every client has been aknowledged, + // because if you need to resend a PT_SERVERTICS packet, you need to put the commands in it + if (!server) + D_FreeTextcmd(gametic); } static void D_Clearticcmd(tic_t tic) @@ -420,6 +420,19 @@ static void D_Clearticcmd(tic_t tic) DEBFILE(va("clear tic %5u (%2u)\n", tic, tic%BACKUPTICS)); } +void D_ResetTiccmds(void) +{ + INT32 i; + + memset(&localcmds, 0, sizeof(ticcmd_t)); + memset(&localcmds2, 0, sizeof(ticcmd_t)); + + // Reset the net command list + for (i = 0; i < TEXTCMD_HASH_SIZE; i++) + while (textcmds[i]) + D_Clearticcmd(textcmds[i]->tic); +} + // ----------------------------------------------------------------- // end of extra data function // ----------------------------------------------------------------- diff --git a/src/d_net.c b/src/d_net.c index 741fd56f..6be1dbe5 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -1364,4 +1364,6 @@ void D_CloseConnection(void) netgame = false; addedtogame = false; } + + D_ResetTiccmds(); }