hide gamestate resynch stuff behind SATURNSYNCH ifdef
This commit is contained in:
1 parent
31b8038aa0
commit
e21b83b1ec
8 files changed
+115
-15
No files matched your search
+78
-8
@@ -94,8 +94,10 @@ UINT8 playernode[MAXPLAYERS];
|
||||
// The actual timeout will be longer depending on the savegame length
|
||||
tic_t jointimeout = (3*TICRATE);
|
||||
static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame?
|
||||
#ifdef SATURNSYNCH
|
||||
static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame?
|
||||
static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can resend again?
|
||||
#endif
|
||||
static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout?
|
||||
|
||||
UINT16 pingmeasurecount = 1;
|
||||
@@ -127,11 +129,12 @@ static UINT8 resynch_inprogress[MAXNETNODES];
|
||||
static UINT8 resynch_local_inprogress = false; // WE are desynched and getting packets to fix it.
|
||||
static UINT8 player_joining = false;
|
||||
UINT8 hu_resynching = 0;
|
||||
|
||||
#ifdef SATURNSYNCH
|
||||
UINT8 hu_redownloadinggamestate = 0;
|
||||
|
||||
static boolean can_receive_gamestate[MAXNETNODES];
|
||||
|
||||
static UINT8 gamestate_resend_counter[MAXNETNODES];
|
||||
#endif
|
||||
|
||||
// kart, true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks
|
||||
UINT8 hu_stopped = 0;
|
||||
@@ -144,15 +147,20 @@ static ticcmd_t localcmds4;
|
||||
static boolean cl_packetmissed;
|
||||
// here it is for the secondary local player (splitscreen)
|
||||
static UINT8 mynode; // my address pointofview server
|
||||
|
||||
#ifdef SATURNSYNCH
|
||||
static boolean cl_redownloadinggamestate = false;
|
||||
#endif
|
||||
|
||||
#ifdef SATURNPAK
|
||||
boolean is_client_saturn[MAXNETNODES];
|
||||
#endif
|
||||
|
||||
#ifdef SATURNSYNCH
|
||||
#ifdef SATURNJOIN
|
||||
#define ISSATURN 69
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static UINT8 localtextcmd[MAXTEXTCMD];
|
||||
static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen
|
||||
@@ -190,7 +198,6 @@ typedef struct textcmdtic_s
|
||||
ticcmd_t netcmds[TICQUEUE][MAXPLAYERS];
|
||||
static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL};
|
||||
|
||||
|
||||
consvar_t cv_showjoinaddress = {"showjoinaddress", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_shownodeip = {"showipinnodelist", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
@@ -1899,7 +1906,6 @@ static void SV_SavedGame(void)
|
||||
#endif
|
||||
#define TMPSAVENAME "$$$.sav"
|
||||
|
||||
|
||||
static void CL_LoadReceivedSavegame(boolean reloading)
|
||||
{
|
||||
UINT8 *savebuffer = NULL;
|
||||
@@ -1959,6 +1965,7 @@ static void CL_LoadReceivedSavegame(boolean reloading)
|
||||
consistancy[gametic%TICQUEUE] = Consistancy();
|
||||
CON_ToggleOff();
|
||||
|
||||
#ifdef SATURNSYNCH
|
||||
// Tell the server we have received and reloaded the gamestate
|
||||
// so they know they can resume the game
|
||||
if (reloading)
|
||||
@@ -1966,8 +1973,10 @@ static void CL_LoadReceivedSavegame(boolean reloading)
|
||||
netbuffer->packettype = PT_RECEIVEDGAMESTATE;
|
||||
HSendPacket(servernode, true, 0, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef SATURNSYNCH
|
||||
static void CL_ReloadReceivedSavegame(void)
|
||||
{
|
||||
INT32 i;
|
||||
@@ -1991,6 +2000,7 @@ static void CL_ReloadReceivedSavegame(void)
|
||||
CONS_Printf(M_GetText("Game state reloaded\n"));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NONET
|
||||
static void SendAskInfo(INT32 node)
|
||||
@@ -3218,7 +3228,9 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason)
|
||||
#ifdef SATURNPAK
|
||||
is_client_saturn[node] = false;
|
||||
#endif
|
||||
#ifdef SATURNSYNCH
|
||||
can_receive_gamestate[node] = false;
|
||||
#endif
|
||||
Net_CloseConnection(node);
|
||||
ResetNode(node);
|
||||
}
|
||||
@@ -4022,6 +4034,7 @@ static void Command_list_http_logins (void)
|
||||
}
|
||||
#endif/*HAVE_CURL*/
|
||||
|
||||
#ifdef SATURNSYNCH
|
||||
static void Command_ResendGamestate(void)
|
||||
{
|
||||
SINT8 playernum;
|
||||
@@ -4049,6 +4062,7 @@ static void Command_ResendGamestate(void)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static CV_PossibleValue_t netticbuffer_cons_t[] = {{0, "MIN"}, {3, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_netticbuffer = {"netticbuffer", "1", CV_SAVE, netticbuffer_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
@@ -4077,11 +4091,14 @@ 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};
|
||||
|
||||
#ifdef SATURNSYNCH
|
||||
static CV_PossibleValue_t gamestateattempts_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_gamestateattempts = {"gamestateresendattempts", "10", 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 };
|
||||
#endif
|
||||
|
||||
consvar_t cv_blamecfail = {"blamecfail", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL };
|
||||
|
||||
// max file size to send to a player (in kilobytes)
|
||||
@@ -4141,7 +4158,9 @@ void D_ClientServerInit(void)
|
||||
COM_AddCommand("reloadbans", Command_ReloadBan);
|
||||
COM_AddCommand("connect", Command_connect);
|
||||
COM_AddCommand("nodes", Command_Nodes);
|
||||
#ifdef SATURNSYNCH
|
||||
COM_AddCommand("resendgamestate", Command_ResendGamestate);
|
||||
#endif
|
||||
COM_AddCommand("listplayers", Command_Listplayers);
|
||||
COM_AddCommand("packetstat", Command_Packetstat);
|
||||
#ifdef HAVE_CURL
|
||||
@@ -4201,9 +4220,11 @@ static void ResetNode(INT32 node)
|
||||
is_client_saturn[node] = false;
|
||||
#endif
|
||||
|
||||
#ifdef SATURNSYNCH
|
||||
resendingsavegame[node] = false;
|
||||
can_receive_gamestate[node] = false;
|
||||
savegameresendcooldown[node] = 0;
|
||||
#endif
|
||||
//
|
||||
}
|
||||
|
||||
@@ -4240,7 +4261,9 @@ void SV_ResetServer(void)
|
||||
|
||||
mynode = 0;
|
||||
cl_packetmissed = false;
|
||||
#ifdef SATURNSYNCH
|
||||
cl_redownloadinggamestate = false;
|
||||
#endif
|
||||
|
||||
if (dedicated)
|
||||
{
|
||||
@@ -4770,7 +4793,7 @@ static void HandleConnect(SINT8 node)
|
||||
|
||||
/// \note Wait what???
|
||||
/// What if the gamestate takes more than one second to get downloaded?
|
||||
/// Or if a lagspike happdsfens?
|
||||
/// Or if a lagspike happens?
|
||||
// you get a free second before desynch checks. use it wisely.
|
||||
SV_InitResynchVars(node);
|
||||
|
||||
@@ -4870,7 +4893,7 @@ static void HandleServerInfo(SINT8 node)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SATURNSYNCH
|
||||
static void PT_WillResendGamestate(void)
|
||||
{
|
||||
char tmpsave[264];
|
||||
@@ -4893,7 +4916,6 @@ static void PT_WillResendGamestate(void)
|
||||
I_Error("Can't delete %s\n", tmpsave);
|
||||
|
||||
CL_PrepareDownloadSaveGame(tmpsave);
|
||||
|
||||
cl_redownloadinggamestate = true;
|
||||
}
|
||||
|
||||
@@ -4907,6 +4929,7 @@ static void PT_CanReceiveGamestate(SINT8 node)
|
||||
SV_SendSaveGame(node, true); // Resend a complete game state
|
||||
resendingsavegame[node] = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Handles a packet received from a node that isn't in game
|
||||
*
|
||||
@@ -5342,6 +5365,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef SATURNSYNCH
|
||||
if ((gamestate_resend_counter[node] != 0) && (I_GetTime() % ((max(cv_resynchcooldown.value, 1) * TICRATE) *2) == 0))
|
||||
gamestate_resend_counter[node]--;
|
||||
|
||||
@@ -5397,6 +5421,43 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||
else if (resynch_score[node])
|
||||
--resynch_score[node];
|
||||
break;
|
||||
#else
|
||||
// Check player consistancy during the level
|
||||
if (realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL
|
||||
&& consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy))
|
||||
{
|
||||
SV_RequireResynch(node);
|
||||
|
||||
if (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250)
|
||||
{
|
||||
if (cv_blamecfail.value)
|
||||
CONS_Printf(M_GetText("Synch failure for player %d (%s); expected %hd, got %hd\n"),
|
||||
netconsole+1, player_names[netconsole],
|
||||
consistancy[realstart%TICQUEUE],
|
||||
SHORT(netbuffer->u.clientpak.consistancy));
|
||||
DEBFILE(va("Restoring player %d (synch failure) [%update] %d!=%d\n",
|
||||
netconsole, realstart, consistancy[realstart%TICQUEUE],
|
||||
SHORT(netbuffer->u.clientpak.consistancy)));
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT8 buf[3];
|
||||
|
||||
buf[0] = (UINT8)netconsole;
|
||||
buf[1] = KICK_MSG_CON_FAIL;
|
||||
SendNetXCmd(XD_KICK, &buf, 2);
|
||||
DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n",
|
||||
netconsole, realstart, consistancy[realstart%TICQUEUE],
|
||||
SHORT(netbuffer->u.clientpak.consistancy)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (resynch_score[node])
|
||||
--resynch_score[node];
|
||||
break;
|
||||
#endif
|
||||
|
||||
case PT_BASICKEEPALIVE:
|
||||
if (client)
|
||||
break;
|
||||
@@ -5534,7 +5595,9 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||
#ifdef SATURNPAK
|
||||
is_client_saturn[node] = false;
|
||||
#endif
|
||||
#ifdef SATURNSYNCH
|
||||
can_receive_gamestate[node] = false;
|
||||
#endif
|
||||
break;
|
||||
// -------------------------------------------- CLIENT RECEIVE ----------
|
||||
case PT_RESYNCHEND:
|
||||
@@ -5704,6 +5767,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||
is_client_saturn[node] = true;
|
||||
break;
|
||||
#endif
|
||||
#ifdef SATURNSYNCH
|
||||
case PT_CANRECEIVEGAMESTATE:
|
||||
can_receive_gamestate[node] = true;
|
||||
PT_CanReceiveGamestate(node);
|
||||
@@ -5716,6 +5780,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||
case PT_WILLRESENDGAMESTATE:
|
||||
PT_WillResendGamestate();
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n",
|
||||
netbuffer->packettype, node));
|
||||
@@ -6675,15 +6740,18 @@ void NetUpdate(void)
|
||||
|
||||
if (client)
|
||||
{
|
||||
#ifdef SATURNSYNCH
|
||||
// If the client just finished redownloading the game state, load it
|
||||
if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND)
|
||||
CL_ReloadReceivedSavegame();
|
||||
|
||||
#endif
|
||||
if (!resynch_local_inprogress)
|
||||
CL_SendClientCmd(); // Send tic cmd
|
||||
|
||||
hu_resynching = resynch_local_inprogress;
|
||||
#ifdef SATURNSYNCH
|
||||
hu_redownloadinggamestate = cl_redownloadinggamestate;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6692,7 +6760,9 @@ void NetUpdate(void)
|
||||
INT32 counts;
|
||||
|
||||
hu_resynching = false;
|
||||
#ifdef SATURNSYNCH
|
||||
hu_redownloadinggamestate = false;
|
||||
#endif
|
||||
|
||||
firstticstosend = gametic;
|
||||
for (i = 0; i < MAXNETNODES; i++)
|
||||
|
||||
+9
-1
@@ -102,9 +102,11 @@ typedef enum
|
||||
#ifdef SATURNPAK
|
||||
PT_ISSATURN,
|
||||
#endif
|
||||
#ifdef SATURNSYNCH
|
||||
PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate!
|
||||
PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead.
|
||||
PT_RECEIVEDGAMESTATE, // Thank you Server, I am ready to play again!
|
||||
#endif
|
||||
|
||||
NUMPACKETTYPE
|
||||
} packettype_t;
|
||||
@@ -582,7 +584,11 @@ extern consvar_t
|
||||
#ifdef SATURNJOIN
|
||||
cv_allownewsaturnplayer,
|
||||
#endif
|
||||
cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_gamestateattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed;
|
||||
cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts,
|
||||
#ifdef SATURNSYNCH
|
||||
cv_resynchcooldown, cv_gamestateattempts,
|
||||
#endif
|
||||
cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed;
|
||||
|
||||
extern consvar_t cv_connectawaittime;
|
||||
|
||||
@@ -647,7 +653,9 @@ tic_t GetLag(INT32 node);
|
||||
UINT8 GetFreeXCmdSize(void);
|
||||
|
||||
extern UINT8 hu_resynching;
|
||||
#ifdef SATURNSYNCH
|
||||
extern UINT8 hu_redownloadinggamestate;
|
||||
#endif
|
||||
extern UINT8 hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player
|
||||
|
||||
typedef struct rewind_s {
|
||||
|
||||
+2
-1
@@ -837,10 +837,11 @@ const char *packettypename[NUMPACKETTYPE] =
|
||||
#ifdef SATURNPAK
|
||||
"ISSATURN",
|
||||
#endif
|
||||
|
||||
#ifdef SATURNSYNCH
|
||||
"WILLRESENDGAMESTATE",
|
||||
"CANRECEIVEGAMESTATE",
|
||||
"RECEIVEDGAMESTATE"
|
||||
#endif
|
||||
};
|
||||
|
||||
const char *Net_GetPacketName(UINT8 packettype)
|
||||
|
||||
@@ -786,8 +786,10 @@ void D_RegisterServerCommands(void)
|
||||
// d_clisrv
|
||||
CV_RegisterVar(&cv_maxplayers);
|
||||
CV_RegisterVar(&cv_resynchattempts);
|
||||
#ifdef SATURNSYNCH
|
||||
CV_RegisterVar(&cv_gamestateattempts);
|
||||
CV_RegisterVar(&cv_resynchcooldown);
|
||||
#endif
|
||||
CV_RegisterVar(&cv_maxsend);
|
||||
CV_RegisterVar(&cv_noticedownload);
|
||||
CV_RegisterVar(&cv_downloadspeed);
|
||||
|
||||
@@ -580,6 +580,11 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
||||
// Compile them at your own risk!
|
||||
|
||||
//-- SATURN __
|
||||
/// Enable gamestate resynching between Saturn servers and clients
|
||||
/// Like SRB2 and RR does
|
||||
/// Still highly experimental
|
||||
//#define SATURNSYNCH
|
||||
|
||||
/// Server detection for if a connecting client is on Saturn.
|
||||
/// For stuff like extra synching, etc.
|
||||
//#define SATURNPAK
|
||||
|
||||
+5
-1
@@ -1192,7 +1192,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
// why build a ticcmd if we're paused?
|
||||
// Or, for that matter, if we're being reborn.
|
||||
// Kart, don't build a ticcmd if someone is resynching or the server is stopped too so we don't fly off course in bad conditions
|
||||
if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching || hu_redownloadinggamestate)
|
||||
if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching
|
||||
#ifdef SATURNSYNCH
|
||||
|| hu_redownloadinggamestate
|
||||
#endif
|
||||
)
|
||||
{
|
||||
cmd->angleturn = (INT16)(lang >> 16);
|
||||
cmd->aiming = G_ClipAimingPitch(&laim);
|
||||
|
||||
+10
-2
@@ -1256,7 +1256,11 @@ void HU_Ticker(void)
|
||||
if (cechotimer > 0) --cechotimer;
|
||||
|
||||
// Animate the desynch dots
|
||||
if (hu_resynching || hu_redownloadinggamestate)
|
||||
if (hu_resynching
|
||||
#ifdef SATURNSYNCH
|
||||
|| hu_redownloadinggamestate
|
||||
#endif
|
||||
)
|
||||
resynch_ticker++; //tic tic tic tic tic
|
||||
|
||||
HU_TickSongCredits();
|
||||
@@ -2421,7 +2425,11 @@ void HU_Drawer(void)
|
||||
HU_DrawSongCredits();
|
||||
|
||||
// draw desynch text
|
||||
if (hu_resynching || hu_redownloadinggamestate)
|
||||
if (hu_resynching
|
||||
#ifdef SATURNSYNCH
|
||||
|| hu_redownloadinggamestate
|
||||
#endif
|
||||
)
|
||||
{
|
||||
char resynch_text[14];
|
||||
UINT32 i;
|
||||
|
||||
+4
-2
@@ -2023,8 +2023,10 @@ static menuitem_t OP_AdvServerOptionsMenu[] =
|
||||
NULL, "Server Browser Address", &cv_masterserver, 10},
|
||||
#endif
|
||||
{IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40},
|
||||
#ifdef SATURNSYNCH
|
||||
{IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 50},
|
||||
{IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 60},
|
||||
#endif
|
||||
{IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 70},
|
||||
{IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 80},
|
||||
{IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 90},
|
||||
@@ -2037,15 +2039,15 @@ static menuitem_t OP_AdvServerOptionsMenu[] =
|
||||
{IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 160},
|
||||
{IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 170},
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef NONET
|
||||
static const char* OP_AdvServerOptionsTooltips[] =
|
||||
{
|
||||
"Server used for master server.",
|
||||
"Attempts to resynchronise player to server.",
|
||||
#ifdef SATURNSYNCH
|
||||
"Cooldown in seconds before the Server attempts\nto resend the gamestate to a Saturn Client\nbetween resending attempts.",
|
||||
"Attempts to resend the Gamestate to player\nThis increments a Counter everytime a gamestate resend occurs\nThis Counter decrements at double the time of the Cooldown\nonce the Counter reaches the threshold, the client gets kicked.",
|
||||
#endif
|
||||
"Maximum allowed delay.",
|
||||
"Delay timeout in seconds.",
|
||||
"Connection timeout in tics.",
|
||||
|
||||
Reference in new issue
Block a user