From 4c8899b373bf12aec4f837132ad473a76be630c4 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Tue, 5 May 2026 00:37:01 -0400 Subject: [PATCH] Revert "DUMPCONSISTENCY for the modern age" This reverts commit 40dc3de4684b4852f9b4273848b9c6e4c4b1aa36. --- src/d_clisrv.c | 66 ++++++++++++++++---------------------------------- src/doomdef.h | 3 +++ src/m_misc.cpp | 6 ----- src/m_misc.h | 2 -- 4 files changed, 24 insertions(+), 53 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index dedb161c3..eb1d3b8b0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1456,20 +1456,25 @@ static void SV_SendSaveGame(INT32 node, boolean resending) freezetimeout[node] = I_GetTime() + jointimeout + length / 1024; // 1 extra tic for each kilobyte } +#ifdef DUMPCONSISTENCY +#define TMPSAVENAME "badmath.sav" static consvar_t cv_dumpconsistency = CVAR_INIT ("dumpconsistency", "Off", CV_SAVE|CV_NETVAR, CV_OnOff, NULL); -static void CL_DumpConsistency(const char *file_name) +static void SV_SavedGame(void) { size_t length; savebuffer_t save = {0}; - char tmpsave[1024]; + char tmpsave[256]; - snprintf(tmpsave, sizeof(tmpsave), "%s" PATHSEP "%s", srb2home, file_name); + if (!cv_dumpconsistency.value) + return; + + sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); // first save it in a malloced buffer if (P_SaveBufferAlloc(&save, NETSAVEGAMESIZE) == false) { - CONS_Alert(CONS_ERROR, M_GetText("No more free memory for consistency dump\n")); + CONS_Alert(CONS_ERROR, M_GetText("No more free memory for savegame\n")); return; } @@ -1479,18 +1484,21 @@ static void CL_DumpConsistency(const char *file_name) if (length > NETSAVEGAMESIZE) { P_SaveBufferFree(&save); - I_Error("Consistency dump buffer overrun"); + I_Error("Savegame buffer overrun"); } // then save it! if (!FIL_WriteFile(tmpsave, save.buffer, length)) - CONS_Printf(M_GetText("Didn't save %s for consistency dump"), tmpsave); + CONS_Printf(M_GetText("Didn't save %s for netgame"), tmpsave); P_SaveBufferFree(&save); } +#undef TMPSAVENAME +#endif #define TMPSAVENAME "$$$.sav" + static void CL_LoadReceivedSavegame(boolean reloading) { savebuffer_t save = {0}; @@ -1591,12 +1599,8 @@ static void CL_LoadReceivedSavegame(boolean reloading) static void CL_ReloadReceivedSavegame(void) { - if (cv_dumpconsistency.value) - { - CL_DumpConsistency("TEMP.consdump"); - } - INT32 i; + for (i = 0; i < MAXPLAYERS; i++) { LUA_InvalidatePlayer(&players[i]); @@ -1621,26 +1625,6 @@ static void CL_ReloadReceivedSavegame(void) cl_redownloadinggamestate = false; CONS_Printf(M_GetText("Game state reloaded\n")); - - if (cv_dumpconsistency.value) - { - // This is dumb, but we want the file names - // to be pairable together with the server's - // version, and gametic being randomly off - // is a deal breaker. - char dump_name[1024]; - snprintf( - dump_name, sizeof(dump_name), - "%s_%u_%s-client.consdump", - server_context, - gametic, - player_names[consoleplayer] - ); - if (FIL_RenameFile("TEMP.consdump", dump_name) == false) - { - CONS_Alert(CONS_WARNING, "Failed to rename temporary consdump file.\n"); - } - } } static void SendAskInfo(INT32 node) @@ -3646,6 +3630,9 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) if (playernode[pnum] == playernode[consoleplayer]) { +#ifdef DUMPCONSISTENCY + if (msg == KICK_MSG_CON_FAIL) SV_SavedGame(); +#endif LUA_HookBool(false, HOOK(GameQuit)); //Lua hooks handled differently now D_QuitNetGame(); @@ -3890,7 +3877,9 @@ void D_ClientServerInit(void) RegisterNetXCmd(XD_ADDPLAYER, Got_AddPlayer); RegisterNetXCmd(XD_REMOVEPLAYER, Got_RemovePlayer); RegisterNetXCmd(XD_ADDBOT, Got_AddBot); +#ifdef DUMPCONSISTENCY CV_RegisterVar(&cv_dumpconsistency); +#endif D_LoadBan(false); gametic = 0; @@ -5561,19 +5550,6 @@ static void PT_CanReceiveGamestate(SINT8 node) CONS_Printf(M_GetText("Resending game state to %s...\n"), player_names[nodetoplayer[node]]); - if (cv_dumpconsistency.value) - { - char dump_name[1024]; - snprintf( - dump_name, sizeof(dump_name), - "%s_%u_%s-server.consdump", - server_context, - gametic, - player_names[nodetoplayer[node]] - ); - CL_DumpConsistency(dump_name); - } - SV_SendSaveGame(node, true); // Resend a complete game state resendingsavegame[node] = true; } @@ -5715,8 +5691,8 @@ static void PT_WillResendGamestate(SINT8 node) { (void)node; + char tmpsave[256]; doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); - char tmpsave[1024]; if (server || cl_redownloadinggamestate) return; diff --git a/src/doomdef.h b/src/doomdef.h index 8c9ccc5da..d49664d13 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -482,6 +482,9 @@ extern int compuncommitted; /// Allows gravity changes in netgames, no questions asked. //#define NETGAME_GRAVITY +/// Dumps the contents of a network save game upon consistency failure for debugging. +//#define DUMPCONSISTENCY + /// Allow loading of savegames between different versions of the game. /// \note XMOD port. /// Most modifications should probably enable this. diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 6856c4adf..1bf37e489 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -319,12 +319,6 @@ boolean FIL_ConvertTextFileToBinary(const char *textfilename, const char *binfil return success; } -boolean FIL_RenameFile(char const *old_name, char const *new_name) -{ - int result = rename(old_name, new_name); - return (result == 0); -} - /** Check if the filename exists * * \param name Filename to check. diff --git a/src/m_misc.h b/src/m_misc.h index 318883f30..575e63225 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -52,8 +52,6 @@ size_t FIL_ReadFileTag(char const *name, UINT8 **buffer, INT32 tag); boolean FIL_ConvertTextFileToBinary(const char *textfilename, const char *binfilename); -boolean FIL_RenameFile(const char *old_name, const char *new_name); - boolean FIL_FileExists(const char *name); boolean FIL_WriteFileOK(char const *name); boolean FIL_ReadFileOK(char const *name);