From be5ea069ade142feccea0413e7283338621d2a85 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jul 2024 23:09:04 +0200 Subject: [PATCH] add gamestateresendattempts so you can specify how often the game tries to resend gamestate to player in given time so they dont get stuck in a synch loop this is gamestateresendattempts value in the time of resynchcooldown *2 --- src/d_clisrv.c | 19 ++++++++++++++++++- src/d_clisrv.h | 2 +- src/d_netcmd.c | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index fc4d35366..af463692d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -10,6 +10,7 @@ /// \file d_clisrv.c /// \brief SRB2 Network game communication and protocol, all OS independent parts. +#include "doomdef.h" #include #ifdef __GNUC__ #include //for unlink @@ -129,6 +130,8 @@ UINT8 hu_redownloadinggamestate = 0; static boolean can_receive_gamestate[MAXNETNODES]; +static UINT8 gamestate_resend_counter[MAXNETNODES]; + // kart, true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks UINT8 hu_stopped = 0; @@ -4068,6 +4071,11 @@ consvar_t cv_discordinvites = {"discordinvites", "Everyone", CV_SAVE|CV_CALL, di static CV_PossibleValue_t resynchattempts_cons_t[] = {{0, "MIN"}, {20, "MAX"}, {0, NULL}}; consvar_t cv_resynchattempts = {"resynchattempts", "2", CV_SAVE, resynchattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; + +static CV_PossibleValue_t gamestateattempts_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; +consvar_t cv_gamestateattempts = {"gamestateresendattempts", "5", CV_SAVE, gamestateattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; + + static CV_PossibleValue_t resynchcooldown_cons_t[] = {{0, "MIN"}, {20, "MAX"}, {0, NULL}}; consvar_t cv_resynchcooldown = {"gamestatecooldown", "5", CV_SAVE, resynchcooldown_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL }; consvar_t cv_blamecfail = {"blamecfail", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL }; @@ -5306,6 +5314,9 @@ static void HandlePacketFromPlayer(SINT8 node) break; } + if (gamestate_resend_counter[node] && (I_GetTime() % ((max(cv_resynchcooldown.value, 1) * TICRATE) *2) == 0)) + gamestate_resend_counter[node] = 0; + // Check player consistancy during the level if (((!can_receive_gamestate[node]) && realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) || (can_receive_gamestate[node] && realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL @@ -5324,8 +5335,14 @@ static void HandlePacketFromPlayer(SINT8 node) resendingsavegame[node] = false; } - if (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250) + if ((!can_receive_gamestate[node] && cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250) || (can_receive_gamestate[node] && (gamestate_resend_counter[node] < cv_gamestateattempts.value))) { + if (can_receive_gamestate[node] && resendingsavegame[node]) + { + gamestate_resend_counter[node]++; + DEBFILE(va("gamestate counter %d for player %d\n", gamestate_resend_counter[node], netconsole)); + } + if (cv_blamecfail.value) CONS_Printf(M_GetText("Synch failure for player %d (%s); expected %hd, got %hd\n"), netconsole+1, player_names[netconsole], diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 19f5dae1e..ff7fb4a84 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -573,7 +573,7 @@ extern consvar_t #ifdef VANILLAJOINNEXTROUND cv_joinnextround, #endif - cv_netticbuffer, cv_allownewplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; + cv_netticbuffer, cv_allownewplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_gamestateattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; extern consvar_t cv_connectawaittime; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index cc3e45003..13c2be865 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -782,6 +782,7 @@ void D_RegisterServerCommands(void) // d_clisrv CV_RegisterVar(&cv_maxplayers); CV_RegisterVar(&cv_resynchattempts); + CV_RegisterVar(&cv_gamestateattempts); CV_RegisterVar(&cv_resynchcooldown); CV_RegisterVar(&cv_maxsend); CV_RegisterVar(&cv_noticedownload);