From a4af2546437b033693dc5fec2ece1a6535b0e3c9 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 22 Dec 2025 20:16:04 +0100 Subject: [PATCH 1/9] Revert "dont call I_Quit from within "quit_handler", let it signal main loop to quit" This reverts commit a2feaa7fde4c2d3138cf21c40c2f8f671fac78ad. --- src/d_main.c | 3 --- src/dedicated/i_system.c | 12 ++---------- src/i_system.h | 3 +-- src/sdl/i_system.cpp | 20 +++++++++++--------- src/sdl/i_video.c | 3 +-- src/sdl/mixer_sound.c | 3 +-- 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index ab10af215..c46ef0c44 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -679,9 +679,6 @@ void D_SRB2Loop(void) for (;;) { - if (I_Interrupted()) - I_Quit(); - // capbudget is the minimum precise_t duration of a single loop iteration precise_t capbudget; precise_t elapsed; diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 5edb71a99..31eaf0346 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1075,19 +1075,11 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -static volatile sig_atomic_t interrupted = 0; - -boolean I_Interrupted(void) -{ - return interrupted; -} - -static void quit_handler(int num) +FUNCNORETURN static ATTRNORETURN void quit_handler(int num) { signal(num, SIG_DFL); //default signal action raise(num); - //I_Quit(); - interrupted = true; + I_Quit(); } #ifdef HAVE_LIBBACKTRACE diff --git a/src/i_system.h b/src/i_system.h index 68d51f022..7084c655f 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -29,6 +29,7 @@ extern "C" { */ #define MAX_QUIT_FUNCS 16 + /** \brief Graphic system had started up */ extern UINT8 graphics_started; @@ -190,8 +191,6 @@ INT32 I_StartupSystem(void); */ void I_ShutdownSystem(void); -boolean I_Interrupted(void); - /** \brief The I_GetDiskFreeSpace function \param freespace a INT64 pointer to hold the free space amount diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 8a9b8bd69..0c024a5bd 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1670,19 +1670,21 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -static volatile sig_atomic_t interrupted = 0; - -boolean I_Interrupted(void) +FUNCNORETURN static ATTRNORETURN void quit_handler(int num) { - return interrupted; -} +#ifdef HAVE_THREADS + if (g_main_thread_id != std::this_thread::get_id()) + { + // Do not attempt any sort of recovery if this signal triggers off the main thread + signal(num, SIG_DFL); + raise(num); + exit(-2); + } +#endif -static void quit_handler(int num) -{ signal(num, SIG_DFL); //default signal action raise(num); - //I_Quit(); - interrupted = true; + I_Quit(); } static void I_RegisterSignals(void) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index ae2691359..c2d87e3f1 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -2012,8 +2012,7 @@ void I_ShutdownGraphics(void) SDL_DestroyWindow(window); window = NULL; - if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO) - SDL_QuitSubSystem(SDL_INIT_VIDEO); + SDL_QuitSubSystem(SDL_INIT_VIDEO); framebuffer = SDL_FALSE; } diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index c455aab01..529b47399 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -237,8 +237,7 @@ void I_ShutdownSound(void) Mix_Quit(); #endif - if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO) - SDL_QuitSubSystem(SDL_INIT_AUDIO); + SDL_QuitSubSystem(SDL_INIT_AUDIO); #ifdef HAVE_LIBGME if (gme) From 7c848f4be561876c4b833f711fe8458cbeb66580 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 24 Dec 2025 00:54:39 +0300 Subject: [PATCH 2/9] Sort directories too in replay list --- src/m_menu.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index c2978fe82..15309dd2d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4170,8 +4170,6 @@ static int ReplayListSortComparator(const void *entry1, const void *entry2) return -1; else if (demo2->type == MD_SUBDIR && demo1->type != MD_SUBDIR) return 1; - else if (demo1->type == MD_SUBDIR && demo2->type == MD_SUBDIR) - return 0; memcpy(filepath1, demo1->filepath, sizeof(filepath1)); memcpy(filepath2, demo2->filepath, sizeof(filepath2)); From 1c95e5f40e58dabf8b22d7221e863b789327583b Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 24 Dec 2025 01:23:20 +0300 Subject: [PATCH 3/9] Actually add filepath to directories to sort them --- src/m_menu.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 15309dd2d..9a8c8bfba 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4174,8 +4174,14 @@ static int ReplayListSortComparator(const void *entry1, const void *entry2) memcpy(filepath1, demo1->filepath, sizeof(filepath1)); memcpy(filepath2, demo2->filepath, sizeof(filepath2)); - nameonly(filepath1); - nameonly(filepath2); + // nameonly will make filepath's empty for directories since they may end with PATHSEP + // this is a lazy solution but if we don't do nameonly, dirs still will be sorted in correct only, + // just not very efficently + if (demo1->type != MD_SUBDIR) + { + nameonly(filepath1); + nameonly(filepath2); + } // Comparing in opposite order to move new replays to the top return strncmp(filepath2, filepath1, sizeof(filepath1)); @@ -4211,6 +4217,9 @@ static void PrepReplayList(boolean reset) { demolist_all[i].type = MD_SUBDIR; strncpy(demolist_all[i].title, dirmenu[i] + DIR_STRING, 64); + snprintf(demolist_all[i].filepath, sizeof(demolist_all[i].filepath), + // 255 = UINT8 limit. dirmenu entries are restricted to this length (see DIR_LEN). + "%s%.255s", menupath, dirmenu[i] + DIR_STRING); } else { From 2bf4c442597768e83790e0d6688393a3a746e1c4 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 24 Dec 2025 01:36:00 +0300 Subject: [PATCH 4/9] Revert "Actually add filepath to directories to sort them" This reverts commit 1c95e5f40e58dabf8b22d7221e863b789327583b. --- 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 9a8c8bfba..15309dd2d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4174,14 +4174,8 @@ static int ReplayListSortComparator(const void *entry1, const void *entry2) memcpy(filepath1, demo1->filepath, sizeof(filepath1)); memcpy(filepath2, demo2->filepath, sizeof(filepath2)); - // nameonly will make filepath's empty for directories since they may end with PATHSEP - // this is a lazy solution but if we don't do nameonly, dirs still will be sorted in correct only, - // just not very efficently - if (demo1->type != MD_SUBDIR) - { - nameonly(filepath1); - nameonly(filepath2); - } + nameonly(filepath1); + nameonly(filepath2); // Comparing in opposite order to move new replays to the top return strncmp(filepath2, filepath1, sizeof(filepath1)); @@ -4217,9 +4211,6 @@ static void PrepReplayList(boolean reset) { demolist_all[i].type = MD_SUBDIR; strncpy(demolist_all[i].title, dirmenu[i] + DIR_STRING, 64); - snprintf(demolist_all[i].filepath, sizeof(demolist_all[i].filepath), - // 255 = UINT8 limit. dirmenu entries are restricted to this length (see DIR_LEN). - "%s%.255s", menupath, dirmenu[i] + DIR_STRING); } else { From 7518a6f181e59de80e56e707c5972926447ee871 Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 24 Dec 2025 01:36:02 +0300 Subject: [PATCH 5/9] Revert "Sort directories too in replay list" This reverts commit 7c848f4be561876c4b833f711fe8458cbeb66580. --- src/m_menu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/m_menu.c b/src/m_menu.c index 15309dd2d..c2978fe82 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4170,6 +4170,8 @@ static int ReplayListSortComparator(const void *entry1, const void *entry2) return -1; else if (demo2->type == MD_SUBDIR && demo1->type != MD_SUBDIR) return 1; + else if (demo1->type == MD_SUBDIR && demo2->type == MD_SUBDIR) + return 0; memcpy(filepath1, demo1->filepath, sizeof(filepath1)); memcpy(filepath2, demo2->filepath, sizeof(filepath2)); From c9afd4a2cd6005b0ad5308f386da39003a414cbb Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 24 Dec 2025 00:06:05 +0100 Subject: [PATCH 6/9] G_GetDemoDate: make safer and use static memory bunch of smaller issues before, no real checks for strltol and potential free on a null pointer lul also skips replays with shorter than 10 char names and handles errors better --- src/g_demo.c | 93 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index a714f8e48..312e57530 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -55,6 +55,8 @@ #include "k_stats.h" // SRB2kart #include "r_fps.h" // frame interpolation/uncapped +#include + #ifdef HAVE_DISCORDRPC #include "discord.h" #endif @@ -2401,49 +2403,69 @@ static long G_GetCreationTime(char *filepath) static char *G_GetDemoDate(menudemo_t *pdemo) { - char *datetime; - datetime = malloc(sizeof(pdemo->date)); // mallocma balls - - // no mallocma balls... :c - if (!datetime) - { - return NULL; - } - + char *endPos = NULL; + static char datetime[11]; time_t file_time = 0; + const char *format = NULL; + struct tm *tm_buf = NULL; + CLEANUP(pfree) char *filename = NULL; // get le filepath - char *filename; filename = strdup(pdemo->filepath); -#if defined (_WIN32) if (!filename) { - // if we cant get a filename try just getting the file create time +#if defined (_WIN32) + // if we cant get a filename try just getting the file creation time file_time = G_GetCreationTime(pdemo->filepath); goto skipfilenametime; - } #else - if (!filename) - { - free(datetime); return NULL; - } #endif + } // get the actual filename Zzz... nameonly(filename); - // convert it to long Zzz.... - file_time = strtol(filename, NULL, 10); - free(filename); // dont need this anymore a + // the first 10 characters of a replay name usually is a unix timestamp + + // not long enough to contain a valid timestamp + if (strlen(filename) < 10) + { +#if defined (_WIN32) + // try to get file creation time + file_time = G_GetCreationTime(pdemo->filepath); + goto skipfilenametime; +#else + return NULL; +#endif + } + +#ifndef AVOID_ERRNO + errno = 0; +#endif + // get the timestamp as actual numbers lul + file_time = strtol(filename, &endPos, 10); + + if (endPos == filename // Empty string +#ifndef AVOID_ERRNO + || errno == ERANGE // Number out-of-range +#endif + || file_time < 0) // Number is not positive + { +#if defined (_WIN32) + // just try and get the creation time then + file_time = G_GetCreationTime(pdemo->filepath); +#else + return NULL; +#endif + } #if defined (_WIN32) skipfilenametime: #endif // then throw it into localtime to get an actual human readable format lmao - struct tm *tm_buf = NULL; tm_buf = localtime(&file_time); // cant believe we ended up in 1970 @@ -2456,14 +2478,10 @@ skipfilenametime: tm_buf = localtime(&file_time); if (tm_buf == NULL || tm_buf->tm_year <= 110) - { - free(datetime); return NULL; - } goto gotcreationtime; #else - free(datetime); return NULL; #endif } @@ -2472,17 +2490,27 @@ skipfilenametime: gotcreationtime: #endif - const char *format; - // US ppl are special (: if (cv_demodateformat.value == 2) format = "%m.%d.%Y"; else if (cv_demodateformat.value == 1) format = "%d.%m.%Y"; else - format = strstr(setlocale(LC_TIME, NULL), "en_US") ? "%m.%d.%Y" : "%d.%m.%Y"; + { + const char *locale = setlocale(LC_TIME, NULL); - strftime(datetime, sizeof(pdemo->date), format, tm_buf); + if (locale == NULL) + format = "%d.%m.%Y"; // fallback to non US format + else if (strstr(locale, "en_US")) + format = "%m.%d.%Y"; + else + format = "%d.%m.%Y"; + } + + if (strftime(datetime, sizeof(datetime), format, tm_buf) == 0) + { + return NULL; + } return datetime; } @@ -2491,6 +2519,7 @@ void G_LoadDemoTitle(menudemo_t *pdemo) { UINT8 infobuffer[96], *info_p; UINT16 pdemoversion; + char *demodate = NULL; size_t count; FILE *handle = fopen(pdemo->filepath, "rb"); @@ -2529,13 +2558,13 @@ void G_LoadDemoTitle(menudemo_t *pdemo) memcpy(pdemo->title, info_p, 64); // demo date - char *demodate; demodate = G_GetDemoDate(pdemo); if (demodate) - strncpy(pdemo->date, demodate, sizeof(pdemo->date)); + { + strlcpy(pdemo->date, demodate, sizeof(pdemo->date)); + } - free(demodate); break; #ifdef DEMO_COMPAT_100 case 0x0001: From 0fe3086a5ad41d9ec61609bebbe3c7ccdcfa0cf6 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Dec 2025 18:58:41 +0100 Subject: [PATCH 7/9] Fixup the doomednum lookup properly match the old linear lookup by returning the FIRST match for doomednum also shrinks the array, doomednum max is 4095, no need for such massive array, also fixed a off by should fix some join desynchs and desynchs on certain maps --- src/d_netcmd.c | 2 -- src/info.h | 2 ++ src/p_local.h | 2 +- src/p_mobj.c | 15 +++++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 870ceba69..c669da59b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4751,8 +4751,6 @@ static void Command_LocateLump_f(void) } } -#define MAXDOOMEDNUM 4095 - static void Command_ListDoomednums_f(void) { INT16 i, j, k = 0, l = 0; diff --git a/src/info.h b/src/info.h index 4ee851cee..c84d63214 100644 --- a/src/info.h +++ b/src/info.h @@ -19,6 +19,8 @@ #include "sounds.h" #include "m_fixed.h" +#define MAXDOOMEDNUM 4095 + // dehacked.c now has lists for the more named enums! PLEASE keep them up to date! // For great modding!! diff --git a/src/p_local.h b/src/p_local.h index 4b6530eb9..3c16b5c62 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -272,7 +272,7 @@ extern consvar_t cv_gravity; void P_RespawnSpecials(void); -extern mobjtype_t g_doomednum_to_mobjtype[UINT16_MAX]; +extern mobjtype_t g_doomednum_to_mobjtype[MAXDOOMEDNUM+1]; void CalculateDoomednumToMobjtype(void); mobj_t *P_AllocateMobj(void); diff --git a/src/p_mobj.c b/src/p_mobj.c index cd7d44a62..ad7982d87 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10463,17 +10463,20 @@ void P_PrecipitationEffects(void) } } -mobjtype_t g_doomednum_to_mobjtype[UINT16_MAX]; +mobjtype_t g_doomednum_to_mobjtype[MAXDOOMEDNUM+1] = {}; void CalculateDoomednumToMobjtype(void) { memset(g_doomednum_to_mobjtype, MT_NULL, sizeof(g_doomednum_to_mobjtype)); - for (size_t i = MT_NULL+1; i < NUMMOBJTYPES; i++) + for (size_t i = 0; i < NUMMOBJTYPES; i++) { - if (mobjinfo[i].doomednum > 0 && mobjinfo[i].doomednum <= UINT16_MAX) + const INT32 doomednum = mobjinfo[i].doomednum; + + if (doomednum > 0 && doomednum <= MAXDOOMEDNUM) { - g_doomednum_to_mobjtype[ mobjinfo[i].doomednum ] = i; + if (g_doomednum_to_mobjtype[doomednum] == MT_NULL) + g_doomednum_to_mobjtype[doomednum] = (mobjtype_t)i; } } } @@ -10551,7 +10554,7 @@ void P_RespawnSpecials(void) if (mthing) { - mobjtype_t i; + mobjtype_t i = MT_NULL; x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; ss = R_PointInSubsector(x, y); @@ -10987,7 +10990,7 @@ INT32 numhuntemeralds = 0; // void P_SpawnMapThing(mapthing_t *mthing) { - mobjtype_t i; + mobjtype_t i = MT_NULL; mobj_t *mobj; fixed_t x, y, z; subsector_t *ss; From 4a3c9ccfbb81f8c11d92213be6c0ffdfd08abbdd Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 26 Dec 2025 21:36:29 +0100 Subject: [PATCH 8/9] Remove tic provision (vanilla compat edition) based on https://codeberg.org/srb2classic/srb2classic/commit/7cf14fbe740998c3246dd190904f49a236b2ccec seems to get rid of some jitter in localhost --- src/d_clisrv.c | 54 +++++++++++++------------------------------------- src/d_net.c | 3 ++- 2 files changed, 16 insertions(+), 41 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1a2717a12..ef78fe91a 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -159,7 +159,6 @@ boolean nodeingame[MAXNETNODES] = {}; // set false as nodes leave game tic_t servermaxping = 20; // server's max delay, in frames. Defaults to 20 static tic_t nettics[MAXNETNODES]; // what tic the client have received -static tic_t supposedtics[MAXNETNODES]; // nettics prevision for smaller packet static UINT8 nodewaiting[MAXNETNODES]; static tic_t firstticstosend; // min of the nettics static tic_t tictoclear = 0; // optimize d_clearticcmd @@ -186,7 +185,6 @@ boolean hu_stopped = false; // Client specific static ticcmd_t localcmds[MAXSPLITSCREENPLAYERS][MAXGENTLEMENDELAY]; -static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server @@ -4296,7 +4294,6 @@ static void ResetNode(INT32 node) playerpernode[node] = 0; nettics[node] = gametic; - supposedtics[node] = gametic; sendingsavegame[node] = false; @@ -4351,7 +4348,7 @@ void SV_ResetServer(void) ClearAdminPlayers(); mynode = 0; - cl_packetmissed = false; + #ifdef SATURNPAK cl_redownloadinggamestate = false; #endif @@ -4453,7 +4450,7 @@ void D_QuitNetGame(void) static inline void SV_AddNode(INT32 node) { nettics[node] = gametic; - supposedtics[node] = gametic; + // little hack because the server connects to itself and puts // nodeingame when connected not here if (node) @@ -5535,14 +5532,6 @@ static void PT_ClientCmd(INT32 netconsole, SINT8 node) realstart = ExpandTics(netbuffer->u.clientpak.client_tic, nettics[node]); realend = ExpandTics(netbuffer->u.clientpak.resendfrom, nettics[node]); - if (netbuffer->packettype == PT_CLIENTMIS || netbuffer->packettype == PT_CLIENT2MIS - || netbuffer->packettype == PT_CLIENT3MIS || netbuffer->packettype == PT_CLIENT4MIS - || netbuffer->packettype == PT_NODEKEEPALIVEMIS - || supposedtics[node] < realend) - { - supposedtics[node] = realend; - } - // Discard out of order packet if (nettics[node] > realend) { @@ -5894,7 +5883,6 @@ static void PT_ServerTics(SINT8 node) if (realend > gametic + CLIENTBACKUPTICS) realend = gametic + CLIENTBACKUPTICS; - cl_packetmissed = realstart > neededtic; UINT8 *pak = (UINT8 *)&packet->cmds; UINT8 *txtpak = (UINT8 *)&packet->cmds[packet->numslots * packet->numtics]; @@ -6027,11 +6015,12 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_CLIENT2CMD: case PT_CLIENT3CMD: case PT_CLIENT4CMD: + case PT_NODEKEEPALIVE: + // "mis" tics kept for vanilla compat case PT_CLIENTMIS: case PT_CLIENT2MIS: case PT_CLIENT3MIS: case PT_CLIENT4MIS: - case PT_NODEKEEPALIVE: case PT_NODEKEEPALIVEMIS: PT_ClientCmd(netconsole, node); break; @@ -6323,25 +6312,18 @@ static void SV_SendServerKeepAlive(void) static void CL_SendClientCmd(void) { size_t packetsize = 0; - boolean mis = false; doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); netbuffer->packettype = PT_CLIENTCMD; - if (cl_packetmissed) - { - netbuffer->packettype = PT_CLIENTMIS; - mis = true; - } - netbuffer->u.clientpak.resendfrom = (UINT8)(neededtic & UINT8_MAX); netbuffer->u.clientpak.client_tic = (UINT8)(gametic & UINT8_MAX); if (gamestate == GS_WAITINGPLAYERS) { // Send PT_NODEKEEPALIVE packet - netbuffer->packettype = (mis ? PT_NODEKEEPALIVEMIS : PT_NODEKEEPALIVE); + netbuffer->packettype = PT_NODEKEEPALIVE; packetsize = sizeof (clientcmd_pak) - sizeof (ticcmd_t) - sizeof (INT16); HSendPacket(servernode, false, 0, packetsize); } @@ -6404,19 +6386,19 @@ static void CL_SendClientCmd(void) if (splitscreen || botingame) // Send a special packet with 2 cmd for splitscreen { - netbuffer->packettype = (mis ? PT_CLIENT2MIS : PT_CLIENT2CMD); + netbuffer->packettype = PT_CLIENT2CMD; packetsize = sizeof (client2cmd_pak); G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds[1][lagDelay], 1); if (splitscreen > 1) { - netbuffer->packettype = (mis ? PT_CLIENT3MIS : PT_CLIENT3CMD); + netbuffer->packettype = PT_CLIENT3CMD; packetsize = sizeof (client3cmd_pak); G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds[2][lagDelay], 1); if (splitscreen > 2) { - netbuffer->packettype = (mis ? PT_CLIENT4MIS : PT_CLIENT4CMD); + netbuffer->packettype = PT_CLIENT4CMD; packetsize = sizeof (client4cmd_pak); G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds[3][lagDelay], 1); } @@ -6471,14 +6453,13 @@ static void SV_SendTics(void) // send to all client but not to me // for each node create a packet with x tics and send it - // x is computed using supposedtics[n], max packet size and maketic + // x is computed using nettics[n], max packet size and maketic for (n = 1; n < MAXNETNODES; n++) { if (!nodeingame[n]) continue; - // assert supposedtics[n]>=nettics[n] - realfirsttic = supposedtics[n]; + realfirsttic = nettics[n]; lasttictosend = min(maketic, nettics[n] + CLIENTBACKUPTICS); if (realfirsttic >= lasttictosend) @@ -6487,8 +6468,8 @@ static void SV_SendTics(void) // to resent packet that are supposed lost (this is necessary since lost // packet detection work when we have received packet with firsttic > neededtic // (getpacket servertics case) - DEBFILE(va("Nothing to send node %u mak=%u sup=%u net=%u \n", - n, lasttictosend, supposedtics[n], nettics[n])); + DEBFILE(va("Nothing to send node %u mak=%u net=%u \n", + n, lasttictosend, nettics[n])); realfirsttic = nettics[n]; if (realfirsttic >= lasttictosend || (I_GetTime() + n)&3) // all tic are ok @@ -6568,17 +6549,10 @@ static void SV_SendTics(void) packsize = bufpos - (UINT8 *)&(netbuffer->u); HSendPacket(n, false, 0, packsize); - - // when tic are too large, only one tic is sent so don't go backward! - if (lasttictosend-doomcom->extratics > realfirsttic) - supposedtics[n] = lasttictosend-doomcom->extratics; - else - supposedtics[n] = lasttictosend; - - supposedtics[n] = max(supposedtics[n], nettics[n]); } + // node 0 is me! - supposedtics[0] = maketic; + nettics[0] = maketic; } // diff --git a/src/d_net.c b/src/d_net.c index fd8fb0e31..3e0d4410c 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -863,11 +863,12 @@ static void DebugPrintpacket(const char *header) case PT_CLIENT2CMD: case PT_CLIENT3CMD: case PT_CLIENT4CMD: + case PT_NODEKEEPALIVE: + // "mis" tics kept for vanilla compat case PT_CLIENTMIS: case PT_CLIENT2MIS: case PT_CLIENT3MIS: case PT_CLIENT4MIS: - case PT_NODEKEEPALIVE: case PT_NODEKEEPALIVEMIS: fprintf(debugfile, " tic %4u resendfrom %u\n", (UINT32)netbuffer->u.clientpak.client_tic, From 08864e27b2de8382ca7530feedc37e7f5783d3e5 Mon Sep 17 00:00:00 2001 From: PAS Date: Tue, 23 Dec 2025 17:17:32 -0500 Subject: [PATCH 9/9] Fix double byte-swap in SV_MakeTic --- 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 ef78fe91a..729a8f698 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6626,7 +6626,7 @@ void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle) // create missed tic static void SV_Maketic(void) { - G_MoveTiccmd(netcmds[maketic % BACKUPTICS], playercmds, MAXPLAYERS); + G_CopyTiccmd(netcmds[maketic % BACKUPTICS], playercmds, MAXPLAYERS); maketic++; }