From 19eee66c39346b09970c75ab03b9a23816e52a8e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 14:38:38 +0200 Subject: [PATCH 01/63] make a packet to tell if a joined client is on saturn initial stuff works and seems to be vanilla compatible needs its own function and other things to be useful --- src/d_clisrv.c | 12 +++++++++++- src/d_clisrv.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 710f2687b..93b89ca41 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4672,6 +4672,8 @@ static void HandleConnect(SINT8 node) #ifdef JOININGAME if (nodewaiting[node]) { + netbuffer->packettype = PT_ISSATURN; + HSendPacket(node, false, 0, 0); if (node && newnode) { SV_SendSaveGame(node); // send a complete game state @@ -4995,6 +4997,11 @@ static void HandlePacketFromAwayNode(SINT8 node) break; /* FALLTHRU */ + case PT_ISSATURN: + CONS_Printf("hi im on saturn\n"); + client_is_saturn = true; + break; + default: DEBFILE(va("unknown packet received (%d) from unknown host\n",netbuffer->packettype)); Net_CloseConnection(node); @@ -5044,7 +5051,6 @@ static void HandlePacketFromPlayer(SINT8 node) tic_t realend, realstart; UINT8 *pak, *txtpak, numtxtpak; - txtpak = NULL; if (dedicated && node == 0) @@ -5499,6 +5505,10 @@ static void HandlePacketFromPlayer(SINT8 node) if (client) Got_Filetxpak(); break; + case PT_ISSATURN: + CONS_Printf("hi im on saturn\n"); + client_is_saturn = true; + break; default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", netbuffer->packettype, node)); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 13c2bc353..6faf62d97 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -98,6 +98,7 @@ typedef enum PT_MOREFILESNEEDED, // Server, to client: "you need these (+ more on top of those)" PT_PING, // Packet sent to tell clients the other client's latency to server. + PT_ISSATURN, NUMPACKETTYPE } packettype_t; -- 2.54.0 From 9bff8dd91fa918c19b0112146497a966e737b758 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 14:39:23 +0200 Subject: [PATCH 02/63] whoopss remove test stuff --- src/d_clisrv.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 93b89ca41..5755a0343 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4997,11 +4997,6 @@ static void HandlePacketFromAwayNode(SINT8 node) break; /* FALLTHRU */ - case PT_ISSATURN: - CONS_Printf("hi im on saturn\n"); - client_is_saturn = true; - break; - default: DEBFILE(va("unknown packet received (%d) from unknown host\n",netbuffer->packettype)); Net_CloseConnection(node); @@ -5507,7 +5502,6 @@ static void HandlePacketFromPlayer(SINT8 node) break; case PT_ISSATURN: CONS_Printf("hi im on saturn\n"); - client_is_saturn = true; break; default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", -- 2.54.0 From b07c8848ca03e87d8468bee8840bab91782c53ff Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 14:43:19 +0200 Subject: [PATCH 03/63] make smol function for now --- src/d_clisrv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5755a0343..0c15386ec 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4423,6 +4423,12 @@ static boolean SV_AddWaitingPlayers(void) return newplayer; } +static inline void SendSaturnInfo(INT32 node) +{ + netbuffer->packettype = PT_ISSATURN; + HSendPacket(node, false, 0, 0); +} + void CL_AddSplitscreenPlayer(void) { if (cl_mode == CL_CONNECTED) @@ -4672,8 +4678,7 @@ static void HandleConnect(SINT8 node) #ifdef JOININGAME if (nodewaiting[node]) { - netbuffer->packettype = PT_ISSATURN; - HSendPacket(node, false, 0, 0); + SendSaturnInfo(node); if (node && newnode) { SV_SendSaveGame(node); // send a complete game state -- 2.54.0 From 2b5db9ff3f654a85bf634525083e0c908dbb344e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 14:46:24 +0200 Subject: [PATCH 04/63] make saturn packet reliable --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0c15386ec..526570bc9 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4426,7 +4426,7 @@ static boolean SV_AddWaitingPlayers(void) static inline void SendSaturnInfo(INT32 node) { netbuffer->packettype = PT_ISSATURN; - HSendPacket(node, false, 0, 0); + HSendPacket(node, true, 0, 0); } void CL_AddSplitscreenPlayer(void) -- 2.54.0 From 800dbf5e789a4f57c2579372099340990b3aebb8 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 15:00:45 +0200 Subject: [PATCH 05/63] add packet into packettypename --- src/d_net.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/d_net.c b/src/d_net.c index 15ab46b5c..dd0b9d5e9 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -832,7 +832,9 @@ const char *packettypename[NUMPACKETTYPE] = "TELLFILESNEEDED", "MOREFILESNEEDED", - "PING" + "PING", + + "ISSATURN" }; const char *Net_GetPacketName(UINT8 packettype) -- 2.54.0 From 3f5c19bffddab3b642ab33d53621730f0bff9497 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 19 Jul 2024 15:01:30 +0200 Subject: [PATCH 06/63] add boolean to tell if node is saturn --- src/d_clisrv.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 526570bc9..a4222ace7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -136,6 +136,8 @@ static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server +boolean is_client_saturn[MAXNETNODES]; + static UINT8 localtextcmd[MAXTEXTCMD]; static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen static UINT8 localtextcmd3[MAXTEXTCMD]; // splitscreen == 2 @@ -3175,6 +3177,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) SV_InitResynchVars(node); nodeingame[node] = false; + is_client_saturn[node] = false; Net_CloseConnection(node); ResetNode(node); } @@ -3280,6 +3283,7 @@ void CL_Reset(void) if (servernode > 0 && servernode < MAXNETNODES) { nodeingame[(UINT8)servernode] = false; + is_client_saturn[(UINT8)servernode] = false; Net_CloseConnection(servernode); } D_CloseConnection(); // netgame = false @@ -4086,6 +4090,7 @@ void D_ClientServerInit(void) static void ResetNode(INT32 node) { nodeingame[node] = false; + is_client_saturn[node] = false; nodetoplayer[node] = -1; nodetoplayer2[node] = -1; nodetoplayer3[node] = -1; @@ -5342,6 +5347,7 @@ static void HandlePacketFromPlayer(SINT8 node) } Net_CloseConnection(node); nodeingame[node] = false; + is_client_saturn[node] = false; break; // -------------------------------------------- CLIENT RECEIVE ---------- case PT_RESYNCHEND: @@ -5507,6 +5513,7 @@ static void HandlePacketFromPlayer(SINT8 node) break; case PT_ISSATURN: CONS_Printf("hi im on saturn\n"); + is_client_saturn[node] = true; break; default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", -- 2.54.0 From ea4998f66608ffcb9c8e9ac83c26118aa5db8e45 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jul 2024 16:17:19 +0200 Subject: [PATCH 07/63] add gamestate resend ontop of resynch code lmao absolute hell will fallback to just normal resynching when the client doesent send gamestate request packet --- src/d_clisrv.c | 229 ++++++++++++++++++++++++++++++++++++++++--------- src/d_clisrv.h | 4 + src/d_main.c | 2 +- src/d_net.c | 6 +- src/g_game.c | 6 +- src/hu_stuff.c | 4 +- src/p_saveg.c | 64 +++++++++++--- src/p_saveg.h | 4 +- src/p_setup.c | 25 ++++-- src/p_setup.h | 2 +- 10 files changed, 274 insertions(+), 72 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5af4209a4..c67ef524b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -92,6 +92,8 @@ 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? +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? UINT16 pingmeasurecount = 1; @@ -123,6 +125,7 @@ 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; +UINT8 hu_redownloadinggamestate = 0; // kart, true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks UINT8 hu_stopped = 0; @@ -135,6 +138,7 @@ static ticcmd_t localcmds4; static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server +static boolean cl_redownloadinggamestate = false; boolean is_client_saturn[MAXNETNODES]; @@ -1706,22 +1710,26 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.gametype = (UINT8)gametype; netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; - // we fill these structs with FFs so that any players not in game get sent as 0xFFFF - // which is nice and easy for us to detect - memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins)); - memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor)); - memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers)); - - for (i = 0; i < MAXPLAYERS; i++) + if (!resendingsavegame[node]) { - netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; + // we fill these structs with FFs so that any players not in game get sent as 0xFFFF + // which is nice and easy for us to detect + memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins)); + memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor)); - if (!playeringame[i]) - continue; + memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers)); - netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; - netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; + for (i = 0; i < MAXPLAYERS; i++) + { + netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; + + if (!playeringame[i]) + continue; + + netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; + netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; + } } netbuffer->u.servercfg.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); @@ -1729,12 +1737,21 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.discordinvites = (boolean)cv_discordinvites.value; memcpy(netbuffer->u.servercfg.server_context, server_context, 8); - op = p = netbuffer->u.servercfg.varlengthinputs; - CV_SavePlayerNames(&p); - CV_SaveNetVars(&p, false); + if (!resendingsavegame[node]) { - const size_t len = sizeof (serverconfig_pak) + (size_t)(p - op); + op = p = netbuffer->u.servercfg.varlengthinputs; + + CV_SavePlayerNames(&p); + CV_SaveNetVars(&p, false); + } + { + size_t len; + + if (resendingsavegame[node]) + len = sizeof (serverconfig_pak); + else + len = sizeof (serverconfig_pak) + (size_t)(p - op); #ifdef DEBUGFILE if (debugfile) @@ -1767,7 +1784,7 @@ static boolean SV_SendServerConfig(INT32 node) #ifdef JOININGAME #define SAVEGAMESIZE (768*1024) -static void SV_SendSaveGame(INT32 node) +static void SV_SendSaveGame(INT32 node, boolean resending) { size_t length, compressedlen; UINT8 *savebuffer; @@ -1785,7 +1802,7 @@ static void SV_SendSaveGame(INT32 node) // Leave room for the uncompressed length. save_p = savebuffer + sizeof(UINT32); - P_SaveNetGame(); + P_SaveNetGame(resending); length = save_p - savebuffer; if (length > SAVEGAMESIZE) @@ -1881,7 +1898,7 @@ static void SV_SavedGame(void) #define TMPSAVENAME "$$$.sav" -static void CL_LoadReceivedSavegame(void) +static void CL_LoadReceivedSavegame(boolean reloading) { UINT8 *savebuffer = NULL; size_t length, decompressedlen; @@ -1925,7 +1942,7 @@ static void CL_LoadReceivedSavegame(void) } // load a base level - if (P_LoadNetGame()) + if (P_LoadNetGame(reloading)) { CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap))); if (strlen(mapheaderinfo[gamemap-1]->lvlttl) > 0) @@ -1940,15 +1957,6 @@ static void CL_LoadReceivedSavegame(void) } CON_LogMessage("\"\n"); } - else - { - CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); - Z_Free(savebuffer); - save_p = NULL; - if (unlink(tmpsave) == -1) - CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave); - return; - } // done Z_Free(savebuffer); @@ -1957,6 +1965,34 @@ static void CL_LoadReceivedSavegame(void) CONS_Alert(CONS_ERROR, M_GetText("Can't delete %s\n"), tmpsave); consistancy[gametic%TICQUEUE] = Consistancy(); CON_ToggleOff(); + + // Tell the server we have received and reloaded the gamestate + // so they know they can resume the game + netbuffer->packettype = PT_RECEIVEDGAMESTATE; + HSendPacket(servernode, true, 0, 0); +} + +static void CL_ReloadReceivedSavegame(void) +{ + INT32 i; + + for (i = 0; i < MAXPLAYERS; i++) + { + LUA_InvalidatePlayer(&players[i]); + sprintf(player_names[i], "Player %d", i + 1); + } + + CL_LoadReceivedSavegame(true); + + if (neededtic < gametic) + neededtic = gametic; + maketic = neededtic; + + camera->subsector = R_PointInSubsector(camera->x, camera->y); + + cl_redownloadinggamestate = false; + + CONS_Printf(M_GetText("Game state reloaded\n")); } #endif @@ -2570,7 +2606,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic if (fileneeded[0].status == FS_FOUND) { // Gamestate is now handled within CL_LoadReceivedSavegame() - CL_LoadReceivedSavegame(); + CL_LoadReceivedSavegame(false); cl_mode = CL_CONNECTED; break; } // don't break case continue to CL_CONNECTED @@ -3173,8 +3209,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) playerpernode[node]--; if (playerpernode[node] <= 0) { - // If a resynch was in progress, well, it no longer needs to be. - SV_InitResynchVars(node); + SV_InitResynchVars(node); // If a resynch was in progress, well, it no longer needs to be. nodeingame[node] = false; is_client_saturn[node] = false; @@ -3979,6 +4014,34 @@ static void Command_list_http_logins (void) } #endif/*HAVE_CURL*/ +static void Command_ResendGamestate(void) +{ + SINT8 playernum; + + if (COM_Argc() == 1) + { + CONS_Printf(M_GetText("resendgamestate : resend the game state to a player\n")); + return; + } + else if (client) + { + CONS_Printf(M_GetText("Only the server can use this.\n")); + return; + } + + playernum = nametonum(COM_Argv(1)); + if (playernum == -1 || playernum == 0) + return; + + // Send a PT_WILLRESENDGAMESTATE packet to the client so they know what's going on + netbuffer->packettype = PT_WILLRESENDGAMESTATE; + if (!HSendPacket(playernode[playernum], true, 0, 0)) + { + CONS_Alert(CONS_ERROR, M_GetText("A problem occured, please try again.\n")); + return; + } +} + 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}; @@ -4052,6 +4115,7 @@ void D_ClientServerInit(void) COM_AddCommand("reloadbans", Command_ReloadBan); COM_AddCommand("connect", Command_connect); COM_AddCommand("nodes", Command_Nodes); + COM_AddCommand("resendgamestate", Command_ResendGamestate); COM_AddCommand("listplayers", Command_Listplayers); COM_AddCommand("packetstat", Command_Packetstat); #ifdef HAVE_CURL @@ -4090,6 +4154,11 @@ void D_ClientServerInit(void) static void ResetNode(INT32 node) { nodeingame[node] = false; + + nodewaiting[node] = 0; + nettics[node] = gametic; + supposedtics[node] = gametic; + is_client_saturn[node] = false; nodetoplayer[node] = -1; nodetoplayer2[node] = -1; @@ -4100,6 +4169,8 @@ static void ResetNode(INT32 node) nodewaiting[node] = 0; playerpernode[node] = 0; sendingsavegame[node] = false; + resendingsavegame[node] = false; + savegameresendcooldown[node] = 0; bannednode[node].banid = SIZE_MAX; bannednode[node].timeleft = NO_BAN_TIME; } @@ -4120,8 +4191,8 @@ void SV_ResetServer(void) { ResetNode(i); - // Make sure resynch status doesn't get carried over! - SV_InitResynchVars(i); + //if (!(resendingsavegame[i] && is_client_saturn[i]))// Make sure resynch status doesn't get carried over! + SV_InitResynchVars(i); } for (i = 0; i < MAXPLAYERS; i++) @@ -4137,6 +4208,7 @@ void SV_ResetServer(void) mynode = 0; cl_packetmissed = false; + cl_redownloadinggamestate = false; if (dedicated) { @@ -4658,9 +4730,10 @@ static void HandleConnect(SINT8 node) /// \note Wait what??? /// What if the gamestate takes more than one second to get downloaded? - /// Or if a lagspike happens? + /// Or if a lagspike happdsfens? // you get a free second before desynch checks. use it wisely. - SV_InitResynchVars(node); + //if (!(resendingsavegame[node] && is_client_saturn[node])) + SV_InitResynchVars(node); #ifdef VANILLAJOINNEXTROUND if (cv_joinnextround.value && gameaction == ga_nothing) @@ -4686,7 +4759,7 @@ static void HandleConnect(SINT8 node) SendSaturnInfo(node); if (node && newnode) { - SV_SendSaveGame(node); // send a complete game state + SV_SendSaveGame(node, false); // send a complete game state DEBFILE("send savegame\n"); } SV_AddWaitingPlayers(); @@ -4755,6 +4828,44 @@ static void HandleServerInfo(SINT8 node) } #endif + +static void PT_WillResendGamestate(void) +{ + char tmpsave[264]; + + if (server || cl_redownloadinggamestate) + return; + + // Send back a PT_CANRECEIVEGAMESTATE packet to the server + // so they know they can start sending the game state + netbuffer->packettype = PT_CANRECEIVEGAMESTATE; + if (!HSendPacket(servernode, true, 0, 0)) + return; + + CONS_Printf(M_GetText("Reloading game state...\n")); + + sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); + + // Don't get a corrupt savegame error because tmpsave already exists + if (FIL_FileExists(tmpsave) && unlink(tmpsave) == -1) + I_Error("Can't delete %s\n", tmpsave); + + CL_PrepareDownloadSaveGame(tmpsave); + + cl_redownloadinggamestate = true; +} + +static void PT_CanReceiveGamestate(SINT8 node) +{ + if (client || sendingsavegame[node]) + return; + + CONS_Printf(M_GetText("Resending game state to %s...\n"), player_names[nodetoplayer[node]]); + + SV_SendSaveGame(node, true); // Resend a complete game state + resendingsavegame[node] = true; +} + /** Handles a packet received from a node that isn't in game * * \param node The packet sender @@ -5179,11 +5290,23 @@ static void HandlePacketFromPlayer(SINT8 node) --resynch_delay[node]; break; } + // Check player consistancy during the level - if (realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL - && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) + if ((realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL + && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) || (/*is_client_saturn[node] &&*/ realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL + && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy) + && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime())) { - SV_RequireResynch(node); + //if (!is_client_saturn[node]) + SV_RequireResynch(node); + //else + { + // Tell the client we are about to resend them the gamestate + netbuffer->packettype = PT_WILLRESENDGAMESTATE; + HSendPacket(node, true, 0, 0); + + resendingsavegame[node] = true; + } if (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250) { @@ -5515,6 +5638,17 @@ static void HandlePacketFromPlayer(SINT8 node) CONS_Printf("hi im on saturn\n"); is_client_saturn[node] = true; break; + case PT_CANRECEIVEGAMESTATE: + PT_CanReceiveGamestate(node); + break; + case PT_RECEIVEDGAMESTATE: + sendingsavegame[node] = false; + resendingsavegame[node] = false; + savegameresendcooldown[node] = I_GetTime() + 5 * TICRATE; + break; + case PT_WILLRESENDGAMESTATE: + PT_WillResendGamestate(); + break; default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", netbuffer->packettype, node)); @@ -6476,6 +6610,16 @@ void NetUpdate(void) if (!resynch_local_inprogress) CL_SendClientCmd(); // Send tic cmd hu_resynching = resynch_local_inprogress; + + if (cl_redownloadinggamestate) + { + // If the client just finished redownloading the game state, load it + if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) + CL_ReloadReceivedSavegame(); + + CL_SendClientCmd(); // Send tic cmd + } + hu_redownloadinggamestate = cl_redownloadinggamestate; } else { @@ -6484,6 +6628,7 @@ void NetUpdate(void) INT32 counts; hu_resynching = false; + hu_redownloadinggamestate = false; firstticstosend = gametic; for (i = 0; i < MAXNETNODES; i++) @@ -6585,7 +6730,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos) return NULL; save_p = rewind->savebuffer; - P_SaveNetGame(); + P_SaveNetGame(true); rewind->leveltime = leveltime; rewind->next = rewindhead; rewind->demopos = demopos; @@ -6609,7 +6754,7 @@ rewind_t *CL_RewindToTime(tic_t time) return NULL; save_p = rewindhead->savebuffer; - P_LoadNetGame(); + P_LoadNetGame(true); wipegamestate = gamestate; // No fading back in! timeinmap = leveltime; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 6faf62d97..31a0967bc 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -99,6 +99,9 @@ typedef enum PT_PING, // Packet sent to tell clients the other client's latency to server. PT_ISSATURN, + 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! NUMPACKETTYPE } packettype_t; @@ -633,6 +636,7 @@ tic_t GetLag(INT32 node); UINT8 GetFreeXCmdSize(void); extern UINT8 hu_resynching; +extern UINT8 hu_redownloadinggamestate; extern UINT8 hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player typedef struct rewind_s { diff --git a/src/d_main.c b/src/d_main.c index ac6785a53..fc4b75731 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1998,7 +1998,7 @@ void D_SRB2Main(void) pagename = "TITLESKY"; levelstarttic = gametic; G_SetGamestate(GS_LEVEL); - if (!P_SetupLevel(false)) + if (!P_SetupLevel(false, false)) I_Quit(); // fail so reset game stuff } diff --git a/src/d_net.c b/src/d_net.c index dd0b9d5e9..312e90caa 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -834,7 +834,11 @@ const char *packettypename[NUMPACKETTYPE] = "PING", - "ISSATURN" + "ISSATURN", + + "WILLRESENDGAMESTATE", + "CANRECEIVEGAMESTATE", + "RECEIVEDGAMESTATE" }; const char *Net_GetPacketName(UINT8 packettype) diff --git a/src/g_game.c b/src/g_game.c index 203b1aba5..4262c2a3a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1188,7 +1188,7 @@ 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) + if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN) || hu_resynching || hu_redownloadinggamestate) { cmd->angleturn = (INT16)(lang >> 16); cmd->aiming = G_ClipAimingPitch(&laim); @@ -1638,7 +1638,7 @@ void G_DoLoadLevel(boolean resetplayer) } // Setup the level. - if (!P_SetupLevel(false)) + if (!P_SetupLevel(false,false)) { // fail so reset game stuff Command_ExitGame_f(); @@ -1661,6 +1661,8 @@ void G_DoLoadLevel(boolean resetplayer) Z_CheckHeap(-2); #endif + memset(localaiming, 0, sizeof(localaiming)); + for (i = 0; i <= splitscreen; i++) { if (camera[i].chase) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index cd0f42a9c..27a44f6d7 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1253,7 +1253,7 @@ void HU_Ticker(void) if (cechotimer > 0) --cechotimer; // Animate the desynch dots - if (hu_resynching) + if (hu_resynching || hu_redownloadinggamestate) resynch_ticker++; //tic tic tic tic tic HU_TickSongCredits(); @@ -2418,7 +2418,7 @@ void HU_Drawer(void) HU_DrawSongCredits(); // draw desynch text - if (hu_resynching) + if (hu_resynching || hu_redownloadinggamestate) { char resynch_text[14]; UINT32 i; diff --git a/src/p_saveg.c b/src/p_saveg.c index ca41198ab..e1569bcbc 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -107,7 +107,7 @@ static inline void P_UnArchivePlayer(void) // // P_NetArchivePlayers // -static void P_NetArchivePlayers(void) +static void P_NetArchivePlayers(boolean resending) { INT32 i, j; UINT16 flags; @@ -117,6 +117,9 @@ static void P_NetArchivePlayers(void) for (i = 0; i < MAXPLAYERS; i++) { + if (resending) + WRITESINT8(save_p, (SINT8)adminplayers[i]); + if (!playeringame[i]) continue; @@ -124,6 +127,9 @@ static void P_NetArchivePlayers(void) // no longer send ticcmds, player name, skin, or color + if (resending) + WRITESTRINGN(save_p, player_names[i], MAXPLAYERNAME); + WRITEANGLE(save_p, players[i].aiming); WRITEANGLE(save_p, players[i].awayviewaiming); WRITEINT32(save_p, players[i].awayviewtics); @@ -148,6 +154,13 @@ static void P_NetArchivePlayers(void) WRITEUINT16(save_p, players[i].flashpal); WRITEUINT16(save_p, players[i].flashcount); + if (resending) + { + WRITEUINT8(save_p, players[i].skincolor); + WRITEINT32(save_p, players[i].skin); + } + + WRITEUINT32(save_p, players[i].score); WRITEFIXED(save_p, players[i].dashspeed); WRITEINT32(save_p, players[i].dashtime); @@ -285,7 +298,7 @@ static void P_NetArchivePlayers(void) // // P_NetUnArchivePlayers // -static void P_NetUnArchivePlayers(void) +static void P_NetUnArchivePlayers(boolean resending) { INT32 i, j; UINT16 flags; @@ -295,6 +308,8 @@ static void P_NetUnArchivePlayers(void) for (i = 0; i < MAXPLAYERS; i++) { + if (resending) + adminplayers[i] = (INT32)READSINT8(save_p); // Do NOT memset player struct to 0 // other areas may initialize data elsewhere //memset(&players[i], 0, sizeof (player_t)); @@ -305,6 +320,9 @@ static void P_NetUnArchivePlayers(void) // sending player names, skin and color should not be necessary at all! // (that data is handled in the server config now) + if (resending) + READSTRINGN(save_p, player_names[i], MAXPLAYERNAME); + players[i].aiming = READANGLE(save_p); players[i].awayviewaiming = READANGLE(save_p); players[i].awayviewtics = READINT32(save_p); @@ -329,6 +347,12 @@ static void P_NetUnArchivePlayers(void) players[i].flashpal = READUINT16(save_p); players[i].flashcount = READUINT16(save_p); + if (resending) + { + players[i].skincolor = READUINT8(save_p); + players[i].skin = READINT32(save_p); + } + players[i].score = READUINT32(save_p); players[i].dashspeed = READFIXED(save_p); // dashing speed players[i].dashtime = READINT32(save_p); // dashing speed @@ -3233,19 +3257,25 @@ static inline void P_UnArchiveSPGame(INT16 mapoverride) playeringame[consoleplayer] = true; } -static void P_NetArchiveMisc(void) +static void P_NetArchiveMisc(boolean resending) { UINT32 pig = 0; INT32 i; WRITEUINT32(save_p, ARCHIVEBLOCK_MISC); + if (resending) + WRITEUINT32(save_p, gametic); + WRITEINT16(save_p, gamemap); if (gamestate != GS_LEVEL) WRITEINT16(save_p, GS_WAITINGPLAYERS); // nice hack to put people back into waitingplayers else WRITEINT16(save_p, gamestate); + if (resending) + WRITEINT16(save_p, gametype); + for (i = 0; i < MAXPLAYERS; i++) pig |= (playeringame[i] != 0)<data); P_LoadThings(); @@ -2593,7 +2596,7 @@ static boolean P_CanSave(void) * \param skipprecip If true, don't spawn precipitation. * \todo Clean up, refactor, split up; get rid of the bloat. */ -boolean P_SetupLevel(boolean skipprecip) +boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) { // use gamemap to get map number. // 99% of the things already did, so. @@ -2631,7 +2634,7 @@ boolean P_SetupLevel(boolean skipprecip) if (cv_runscripts.value && mapheaderinfo[gamemap-1]->scriptname[0] != '#') P_RunLevelScript(mapheaderinfo[gamemap-1]->scriptname); - P_LevelInitStuff(); + P_LevelInitStuff(reloadinggamestate); for (i = 0; i <= splitscreen; i++) postimgtype[i] = postimg_none; @@ -2664,9 +2667,12 @@ boolean P_SetupLevel(boolean skipprecip) // will be set by player think. players[consoleplayer].viewz = 1; + // Cancel all d_main.c fadeouts (keep fade in though). + if (reloadinggamestate) + wipegamestate = gamestate; // Don't fade if reloading the gamestate // Encore mode fade to pink to white // This is handled BEFORE sounds are stopped. - if (encoremode && !prevencoremode && !demo.rewinding) + else if (encoremode && !prevencoremode && !demo.rewinding) { tic_t locstarttime, endtime, nowtime; @@ -2725,13 +2731,14 @@ boolean P_SetupLevel(boolean skipprecip) // As oddly named as this is, this handles music only. // We should be fine starting it here. - S_Start(); + if (!reloadinggamestate) + S_Start(); levelfadecol = (encoremode && !ranspecialwipe ? 122 : 120); // Let's fade to white here // But only if we didn't do the encore startup wipe - if (!ranspecialwipe && !demo.rewinding) + if (!ranspecialwipe && !demo.rewinding && !reloadinggamestate) { if(rendermode != render_none) { @@ -3020,7 +3027,7 @@ boolean P_SetupLevel(boolean skipprecip) P_MapEnd(); // Remove the loading shit from the screen - if (rendermode != render_none) + if (rendermode != render_none && (!reloadinggamestate)) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); if (precache || dedicated) diff --git a/src/p_setup.h b/src/p_setup.h index 5df0f0b68..057ea505f 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -63,7 +63,7 @@ void P_SetupLevelSky(INT32 skynum, boolean global); void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum); #endif void P_LoadThingsOnly(void); -boolean P_SetupLevel(boolean skipprecip); +boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate); #ifdef HWRENDER void HWR_LoadLevel(void); #endif -- 2.54.0 From 13aadc41ffa4c872abe4c5376979562806403b5c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jul 2024 16:22:51 +0200 Subject: [PATCH 08/63] should reset those here perhaps --- src/d_clisrv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index c67ef524b..f4798aa90 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5644,6 +5644,8 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_RECEIVEDGAMESTATE: sendingsavegame[node] = false; resendingsavegame[node] = false; + resynch_inprogress[node] = false; + resynch_local_inprogress = false; savegameresendcooldown[node] = I_GetTime() + 5 * TICRATE; break; case PT_WILLRESENDGAMESTATE: -- 2.54.0 From 930bde785c5ab1d03ca27350592e7299c348f566 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jul 2024 16:24:36 +0200 Subject: [PATCH 09/63] just reset everything resynchwise here --- src/d_clisrv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f4798aa90..1bad4a0b3 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5646,6 +5646,7 @@ static void HandlePacketFromPlayer(SINT8 node) resendingsavegame[node] = false; resynch_inprogress[node] = false; resynch_local_inprogress = false; + SV_InitResynchVars(node); savegameresendcooldown[node] = I_GetTime() + 5 * TICRATE; break; case PT_WILLRESENDGAMESTATE: -- 2.54.0 From 56fcca1f6b893a4087fa6c5bbe4a8f113081f6e9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jul 2024 18:15:42 +0200 Subject: [PATCH 10/63] mark if node can receive savegame so it doesent run resynch code on em should prevent some issues for when a client received gamestate but thinks it needs to be resynched getting stuck --- src/d_clisrv.c | 33 ++++++++++++++++++++------------- src/d_clisrv.h | 2 ++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1bad4a0b3..55eae8c74 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -127,6 +127,8 @@ static UINT8 player_joining = false; UINT8 hu_resynching = 0; UINT8 hu_redownloadinggamestate = 0; +static boolean can_receive_gamestate[MAXNETNODES]; + // kart, true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks UINT8 hu_stopped = 0; @@ -1711,7 +1713,7 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; - if (!resendingsavegame[node]) + if (!can_receive_gamestate[node]) { // we fill these structs with FFs so that any players not in game get sent as 0xFFFF // which is nice and easy for us to detect @@ -1738,7 +1740,7 @@ static boolean SV_SendServerConfig(INT32 node) memcpy(netbuffer->u.servercfg.server_context, server_context, 8); - if (!resendingsavegame[node]) + if (!can_receive_gamestate[node]) { op = p = netbuffer->u.servercfg.varlengthinputs; @@ -1748,7 +1750,7 @@ static boolean SV_SendServerConfig(INT32 node) { size_t len; - if (resendingsavegame[node]) + if (can_receive_gamestate[node]) len = sizeof (serverconfig_pak); else len = sizeof (serverconfig_pak) + (size_t)(p - op); @@ -3213,6 +3215,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) nodeingame[node] = false; is_client_saturn[node] = false; + can_receive_gamestate[node] = false; Net_CloseConnection(node); ResetNode(node); } @@ -4170,6 +4173,7 @@ static void ResetNode(INT32 node) playerpernode[node] = 0; sendingsavegame[node] = false; resendingsavegame[node] = false; + can_receive_gamestate[node] = false; savegameresendcooldown[node] = 0; bannednode[node].banid = SIZE_MAX; bannednode[node].timeleft = NO_BAN_TIME; @@ -5297,16 +5301,20 @@ static void HandlePacketFromPlayer(SINT8 node) && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy) && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime())) { - //if (!is_client_saturn[node]) - SV_RequireResynch(node); - //else - { - // Tell the client we are about to resend them the gamestate - netbuffer->packettype = PT_WILLRESENDGAMESTATE; - HSendPacket(node, true, 0, 0); + // we need to send this so the client can tell us if it can receive the savegame + netbuffer->packettype = PT_WILLRESENDGAMESTATE; + HSendPacket(node, true, 0, 0); + if (can_receive_gamestate[node]) + { resendingsavegame[node] = true; } + else + { + CONS_Printf("resynch"); + SV_RequireResynch(node); + resendingsavegame[node] = false; + } if (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250) { @@ -5471,6 +5479,7 @@ static void HandlePacketFromPlayer(SINT8 node) Net_CloseConnection(node); nodeingame[node] = false; is_client_saturn[node] = false; + can_receive_gamestate[node] = false; break; // -------------------------------------------- CLIENT RECEIVE ---------- case PT_RESYNCHEND: @@ -5639,14 +5648,12 @@ static void HandlePacketFromPlayer(SINT8 node) is_client_saturn[node] = true; break; case PT_CANRECEIVEGAMESTATE: + can_receive_gamestate[node] = true; PT_CanReceiveGamestate(node); break; case PT_RECEIVEDGAMESTATE: sendingsavegame[node] = false; resendingsavegame[node] = false; - resynch_inprogress[node] = false; - resynch_local_inprogress = false; - SV_InitResynchVars(node); savegameresendcooldown[node] = I_GetTime() + 5 * TICRATE; break; case PT_WILLRESENDGAMESTATE: diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 31a0967bc..b1afac2e0 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -98,10 +98,12 @@ typedef enum PT_MOREFILESNEEDED, // Server, to client: "you need these (+ more on top of those)" PT_PING, // Packet sent to tell clients the other client's latency to server. + PT_ISSATURN, 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! + NUMPACKETTYPE } packettype_t; -- 2.54.0 From 550871f576fef13718234e375f4a0036dc0c3e97 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jul 2024 18:21:19 +0200 Subject: [PATCH 11/63] smol cleanup --- src/d_clisrv.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 55eae8c74..747ae33b7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4195,8 +4195,8 @@ void SV_ResetServer(void) { ResetNode(i); - //if (!(resendingsavegame[i] && is_client_saturn[i]))// Make sure resynch status doesn't get carried over! - SV_InitResynchVars(i); + // Make sure resynch status doesn't get carried over! + SV_InitResynchVars(i); } for (i = 0; i < MAXPLAYERS; i++) @@ -4736,8 +4736,7 @@ static void HandleConnect(SINT8 node) /// What if the gamestate takes more than one second to get downloaded? /// Or if a lagspike happdsfens? // you get a free second before desynch checks. use it wisely. - //if (!(resendingsavegame[node] && is_client_saturn[node])) - SV_InitResynchVars(node); + SV_InitResynchVars(node); #ifdef VANILLAJOINNEXTROUND if (cv_joinnextround.value && gameaction == ga_nothing) @@ -5296,8 +5295,8 @@ static void HandlePacketFromPlayer(SINT8 node) } // Check player consistancy during the level - if ((realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL - && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) || (/*is_client_saturn[node] &&*/ realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL + if ((!can_receive_gamestate[node] && realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL + && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy)) || (realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_LEVEL && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy) && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime())) { -- 2.54.0 From 01c1ae42a140141766f272695973992e5219ff2d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 20 Jul 2024 18:30:10 +0200 Subject: [PATCH 12/63] fix saturn packet going the wrong way --- src/d_clisrv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 747ae33b7..a6e9f3c2b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4759,7 +4759,6 @@ static void HandleConnect(SINT8 node) #ifdef JOININGAME if (nodewaiting[node]) { - SendSaturnInfo(node); if (node && newnode) { SV_SendSaveGame(node, false); // send a complete game state @@ -5057,6 +5056,8 @@ static void HandlePacketFromAwayNode(SINT8 node) #endif DEBFILE(va("Server accept join gametic=%u mynode=%d\n", gametic, mynode)); + SendSaturnInfo(node); + memset(playeringame, 0, sizeof(playeringame)); for (j = 0; j < MAXPLAYERS; j++) { @@ -5643,7 +5644,7 @@ static void HandlePacketFromPlayer(SINT8 node) Got_Filetxpak(); break; case PT_ISSATURN: - CONS_Printf("hi im on saturn\n"); + //CONS_Printf("hi im on saturn\n"); is_client_saturn[node] = true; break; case PT_CANRECEIVEGAMESTATE: -- 2.54.0 From e1d4f102234b04710f88eb1929c5562fb6da22a5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 11:49:21 +0200 Subject: [PATCH 13/63] add "gamestatecooldown" cvar to be able to change the cooldown between gamestate resends --- src/d_clisrv.c | 8 ++++---- src/d_clisrv.h | 2 +- src/d_netcmd.c | 1 + src/m_menu.c | 20 +++++++++++--------- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a6e9f3c2b..1f14f4103 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4067,6 +4067,9 @@ 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 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 }; // max file size to send to a player (in kilobytes) @@ -5306,12 +5309,9 @@ static void HandlePacketFromPlayer(SINT8 node) HSendPacket(node, true, 0, 0); if (can_receive_gamestate[node]) - { resendingsavegame[node] = true; - } else { - CONS_Printf("resynch"); SV_RequireResynch(node); resendingsavegame[node] = false; } @@ -5654,7 +5654,7 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_RECEIVEDGAMESTATE: sendingsavegame[node] = false; resendingsavegame[node] = false; - savegameresendcooldown[node] = I_GetTime() + 5 * TICRATE; + savegameresendcooldown[node] = I_GetTime() + cv_resynchcooldown.value * TICRATE; // I_GetTime() + 5 * TICRATE; break; case PT_WILLRESENDGAMESTATE: PT_WillResendGamestate(); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index b1afac2e0..19f5dae1e 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_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; + cv_netticbuffer, cv_allownewplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, 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 3cf64d065..4584ff3da 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -779,6 +779,7 @@ void D_RegisterServerCommands(void) // d_clisrv CV_RegisterVar(&cv_maxplayers); CV_RegisterVar(&cv_resynchattempts); + CV_RegisterVar(&cv_resynchcooldown); CV_RegisterVar(&cv_maxsend); CV_RegisterVar(&cv_noticedownload); CV_RegisterVar(&cv_downloadspeed); diff --git a/src/m_menu.c b/src/m_menu.c index 8f884d05c..674c33d3b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1912,17 +1912,18 @@ static menuitem_t OP_AdvServerOptionsMenu[] = NULL, "Server Browser Address", &cv_masterserver, 10}, #endif {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, - {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 50}, - {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 60}, - {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 70}, - {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 80}, + {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 50}, + {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 60}, + {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 70}, + {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 80}, + {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 90}, - {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 100}, - {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 110}, + {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 110}, + {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 120}, - {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 130}, - {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 140}, - {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 150}, + {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 140}, + {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 150}, + {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 160}, }; #endif @@ -1931,6 +1932,7 @@ static const char* OP_AdvServerOptionsTooltips[] = { "Server used for master server.", "Attempts to resynchronise player to server.", + "Cooldown in seconds before the Server attempts\nto resend the gamestate to a Saturn Client\nbetween resending attempts.", "Maximum allowed delay.", "Delay timeout in seconds.", "Connection timeout in tics.", -- 2.54.0 From 86950c26d0494650e0c38221d01d15e71b50ffaf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 11:49:48 +0200 Subject: [PATCH 14/63] add check here too --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1f14f4103..08f9f3a82 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5299,8 +5299,8 @@ static void HandlePacketFromPlayer(SINT8 node) } // 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)) || (realstart <= gametic && realstart + TICQUEUE - 1 > gametic && gamestate == GS_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 && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy) && !resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime())) { -- 2.54.0 From db6f76d12da7fd54e0595f5ebe2a38ff05a83854 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:24:01 +0200 Subject: [PATCH 15/63] more reference fixes --- src/lua_blockmaplib.c | 4 +++- src/p_map.c | 18 ++++++++++-------- src/p_mobj.c | 27 ++++++++++++++++++++++----- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/lua_blockmaplib.c b/src/lua_blockmaplib.c index 0b93766b8..2367673cd 100644 --- a/src/lua_blockmaplib.c +++ b/src/lua_blockmaplib.c @@ -53,10 +53,12 @@ static UINT8 lib_searchBlockmap_Objects(lua_State *L, INT32 x, INT32 y, mobj_t * CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); blockfuncerror = true; + P_SetTarget(&bnext, NULL); return 0; // *shrugs* } if (!lua_isnil(gL, -1)) { // if nil, continue + P_SetTarget(&bnext, NULL); if (lua_toboolean(gL, -1)) return 2; // stop whole search else @@ -256,4 +258,4 @@ int LUA_BlockmapLib(lua_State *L) { lua_register(L, "searchBlockmap", lib_searchBlockmap); return 0; -} \ No newline at end of file +} diff --git a/src/p_map.c b/src/p_map.c index 6051d5d1c..bcb2b6a73 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1548,13 +1548,13 @@ static boolean PIT_CheckThing(mobj_t *thing) { tmfloorz = tmceilingz = topz; // block while in air tmceilingslope = NULL; - tmfloorthing = thing; // needed for side collision + P_SetTarget(&tmfloorthing, thing); // needed for side collision } else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; tmceilingslope = NULL; - tmfloorthing = thing; // thing we may stand on + P_SetTarget(&tmfloorthing, thing); // thing we may stand on } } else @@ -1585,13 +1585,13 @@ static boolean PIT_CheckThing(mobj_t *thing) { tmfloorz = tmceilingz = topz; // block while in air tmfloorslope = NULL; - tmfloorthing = thing; // needed for side collision + P_SetTarget(&tmfloorthing, thing); // needed for side collision } else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; tmfloorslope = NULL; - tmfloorthing = thing; // thing we may stand on + P_SetTarget(&tmfloorthing, thing); // thing we may stand on } } } @@ -1991,8 +1991,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) } // tmfloorthing is set when tmfloorz comes from a thing's top - tmfloorthing = NULL; - tmhitthing = NULL; + P_SetTarget(&tmfloorthing, NULL); + P_SetTarget(&tmhitthing, NULL); validcount++; @@ -2489,8 +2489,10 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (tmceilingz - tmfloorz < thing->height) { - if (tmfloorthing) - tmhitthing = tmfloorthing; + if (tmfloorthing != NULL) + { + P_SetTarget(&tmhitthing, tmfloorthing); + } return false; // doesn't fit } diff --git a/src/p_mobj.c b/src/p_mobj.c index 0423b00f3..b25a30065 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6073,7 +6073,8 @@ void P_MobjThinker(mobj_t *mobj) mobj->flags2 &= ~MF2_PUSHED; mobj->eflags &= ~(MFE_SPRUNG|MFE_JUSTBOUNCEDWALL); - tmfloorthing = tmhitthing = NULL; + P_SetTarget(&tmfloorthing, NULL); + P_SetTarget(&tmhitthing, NULL); // 970 allows ANY mobj to trigger a linedef exec if (mobj->subsector && GETSECSPECIAL(mobj->subsector->sector->special, 2) == 8) @@ -10030,13 +10031,29 @@ void P_RemoveMobj(mobj_t *mobj) P_SetTarget(&mobj->target, NULL); P_SetTarget(&mobj->tracer, NULL); + // repair hnext chain + mobj_t *cachenext = mobj->hnext; + if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) - P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + { + if (mobj->hnext->hprev == mobj) + { + P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + } + + P_SetTarget(&mobj->hnext, NULL); + } + if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) - P_SetTarget(&mobj->hprev->hnext, mobj->hnext); - - P_SetTarget(&mobj->hnext, P_SetTarget(&mobj->hprev, NULL)); + { + if (mobj->hprev->hnext == mobj) + { + P_SetTarget(&mobj->hprev->hnext, cachenext); + } + P_SetTarget(&mobj->hprev, NULL); + } + // clear the reference from the mapthing if (mobj->spawnpoint) P_SetTarget(&mobj->spawnpoint->mobj, NULL); -- 2.54.0 From 147c59c26bbe1bd7813890fdc90a273250185979 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 20:07:23 +0200 Subject: [PATCH 16/63] smol cleanup also check for splitscreen and if not dont run a for loop lul --- src/p_tick.c | 262 ++------------------------------------------------- src/p_tick.h | 1 + 2 files changed, 10 insertions(+), 253 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 3bbc219ca..deb84a516 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -324,265 +324,25 @@ static inline void P_RunThinkers(void) } } -// -// P_DoAutobalanceTeams() -// -// Determine if the teams are unbalanced, and if so, move a player to the other team. -// -/*static void P_DoAutobalanceTeams(void) +void P_RunChaseCameras(void) { - changeteam_union NetPacket; - UINT16 usvalue; - INT32 i=0; - INT32 red=0, blue=0; - INT32 redarray[MAXPLAYERS], bluearray[MAXPLAYERS]; - INT32 redflagcarrier = 0, blueflagcarrier = 0; - INT32 totalred = 0, totalblue = 0; + UINT8 i; - NetPacket.value.l = NetPacket.value.b = 0; - memset(redarray, 0, sizeof(redarray)); - memset(bluearray, 0, sizeof(bluearray)); - - // Only do it if we have enough room in the net buffer to send it. - // Otherwise, come back next time and try again. - if (sizeof(usvalue) > GetFreeXCmdSize()) - return; - - //We have to store the players in an array with the rest of their team. - //We can then pick a random player to be forced to change teams. - for (i = 0; i < MAXPLAYERS; i++) + if (!splitscreen) { - if (playeringame[i] && players[i].ctfteam) - { - if (players[i].ctfteam == 1) - { - if (!players[i].gotflag) - { - redarray[red] = i; //store the player's node. - red++; - } - else - redflagcarrier++; - } - else - { - if (!players[i].gotflag) - { - bluearray[blue] = i; //store the player's node. - blue++; - } - else - blueflagcarrier++; - } - } - } - - totalred = red + redflagcarrier; - totalblue = blue + blueflagcarrier; - - if ((abs(totalred - totalblue) > cv_autobalance.value)) - { - if (totalred > totalblue) - { - i = M_RandomKey(red); - NetPacket.packet.newteam = 2; - NetPacket.packet.playernum = redarray[i]; - NetPacket.packet.verification = true; - NetPacket.packet.autobalance = true; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); - } - - if (totalblue > totalred) - { - i = M_RandomKey(blue); - NetPacket.packet.newteam = 1; - NetPacket.packet.playernum = bluearray[i]; - NetPacket.packet.verification = true; - NetPacket.packet.autobalance = true; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); - } - } -} - -// -// P_DoTeamscrambling() -// -// If a team scramble has been started, scramble one person from the -// pre-made scramble array. Said array is created in TeamScramble_OnChange() -// -void P_DoTeamscrambling(void) -{ - changeteam_union NetPacket; - UINT16 usvalue; - NetPacket.value.l = NetPacket.value.b = 0; - - // Only do it if we have enough room in the net buffer to send it. - // Otherwise, come back next time and try again. - if (sizeof(usvalue) > GetFreeXCmdSize()) - return; - - if (scramblecount < scrambletotal) - { - if (players[scrambleplayers[scramblecount]].ctfteam != scrambleteams[scramblecount]) - { - NetPacket.packet.newteam = scrambleteams[scramblecount]; - NetPacket.packet.playernum = scrambleplayers[scramblecount]; - NetPacket.packet.verification = true; - NetPacket.packet.scrambled = true; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); - } - - scramblecount++; //Increment, and get to the next player when we come back here next time. + if (camera[consoleplayer].chase) + P_MoveChaseCamera(&players[consoleplayer], &camera[consoleplayer], false); } else - CV_SetValue(&cv_teamscramble, 0); -} - -static inline void P_DoSpecialStageStuff(void) -{ - boolean inwater = false; - INT32 i; - - // Can't drown in a special stage - for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator) - continue; - - players[i].powers[pw_underwater] = players[i].powers[pw_spacetime] = 0; - } - - if (sstimer < 15*TICRATE+6 && sstimer > 7 && (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC)) - S_SpeedMusic(1.4f); - - if (sstimer < 7 && sstimer > 0) // The special stage time is up! - { - sstimer = 0; - for (i = 0; i < MAXPLAYERS; i++) + for (i = 0; i <= splitscreen; i++) { - if (playeringame[i]) - { - players[i].exiting = raceexittime+1; - players[i].pflags &= ~PF_GLIDING; - } - - if (i == consoleplayer) - S_StartSound(NULL, sfx_lose); - } - - if (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC) - S_SpeedMusic(1.0f); - - stagefailed = true; - } - - if (sstimer > 1) // As long as time isn't up... - { - UINT32 ssrings = 0; - // Count up the rings of all the players and see if - // they've collected the required amount. - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - { - ssrings += (players[i].mo->health-1); - - // If in water, deplete timer 6x as fast. - if ((players[i].mo->eflags & MFE_TOUCHWATER) - || (players[i].mo->eflags & MFE_UNDERWATER)) - inwater = true; - } - - if (ssrings >= totalrings && totalrings > 0) - { - // Halt all the players - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - { - players[i].mo->momx = players[i].mo->momy = 0; - players[i].exiting = raceexittime+1; - } - - sstimer = 0; - - P_GiveEmerald(true); - } - - // Decrement the timer - if (!objectplacing) - { - if (inwater) - sstimer -= 6; - else - sstimer--; + if (camera[i].chase) + P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); } } } -static inline void P_DoTagStuff(void) -{ - INT32 i; - - // tell the netgame who the initial IT person is. - if (leveltime == TICRATE) - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (players[i].pflags & PF_TAGIT) - { - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[i]); // Tell everyone who is it! - break; - } - } - } - - //increment survivor scores - if (leveltime % TICRATE == 0 && leveltime > (hidetime * TICRATE)) - { - INT32 participants = 0; - - for (i=0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator) - participants++; - } - - for (i=0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator && players[i].playerstate == PST_LIVE - && !(players[i].pflags & (PF_TAGIT|PF_TAGGED))) - //points given is the number of participating players divided by two. - P_AddPlayerScore(&players[i], participants/2); - } - } -} - -static inline void P_DoCTFStuff(void) -{ - // Automatic team balance for CTF and team match - if (leveltime % (TICRATE * 5) == 0) //only check once per five seconds for the sake of CPU conservation. - { - // Do not attempt to autobalance and scramble teams at the same time. - // Only the server should execute this. No verified admins, please. - if ((cv_autobalance.value && !cv_teamscramble.value) && cv_allowteamchange.value && server) - P_DoAutobalanceTeams(); - } - - // Team scramble code for team match and CTF. - if ((leveltime % (TICRATE/7)) == 0) - { - // If we run out of time in the level, the beauty is that - // the Y_Ticker() team scramble code will pick it up. - if (cv_teamscramble.value && server) - P_DoTeamscrambling(); - } -}*/ - // // P_Ticker // @@ -830,11 +590,7 @@ void P_Ticker(boolean run) } // Always move the camera. - for (i = 0; i <= splitscreen; i++) - { - if (camera[i].chase) - P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); - } + P_RunChaseCameras(); if (run) { diff --git a/src/p_tick.h b/src/p_tick.h index 2cbbb8104..11b5889ed 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -24,6 +24,7 @@ extern tic_t leveltime; void Command_Numthinkers_f(void); void Command_CountMobjs_f(void); +void P_RunChaseCameras(void); void P_Ticker(boolean run); void P_PreTicker(INT32 frames); void P_DoTeamscrambling(void); -- 2.54.0 From 3e6cab1ec9a534fafde8e43d29c1d9a3458226ee Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 20:22:10 +0200 Subject: [PATCH 17/63] fix this oops --- src/p_tick.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index deb84a516..af187bbea 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -330,8 +330,8 @@ void P_RunChaseCameras(void) if (!splitscreen) { - if (camera[consoleplayer].chase) - P_MoveChaseCamera(&players[consoleplayer], &camera[consoleplayer], false); + if (camera[0].chase) + P_MoveChaseCamera(&players[displayplayers[0]], &camera[0], false); } else { -- 2.54.0 From 6b4d02ae9986f4284c54321dda03b17e22409cb9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 20:07:39 +0200 Subject: [PATCH 18/63] stop yelling clang --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index fc4b75731..ff05e1a64 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -727,7 +727,7 @@ void D_SRB2Loop(void) if (lastdraw || singletics || gametic > rendergametic) { rendergametic = gametic; - rendertimeout = entertic + TICRATE/(TICRATE/2); + rendertimeout = entertic + TICRATE/17.5; doDisplay = true; } -- 2.54.0 From a771ebf0e832d0af43ad5e1a591c3637be53c9d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:21:01 +0200 Subject: [PATCH 19/63] cleanup r_things a little --- src/r_things.c | 55 +++++++++++++++++--------------------------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index a769960ea..068358802 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -38,12 +38,6 @@ #include "qs22j.h" -#ifdef PC_DOS -#include // for snprintf -int snprintf(char *str, size_t n, const char *fmt, ...); -//int vsnprintf(char *str, size_t n, const char *fmt, va_list ap); -#endif - CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2]; static void R_InitSkins(void); @@ -532,15 +526,6 @@ void R_InitSprites(void) R_AddSkins((UINT16)i, false); R_LoadSpriteInfoLumps(i, wadfiles[i]->numlumps); } - - // - // check if all sprites have frames - // - /* - for (i = 0; i < numsprites; i++) - if (sprites[i].numframes < 1) - CONS_Debug(DBG_SETUP, "R_InitSprites: sprite %s has no frames at all\n", sprnames[i]); - */ } // @@ -1034,13 +1019,6 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) newsprite->extra_colormap = sector->lightlist[i].extra_colormap; -/* - if (thing->frame & FF_TRANSMASK) - ; - else if (thing->flags2 & MF2_SHADOW) - ; - else -*/ if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) { @@ -1068,6 +1046,7 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) msecnode_t *node; sector_t *sector; ffloor_t *rover; + #define CHECKZ (isflipped ? z > thing->z+thing->height/2 && z < groundz : z < thing->z+thing->height/2 && z > groundz) for (node = thing->touching_sectorlist; node; node = node->m_sectorlist_next) @@ -1347,7 +1326,7 @@ static void R_ProjectSprite(mobj_t *thing) rollangle = thing->rollangle; } - if ((rollangle) || (pitchnroll) || (thing->player && thing->player->sliproll)) + if (rollangle || pitchnroll || (thing->player && thing->player->sliproll)) { rollsum = pitchnroll; @@ -1585,7 +1564,8 @@ static void R_ProjectSprite(mobj_t *thing) for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, interp.x, interp.y) : thing->subsector->sector->lightlist[lightnum].height; - if (h <= gzt) { + if (h <= gzt) + { light = lightnum - 1; break; } @@ -3171,12 +3151,15 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) } } - if (cvar != NULL) { - if (player->localskin > 0) { + if (cvar != NULL) + { + if (player->localskin > 0) + { CV_StealthSet(&cv_fakelocalskin, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name); CV_StealthSet(cvar, ( (player->skinlocal) ? localskins : skins )[player->localskin - 1].name); } - else { + else + { CV_StealthSet(&cv_fakelocalskin, "none"); CV_StealthSet(cvar, "none"); } @@ -3634,8 +3617,8 @@ next_token: CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); #ifdef SKINVALUES - ( (local) ? localskin_cons_t : skin_cons_t )[( (local) ? numlocalskins : numskins )].value = ( (local) ? numlocalskins : numskins ); - ( (local) ? localskin_cons_t : skin_cons_t )[( (local) ? numlocalskins : numskins )].strvalue = skin->name; + (local ? localskin_cons_t : skin_cons_t)[(local ? numlocalskins : numskins)].value = (local ? numlocalskins : numskins); + (local ? localskin_cons_t : skin_cons_t)[(local ? numlocalskins : numskins)].strvalue = skin->name; #endif // Update the forceskin possiblevalues @@ -3646,6 +3629,7 @@ next_token: } skin->localskin = local; + // so we dont have to guess if (local) skin->localnum = numlocalskins; @@ -3653,28 +3637,27 @@ next_token: skin->localnum = numskins; // add face graphics - if (local) { + if (local) ST_LoadLocalFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numlocalskins); - } else { + else ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numskins); - } #ifdef HWRENDER if (rendermode == render_opengl) - HWR_AddPlayerMD2(( (local) ? numlocalskins : numskins ), local); + HWR_AddPlayerMD2(((local) ? numlocalskins : numskins), local); #endif - if (!local) { + if (!local) + { skinstats[skin->kartspeed-1][skin->kartweight-1][skinstatscount[skin->kartspeed-1][skin->kartweight-1]] = numskins; CONS_Debug(DBG_SETUP, M_GetText("Added %d to %d, %d\n"), numskins, skin->kartweight, skin->kartweight); skinstatscount[skin->kartspeed-1][skin->kartweight-1]++; CONS_Debug(DBG_SETUP, M_GetText("Incremented %d, %d to %d\n"), skin->kartspeed, skin->kartweight, skinstatscount[skin->kartspeed - 1][skin->kartweight - 1]); - skinsorted[numskins] = numskins; } allskins[numallskins] = ( (local) ? localskins : skins )[( (local) ? numlocalskins : numskins )]; - ( (local) ? numlocalskins++ : numskins++ ); + local ? numlocalskins++ : numskins++; numallskins++; } -- 2.54.0 From f7bf3fe5105227d434a8a3dc326086bb038c55cc Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 21 Jul 2024 22:23:21 +0200 Subject: [PATCH 20/63] cleanup hw_main --- src/hardware/hw_main.c | 266 ++++++++++++++++++++--------------------- 1 file changed, 127 insertions(+), 139 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index cf95fdbcb..c4449f512 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -490,6 +490,9 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col tint_color.rgba = (colormap != NULL) ? (UINT32)colormap->rgba : GL_DEFAULTMIX; fade_color.rgba = (colormap != NULL) ? (UINT32)colormap->fadergba : GL_DEFAULTFOG; + // Clamp the light level, since it can sometimes go out of the 0-255 range from animations + light_level = CLAMP(SOFTLIGHT(light_level), cv_secbright.value, 255); + // Crappy backup coloring if you can't do shaders if (!HWR_UseShader()) { @@ -527,9 +530,6 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col poly_color.s.blue = (UINT8)blue; } - // Clamp the light level, since it can sometimes go out of the 0-255 range from animations - light_level = CLAMP(SOFTLIGHT(light_level), cv_secbright.value, 255); - // in palette rendering mode, this is not needed since it properly takes the changes to the palette itself if (!HWR_ShouldUsePaletteRendering()) { @@ -562,9 +562,8 @@ UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if } else { - light = light - (255 - light); // Don't go out of bounds - light = CLAMP(light, 0, 255); + light = CLAMP(light - (255 - light), 0, 255); alpha = (realcolor.s.alpha*255)/25; @@ -848,11 +847,11 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc if (HWR_UseShader()) { if (PolyFlags & PF_Fog) - shader = SHADER_FOG; // fog shader + shader = SHADER_FOG; else if (PolyFlags & PF_Ripple) - shader = SHADER_WATER; // water shader + shader = SHADER_WATER; else - shader = SHADER_FLOOR; // floor shader + shader = SHADER_FLOOR; PolyFlags |= PF_ColorMapped; } @@ -1012,7 +1011,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) } if (HWR_UseShader()) - shader = SHADER_WALL; // wall shader + shader = SHADER_WALL; HWR_ProcessPolygon(&pSurf, wallVerts, 4, i|PF_Modulated|PF_Decal, shader, false); } @@ -1677,51 +1676,49 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // check BOTTOM TEXTURE if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gr_bottomtexture) //only if VISIBLE!!! { + fixed_t texturevpegbottom = 0; // bottom + + grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); + + // PEGGING + if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) + texturevpegbottom = 0; + else if (gr_linedef->flags & ML_EFFECT1) + texturevpegbottom = worldbottom - worldlow; + else + texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight; + + texturevpegbottom += gr_sidedef->rowoffset; + + // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway + texturevpegbottom %= SHORT(textures[gr_bottomtexture]->height)<scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; + wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; + + // Adjust t value for sloped walls + if (!(gr_linedef->flags & ML_EFFECT1)) { - fixed_t texturevpegbottom = 0; // bottom - - grTex = HWR_GetTexture(gr_bottomtexture, gr_linedef->flags & ML_TFERLINE); - - // PEGGING - if (!(gr_linedef->flags & ML_DONTPEGBOTTOM)) - texturevpegbottom = 0; - else if (gr_linedef->flags & ML_EFFECT1) - texturevpegbottom = worldbottom - worldlow; - else - texturevpegbottom = gr_frontsector->floorheight - gr_backsector->floorheight; - - texturevpegbottom += gr_sidedef->rowoffset; - - // This is so that it doesn't overflow and screw up the wall, it doesn't need to go higher than the texture's height anyway - texturevpegbottom %= SHORT(textures[gr_bottomtexture]->height)<scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + gr_backsector->floorheight - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; - - // Adjust t value for sloped walls - if (!(gr_linedef->flags & ML_EFFECT1)) - { - // Unskewed - wallVerts[0].t -= (worldbottom - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[1].t -= (worldbottomslope - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[3].t -= (worldlow - gr_backsector->floorheight) * grTex->scaleY; - wallVerts[2].t -= (worldlowslope - gr_backsector->floorheight) * grTex->scaleY; - } - else if (gr_linedef->flags & ML_DONTPEGBOTTOM) - { - // Skewed by bottom - wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; - //wallVerts[3].t = wallVerts[0].t - (worldlow - worldbottom) * grTex->scaleY; // no need, [3] is already this - wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY; - } - else - { - // Skewed by top - wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; - wallVerts[1].t = (texturevpegbottom + worldlowslope - worldbottomslope) * grTex->scaleY; - } + // Unskewed + wallVerts[0].t -= (worldbottom - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[1].t -= (worldbottomslope - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[3].t -= (worldlow - gr_backsector->floorheight) * grTex->scaleY; + wallVerts[2].t -= (worldlowslope - gr_backsector->floorheight) * grTex->scaleY; + } + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + { + // Skewed by bottom + wallVerts[0].t = wallVerts[1].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; + //wallVerts[3].t = wallVerts[0].t - (worldlow - worldbottom) * grTex->scaleY; // no need, [3] is already this + wallVerts[2].t = wallVerts[1].t - (worldlowslope - worldbottomslope) * grTex->scaleY; + } + else + { + // Skewed by top + wallVerts[0].t = (texturevpegbottom + worldlow - worldbottom) * grTex->scaleY; + wallVerts[1].t = (texturevpegbottom + worldlowslope - worldbottomslope) * grTex->scaleY; } // set top/bottom coords @@ -1900,12 +1897,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom blendmode |= PF_Decal; if (!gl_drawing_stencil && gr_frontsector->numlights) - { - if (!(blendmode & PF_Masked)) - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_TRANSLUCENT, NULL, PF_Decal); - else - HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, PF_Decal); - } + HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, (!(blendmode & PF_Masked)) ? FF_TRANSLUCENT : FF_CUTLEVEL, NULL, PF_Decal); else if (!gl_drawing_stencil && !(blendmode & PF_Masked)) HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, blendmode, false, lightnum, colormap); else @@ -1915,41 +1907,44 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { // Single sided line... Deal only with the middletexture (if one exists) - if (gr_midtexture && gr_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL { + fixed_t texturevpeg; + + // PEGGING + if ((gr_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) + texturevpeg = gr_frontsector->floorheight + textureheight[gr_sidedef->midtexture] - gr_frontsector->ceilingheight + gr_sidedef->rowoffset; + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + texturevpeg = worldbottom + textureheight[gr_sidedef->midtexture] - worldtop + gr_sidedef->rowoffset; + else + texturevpeg = gr_sidedef->rowoffset; // top of texture at top + + grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); + + wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; + wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY; + wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; + wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; + + // Texture correction for slopes + if (gr_linedef->flags & ML_EFFECT2) { - fixed_t texturevpeg; - // PEGGING - if ((gr_linedef->flags & (ML_DONTPEGBOTTOM|ML_EFFECT2)) == (ML_DONTPEGBOTTOM|ML_EFFECT2)) - texturevpeg = gr_frontsector->floorheight + textureheight[gr_sidedef->midtexture] - gr_frontsector->ceilingheight + gr_sidedef->rowoffset; - else if (gr_linedef->flags & ML_DONTPEGBOTTOM) - texturevpeg = worldbottom + textureheight[gr_sidedef->midtexture] - worldtop + gr_sidedef->rowoffset; - else - // top of texture at top - texturevpeg = gr_sidedef->rowoffset; - - grTex = HWR_GetTexture(gr_midtexture, gr_linedef->flags & ML_TFERLINE); - - wallVerts[3].t = wallVerts[2].t = texturevpeg * grTex->scaleY; - wallVerts[0].t = wallVerts[1].t = (texturevpeg + gr_frontsector->ceilingheight - gr_frontsector->floorheight) * grTex->scaleY; - wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; - wallVerts[2].s = wallVerts[1].s = cliphigh * grTex->scaleX; - - // Texture correction for slopes - if (gr_linedef->flags & ML_EFFECT2) { - wallVerts[3].t += (gr_frontsector->ceilingheight - worldtop) * grTex->scaleY; - wallVerts[2].t += (gr_frontsector->ceilingheight - worldtopslope) * grTex->scaleY; - wallVerts[0].t += (gr_frontsector->floorheight - worldbottom) * grTex->scaleY; - wallVerts[1].t += (gr_frontsector->floorheight - worldbottomslope) * grTex->scaleY; - } else if (gr_linedef->flags & ML_DONTPEGBOTTOM) { - wallVerts[3].t = wallVerts[0].t + (worldbottom-worldtop) * grTex->scaleY; - wallVerts[2].t = wallVerts[1].t + (worldbottomslope-worldtopslope) * grTex->scaleY; - } else { - wallVerts[0].t = wallVerts[3].t - (worldbottom-worldtop) * grTex->scaleY; - wallVerts[1].t = wallVerts[2].t - (worldbottomslope-worldtopslope) * grTex->scaleY; - } + wallVerts[3].t += (gr_frontsector->ceilingheight - worldtop) * grTex->scaleY; + wallVerts[2].t += (gr_frontsector->ceilingheight - worldtopslope) * grTex->scaleY; + wallVerts[0].t += (gr_frontsector->floorheight - worldbottom) * grTex->scaleY; + wallVerts[1].t += (gr_frontsector->floorheight - worldbottomslope) * grTex->scaleY; } + else if (gr_linedef->flags & ML_DONTPEGBOTTOM) + { + wallVerts[3].t = wallVerts[0].t + (worldbottom-worldtop) * grTex->scaleY; + wallVerts[2].t = wallVerts[1].t + (worldbottomslope-worldtopslope) * grTex->scaleY; + } + else + { + wallVerts[0].t = wallVerts[3].t - (worldbottom-worldtop) * grTex->scaleY; + wallVerts[1].t = wallVerts[2].t - (worldbottomslope-worldtopslope) * grTex->scaleY; + } + //Set textures properly on single sided walls that are sloped wallVerts[3].y = FIXED_TO_FLOAT(worldtop); wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); @@ -1958,8 +1953,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gr_frontsector->numlights) HWR_SplitWall(gr_frontsector, wallVerts, gr_midtexture, gr_linedef->flags & ML_TFERLINE, &Surf, FF_CUTLEVEL, NULL, 0); - // I don't think that solid walls can use translucent linedef types... - else + else // I don't think that solid walls can use translucent linedef types... { if (grTex->mipmap.flags & TF_TRANSPARENT) HWR_AddTransparentWall(wallVerts, &Surf, gr_midtexture, gr_linedef->flags & ML_TFERLINE, PF_Environment, false, lightnum, colormap); @@ -2150,7 +2144,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { blendmode = PF_Translucent; - Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255)); + Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gr_frontsector->numlights) @@ -2264,7 +2258,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) { blendmode = PF_Translucent; - Surf.PolyColor.s.alpha = max(0, min(rover->alpha, 255)); + Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gr_backsector->numlights) @@ -2280,7 +2274,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } } - #undef SLOPEPARAMS //Hurdler: end of 3d-floors test } @@ -2420,8 +2413,7 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) // Window. // We know it's a window when the above isn't true and the back and front sectors don't match - if (backc1 != frontc1 || backc2 != frontc2 - || backf1 != frontf1 || backf2 != frontf2) + if (backc1 != frontc1 || backc2 != frontc2 || backf1 != frontf1 || backf2 != frontf2) { checkforemptylines = false; return false; @@ -2554,6 +2546,7 @@ doaddline: gld_clipper_SafeAddClipRange(angle2, angle1); checkforemptylines = false; } + // Reject empty lines used for triggers and special events. // Identical floor and ceiling on both sides, // identical light levels on both sides, @@ -2862,11 +2855,11 @@ void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t if (HWR_UseShader()) { - shader = SHADER_FLOOR; // floor shader + shader = SHADER_FLOOR; blendmode |= PF_ColorMapped; } - HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, shader, false); // floor shader + HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, shader, false); } void HWR_AddPolyObjectPlanes(void) @@ -3022,7 +3015,6 @@ static void HWR_Subsector(size_t num) //SoM: 4/7/2000: Test to make Boom water work in Hardware mode. gr_frontsector = R_FakeFlat(gr_frontsector, &tempsec, &floorlightlevel, &ceilinglightlevel, false); - //FIXME: Use floorlightlevel and ceilinglightlevel insted of lightlevel. if (gr_portal == GRPORTAL_SEARCH) { @@ -3166,7 +3158,7 @@ static void HWR_Subsector(size_t num) false, *rover->bottomheight, *gr_frontsector->lightlist[light].lightlevel, - max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } else @@ -3210,7 +3202,7 @@ static void HWR_Subsector(size_t num) true, *rover->topheight, *gr_frontsector->lightlist[light].lightlevel, - max(0, min(rover->alpha, 255)), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + rover->alpha, rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, false, gr_frontsector->lightlist[light].extra_colormap); } else @@ -3865,7 +3857,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) continue; if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i-1].lightlevel > 255 ? 255 : *list[i-1].lightlevel; + lightlevel = *list[i-1].lightlevel; colormap = list[i-1].extra_colormap; break; } @@ -3879,7 +3871,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *list[i].lightlevel > 255 ? 255 : *list[i].lightlevel; + lightlevel = *list[i].lightlevel; colormap = list[i].extra_colormap; } @@ -4092,16 +4084,14 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) /// \todo coloured // colormap test - { - sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 255; - extracolormap_t *colormap = sector->extra_colormap; + sector_t *sector = spr->mobj->subsector->sector; + UINT8 lightlevel = 255; + extracolormap_t *colormap = sector->extra_colormap; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = sector->lightlevel; - HWR_Lighting(&Surf, lightlevel, colormap); - } + HWR_Lighting(&Surf, lightlevel, colormap); { FBITFIELD blend = 0; @@ -4129,7 +4119,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) if (HWR_UseShader()) { - shader = SHADER_SPRITE; // sprite shader + shader = SHADER_SPRITE; blend |= PF_ColorMapped; } @@ -4187,34 +4177,32 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) HWR_GetMappedPatch(gpatch, spr->colormap); // colormap test + sector_t *sector = spr->mobj->subsector->sector; + UINT8 lightlevel = 255; + extracolormap_t *colormap = sector->extra_colormap; + + if (sector->numlights) { - sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 255; - extracolormap_t *colormap = sector->extra_colormap; + INT32 light; - if (sector->numlights) - { - INT32 light; + light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before - light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = *sector->lightlist[light].lightlevel; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *sector->lightlist[light].lightlevel > 255 ? 255 : *sector->lightlist[light].lightlevel; - - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; - } - else - { - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = sector->lightlevel > 255 ? 255 : sector->lightlevel; - - if (sector->extra_colormap) - colormap = sector->extra_colormap; - } - - HWR_Lighting(&Surf, lightlevel, colormap); + if (sector->lightlist[light].extra_colormap) + colormap = sector->lightlist[light].extra_colormap; } + else + { + if (!(spr->mobj->frame & FF_FULLBRIGHT)) + lightlevel = sector->lightlevel; + + if (sector->extra_colormap) + colormap = sector->extra_colormap; + } + + HWR_Lighting(&Surf, lightlevel, colormap); if (spr->mobj->frame & FF_TRANSMASK) blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); @@ -4402,7 +4390,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean planeinfo->lumpnum = lumpnum; planeinfo->xsub = xsub; - planeinfo->alpha = alpha; + planeinfo->alpha = CLAMP(alpha, 0, 255); planeinfo->FOFSector = FOFSector; planeinfo->blend = blend; planeinfo->fogplane = fogplane; @@ -4422,7 +4410,7 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, polyplaneinfo->lumpnum = lumpnum; polyplaneinfo->polysector = polysector; - polyplaneinfo->alpha = alpha; + polyplaneinfo->alpha = CLAMP(alpha, 0, 255); polyplaneinfo->FOFSector = FOFSector; polyplaneinfo->blend = blend; polyplaneinfo->planecolormap = planecolormap; @@ -5879,7 +5867,7 @@ void HWR_Startup(void) HWR_TogglePaletteRendering(); -#ifdef USE_FBO_OGL +#ifdef USE_FBO_OGL HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value); #endif -- 2.54.0 From b4a737d91063cf0bd1fef4aa540549d10dc4206d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 24 Jun 2024 21:28:07 +0200 Subject: [PATCH 21/63] Test: Restore save_p after P_LoadLevel P_LoadLevel calls some functions that save gamedata and unset save_p. this is kinda hacky but i perhaps will port the redone save buffer sometime --- src/p_saveg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index e1569bcbc..a6ed1b807 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3362,6 +3362,7 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(boolean reloading) { UINT32 pig; INT32 i; + UINT8 *old_save_p; if (READUINT32(save_p) != ARCHIVEBLOCK_MISC) I_Error("Bad $$$.sav at archive block Misc"); @@ -3399,12 +3400,17 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(boolean reloading) encoremode = (boolean)READUINT8(save_p); + // FIXME: save_p should not be global!!! + old_save_p = save_p; + if (!P_SetupLevel(true, reloading)) { CONS_Alert(CONS_ERROR, M_GetText("Can't load the level!\n")); return false; } + save_p = old_save_p; + // get the time leveltime = READUINT32(save_p); totalrings = READUINT32(save_p); -- 2.54.0 From 4de22e9d669fde717012f0a62c0cf91023c805c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jul 2024 23:09:04 +0200 Subject: [PATCH 22/63] 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 08f9f3a82..d7aaa1d1b 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 }; @@ -5298,6 +5306,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 @@ -5316,8 +5327,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 4584ff3da..c09903823 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -779,6 +779,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); -- 2.54.0 From 283218f2d6561ef2d5d7aa32bb272f27bffa757f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Jul 2024 23:36:13 +0200 Subject: [PATCH 23/63] changuer how this works counter decrements - 1 double the cooldown time --- src/d_clisrv.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d7aaa1d1b..dcb3a7eb7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4069,12 +4069,10 @@ static CV_PossibleValue_t discordinvites_cons_t[] = {{0, "Admins Only"}, {1, "Ev consvar_t cv_discordinvites = {"discordinvites", "Everyone", CV_SAVE|CV_CALL, discordinvites_cons_t, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; 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 }; - +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 }; - +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 }; @@ -5306,8 +5304,8 @@ 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; + if ((gamestate_resend_counter[node] != 0) && (I_GetTime() % ((max(cv_resynchcooldown.value, 1) * TICRATE) *2) == 0)) + gamestate_resend_counter[node]--; // Check player consistancy during the level if (((!can_receive_gamestate[node]) && realstart <= gametic && realstart > gametic - TICQUEUE+1 && gamestate == GS_LEVEL -- 2.54.0 From c6351c6c536a310bf6825d8c8114e1391755a121 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 00:55:48 +0200 Subject: [PATCH 24/63] add to menu --- src/m_menu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 674c33d3b..6d3bd2c9a 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1911,8 +1911,9 @@ static menuitem_t OP_AdvServerOptionsMenu[] = NULL, "Server Browser Address", &cv_masterserver, 10}, #endif - {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, - {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 50}, + {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 30}, + {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 40}, + {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 50}, {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 60}, {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 70}, {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 80}, @@ -1933,6 +1934,7 @@ static const char* OP_AdvServerOptionsTooltips[] = "Server used for master server.", "Attempts to resynchronise player to server.", "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.", "Maximum allowed delay.", "Delay timeout in seconds.", "Connection timeout in tics.", -- 2.54.0 From 1f41cb9a3f2ac4b5cbfce8bc8c66f5aefc6c937f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 00:59:15 +0200 Subject: [PATCH 25/63] e --- src/m_menu.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 6d3bd2c9a..d88653b51 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1911,20 +1911,20 @@ static menuitem_t OP_AdvServerOptionsMenu[] = NULL, "Server Browser Address", &cv_masterserver, 10}, #endif - {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 30}, - {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 40}, - {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 50}, - {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 60}, - {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 70}, - {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 80}, - {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 90}, + {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, + {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 50}, + {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 60}, + {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}, + {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 100}, - {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 110}, - {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 120}, + {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 120}, + {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 130}, - {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 140}, - {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 150}, - {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 160}, + {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 150}, + {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 160}, + {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 170}, }; #endif -- 2.54.0 From 4b71d9a48d847452b7591c0c7cd2293ab8ec85a7 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 17:07:59 +0200 Subject: [PATCH 26/63] add "allowsaturnjoin" cvar to let toggle allowjoin for saturn clients seperately --- src/d_clisrv.c | 6 +++++- src/d_clisrv.h | 3 ++- src/d_netcmd.c | 1 + src/m_menu.c | 26 ++++++++++++++------------ 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index dcb3a7eb7..dbf2228e6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -146,6 +146,7 @@ static UINT8 mynode; // my address pointofview server static boolean cl_redownloadinggamestate = false; boolean is_client_saturn[MAXNETNODES]; +#define ISSATURN 69 static UINT8 localtextcmd[MAXTEXTCMD]; static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen @@ -1441,6 +1442,7 @@ static boolean CL_SendJoin(void) netbuffer->u.clientcfg.subversion = SUBVERSION; strncpy(netbuffer->u.clientcfg.application, SRB2APPLICATION, sizeof netbuffer->u.clientcfg.application); + netbuffer->u.clientcfg.issaturn = ISSATURN; return HSendPacket(servernode, false, 0, sizeof (clientconfig_pak)); } @@ -4057,6 +4059,8 @@ consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accept consvar_t cv_allownewplayer = {"allowjoin", "On", CV_SAVE|CV_CALL, CV_OnOff, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + #ifdef VANILLAJOINNEXTROUND consvar_t cv_joinnextround = {"joinnextround", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /// \todo not done #endif @@ -4704,7 +4708,7 @@ static void HandleConnect(SINT8 node) { SV_SendRefuse(node, va(M_GetText("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)"), VERSION, SUBVERSION)); } - else if (!cv_allownewplayer.value && node) + else if ((!cv_allownewplayer.value && node && netbuffer->u.clientcfg.issaturn != ISSATURN) || (!cv_allownewsaturnplayer.value && node && netbuffer->u.clientcfg.issaturn == ISSATURN)) { SV_SendRefuse(node, M_GetText(cv_joinrefusemessage.string)); } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index ff7fb4a84..535485672 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -369,6 +369,7 @@ typedef struct UINT8 subversion; // Contains build version UINT8 localplayers; // number of splitscreen players UINT8 mode; + UINT8 issaturn; } ATTRPACK clientconfig_pak; #define SV_SPEEDMASK 0x03 // used to send kartspeed @@ -573,7 +574,7 @@ extern consvar_t #ifdef VANILLAJOINNEXTROUND cv_joinnextround, #endif - cv_netticbuffer, cv_allownewplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_gamestateattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; + cv_netticbuffer, cv_allownewplayer, cv_allownewsaturnplayer, 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 c09903823..db9ce03b8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -788,6 +788,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_httpsource); #ifndef NONET CV_RegisterVar(&cv_allownewplayer); + CV_RegisterVar(&cv_allownewsaturnplayer); CV_RegisterVar(&cv_joinrefusemessage); CV_RegisterVar(&cv_chatlogsize); #ifdef VANILLAJOINNEXTROUND diff --git a/src/m_menu.c b/src/m_menu.c index d88653b51..6d5d78c20 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1861,22 +1861,23 @@ static menuitem_t OP_ServerOptionsMenu[] = { #ifndef NONET {IT_STRING | IT_CVAR | IT_CV_STRING, - NULL, "Server Name", &cv_servername, 10}, + NULL, "Server Name", &cv_servername, 10}, #endif - {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 40}, - {IT_STRING | IT_CVAR, NULL, "Map Progression", &cv_advancemap, 50}, - {IT_STRING | IT_CVAR, NULL, "Voting Timer", &cv_votetime, 60}, - {IT_STRING | IT_CVAR, NULL, "Voting Rule Changes", &cv_kartvoterulechanges, 70}, + {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 40}, + {IT_STRING | IT_CVAR, NULL, "Map Progression", &cv_advancemap, 50}, + {IT_STRING | IT_CVAR, NULL, "Voting Timer", &cv_votetime, 60}, + {IT_STRING | IT_CVAR, NULL, "Voting Rule Changes", &cv_kartvoterulechanges, 70}, #ifndef NONET - {IT_STRING | IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 90}, - {IT_STRING | IT_CVAR, NULL, "Allow Players to Join", &cv_allownewplayer, 100}, - {IT_STRING | IT_CVAR, NULL, "Allow Addon Downloading", &cv_downloading, 110}, - {IT_STRING | IT_CVAR, NULL, "Pause Permission", &cv_pause, 120}, - {IT_STRING | IT_CVAR, NULL, "Mute All Chat", &cv_mute, 130}, + {IT_STRING | IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 90}, + {IT_STRING | IT_CVAR, NULL, "Allow Vanilla Players to Join", &cv_allownewplayer, 100}, + {IT_STRING | IT_CVAR, NULL, "Allow Saturn Players to Join", &cv_allownewsaturnplayer,110}, + {IT_STRING | IT_CVAR, NULL, "Allow Addon Downloading", &cv_downloading, 120}, + {IT_STRING | IT_CVAR, NULL, "Pause Permission", &cv_pause, 130}, + {IT_STRING | IT_CVAR, NULL, "Mute All Chat", &cv_mute, 140}, - {IT_SUBMENU|IT_STRING, NULL, "Advanced Options...", &OP_AdvServerOptionsDef,150}, + {IT_SUBMENU|IT_STRING, NULL, "Advanced Options...", &OP_AdvServerOptionsDef, 160}, #endif }; @@ -1891,7 +1892,8 @@ static const char* OP_ServerOptionsTooltips[] = "How often should other gamemodes appear.", #ifndef NONET "Max amount of players allowed in this server.", - "Allow players to join this server.", + "Allow Vanilla players to join this server.", + "Allow Saturn players to join this server.", "Allow players to download addons.", "Who has permission to pause the server?", "Completely mute in game chat.", -- 2.54.0 From 17dbe77cd3aefdbabef15e89aad087b7c4e9d173 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 23 Jul 2024 17:45:00 +0200 Subject: [PATCH 27/63] allowjoin now sets saturnjoin to its value use CV_StealthSet to prevent its only for scripts pretty much so no need to toggle it seperately --- src/d_clisrv.c | 8 +++++++- src/m_menu.c | 26 ++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index dbf2228e6..9df6dba66 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4059,7 +4059,7 @@ consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accept consvar_t cv_allownewplayer = {"allowjoin", "On", CV_SAVE|CV_CALL, CV_OnOff, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_SAVE|CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #ifdef VANILLAJOINNEXTROUND consvar_t cv_joinnextround = {"joinnextround", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /// \todo not done @@ -4106,6 +4106,12 @@ static void Joinable_OnChange(void) if (!server) return; + // disabling joins should also disable saturn joins unless its called with CV_StealthSet and vice versa to make life a bit easier + if (!cv_allownewplayer.value) + CV_Set(&cv_allownewsaturnplayer, "Off"); + else if (cv_allownewplayer.value) + CV_Set(&cv_allownewsaturnplayer, "On"); + maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); WRITEUINT8(p, maxplayer); diff --git a/src/m_menu.c b/src/m_menu.c index 6d5d78c20..d88653b51 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1861,23 +1861,22 @@ static menuitem_t OP_ServerOptionsMenu[] = { #ifndef NONET {IT_STRING | IT_CVAR | IT_CV_STRING, - NULL, "Server Name", &cv_servername, 10}, + NULL, "Server Name", &cv_servername, 10}, #endif - {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 40}, - {IT_STRING | IT_CVAR, NULL, "Map Progression", &cv_advancemap, 50}, - {IT_STRING | IT_CVAR, NULL, "Voting Timer", &cv_votetime, 60}, - {IT_STRING | IT_CVAR, NULL, "Voting Rule Changes", &cv_kartvoterulechanges, 70}, + {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 40}, + {IT_STRING | IT_CVAR, NULL, "Map Progression", &cv_advancemap, 50}, + {IT_STRING | IT_CVAR, NULL, "Voting Timer", &cv_votetime, 60}, + {IT_STRING | IT_CVAR, NULL, "Voting Rule Changes", &cv_kartvoterulechanges, 70}, #ifndef NONET - {IT_STRING | IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 90}, - {IT_STRING | IT_CVAR, NULL, "Allow Vanilla Players to Join", &cv_allownewplayer, 100}, - {IT_STRING | IT_CVAR, NULL, "Allow Saturn Players to Join", &cv_allownewsaturnplayer,110}, - {IT_STRING | IT_CVAR, NULL, "Allow Addon Downloading", &cv_downloading, 120}, - {IT_STRING | IT_CVAR, NULL, "Pause Permission", &cv_pause, 130}, - {IT_STRING | IT_CVAR, NULL, "Mute All Chat", &cv_mute, 140}, + {IT_STRING | IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 90}, + {IT_STRING | IT_CVAR, NULL, "Allow Players to Join", &cv_allownewplayer, 100}, + {IT_STRING | IT_CVAR, NULL, "Allow Addon Downloading", &cv_downloading, 110}, + {IT_STRING | IT_CVAR, NULL, "Pause Permission", &cv_pause, 120}, + {IT_STRING | IT_CVAR, NULL, "Mute All Chat", &cv_mute, 130}, - {IT_SUBMENU|IT_STRING, NULL, "Advanced Options...", &OP_AdvServerOptionsDef, 160}, + {IT_SUBMENU|IT_STRING, NULL, "Advanced Options...", &OP_AdvServerOptionsDef,150}, #endif }; @@ -1892,8 +1891,7 @@ static const char* OP_ServerOptionsTooltips[] = "How often should other gamemodes appear.", #ifndef NONET "Max amount of players allowed in this server.", - "Allow Vanilla players to join this server.", - "Allow Saturn players to join this server.", + "Allow players to join this server.", "Allow players to download addons.", "Who has permission to pause the server?", "Completely mute in game chat.", -- 2.54.0 From ae3b3f750d7f466092632504ed9970ec04181bc5 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Jul 2024 15:03:01 +0200 Subject: [PATCH 28/63] when no autoload config is found skip everything in D_AddAutoloadFiles stuff doesent need to run if theres nothing to autoload so things can be skipped --- src/d_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index c261e9bd0..8b3f3520b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1039,7 +1039,10 @@ static void D_FindAddonsToAutoload(void) // If the file is found, run our shit if (!autoloadconfigfile) // nope outta here + { + wasautoloaded = postautoloaded = true; // so D_AddAutoloadFiles can skip everything since nothings there to autoload return; + } while (fgets(wadsToAutoload, sizeof wadsToAutoload, autoloadconfigfile) != NULL) { -- 2.54.0 From d09e02721bc1aa95290dd72e092da5433bfbc3b2 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 27 Jul 2024 15:56:44 +0200 Subject: [PATCH 29/63] e --- src/r_main.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index 6ea1433a8..764d34403 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -140,7 +140,6 @@ ps_metric_t ps_numsprites = {0}; ps_metric_t ps_numdrawnodes = {0}; ps_metric_t ps_numpolyobjects = {0}; -#if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) static CV_PossibleValue_t drawdist_cons_t[] = { /*{256, "256"},*/ {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, @@ -148,17 +147,12 @@ static CV_PossibleValue_t drawdist_cons_t[] = { {8192, "8192"}, {12288, "12288"}, {20480, "20480"}, {24576, "24576"},{0, "Infinite"}, {0, NULL}}; +#if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) static CV_PossibleValue_t drawdist_precip_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, {3072, "3072"}, {4096, "4096"}, {0, "None"}, {0, NULL}}; #else -static CV_PossibleValue_t drawdist_cons_t[] = { - /*{256, "256"},*/ {512, "512"}, {768, "768"}, - {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, - {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, - {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; - static CV_PossibleValue_t drawdist_precip_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, -- 2.54.0 From 2100f11af77155e37a8f3d672aae8ddd0592318e Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 17:32:15 +0200 Subject: [PATCH 30/63] remove duplicates in ResetNode --- src/d_clisrv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8b24616b6..071a92504 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4168,20 +4168,19 @@ void D_ClientServerInit(void) static void ResetNode(INT32 node) { nodeingame[node] = false; - nodewaiting[node] = 0; + nettics[node] = gametic; supposedtics[node] = gametic; is_client_saturn[node] = false; + nodetoplayer[node] = -1; nodetoplayer2[node] = -1; nodetoplayer3[node] = -1; nodetoplayer4[node] = -1; - nettics[node] = gametic; - supposedtics[node] = gametic; - nodewaiting[node] = 0; playerpernode[node] = 0; + sendingsavegame[node] = false; resendingsavegame[node] = false; can_receive_gamestate[node] = false; -- 2.54.0 From ac55d473e74a41ef03de3e3104d486735fc0ee8b Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 17:33:18 +0200 Subject: [PATCH 31/63] smol cleanup --- src/d_clisrv.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 071a92504..57a990fb0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1718,7 +1718,6 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.gametype = (UINT8)gametype; netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; - if (!can_receive_gamestate[node]) { // we fill these structs with FFs so that any players not in game get sent as 0xFFFF @@ -1753,24 +1752,23 @@ static boolean SV_SendServerConfig(INT32 node) CV_SavePlayerNames(&p); CV_SaveNetVars(&p, false); } - { - size_t len; - if (can_receive_gamestate[node]) - len = sizeof (serverconfig_pak); - else - len = sizeof (serverconfig_pak) + (size_t)(p - op); + size_t len; + + if (can_receive_gamestate[node]) + len = sizeof (serverconfig_pak); + else + len = sizeof (serverconfig_pak) + (size_t)(p - op); #ifdef DEBUGFILE - if (debugfile) - { - fprintf(debugfile, "ServerConfig Packet about to be sent, size of packet:%s to node:%d\n", - sizeu1(len), node); - } + if (debugfile) + { + fprintf(debugfile, "ServerConfig Packet about to be sent, size of packet:%s to node:%d\n", + sizeu1(len), node); + } #endif - waspacketsent = HSendPacket(node, true, 0, len); - } + waspacketsent = HSendPacket(node, true, 0, len); #ifdef DEBUGFILE if (debugfile) @@ -1967,8 +1965,11 @@ static void CL_LoadReceivedSavegame(boolean reloading) // Tell the server we have received and reloaded the gamestate // so they know they can resume the game - netbuffer->packettype = PT_RECEIVEDGAMESTATE; - HSendPacket(servernode, true, 0, 0); + if (reloading) + { + netbuffer->packettype = PT_RECEIVEDGAMESTATE; + HSendPacket(servernode, true, 0, 0); + } } static void CL_ReloadReceivedSavegame(void) -- 2.54.0 From ada1de7ad61683d5feba553b27d5b36a8e0445f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 23:40:54 +0200 Subject: [PATCH 32/63] dont change connect behaviour regardless of client + smol cleanup and fixes should hopefully fix any remaining issues --- src/d_clisrv.c | 77 ++++++++++++++++++++++---------------------------- src/g_game.c | 2 -- 2 files changed, 33 insertions(+), 46 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 57a990fb0..a9d121997 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1718,25 +1718,22 @@ static boolean SV_SendServerConfig(INT32 node) netbuffer->u.servercfg.gametype = (UINT8)gametype; netbuffer->u.servercfg.modifiedgame = (UINT8)modifiedgame; - if (!can_receive_gamestate[node]) + // we fill these structs with FFs so that any players not in game get sent as 0xFFFF + // which is nice and easy for us to detect + memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins)); + memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor)); + + memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers)); + + for (i = 0; i < MAXPLAYERS; i++) { - // we fill these structs with FFs so that any players not in game get sent as 0xFFFF - // which is nice and easy for us to detect - memset(netbuffer->u.servercfg.playerskins, 0xFF, sizeof(netbuffer->u.servercfg.playerskins)); - memset(netbuffer->u.servercfg.playercolor, 0xFF, sizeof(netbuffer->u.servercfg.playercolor)); + netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; - memset(netbuffer->u.servercfg.adminplayers, -1, sizeof(netbuffer->u.servercfg.adminplayers)); + if (!playeringame[i]) + continue; - for (i = 0; i < MAXPLAYERS; i++) - { - netbuffer->u.servercfg.adminplayers[i] = (SINT8)adminplayers[i]; - - if (!playeringame[i]) - continue; - - netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; - netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; - } + netbuffer->u.servercfg.playerskins[i] = (UINT8)players[i].skin; + netbuffer->u.servercfg.playercolor[i] = (UINT8)players[i].skincolor; } netbuffer->u.servercfg.maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); @@ -1745,20 +1742,12 @@ static boolean SV_SendServerConfig(INT32 node) memcpy(netbuffer->u.servercfg.server_context, server_context, 8); - if (!can_receive_gamestate[node]) - { - op = p = netbuffer->u.servercfg.varlengthinputs; + op = p = netbuffer->u.servercfg.varlengthinputs; - CV_SavePlayerNames(&p); - CV_SaveNetVars(&p, false); - } + CV_SavePlayerNames(&p); + CV_SaveNetVars(&p, false); - size_t len; - - if (can_receive_gamestate[node]) - len = sizeof (serverconfig_pak); - else - len = sizeof (serverconfig_pak) + (size_t)(p - op); + size_t len = sizeof (serverconfig_pak) + (size_t)(p - op); #ifdef DEBUGFILE if (debugfile) @@ -4171,23 +4160,27 @@ static void ResetNode(INT32 node) nodeingame[node] = false; nodewaiting[node] = 0; - nettics[node] = gametic; - supposedtics[node] = gametic; - - is_client_saturn[node] = false; - nodetoplayer[node] = -1; nodetoplayer2[node] = -1; nodetoplayer3[node] = -1; nodetoplayer4[node] = -1; playerpernode[node] = 0; + nettics[node] = gametic; + supposedtics[node] = gametic; + sendingsavegame[node] = false; + + bannednode[node].banid = SIZE_MAX; + bannednode[node].timeleft = NO_BAN_TIME; + + // SATURN + is_client_saturn[node] = false; + resendingsavegame[node] = false; can_receive_gamestate[node] = false; savegameresendcooldown[node] = 0; - bannednode[node].banid = SIZE_MAX; - bannednode[node].timeleft = NO_BAN_TIME; + // } void SV_ResetServer(void) @@ -6651,18 +6644,14 @@ void NetUpdate(void) if (client) { + // If the client just finished redownloading the game state, load it + if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) + CL_ReloadReceivedSavegame(); + if (!resynch_local_inprogress) CL_SendClientCmd(); // Send tic cmd + hu_resynching = resynch_local_inprogress; - - if (cl_redownloadinggamestate) - { - // If the client just finished redownloading the game state, load it - if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) - CL_ReloadReceivedSavegame(); - - CL_SendClientCmd(); // Send tic cmd - } hu_redownloadinggamestate = cl_redownloadinggamestate; } else diff --git a/src/g_game.c b/src/g_game.c index e119c8ee8..daee674b3 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1664,8 +1664,6 @@ void G_DoLoadLevel(boolean resetplayer) Z_CheckHeap(-2); #endif - memset(localaiming, 0, sizeof(localaiming)); - for (i = 0; i <= splitscreen; i++) { if (camera[i].chase) -- 2.54.0 From 9f8db631f0074de1c9e13dda27a48e44051d2b55 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 15 Aug 2024 23:46:02 +0200 Subject: [PATCH 33/63] reset rumble when player is exiting --- src/p_tick.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 8054ee554..cc2600f17 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -333,18 +333,21 @@ static inline void P_DeviceRumbleTick(void) if (!P_IsLocalPlayer(player)) continue; - if (!playeringame[i] || player->spectator) - continue; - if (G_GetDeviceForPlayer(i) == 0) continue; - if (player->exiting) + if (!playeringame[displayplayers[i]] || player->spectator) continue; if (player->mo == NULL) continue; + if (player->exiting) + { + G_PlayerDeviceRumble(i, low, high, 0); + continue; + } + if (player->kartstuff[k_spinouttimer]) { low = high = 65536 / 4; -- 2.54.0 From b432491d34fe552ce81d7183d5b5e62e73dc0e17 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 19:54:56 +0200 Subject: [PATCH 34/63] throw saturnpacket and join stuff behind "SATURNPAK" ifdef, disable it for now --- src/d_clisrv.c | 26 ++++++++++++++++++++++++++ src/d_clisrv.h | 10 +++++++++- src/d_net.c | 2 ++ src/d_netcmd.c | 2 ++ src/doomdef.h | 4 ++++ 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index a9d121997..ef1076b3b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -146,8 +146,10 @@ static boolean cl_packetmissed; static UINT8 mynode; // my address pointofview server static boolean cl_redownloadinggamestate = false; +#ifdef SATURNPAK boolean is_client_saturn[MAXNETNODES]; #define ISSATURN 69 +#endif static UINT8 localtextcmd[MAXTEXTCMD]; static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen @@ -1443,7 +1445,9 @@ static boolean CL_SendJoin(void) netbuffer->u.clientcfg.subversion = SUBVERSION; strncpy(netbuffer->u.clientcfg.application, SRB2APPLICATION, sizeof netbuffer->u.clientcfg.application); +#ifdef SATURNPAK netbuffer->u.clientcfg.issaturn = ISSATURN; +#endif return HSendPacket(servernode, false, 0, sizeof (clientconfig_pak)); } @@ -3201,7 +3205,9 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) SV_InitResynchVars(node); // If a resynch was in progress, well, it no longer needs to be. nodeingame[node] = false; +#ifdef SATURNPAK is_client_saturn[node] = false; +#endif can_receive_gamestate[node] = false; Net_CloseConnection(node); ResetNode(node); @@ -3308,7 +3314,9 @@ void CL_Reset(void) if (servernode > 0 && servernode < MAXNETNODES) { nodeingame[(UINT8)servernode] = false; +#ifdef SATURNPAK is_client_saturn[(UINT8)servernode] = false; +#endif Net_CloseConnection(servernode); } D_CloseConnection(); // netgame = false @@ -4041,7 +4049,9 @@ consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accept consvar_t cv_allownewplayer = {"allowjoin", "On", CV_SAVE|CV_CALL, CV_OnOff, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; +#ifdef SATURNPAK consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_SAVE|CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +#endif #ifdef VANILLAJOINNEXTROUND consvar_t cv_joinnextround = {"joinnextround", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; /// \todo not done @@ -4088,11 +4098,13 @@ static void Joinable_OnChange(void) if (!server) return; +#ifdef SATURNPAK // disabling joins should also disable saturn joins unless its called with CV_StealthSet and vice versa to make life a bit easier if (!cv_allownewplayer.value) CV_Set(&cv_allownewsaturnplayer, "Off"); else if (cv_allownewplayer.value) CV_Set(&cv_allownewsaturnplayer, "On"); +#endif maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); @@ -4175,7 +4187,9 @@ static void ResetNode(INT32 node) bannednode[node].timeleft = NO_BAN_TIME; // SATURN +#ifdef SATURNPAK is_client_saturn[node] = false; +#endif resendingsavegame[node] = false; can_receive_gamestate[node] = false; @@ -4510,11 +4524,13 @@ static boolean SV_AddWaitingPlayers(void) return newplayer; } +#ifdef SATURNPAK static inline void SendSaturnInfo(INT32 node) { netbuffer->packettype = PT_ISSATURN; HSendPacket(node, true, 0, 0); } +#endif void CL_AddSplitscreenPlayer(void) { @@ -4701,7 +4717,11 @@ static void HandleConnect(SINT8 node) { SV_SendRefuse(node, va(M_GetText("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)"), VERSION, SUBVERSION)); } +#ifdef SATURNPAK else if ((!cv_allownewplayer.value && node && netbuffer->u.clientcfg.issaturn != ISSATURN) || (!cv_allownewsaturnplayer.value && node && netbuffer->u.clientcfg.issaturn == ISSATURN)) +#else + else if (!cv_allownewplayer.value && node) +#endif { SV_SendRefuse(node, M_GetText(cv_joinrefusemessage.string)); } @@ -5062,7 +5082,9 @@ static void HandlePacketFromAwayNode(SINT8 node) #endif DEBFILE(va("Server accept join gametic=%u mynode=%d\n", gametic, mynode)); +#ifdef SATURNPAK SendSaturnInfo(node); +#endif memset(playeringame, 0, sizeof(playeringame)); for (j = 0; j < MAXPLAYERS; j++) @@ -5490,7 +5512,9 @@ static void HandlePacketFromPlayer(SINT8 node) } Net_CloseConnection(node); nodeingame[node] = false; +#ifdef SATURNPAK is_client_saturn[node] = false; +#endif can_receive_gamestate[node] = false; break; // -------------------------------------------- CLIENT RECEIVE ---------- @@ -5655,10 +5679,12 @@ static void HandlePacketFromPlayer(SINT8 node) if (client) Got_Filetxpak(); break; +#ifdef SATURNPAK case PT_ISSATURN: //CONS_Printf("hi im on saturn\n"); is_client_saturn[node] = true; break; +#endif case PT_CANRECEIVEGAMESTATE: can_receive_gamestate[node] = true; PT_CanReceiveGamestate(node); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 535485672..37a828788 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -99,7 +99,9 @@ typedef enum PT_PING, // Packet sent to tell clients the other client's latency to server. +#ifdef SATURNPAK PT_ISSATURN, +#endif 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! @@ -369,7 +371,9 @@ typedef struct UINT8 subversion; // Contains build version UINT8 localplayers; // number of splitscreen players UINT8 mode; +#ifdef SATURNPAK UINT8 issaturn; +#endif } ATTRPACK clientconfig_pak; #define SV_SPEEDMASK 0x03 // used to send kartspeed @@ -574,7 +578,11 @@ extern consvar_t #ifdef VANILLAJOINNEXTROUND cv_joinnextround, #endif - cv_netticbuffer, cv_allownewplayer, cv_allownewsaturnplayer, cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_gamestateattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; + cv_netticbuffer, cv_allownewplayer, +#ifdef SATURNPAK + cv_allownewsaturnplayer, +#endif + 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_net.c b/src/d_net.c index 312e90caa..2f60eb3d4 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -834,7 +834,9 @@ const char *packettypename[NUMPACKETTYPE] = "PING", +#ifdef SATURNPAK "ISSATURN", +#endif "WILLRESENDGAMESTATE", "CANRECEIVEGAMESTATE", diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b69a5b437..a81b6d1bf 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -795,7 +795,9 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_httpsource); #ifndef NONET CV_RegisterVar(&cv_allownewplayer); +#ifdef SATURNPAK CV_RegisterVar(&cv_allownewsaturnplayer); +#endif CV_RegisterVar(&cv_joinrefusemessage); CV_RegisterVar(&cv_chatlogsize); #ifdef VANILLAJOINNEXTROUND diff --git a/src/doomdef.h b/src/doomdef.h index 3540c3f4a..37e553816 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -568,6 +568,10 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! +/// Server detection for if a connecting client is on Saturn. +/// For stuff like extra synching, joinblock, etc. +//#define SATURNPAK + /// Undefine to use the new method of Gamma correction see colour cube in v_video.c #define BACKWARDSCOMPATCORRECTION -- 2.54.0 From daf8151a322b15809ecd2dcc84bd6adcf528178d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 19:56:14 +0200 Subject: [PATCH 35/63] Revert "Do not access memory on misaligned addresses" This reverts commit 112716dae58ee75794948f456241795308ef3c26. --- src/byteptr.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/byteptr.h b/src/byteptr.h index 0b3935e63..9756e7d95 100644 --- a/src/byteptr.h +++ b/src/byteptr.h @@ -11,12 +11,17 @@ /// \brief Macros to read/write from/to a UINT8 *, /// used for packet creation and such +#if defined (__alpha__) || defined (__arm__) || defined (__mips__) || defined (__ia64__) || defined (__clang__) +#define DEALIGNED +#endif + #include "endian.h" #ifndef SRB2_BIG_ENDIAN // // Little-endian machines // +#ifdef DEALIGNED #define WRITEUINT8(p,b) do { UINT8 *p_tmp = (void *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITESINT8(p,b) do { SINT8 *p_tmp = (void *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEINT16(p,b) do { INT16 *p_tmp = (void *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; } while (0) @@ -26,8 +31,20 @@ #define WRITECHAR(p,b) do { char *p_tmp = (void *)p; const char tv = ( char)(b); memcpy(p, &tv, sizeof( char)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEFIXED(p,b) do { fixed_t *p_tmp = (void *)p; const fixed_t tv = (fixed_t)(b); memcpy(p, &tv, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; } while (0) #define WRITEANGLE(p,b) do { angle_t *p_tmp = (void *)p; const angle_t tv = (angle_t)(b); memcpy(p, &tv, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; } while (0) +#else +#define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; *p_tmp = ( UINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; *p_tmp = ( SINT8)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; *p_tmp = ( INT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; *p_tmp = ( UINT16)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; *p_tmp = ( INT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEUINT32(p,b) do { UINT32 *p_tmp = ( UINT32 *)p; *p_tmp = ( UINT32)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITECHAR(p,b) do { char *p_tmp = ( char *)p; *p_tmp = ( char)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEFIXED(p,b) do { fixed_t *p_tmp = (fixed_t *)p; *p_tmp = (fixed_t)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#define WRITEANGLE(p,b) do { angle_t *p_tmp = (angle_t *)p; *p_tmp = (angle_t)(b); p_tmp++; p = (void *)p_tmp; } while (0) +#endif #ifdef __GNUC__ +#ifdef DEALIGNED #define READUINT8(p) ({ UINT8 *p_tmp = (void *)p; UINT8 b; memcpy(&b, p, sizeof( UINT8)); p_tmp++; p = (void *)p_tmp; b; }) #define READSINT8(p) ({ SINT8 *p_tmp = (void *)p; SINT8 b; memcpy(&b, p, sizeof( SINT8)); p_tmp++; p = (void *)p_tmp; b; }) #define READINT16(p) ({ INT16 *p_tmp = (void *)p; INT16 b; memcpy(&b, p, sizeof( INT16)); p_tmp++; p = (void *)p_tmp; b; }) @@ -38,6 +55,17 @@ #define READFIXED(p) ({ fixed_t *p_tmp = (void *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; p = (void *)p_tmp; b; }) #define READANGLE(p) ({ angle_t *p_tmp = (void *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; p = (void *)p_tmp; b; }) #else +#define READUINT8(p) ({ UINT8 *p_tmp = ( UINT8 *)p; UINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READSINT8(p) ({ SINT8 *p_tmp = ( SINT8 *)p; SINT8 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READINT16(p) ({ INT16 *p_tmp = ( INT16 *)p; INT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READUINT16(p) ({ UINT16 *p_tmp = ( UINT16 *)p; UINT16 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READINT32(p) ({ INT32 *p_tmp = ( INT32 *)p; INT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READUINT32(p) ({ UINT32 *p_tmp = ( UINT32 *)p; UINT32 b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READCHAR(p) ({ char *p_tmp = ( char *)p; char b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READFIXED(p) ({ fixed_t *p_tmp = (fixed_t *)p; fixed_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = *p_tmp; p_tmp++; p = (void *)p_tmp; b; }) +#endif +#else #define READUINT8(p) *(( UINT8 *)p)++ #define READSINT8(p) *(( SINT8 *)p)++ #define READINT16(p) *(( INT16 *)p)++ @@ -120,6 +148,8 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr) #define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b = readulong(p); p_tmp++; p = (void *)p_tmp; b; }) #endif //SRB2_BIG_ENDIAN +#undef DEALIGNED + #define WRITESTRINGN(p, s, n) ({ \ size_t tmp_i; \ \ -- 2.54.0 From d24bcc9fd700c11842ec917b411093922eb386b9 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 20:01:46 +0200 Subject: [PATCH 36/63] fix NOHW compile --- src/p_slopes.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/p_slopes.c b/src/p_slopes.c index 2b52d6153..38201ad86 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -40,7 +40,11 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope) if (slope->normal.z == 0) { - slope->lightOffset = slope->hwLightOffset = 0; + + slope->lightOffset = 0; +#ifdef HWRENDER + slope->hwLightOffset = 0; +#endif return; } -- 2.54.0 From f36ac0bb4bf6dee24b1e5640856e81f381631c45 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 17 Aug 2024 20:03:35 +0200 Subject: [PATCH 37/63] this should not be in HWRENDER ifdef --- src/m_menu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 52955f1c5..897016b2b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5341,6 +5341,7 @@ static void M_DrawGenericScrollMenu(void) coolalphatimer--; } } +#endif if (currentMenu == &OP_ExpOptionsDef) { @@ -5351,7 +5352,7 @@ static void M_DrawGenericScrollMenu(void) coolalphatimer--; } } -#endif + if (currentMenu == &OP_SaturnDef) { -- 2.54.0 From 76ed4aae121735793acae72180e1be4b3eb972d1 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 18:10:52 +0200 Subject: [PATCH 38/63] forgor speedo doesent draw in splitscreen + change offsets --- src/k_kart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7ed4f5482..e3cf249b2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8924,12 +8924,12 @@ static void K_drawKartBumpersOrKarma(void) fy = info.y; fflags = info.flags; - if (cv_battlespeedo.value) + if (cv_battlespeedo.value && !splitscreen) { if ((cv_newspeedometer.value == 2 && xtra_speedo) || (cv_newspeedometer.value == 3 && achi_speedo) || (cv_newspeedometer.value == 5 && xtra_speedo3)) - fy -= -10; + fy += 5; else - fy -= -14; + fy += 7; } if (splitscreen > 1) -- 2.54.0 From 3e245d49d8ac8d4d0f642a42010d4da4546fa2eb Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 18:34:37 +0200 Subject: [PATCH 39/63] super tiny cleanup m_menu again --- src/m_menu.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 6a888b0f7..4d69efe49 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1053,7 +1053,6 @@ static menuitem_t MP_MainMenu[] = }; #ifndef NONET - static menuitem_t MP_ServerMenu[] = { {IT_STRING|IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 10}, @@ -1069,7 +1068,6 @@ static menuitem_t MP_ServerMenu[] = {IT_WHITESTRING|IT_CALL, NULL, "Start", M_StartServer, 130}, }; - #endif // Separated offline and normal servers. @@ -1088,9 +1086,6 @@ static menuitem_t MP_PlayerSetupMenu[] = {IT_KEYHANDLER | IT_STRING, NULL, "Color", M_HandleSetupMultiPlayer, 152}, }; - - - #ifndef NONET static menuitem_t MP_ConnectMenu[] = { @@ -1895,7 +1890,6 @@ static menuitem_t OP_ServerOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "Server Name", &cv_servername, 10}, #endif - {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 40}, {IT_STRING | IT_CVAR, NULL, "Map Progression", &cv_advancemap, 50}, {IT_STRING | IT_CVAR, NULL, "Voting Timer", &cv_votetime, 60}, @@ -1935,13 +1929,10 @@ static const char* OP_ServerOptionsTooltips[] = static menuitem_t OP_AdvServerOptionsMenu[] = { #ifndef MASTERSERVER - {IT_GRAYEDOUT, - - NULL, "Server Browser Address", NULL, 10}, + {IT_GRAYEDOUT, NULL, "Server Browser Address", NULL, 10}, #else {IT_STRING | IT_CVAR | IT_CV_STRING, - - NULL, "Server Browser Address", &cv_masterserver, 10}, + NULL, "Server Browser Address", &cv_masterserver, 10}, #endif {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 40}, {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 50}, -- 2.54.0 From 594931e07e288917acbd790856e8ceeab685d619 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 23 Aug 2024 15:44:28 +0200 Subject: [PATCH 40/63] when looking back camera momentum should inherit the mom of the player makes using shoes or any boost stuff less jarring when looking back --- src/p_user.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 6aa3ee7a7..14d60ddbd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3888,6 +3888,15 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { thiscam->momx = x - thiscam->x; thiscam->momy = y - thiscam->y; + + // when looking back, camera's momentum + // should inherit the momentum of the player + if (lookback && lookbackdelay[num]) + { + thiscam->momx += mo->momx; + thiscam->momy += mo->momy; + } + thiscam->momz = FixedMul(z - thiscam->z, camspeed/2); } -- 2.54.0 From 783ce7bada0afb8ce0aafe0d95007f1b47c27aff Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 31 Aug 2024 18:45:29 +0200 Subject: [PATCH 41/63] give camera lookback a toggle + extra option --- src/p_local.h | 2 ++ src/p_user.c | 10 +++++++--- src/r_main.c | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 725aa20d1..4eb927a58 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -144,6 +144,8 @@ extern consvar_t cv_tiltsmoothing; extern consvar_t cv_actionmovie; +extern consvar_t cv_lookbackmom; + extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate; extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate; extern fixed_t t_cam3_dist, t_cam3_height, t_cam3_rotate; diff --git a/src/p_user.c b/src/p_user.c index 14d60ddbd..f9d909cd5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3073,6 +3073,9 @@ consvar_t cv_tiltsmoothing = {"tiltsmoothing", "32", CV_SAVE, CV_Natural, NULL, consvar_t cv_actionmovie = {"actionmovie", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t lookbackmom_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Extra Momentum"}, {0, NULL}}; +consvar_t cv_lookbackmom = {"cameralookbackmom", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + fixed_t t_cam_dist = -42; fixed_t t_cam_height = -42; fixed_t t_cam_rotate = -42; @@ -3891,10 +3894,11 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // when looking back, camera's momentum // should inherit the momentum of the player - if (lookback && lookbackdelay[num]) + // if value is 2, add extra + if (cv_lookbackmom.value && lookback && lookbackdelay[num]) { - thiscam->momx += mo->momx; - thiscam->momy += mo->momy; + thiscam->momx += cv_lookbackmom.value*mo->momx; + thiscam->momy += cv_lookbackmom.value*mo->momy; } thiscam->momz = FixedMul(z - thiscam->z, camspeed/2); diff --git a/src/r_main.c b/src/r_main.c index e6247ceae..abf2d8310 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1959,6 +1959,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_tiltsmoothing); CV_RegisterVar(&cv_actionmovie); + CV_RegisterVar(&cv_lookbackmom); + CV_RegisterVar(&cv_driftsparkpulse); CV_RegisterVar(&cv_gravstretch); CV_RegisterVar(&cv_sloperoll); -- 2.54.0 From 5efb0c7136143cbfcc61b7c90b3aadc6de8cd838 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 19:23:35 +0200 Subject: [PATCH 42/63] put saturn specific join allow stuff behind SATURNJOIN define so it can be seperate from SATURNPAK --- src/d_clisrv.c | 17 +++++++++-------- src/d_clisrv.h | 4 ++-- src/d_netcmd.c | 2 +- src/doomdef.h | 8 +++++++- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7ab921aaf..2534a51e5 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -147,6 +147,9 @@ static boolean cl_redownloadinggamestate = false; #ifdef SATURNPAK boolean is_client_saturn[MAXNETNODES]; +#endif + +#ifdef SATURNJOIN #define ISSATURN 69 #endif @@ -1444,7 +1447,7 @@ static boolean CL_SendJoin(void) netbuffer->u.clientcfg.subversion = SUBVERSION; strncpy(netbuffer->u.clientcfg.application, SRB2APPLICATION, sizeof netbuffer->u.clientcfg.application); -#ifdef SATURNPAK +#ifdef SATURNJOIN netbuffer->u.clientcfg.issaturn = ISSATURN; #endif @@ -4048,7 +4051,7 @@ consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accept consvar_t cv_allownewplayer = {"allowjoin", "On", CV_SAVE|CV_CALL, CV_OnOff, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; -#ifdef SATURNPAK +#ifdef SATURNJOIN consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_SAVE|CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif @@ -4097,7 +4100,7 @@ static void Joinable_OnChange(void) if (!server) return; -#ifdef SATURNPAK +#ifdef SATURNJOIN // disabling joins should also disable saturn joins unless its called with CV_StealthSet and vice versa to make life a bit easier if (!cv_allownewplayer.value) CV_Set(&cv_allownewsaturnplayer, "Off"); @@ -4716,7 +4719,7 @@ static void HandleConnect(SINT8 node) { SV_SendRefuse(node, va(M_GetText("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)"), VERSION, SUBVERSION)); } -#ifdef SATURNPAK +#ifdef SATURNJOIN else if ((!cv_allownewplayer.value && node && netbuffer->u.clientcfg.issaturn != ISSATURN) || (!cv_allownewsaturnplayer.value && node && netbuffer->u.clientcfg.issaturn == ISSATURN)) #else else if (!cv_allownewplayer.value && node) @@ -5088,7 +5091,6 @@ static void HandlePacketFromAwayNode(SINT8 node) #ifdef SATURNPAK SendSaturnInfo(node); #endif - memset(playeringame, 0, sizeof(playeringame)); for (j = 0; j < MAXPLAYERS; j++) { @@ -6532,13 +6534,12 @@ void NetKeepAlive(void) MasterClient_Ticker(); #endif - #ifdef HOLEPUNCH +#ifdef HOLEPUNCH if (netgame && serverrunning) { RenewHolePunch(); } - #endif - +#endif if (client) { diff --git a/src/d_clisrv.h b/src/d_clisrv.h index b5ad26eea..ed657d75c 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -371,7 +371,7 @@ typedef struct UINT8 subversion; // Contains build version UINT8 localplayers; // number of splitscreen players UINT8 mode; -#ifdef SATURNPAK +#ifdef SATURNJOIN UINT8 issaturn; #endif } ATTRPACK clientconfig_pak; @@ -579,7 +579,7 @@ extern consvar_t cv_joinnextround, #endif cv_netticbuffer, cv_allownewplayer, -#ifdef SATURNPAK +#ifdef SATURNJOIN cv_allownewsaturnplayer, #endif cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, cv_resynchcooldown, cv_gamestateattempts, cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4ca65e956..9852307c1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -795,7 +795,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_httpsource); #ifndef NONET CV_RegisterVar(&cv_allownewplayer); -#ifdef SATURNPAK +#ifdef SATURNJOIN CV_RegisterVar(&cv_allownewsaturnplayer); #endif CV_RegisterVar(&cv_joinrefusemessage); diff --git a/src/doomdef.h b/src/doomdef.h index 37e553816..d8092d83c 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -568,10 +568,16 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! +//-- SATURN __\\ /// Server detection for if a connecting client is on Saturn. -/// For stuff like extra synching, joinblock, etc. +/// For stuff like extra synching, etc. //#define SATURNPAK +/// Detect if a client is on Saturn in the clientconfig. +/// To seperately allow them to join or block joining from vanilla clients. +//#define SATURNJOIN +//-- <( ̄︶ ̄)> __\\ + /// Undefine to use the new method of Gamma correction see colour cube in v_video.c #define BACKWARDSCOMPATCORRECTION -- 2.54.0 From 65e66e8ace90e590f4f455fe1d68a2be51501c27 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 19:52:04 +0200 Subject: [PATCH 43/63] oops --- src/doomdef.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index d8092d83c..98357cea6 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -568,7 +568,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! -//-- SATURN __\\ +//-- SATURN __ /// Server detection for if a connecting client is on Saturn. /// For stuff like extra synching, etc. //#define SATURNPAK @@ -576,7 +576,7 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Detect if a client is on Saturn in the clientconfig. /// To seperately allow them to join or block joining from vanilla clients. //#define SATURNJOIN -//-- <( ̄︶ ̄)> __\\ +//-- <( ̄︶ ̄)> __ /// Undefine to use the new method of Gamma correction see colour cube in v_video.c #define BACKWARDSCOMPATCORRECTION -- 2.54.0 From 6df675523f189fa69107e7937f8d7f64394851b7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 19:55:22 +0200 Subject: [PATCH 44/63] hide gamestate resynch stuff behind SATURNSYNCH ifdef --- src/d_clisrv.c | 86 +++++++++++++++++++++++++++++++++++++++++++++----- src/d_clisrv.h | 10 +++++- src/d_net.c | 3 +- src/d_netcmd.c | 2 ++ src/doomdef.h | 5 +++ src/g_game.c | 6 +++- src/hu_stuff.c | 12 +++++-- src/m_menu.c | 6 ++-- 8 files changed, 115 insertions(+), 15 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2534a51e5..03d3166ec 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -93,8 +93,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; @@ -126,11 +128,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; @@ -143,15 +146,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 @@ -189,7 +197,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}; @@ -1898,7 +1905,6 @@ static void SV_SavedGame(void) #endif #define TMPSAVENAME "$$$.sav" - static void CL_LoadReceivedSavegame(boolean reloading) { UINT8 *savebuffer = NULL; @@ -1958,6 +1964,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) @@ -1965,8 +1972,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; @@ -1990,6 +1999,7 @@ static void CL_ReloadReceivedSavegame(void) CONS_Printf(M_GetText("Game state reloaded\n")); } #endif +#endif #ifndef NONET static void SendAskInfo(INT32 node) @@ -3210,7 +3220,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); } @@ -4014,6 +4026,7 @@ static void Command_list_http_logins (void) } #endif/*HAVE_CURL*/ +#ifdef SATURNSYNCH static void Command_ResendGamestate(void) { SINT8 playernum; @@ -4041,6 +4054,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}; @@ -4069,11 +4083,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) @@ -4133,7 +4150,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 @@ -4193,9 +4212,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 // } @@ -4232,7 +4253,9 @@ void SV_ResetServer(void) mynode = 0; cl_packetmissed = false; +#ifdef SATURNSYNCH cl_redownloadinggamestate = false; +#endif if (dedicated) { @@ -4762,7 +4785,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); @@ -4862,7 +4885,7 @@ static void HandleServerInfo(SINT8 node) } #endif - +#ifdef SATURNSYNCH static void PT_WillResendGamestate(void) { char tmpsave[264]; @@ -4885,7 +4908,6 @@ static void PT_WillResendGamestate(void) I_Error("Can't delete %s\n", tmpsave); CL_PrepareDownloadSaveGame(tmpsave); - cl_redownloadinggamestate = true; } @@ -4899,6 +4921,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 * @@ -5328,6 +5351,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]--; @@ -5383,6 +5407,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; @@ -5520,7 +5581,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: @@ -5690,6 +5753,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); @@ -5702,6 +5766,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)); @@ -6661,15 +6726,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 { @@ -6678,7 +6746,9 @@ void NetUpdate(void) INT32 counts; hu_resynching = false; +#ifdef SATURNSYNCH hu_redownloadinggamestate = false; +#endif firstticstosend = gametic; for (i = 0; i < MAXNETNODES; i++) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index ed657d75c..5376abc43 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -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 { diff --git a/src/d_net.c b/src/d_net.c index 2f60eb3d4..4731ffcc3 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -837,10 +837,11 @@ const char *packettypename[NUMPACKETTYPE] = #ifdef SATURNPAK "ISSATURN", #endif - +#ifdef SATURNSYNCH "WILLRESENDGAMESTATE", "CANRECEIVEGAMESTATE", "RECEIVEDGAMESTATE" +#endif }; const char *Net_GetPacketName(UINT8 packettype) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9852307c1..033c94199 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -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); diff --git a/src/doomdef.h b/src/doomdef.h index 98357cea6..54429b30d 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -569,6 +569,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 diff --git a/src/g_game.c b/src/g_game.c index 060b2e9e3..8e047b78b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -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); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index d363ce73b..0594d28cd 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -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; diff --git a/src/m_menu.c b/src/m_menu.c index 83ed04ea7..4c8718847 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2027,8 +2027,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}, @@ -2041,15 +2043,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.", -- 2.54.0 From d9affe2331fe9f4813018399704aae362dd7a995 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 19:59:39 +0200 Subject: [PATCH 45/63] oops again --- src/d_clisrv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 03d3166ec..dc62f8520 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -155,11 +155,9 @@ static boolean cl_redownloadinggamestate = false; boolean is_client_saturn[MAXNETNODES]; #endif -#ifdef SATURNSYNCH #ifdef SATURNJOIN #define ISSATURN 69 #endif -#endif static UINT8 localtextcmd[MAXTEXTCMD]; static UINT8 localtextcmd2[MAXTEXTCMD]; // splitscreen -- 2.54.0 From 406037dabec1d9a9ae674ed6df61baace593735b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 20:06:49 +0200 Subject: [PATCH 46/63] menu offset stuff for if not using SATURNSYNCH --- src/m_menu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index 4c8718847..df30c38f5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2030,7 +2030,7 @@ static menuitem_t OP_AdvServerOptionsMenu[] = #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}, @@ -2042,6 +2042,19 @@ static menuitem_t OP_AdvServerOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 150}, {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 160}, {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 170}, +#else + {IT_STRING | IT_CVAR, NULL, "Delay limit (frames)", &cv_maxping, 50}, + {IT_STRING | IT_CVAR, NULL, "Delay timeout (s)", &cv_pingtimeout, 60}, + {IT_STRING | IT_CVAR, NULL, "Connection timeout (tics)", &cv_nettimeout, 70}, + {IT_STRING | IT_CVAR, NULL, "Join timeout (tics)", &cv_jointimeout, 80}, + + {IT_STRING | IT_CVAR, NULL, "Max. file transfer send (KB)", &cv_maxsend, 100}, + {IT_STRING | IT_CVAR, NULL, "File transfer packet rate", &cv_downloadspeed, 110}, + + {IT_STRING | IT_CVAR, NULL, "Log join addresses", &cv_showjoinaddress, 130}, + {IT_STRING | IT_CVAR, NULL, "Log resyncs", &cv_blamecfail, 140}, + {IT_STRING | IT_CVAR, NULL, "Log file transfers", &cv_noticedownload, 150}, +#endif }; static const char* OP_AdvServerOptionsTooltips[] = -- 2.54.0 From c9c0c06763701f25faeffa88c69f0f107b446cf6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 20:36:20 +0200 Subject: [PATCH 47/63] reserve saturn packet even if unused to not cause any weird isssues if either one is undefined and stuff like that --- src/d_clisrv.h | 5 ++--- src/d_net.c | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 5376abc43..bd4d25c8a 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -99,13 +99,12 @@ typedef enum PT_PING, // Packet sent to tell clients the other client's latency to server. -#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! + + PT_ISSATURN, #endif NUMPACKETTYPE diff --git a/src/d_net.c b/src/d_net.c index 4731ffcc3..e73a120ab 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -832,15 +832,15 @@ const char *packettypename[NUMPACKETTYPE] = "TELLFILESNEEDED", "MOREFILESNEEDED", - "PING", - -#ifdef SATURNPAK - "ISSATURN", -#endif + "PING" #ifdef SATURNSYNCH + , + "WILLRESENDGAMESTATE", "CANRECEIVEGAMESTATE", - "RECEIVEDGAMESTATE" + "RECEIVEDGAMESTATE", + + "ISSATURN" #endif }; -- 2.54.0 From 915b4e9d15609164f2b32c9a36c27cf21b69ed7e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 21:02:16 +0200 Subject: [PATCH 48/63] set netgame save stuff to false for replays to retain max vanilla compat for replays dont want those breaking between clients --- src/d_clisrv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index dc62f8520..4a016796f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1881,7 +1881,7 @@ static void SV_SavedGame(void) return; } - P_SaveNetGame(); + P_SaveNetGame(false); length = save_p - savebuffer; if (length > SAVEGAMESIZE) @@ -6848,7 +6848,7 @@ rewind_t *CL_SaveRewindPoint(size_t demopos) return NULL; save_p = rewind->savebuffer; - P_SaveNetGame(true); + P_SaveNetGame(false); rewind->leveltime = leveltime; rewind->next = rewindhead; rewind->demopos = demopos; @@ -6872,7 +6872,7 @@ rewind_t *CL_RewindToTime(tic_t time) return NULL; save_p = rewindhead->savebuffer; - P_LoadNetGame(true); + P_LoadNetGame(false); wipegamestate = gamestate; // No fading back in! timeinmap = leveltime; -- 2.54.0 From 51b79e58d3450ab881a861fd4fe9cee62507f480 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 21:05:21 +0200 Subject: [PATCH 49/63] smol cleanup + add comments --- src/d_clisrv.c | 12 ++++++------ src/d_clisrv.h | 3 ++- src/d_net.c | 1 + src/doomdef.h | 8 ++++---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 4a016796f..9140d49b6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5745,12 +5745,6 @@ static void HandlePacketFromPlayer(SINT8 node) if (client) Got_Filetxpak(); break; -#ifdef SATURNPAK - case PT_ISSATURN: - //CONS_Printf("hi im on saturn\n"); - is_client_saturn[node] = true; - break; -#endif #ifdef SATURNSYNCH case PT_CANRECEIVEGAMESTATE: can_receive_gamestate[node] = true; @@ -5764,6 +5758,12 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_WILLRESENDGAMESTATE: PT_WillResendGamestate(); break; +#endif +#ifdef SATURNPAK + case PT_ISSATURN: + //CONS_Printf("hi im on saturn&d\n", node); + is_client_saturn[node] = true; + break; #endif default: DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", diff --git a/src/d_clisrv.h b/src/d_clisrv.h index bd4d25c8a..cc123b1d2 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -104,7 +104,8 @@ typedef enum 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! - PT_ISSATURN, + // we will reserve this for now even if unused, so order wont get mangled + PT_ISSATURN, // Saturn specific identifier packet #endif NUMPACKETTYPE diff --git a/src/d_net.c b/src/d_net.c index e73a120ab..ad031a76b 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -840,6 +840,7 @@ const char *packettypename[NUMPACKETTYPE] = "CANRECEIVEGAMESTATE", "RECEIVEDGAMESTATE", + // we will reserve this for now even if unused, so order wont get mangled "ISSATURN" #endif }; diff --git a/src/doomdef.h b/src/doomdef.h index 54429b30d..719900ced 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -574,13 +574,13 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Still highly experimental //#define SATURNSYNCH -/// Server detection for if a connecting client is on Saturn. -/// For stuff like extra synching, etc. -//#define SATURNPAK - /// Detect if a client is on Saturn in the clientconfig. /// To seperately allow them to join or block joining from vanilla clients. //#define SATURNJOIN + +/// Server detection for if a connecting client is on Saturn. +/// For stuff like extra synching, etc. +//#define SATURNPAK //-- <( ̄︶ ̄)> __ /// Undefine to use the new method of Gamma correction see colour cube in v_video.c -- 2.54.0 From 750f305c46c80e05771b6d294f0b1aca3851198c Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 21:06:00 +0200 Subject: [PATCH 50/63] % --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 9140d49b6..369b42f5c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5761,7 +5761,7 @@ static void HandlePacketFromPlayer(SINT8 node) #endif #ifdef SATURNPAK case PT_ISSATURN: - //CONS_Printf("hi im on saturn&d\n", node); + //CONS_Printf("hi im on saturn%d\n", node); is_client_saturn[node] = true; break; #endif -- 2.54.0 From 2d61f5c861cd2311063f78d91d2ff49be85cccc7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Sep 2024 21:41:46 +0200 Subject: [PATCH 51/63] add compiler flags NOSATURNSYNCH, NOSATURNJOIN and NOSATURNPAK not building with SATURNSYNCH also will disable SATURNJOIN since it makes not much sense to have that when synch stuff is unused --- src/Makefile | 24 ++++++++++++++++++++++++ src/doomdef.h | 12 ++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 72f82265b..4668518b9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -207,6 +207,18 @@ USE_FBO_OGL=1 endif endif +ifndef NONET +ifndef NOSATURNSYNCH +DOSATURNSYNCH=1 +ifndef NOSATURNJOIN +DOSATURNJOIN=1 +endif +#ifndef NOSATURNPAK +#DOSATURNPAK=1 +#endif +endif +endif + ifdef MINGW include win32/Makefile.cfg endif #ifdef MINGW @@ -386,6 +398,18 @@ OPTS+=-DUSE_FBO_OGL endif endif +ifndef NONET +ifndef NOSATURNSYNCH +OPTS+=-DDOSATURNSYNCH +ifndef NOSATURNJOIN +OPTS+=-DDOSATURNJOIN +endif +#ifndef NOSATURNPAK +#OPTS+=-DDOSATURNPAK +#endif +endif +endif + ifdef HAVE_MINIUPNPC ifdef NONET HAVE_MINIUPNPC='' diff --git a/src/doomdef.h b/src/doomdef.h index 719900ced..9aba9b5c5 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -568,20 +568,28 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; // None of these that are disabled in the normal build are guaranteed to work perfectly // Compile them at your own risk! +#ifndef NONET //-- SATURN __ /// Enable gamestate resynching between Saturn servers and clients /// Like SRB2 and RR does /// Still highly experimental -//#define SATURNSYNCH +#ifdef DOSATURNSYNCH +#define SATURNSYNCH /// Detect if a client is on Saturn in the clientconfig. /// To seperately allow them to join or block joining from vanilla clients. -//#define SATURNJOIN +#ifdef DOSATURNJOIN +#define SATURNJOIN +#endif +#endif /// Server detection for if a connecting client is on Saturn. /// For stuff like extra synching, etc. +//#ifdef DOSATURNPAK //#define SATURNPAK +//#endif //-- <( ̄︶ ̄)> __ +#endif /// Undefine to use the new method of Gamma correction see colour cube in v_video.c #define BACKWARDSCOMPATCORRECTION -- 2.54.0 From f9210ee3bc9a634ae3a39cd9216d58ba399eca0c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 15:35:17 +0200 Subject: [PATCH 52/63] smol fixes for gamestate resend in P_SetupLevel - dont reset cameras during gamestate resynch - dont reinit director during gamesate resynch - dont reset view interpolators aswell - dont reset localaiming aswell should make resynching less jarring visually hopefully --- src/p_setup.c | 83 ++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index a21fd5f12..b3ba07e4d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2196,8 +2196,6 @@ static void P_LevelInitStuff(boolean reloadinggamestate) leveltime = 0; - memset(localaiming, 0, sizeof(localaiming)); - // map object scale mapobjectscale = mapheaderinfo[gamemap-1]->mobj_scale; @@ -2334,6 +2332,8 @@ void P_LoadThingsOnly(void) P_LevelInitStuff(false); + memset(localaiming, 0, sizeof(localaiming)); + P_PrepareRawThings(vth->data); P_LoadThings(); @@ -2620,30 +2620,36 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) } } +static void P_InitCamera(void) +{ + INT32 i; + + if (!dedicated) + { + if (!demo.freecam) + for (i = 0; i <= splitscreen; i++) + P_SetupCamera(displayplayers[i], &camera[i]); + + // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P + if (!cv_cam_rotate.changed) + CV_Set(&cv_cam_rotate, cv_cam_rotate.defaultvalue); + + if (!cv_cam2_rotate.changed) + CV_Set(&cv_cam2_rotate, cv_cam2_rotate.defaultvalue); + + if (!cv_cam3_rotate.changed) + CV_Set(&cv_cam3_rotate, cv_cam3_rotate.defaultvalue); + + if (!cv_cam4_rotate.changed) + CV_Set(&cv_cam4_rotate, cv_cam4_rotate.defaultvalue); + + displayplayers[0] = consoleplayer; // Start with your OWN view, please! + } +} + static boolean P_CanSave(void) { -#if 0 - // Saving is completely ignored under these conditions: - if ((cursaveslot < 0) // Playing without saving - || (modifiedgame && !savemoddata) // Game is modified - || (netgame || multiplayer) // Not in single-player - || (demo.playback || demo.recording || metalrecording) // Currently in demo - || (players[consoleplayer].lives <= 0) // Completely dead - || (modeattacking || ultimatemode || G_IsSpecialStage(gamemap))) // Specialized instances - return false; - - if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_ALWAYS) - return true; // Saving should ALWAYS happen! - else if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_NEVER) - return false; // Saving should NEVER happen! - - // Default condition: In a non-hidden map, at the beginning of a zone or on a completed save-file, and not on save reload. - return (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) - && (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete) - && (gamemap != lastmapsaved)); -#else return false; // SRB2Kart: no SP, no saving. -#endif } /** Loads a level from a lump or external wad. @@ -2795,7 +2801,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) // But only if we didn't do the encore startup wipe if (!ranspecialwipe && !demo.rewinding && !reloadinggamestate) { - if(rendermode != render_none) + if (rendermode != render_none) { F_WipeStartScreen(); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); @@ -3015,8 +3021,6 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) G_BeginRecording(); //this has to move here, since dedicated servers dont run got_mapcmd } - K_InitDirector(); - wantedcalcdelay = wantedfrequency*2; indirectitemcooldown = 0; hyubgone = 0; @@ -3052,26 +3056,11 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) // landing point for netgames. netgameskip: - if (!dedicated) + if (!reloadinggamestate) { - if (!demo.freecam) - for (i = 0; i <= splitscreen; i++) - P_SetupCamera(displayplayers[i], &camera[i]); - - // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P - if (!cv_cam_rotate.changed) - CV_Set(&cv_cam_rotate, cv_cam_rotate.defaultvalue); - - if (!cv_cam2_rotate.changed) - CV_Set(&cv_cam2_rotate, cv_cam2_rotate.defaultvalue); - - if (!cv_cam3_rotate.changed) - CV_Set(&cv_cam3_rotate, cv_cam3_rotate.defaultvalue); - - if (!cv_cam4_rotate.changed) - CV_Set(&cv_cam4_rotate, cv_cam4_rotate.defaultvalue); - - displayplayers[0] = consoleplayer; // Start with your OWN view, please! + P_InitCamera(); + memset(localaiming, 0, sizeof(localaiming)); + K_InitDirector(); } // clear special respawning que @@ -3080,7 +3069,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) P_MapEnd(); // Remove the loading shit from the screen - if (rendermode != render_none && (!reloadinggamestate)) + if (rendermode != render_none && !reloadinggamestate) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); if (precache || dedicated) @@ -3127,7 +3116,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) LUAh_MapLoad(); } - if (rendermode != render_none) + if (rendermode != render_none && !reloadinggamestate) { R_ResetViewInterpolation(0); R_ResetViewInterpolation(0); -- 2.54.0 From 62fae0ad8bb4877fdc42581482f2417cb53838f5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 15:55:44 +0200 Subject: [PATCH 53/63] dont print "Map is now" everytime you resynch from gamestate resend --- src/d_clisrv.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 369b42f5c..8a6b502d1 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1940,18 +1940,21 @@ static void CL_LoadReceivedSavegame(boolean reloading) // load a base level if (P_LoadNetGame(reloading)) { - CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap))); - if (strlen(mapheaderinfo[gamemap-1]->lvlttl) > 0) + if (!reloading) { - CON_LogMessage(va(": %s", mapheaderinfo[gamemap-1]->lvlttl)); - if (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) - CON_LogMessage(va(" %s", mapheaderinfo[gamemap-1]->zonttl)); - else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) - CON_LogMessage(M_GetText(" Zone")); - if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) - CON_LogMessage(va(" %s", mapheaderinfo[gamemap-1]->actnum)); + CON_LogMessage(va(M_GetText("Map is now \"%s"), G_BuildMapName(gamemap))); + if (strlen(mapheaderinfo[gamemap-1]->lvlttl) > 0) + { + CON_LogMessage(va(": %s", mapheaderinfo[gamemap-1]->lvlttl)); + if (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) + CON_LogMessage(va(" %s", mapheaderinfo[gamemap-1]->zonttl)); + else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) + CON_LogMessage(M_GetText(" Zone")); + if (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) + CON_LogMessage(va(" %s", mapheaderinfo[gamemap-1]->actnum)); + } + CON_LogMessage("\"\n"); } - CON_LogMessage("\"\n"); } // done @@ -4468,7 +4471,6 @@ static void Got_RemovePlayer(UINT8 **p, INT32 playernum) if (pnum == serverplayer) { CONS_Alert(CONS_WARNING, "Attempt to remove server player\n"); - return; } -- 2.54.0 From ea985151ddf0b851b7c9e47286392635fe82375d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 15:59:10 +0200 Subject: [PATCH 54/63] dont rerun levelload executors when gamestate resent --- src/p_setup.c | 2 +- src/p_spec.c | 5 +++-- src/p_spec.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index b3ba07e4d..3b2eb1281 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2910,7 +2910,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) globalweather = mapheaderinfo[gamemap-1]->weather; // set up world state - P_SpawnSpecials(fromnetsave); + P_SpawnSpecials(fromnetsave, reloadinggamestate); if (loadprecip) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame) P_SpawnPrecipitation(); diff --git a/src/p_spec.c b/src/p_spec.c index c022ef384..0fbddd085 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5236,7 +5236,7 @@ static void P_RunLevelLoadExecutors(void) * as they'll just be erased by UnArchiveThinkers. * \sa P_SpawnPrecipitation, P_SpawnFriction, P_SpawnPushers, P_SpawnScrollers */ -void P_SpawnSpecials(INT32 fromnetsave) +void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) { sector_t *sector; size_t i; @@ -6263,7 +6263,8 @@ void P_SpawnSpecials(INT32 fromnetsave) } } - P_RunLevelLoadExecutors(); + if (!reloadinggamestate) + P_RunLevelLoadExecutors(); } /** Adds 3Dfloors as appropriate based on a common control linedef. diff --git a/src/p_spec.h b/src/p_spec.h index 1231aeda8..477dd4950 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -32,7 +32,7 @@ void P_InitPicAnims(void); void P_SetupLevelFlatAnims(void); // at map load -void P_SpawnSpecials(INT32 fromnetsave); +void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate); // every tic void P_UpdateSpecials(void); -- 2.54.0 From ef8e71cb11733fd3f55ea73de28354ab0324f507 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 16:27:22 +0200 Subject: [PATCH 55/63] set camera angle to player angle in CL_ReloadReceivedSavegame hope i did this right lol should hopefully fix more jarring visual stuffs --- src/d_clisrv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8a6b502d1..41b88714d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1993,6 +1993,11 @@ static void CL_ReloadReceivedSavegame(void) neededtic = gametic; maketic = neededtic; + for (i = 0; i <= splitscreen; i++) + { + localangle[i] = players[displayplayers[i]].mo->angle; + } + camera->subsector = R_PointInSubsector(camera->x, camera->y); cl_redownloadinggamestate = false; -- 2.54.0 From 473e8431422f5fa36059f91a181fdd1ee074c57d Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 16:46:23 +0200 Subject: [PATCH 56/63] this should use angleturn uhhh --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 41b88714d..97aecdf8f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1995,7 +1995,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i <= splitscreen; i++) { - localangle[i] = players[displayplayers[i]].mo->angle; + localangle[i] = players[displayplayers[i]].cmd.angleturn; } camera->subsector = R_PointInSubsector(camera->x, camera->y); -- 2.54.0 From e175a4e00b226851fc30d531182c8a09e8cdaa66 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 16:57:33 +0200 Subject: [PATCH 57/63] guh --- src/d_clisrv.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 97aecdf8f..03b7fa1f1 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2011,13 +2011,13 @@ static void CL_ReloadReceivedSavegame(void) static void SendAskInfo(INT32 node) { tic_t asktime; - #ifdef HOLEPUNCH +#ifdef HOLEPUNCH if (node != 0 && node != BROADCASTADDR && cv_rendezvousserver.string[0]) { I_NetRequestHolePunch(node); } - #endif +#endif asktime = I_GetTime(); @@ -5787,7 +5787,6 @@ static void GetPackets(void) { SINT8 node; // The packet sender - player_joining = false; while (HGetPacket()) @@ -6722,12 +6721,12 @@ void NetUpdate(void) MasterClient_Ticker(); // Acking the Master Server #endif - #ifdef HOLEPUNCH +#ifdef HOLEPUNCH if (netgame && serverrunning) { RenewHolePunch(); } - #endif +#endif if (client) { -- 2.54.0 From 4f532b766f405276af14f33c80286b25c3c975fc Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 17:04:00 +0200 Subject: [PATCH 58/63] this needs to be shifted --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 03b7fa1f1..3b7c08a0a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1995,7 +1995,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i <= splitscreen; i++) { - localangle[i] = players[displayplayers[i]].cmd.angleturn; + localangle[i] = players[displayplayers[i]].cmd.angleturn<<16; } camera->subsector = R_PointInSubsector(camera->x, camera->y); -- 2.54.0 From 8a8db796beeaafe1bc1a532c73bf841170d5c005 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 7 Sep 2024 17:30:00 +0200 Subject: [PATCH 59/63] Show a console error if the gamestate contains too many tables --- src/d_clisrv.c | 1 - src/lua_script.c | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3b7c08a0a..8c10bcf55 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2642,7 +2642,6 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic // Call it only once by tic if (*oldtic != I_GetTime()) { - INT32 key; I_OsPolling(); diff --git a/src/lua_script.c b/src/lua_script.c index c4a0df135..9d5bef4a7 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -670,8 +670,17 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) lua_pop(gL, 1); } if (!found) + { t++; + if (t == 0) + { + CONS_Alert(CONS_ERROR, "Too many tables to archive!\n"); + WRITEUINT8(save_p, ARCH_NULL); + return 0; + } + } + WRITEUINT8(save_p, ARCH_TABLE); WRITEUINT16(save_p, t); -- 2.54.0 From c49aae8d497705243a0cfd04744da08324ba81d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 13:20:49 +0200 Subject: [PATCH 60/63] no need to save saturnjoin value + smol cleanup --- src/d_clisrv.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8c10bcf55..6b569af04 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4071,7 +4071,7 @@ consvar_t cv_joinrefusemessage = {"joinrefusemessage", "The server is not accept consvar_t cv_allownewplayer = {"allowjoin", "On", CV_SAVE|CV_CALL, CV_OnOff, Joinable_OnChange, 0, NULL, NULL, 0, 0, NULL}; #ifdef SATURNJOIN -consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_SAVE|CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_allownewsaturnplayer = {"allowsaturnjoin", "On", CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif #ifdef VANILLAJOINNEXTROUND @@ -4124,10 +4124,7 @@ static void Joinable_OnChange(void) #ifdef SATURNJOIN // disabling joins should also disable saturn joins unless its called with CV_StealthSet and vice versa to make life a bit easier - if (!cv_allownewplayer.value) - CV_Set(&cv_allownewsaturnplayer, "Off"); - else if (cv_allownewplayer.value) - CV_Set(&cv_allownewsaturnplayer, "On"); + CV_SetValue(&cv_allownewsaturnplayer, cv_allownewplayer.value); #endif maxplayer = (UINT8)(min((dedicated ? MAXPLAYERS-1 : MAXPLAYERS), cv_maxplayers.value)); -- 2.54.0 From 1a16012a5c7547875b530b8e5c0ee6f90270e7e7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 13:22:43 +0200 Subject: [PATCH 61/63] this used to be const --- src/d_clisrv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6b569af04..abe821494 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1758,7 +1758,7 @@ static boolean SV_SendServerConfig(INT32 node) CV_SavePlayerNames(&p); CV_SaveNetVars(&p, false); - size_t len = sizeof (serverconfig_pak) + (size_t)(p - op); + const size_t len = sizeof (serverconfig_pak) + (size_t)(p - op); #ifdef DEBUGFILE if (debugfile) -- 2.54.0 From dd39a444f25d9bcc6783d12bdad291298d2c2241 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 13 Sep 2024 13:30:23 +0200 Subject: [PATCH 62/63] add smol comment --- src/d_clisrv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index abe821494..b6eb9930b 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1993,6 +1993,7 @@ static void CL_ReloadReceivedSavegame(void) neededtic = gametic; maketic = neededtic; + // set camera angle to somewhat match where your player is turning for (i = 0; i <= splitscreen; i++) { localangle[i] = players[displayplayers[i]].cmd.angleturn<<16; -- 2.54.0 From accef8f1e1a5e1a3a55c922d1eb302d33627a534 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 14 Sep 2024 21:10:55 +0200 Subject: [PATCH 63/63] version change --- src/doomdef.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 9aba9b5c5..bdc82a0ca 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -128,11 +128,11 @@ extern char logfilename[1024]; #define VERSION 1 // Game version #define SUBVERSION 6 // more precise version number #ifndef USE_FBO_OGL -#define VERSIONSTRING "Saturn v7 - Test " -#define VERSIONSTRINGW L"Saturn v7 - Test" +#define VERSIONSTRING "Saturn v7" +#define VERSIONSTRINGW L"Saturn v7" #else -#define VERSIONSTRING "Saturn v7 - Test - FBO " -#define VERSIONSTRINGW L"Saturn v7 - Test - FBO" +#define VERSIONSTRING "Saturn v7 - FBO " +#define VERSIONSTRINGW L"Saturn v7 - FBO" #endif // Hey! If you change this, add 1 to the MODVERSION below! Otherwise we can't force updates! // And change CMakeLists.txt (not src/, but in root), for CMake users! -- 2.54.0