From e5c0967a3ffefb2651c9135e5123d4703aee3af6 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 11 Apr 2026 16:34:32 +0200 Subject: [PATCH 01/61] BLUA: simplify lua number hash --- src/blua/ltable.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/blua/ltable.c b/src/blua/ltable.c index b21bc4bfa..dc4de9c62 100644 --- a/src/blua/ltable.c +++ b/src/blua/ltable.c @@ -81,6 +81,7 @@ static /*const*/ Node dummynode_ = { /* ** hash for lua_Numbers */ +#if 0 static Node *hashnum (const Table *t, lua_Number n) { unsigned int a[numints]; int i; @@ -90,6 +91,12 @@ static Node *hashnum (const Table *t, lua_Number n) { for (i = 1; i < numints; i++) a[0] += a[i]; return hashmod(t, a[0]); } +#else +// our lua_Number is just typedef´d int32 so no need to do any of the above +static inline Node *hashnum (const Table *t, lua_Number n) { + return hashmod(t, cast(unsigned int, n)); +} +#endif From 1217089d819a807d27b95e5417d7f1bbe35e9576 Mon Sep 17 00:00:00 2001 From: Indev Date: Sat, 11 Apr 2026 21:53:15 +0300 Subject: [PATCH 02/61] G_UseContinue is unused, delet it --- src/g_game.c | 12 ------------ src/g_game.h | 1 - 2 files changed, 13 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 0eb9ee506..6554a22be 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3343,18 +3343,6 @@ static void G_DoStartVote(void) gameaction = ga_nothing; } -// -// G_UseContinue -// -void G_UseContinue(void) -{ - if (gamestate == GS_LEVEL && !netgame && !multiplayer) - { - gameaction = ga_startcont; - lastdraw = true; - } -} - static void G_DoStartContinue(void) { I_Assert(!netgame && !multiplayer); diff --git a/src/g_game.h b/src/g_game.h index 76759d257..f1ed7834e 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -248,7 +248,6 @@ UINT8 G_GetGametypeColor(INT16 gt); void G_ExitLevel(void); void G_NextLevel(void); void G_Continue(void); -void G_UseContinue(void); void G_AfterIntermission(void); void G_EndGame(void); // moved from y_inter.c/h and renamed From eccc3eb33fb280fd3dfa10e3a6ae5f22aacf25dd Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Apr 2026 14:27:44 +0200 Subject: [PATCH 03/61] print opengl extensions in new lines for ogllog otherwise this may still get truncated and lots of text editor also complain about a super long single line of text also fix null ptr dereferencing into strtok should strdup return null --- src/hardware/hw_main.cpp | 4 +++- src/sdl/ogl_sdl.c | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 8f2e33a40..9e0dd6ea6 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5979,7 +5979,7 @@ static void COM_HWR_glinfo(void) // if the GPU is super new and supports a bajillion extensions - xyzzy char *copy = strdup((const char*)gl_extensions); - char *ext = strtok(copy, " "); + char *ext; if (copy == NULL) { @@ -5987,6 +5987,8 @@ static void COM_HWR_glinfo(void) return; } + ext = strtok(copy, " "); + do { CONS_Printf(" - %s\n", ext); diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index d50cdbe93..46af6e178 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -137,13 +137,13 @@ boolean OglSdlSurface(INT32 w, INT32 h) GL_DBG_Printf("OpenGL %s\n", gl_version); GL_DBG_Printf("GPU: %s\n", gl_renderer); - GL_DBG_Printf("Extensions:"); + GL_DBG_Printf("Extensions: \n"); { // Need to do it with strtok for same reason its done like that in gr_glinfo command char *copy = strdup((const char*)gl_extensions); - char *ext = strtok(copy, " "); + char *ext; if (copy == NULL) { @@ -151,9 +151,11 @@ boolean OglSdlSurface(INT32 w, INT32 h) } else { + ext = strtok(copy, " "); + do { - GL_DBG_Printf(" %s", ext); + GL_DBG_Printf(" - %s\n", ext); } while ((ext = strtok(NULL, " ")) != NULL); free(copy); From e0bf663157e280882ec3446ee555349f8625ffcf Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Apr 2026 15:05:51 +0200 Subject: [PATCH 04/61] Hack: fix intermission screen displaying whitescreen in some cases does not fix whitescreen when switching resolutions while in intermission screen, but oh well lets hope there will be no issues with calling D_Renderview in intermission state, but it seems to work from quick testing lul --- src/d_main.c | 46 +++++++++++++++----- src/hardware/hw_main.cpp | 91 ++++++++++++++++++++-------------------- src/hardware/hw_main.h | 5 +++ 3 files changed, 87 insertions(+), 55 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 84abb528d..5a5ecb510 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -362,6 +362,40 @@ static void D_Renderview(void) // added comment : there is a wipe eatch change of the gamestate gamestate_t wipegamestate = GS_LEVEL; +static void D_MakeIntermissionBG(void) +{ + if (rendermode == render_none) + return; + + if (!lastdraw) + return; + + // no more valid map + // shouldnt happen at this point, but better safe than sorry! + if (!numsectors) + return; + + // need to render level again for this + // should be fine since at this point we did not unload it yet + if (cv_renderview.value) + { + D_Renderview(); + } + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + HWR_MakeScreenTexture(); + } + else +#endif + { + VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.width, vid.width); + } + + lastdraw = false; +} + static boolean D_Display(void) { boolean ranwipe = false; @@ -519,6 +553,8 @@ static boolean D_Display(void) break; } + D_MakeIntermissionBG(); + if (gamestate == GS_LEVEL) { // draw the view directly @@ -529,16 +565,6 @@ static boolean D_Display(void) PS_STOP_TIMING(ps_rendercalltime); } - if (lastdraw) - { - if (rendermode == render_soft) - { - VID_BlitLinearScreen(vid.screens[0], vid.screens[1], vid.width, vid.height, vid.width, vid.width); - } - - lastdraw = false; - } - PS_START_TIMING(ps_uitime); ST_Drawer(); HU_Drawer(); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 9e0dd6ea6..f458015ae 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -6093,61 +6093,62 @@ static void HWR_DoPostProcessor(void) if (cv_glscreentextures.value != 2) // screen textures are needed for the rest of the effects return; - //UINT8 viewnum = R_GetViewNumber(); // see below + // Not supported in splitscreen - someone want to add support? + if (splitscreen || cv_reducevfx.value) + return; + + //UINT8 viewnum = R_GetViewNumber(); //camera_t *thiscam = &camera[viewnum]; const camera_t *thiscam = &camera[0]; - // Not supported in splitscreen - someone want to add support? - const boolean screenwave = (!splitscreen && !cv_reducevfx.value && (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)); + if (!(thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)) + return; // Capture the screen for intermission and screen waving - if ((lastdraw || screenwave) && gamestate != GS_INTERMISSION) + if (gamestate != GS_INTERMISSION) GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); // Drunken vision! WooOOooo~ - if (screenwave) + // 10 by 10 grid. 2 coordinates (xy) + float v[SCREENVERTS][SCREENVERTS][2]; + float disStart = (leveltime-1) + FixedToFloat(R_GetTimeFrac(RTF_LEVEL)); + + UINT8 x, y; + float WAVELENGTH; + float AMPLITUDE; + float FREQUENCY; + + // Modifies the wave. + if (thiscam->postimg & POSTIMG_WATER) { - // 10 by 10 grid. 2 coordinates (xy) - float v[SCREENVERTS][SCREENVERTS][2]; - float disStart = (leveltime-1) + FixedToFloat(R_GetTimeFrac(RTF_LEVEL)); - - UINT8 x, y; - float WAVELENGTH; - float AMPLITUDE; - float FREQUENCY; - - // Modifies the wave. - if (thiscam->postimg & POSTIMG_WATER) - { - WAVELENGTH = 5.0f; - AMPLITUDE = 40.0f; - FREQUENCY = 8.0f; - } - else - { - WAVELENGTH = 10.0f; - AMPLITUDE = 60.0f; - FREQUENCY = 4.0f; - } - - //static constexpr float scale = ((float)SCREENVERTS - 1.0f) / 9.0f; // well this evals to just 1.0f and what is x / 1? kek - - for (x = 0; x < SCREENVERTS; x++) - { - for (y = 0; y < SCREENVERTS; y++) - { - // Change X position based on its Y position. - v[x][y][0] = x-4.5f + sinf(((disStart+(static_cast(y) * WAVELENGTH)) / FREQUENCY)) / AMPLITUDE; // (x / scale) - v[x][y][1] = y-4.5f; // (y / scale) - } - } - - GL_PostImgRedraw(v); - - // Capture the screen again for screen waving on the intermission - if (gamestate != GS_INTERMISSION) - GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); + WAVELENGTH = 5.0f; + AMPLITUDE = 40.0f; + FREQUENCY = 8.0f; } + else + { + WAVELENGTH = 10.0f; + AMPLITUDE = 60.0f; + FREQUENCY = 4.0f; + } + + //static constexpr float scale = ((float)SCREENVERTS - 1.0f) / 9.0f; // well this evals to just 1.0f and what is x / 1? kek + + for (x = 0; x < SCREENVERTS; x++) + { + for (y = 0; y < SCREENVERTS; y++) + { + // Change X position based on its Y position. + v[x][y][0] = x-4.5f + sinf(((disStart+(static_cast(y) * WAVELENGTH)) / FREQUENCY)) / AMPLITUDE; // (x / scale) + v[x][y][1] = y-4.5f; // (y / scale) + } + } + + GL_PostImgRedraw(v); + + // Capture the screen again for screen waving on the intermission + if (gamestate != GS_INTERMISSION) + GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); // Flipping of the screen isn't done here anymore } diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 8a501f727..cbd8e11e7 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -151,6 +151,11 @@ FUNCINLINE static ATTRINLINE void HWR_RenderVhsEffect(fixed_t upbary, fixed_t do GL_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize); } +FUNCINLINE static ATTRINLINE void HWR_MakeScreenTexture(void) +{ + GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC1); +} + FUNCINLINE static ATTRINLINE void HWR_MakeScreenFinalTexture(void) { GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); From 4edc102d671bb1e10d01d64f5024a23692c1d9ad Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 12 Apr 2026 15:23:45 +0200 Subject: [PATCH 05/61] hack: fix intermission background becoming white after resolution change --- src/d_main.c | 13 +++++++++---- src/hardware/hw_main.cpp | 4 +++- src/screen.c | 4 ++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 5a5ecb510..9443c0a47 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -364,16 +364,22 @@ gamestate_t wipegamestate = GS_LEVEL; static void D_MakeIntermissionBG(void) { - if (rendermode == render_none) - return; - if (!lastdraw) return; + if (rendermode == render_none) + { + lastdraw = false; + return; + } + // no more valid map // shouldnt happen at this point, but better safe than sorry! if (!numsectors) + { + lastdraw = false; return; + } // need to render level again for this // should be fine since at this point we did not unload it yet @@ -381,7 +387,6 @@ static void D_MakeIntermissionBG(void) { D_Renderview(); } - #ifdef HWRENDER if (rendermode == render_opengl) { diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index f458015ae..6e41a7d3b 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -254,11 +254,13 @@ static void CV_screentextures_OnChange(void) { if (cv_glpaletterendering.value != 0) CV_SetValue(&cv_glpaletterendering, 0); - #ifdef USE_FBO_OGL if (cv_glframebuffer.value != 0) CV_SetValue(&cv_glframebuffer, 0); #endif + // HACK: set lastdraw so intermission bg can refresh after toggling screentextures + if (gamestate == GS_INTERMISSION) + lastdraw = true; } GL_SetSpecialState(HWD_SET_SCREEN_TEXTURES, cv_glscreentextures.value); M_UpdateOGLMenu(); diff --git a/src/screen.c b/src/screen.c index ebc5abddf..84e81617a 100644 --- a/src/screen.c +++ b/src/screen.c @@ -277,6 +277,10 @@ void SCR_Recalc(void) // vid.recalc lasts only for the next refresh... con_recalc = true; am_recalc = true; + + // HACK: set lastdraw so intermission bg can refresh after resolution change + if (gamestate == GS_INTERMISSION) + lastdraw = true; } // Check for screen cmd-line parms: to force a resolution. From 6c58c0de415d63bd95c48615cedd27df3b15ecc4 Mon Sep 17 00:00:00 2001 From: NepDisk Date: Fri, 13 Jun 2025 09:40:57 -0400 Subject: [PATCH 06/61] Add support for using custom SDL2 mappings --- src/sdl/i_system.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 3206bec70..ae11829c6 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -975,6 +975,18 @@ void I_InitJoystick(UINT8 index) if (M_CheckParm("-nojoy")) return; + { + char dbpath[1024]; + sprintf(dbpath, "%s" PATHSEP "gamecontrollerdb.txt", srb2path); + SDL_GameControllerAddMappingsFromFile(dbpath); + } + + { + char dbpath[1024]; + sprintf(dbpath, "%s" PATHSEP "gamecontrollerdb_user.txt", srb2home); + SDL_GameControllerAddMappingsFromFile(dbpath); + } + if (M_CheckParm("-noxinput")) SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); From 81f46224e13e904a1a1a72d00dfe79a81c055a57 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Mon, 13 Apr 2026 18:32:26 +0200 Subject: [PATCH 07/61] Fix asan error when pressing shift and arrow key Also fix addons menu ignoring shift when capslock is on! Also also fix capslock+rshift still typing uppercase letters! --- src/console.c | 193 +++++++++++++++++++++++++++++++++++++++++----- src/hu_stuff.c | 155 ------------------------------------- src/hu_stuff.h | 13 ---- src/m_menu.c | 29 +------ src/sdl/i_video.c | 1 - 5 files changed, 174 insertions(+), 217 deletions(-) diff --git a/src/console.c b/src/console.c index 50d10d020..d02f68bb6 100644 --- a/src/console.c +++ b/src/console.c @@ -208,14 +208,6 @@ static void CONS_Clear_f(void) Unlock_state(); } -// Choose english keymap -// -/*static void CONS_English_f(void) -{ - shiftxform = english_shiftxform; - CONS_Printf(M_GetText("%s keymap.\n"), M_GetText("English")); -}*/ - static char *bindtable[NUMINPUTS]; static void CONS_Bind_f(void) @@ -633,27 +625,186 @@ void CON_MoveConsole(void) Unlock_state(); } +//====================================================================== +// KEYBOARD LAYOUTS FOR ENTERING TEXT +//====================================================================== + +static char english_shiftxform[] = +{ + 0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, + ' ', '!', '"', '#', '$', '%', '&', + '"', // shift-' + '(', ')', '*', '+', + '<', // shift-, + '_', // shift-- + '>', // shift-. + '?', // shift-/ + ')', // shift-0 + '!', // shift-1 + '@', // shift-2 + '#', // shift-3 + '$', // shift-4 + '%', // shift-5 + '^', // shift-6 + '&', // shift-7 + '*', // shift-8 + '(', // shift-9 + ':', + ':', // shift-; + '<', + '+', // shift-= + '>', '?', '@', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '{', // shift-[ + '|', // shift-backslash - OH MY GOD DOES WATCOM SUCK + '}', // shift-] + '"', '_', + '~', // shift-` + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '{', '|', '}', '~', 127 +}; + +static char french_shiftxform[] = +{ + 0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, + ' ','$', //shift-! + '3', //shift-" + '#', '$', '%', + '1', //shift-& + '4', // shift-' + '5', // shift-( + ')', // shift-) + '*', '+', + '?', // shift-, + '6', // shift-- + '.', '/', + '0', '1', '2', '3', '4', '5', + '6', '7', '8', '9', + '/', // shitf-: + '.', // shift-; + '>', // shift-< + '+', // shift-= + '>', '?', '@', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '[', '\\', ']', '^', + '8', //shift-_ + '`', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '{', '|', '}', '~', 127, + 128, 129, + '2', + 131, 132, + '0', + 134, + '9', + 136, 137, + '7', + 139, 140, + '%' +}; + +static char french_altgrxform[] = +{ + 0, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, + ' ', '!', + '#', //altgr-" + '#', '$', '%', '&', + '{', //altgr-' + '[', //altgr-( + ']', //altgr-) + '*', '+', ',', + '|', //altg-- + '.', '/', + '0', '1', '2', '3', '4', '5', + '6', '7', '8', '9', + ':', ';', '<', + '}', //altgr-= + '>', '?', '@', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', + 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '[', '\\', ']', '^', + '\\', //altgr-backslash + '`', + 'a', 'b', 'c', 'd', 'E', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '{', '|', '}', '~', 127, + 128, 129, + '~', + 131, 132, + '@', + 134, + '^', + 136, 137, + '`', + 139, 140, + KEY_FR_U_GRAVE +}; + +// fallback for special letter non displayable in the game (i.e.: 'é','à',etc.) +static INT32 CON_FallBackFrSpecialLetter(INT32 key) +{ + switch (key) + { + case KEY_FR_E_AIGUE: return 'e'; + case KEY_FR_E_GRAVE: return 'e'; + case KEY_FR_C_CEDILLE: return 'c'; + case KEY_FR_A_GRAVE: return 'a'; + case KEY_FR_U_GRAVE: return 'u'; + default: return key; + } +} + +// goddang AZERTY +static size_t CON_GetShiftSize(void) +{ + return ((cv_keyboardlayout.value == 3) ? sizeof(french_shiftxform) : sizeof(english_shiftxform)); +} + +static char *CON_Shiftform(void) +{ + return (cv_keyboardlayout.value == 3) ? french_shiftxform : english_shiftxform; +} + INT32 CON_ShiftChar(INT32 ch) { - if (I_UseNativeKeyboard()) + if (I_UseNativeKeyboard() || ch >= (INT32)CON_GetShiftSize()) return ch; + // warning: shiftdown is NOT a boolean, it's 1 or 2 for lshift/rshift if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { - if (shiftdown ^ capslock) - ch = shiftxform[ch]; + return !!shiftdown != capslock ? CON_Shiftform()[ch] : ch; } - else // if we're holding shift we should still shift non letter symbols + + // if we're holding shift we should still shift non letter symbols + if (shiftdown) { - if (shiftdown) - ch = shiftxform[ch]; - else if (cv_keyboardlayout.value == 3) - { - if (altdown & 0x2) - ch = french_altgrxform[ch]; - else - ch = HU_FallBackFrSpecialLetter(ch); - } + return CON_Shiftform()[ch]; + } + + // AZERTY + if (cv_keyboardlayout.value == 3) + { + if (altdown & 0x2) + return french_altgrxform[ch]; + + return CON_FallBackFrSpecialLetter(ch); } return ch; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 8a60a1a9e..4f84fad89 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -115,155 +115,8 @@ static patch_t *songcreditbg = NULL; // ------- static void HU_DrawRankings(void); - consvar_t cv_showspecstuff = {"showspecstuff", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -//====================================================================== -// KEYBOARD LAYOUTS FOR ENTERING TEXT -//====================================================================== - -char *shiftxform = NULL; - -char english_shiftxform[] = -{ - 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, - ' ', '!', '"', '#', '$', '%', '&', - '"', // shift-' - '(', ')', '*', '+', - '<', // shift-, - '_', // shift-- - '>', // shift-. - '?', // shift-/ - ')', // shift-0 - '!', // shift-1 - '@', // shift-2 - '#', // shift-3 - '$', // shift-4 - '%', // shift-5 - '^', // shift-6 - '&', // shift-7 - '*', // shift-8 - '(', // shift-9 - ':', - ':', // shift-; - '<', - '+', // shift-= - '>', '?', '@', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '{', // shift-[ - '|', // shift-backslash - OH MY GOD DOES WATCOM SUCK - '}', // shift-] - '"', '_', - '~', // shift-` - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '{', '|', '}', '~', 127 -}; - -char french_shiftxform[] = -{ - 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, - ' ','$', //shift-! - '3', //shift-" - '#', '$', '%', - '1', //shift-& - '4', // shift-' - '5', // shift-( - ')', // shift-) - '*', '+', - '?', // shift-, - '6', // shift-- - '.', '/', - '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', - '/', // shitf-: - '.', // shift-; - '>', // shift-< - '+', // shift-= - '>', '?', '@', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '[', '\\', ']', '^', - '8', //shift-_ - '`', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '{', '|', '}', '~', 127, - 128, 129, - '2', - 131, 132, - '0', - 134, - '9', - 136, 137, - '7', - 139, 140, - '%' -}; - -char french_altgrxform[] = -{ - 0, - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, - ' ', '!', - '#', //altgr-" - '#', '$', '%', '&', - '{', //altgr-' - '[', //altgr-( - ']', //altgr-) - '*', '+', ',', - '|', //altg-- - '.', '/', - '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', - ':', ';', '<', - '}', //altgr-= - '>', '?', '@', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - '[', '\\', ']', '^', - '\\', //altgr-backslash - '`', - 'a', 'b', 'c', 'd', 'E', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', - 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '{', '|', '}', '~', 127, - 128, 129, - '~', - 131, 132, - '@', - 134, - '^', - 136, 137, - '`', - 139, 140, - KEY_FR_U_GRAVE -}; - -//fallback for special letter non displayable in the game (i.e.: 'é','à',etc.) -INT32 HU_FallBackFrSpecialLetter(INT32 key) -{ - switch(key){ - case KEY_FR_E_AIGUE: return 'e'; - case KEY_FR_E_GRAVE: return 'e'; - case KEY_FR_C_CEDILLE: return 'c'; - case KEY_FR_A_GRAVE: return 'a'; - case KEY_FR_U_GRAVE: return 'u'; - default: return key; - } -} - static char cechotext[1024]; static tic_t cechotimer = 0; static tic_t cechoduration = 5*TICRATE; @@ -407,9 +260,6 @@ void HU_Init(void) COM_AddCommand("csay", Command_CSay_f); RegisterNetXCmd(XD_SAY, Got_Saycmd); - // set shift translation table - shiftxform = english_shiftxform; - if (dedicated || rendermode == render_none) return; @@ -435,11 +285,6 @@ void HU_Start(void) headsupactive = true; } -void HU_Shiftform(void) -{ - shiftxform = (cv_keyboardlayout.value == 3) ? french_shiftxform : english_shiftxform; -} - //====================================================================== // EXECUTION //====================================================================== diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 8ba4bce19..16b4bf0fc 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -42,15 +42,6 @@ #define CRED_FONTEND 'Z' // the last font character #define CRED_FONTSIZE (CRED_FONTEND - CRED_FONTSTART + 1) -extern char *shiftxform; // english translation shift table -extern char english_shiftxform[]; - -extern char french_shiftxform[]; -extern char french_altgrxform[]; - -//fallback for special letter non displayable in the game (i.e.: 'é','à',etc.) -INT32 HU_FallBackFrSpecialLetter(INT32 key); - //------------------------------------ // sorted player lines //------------------------------------ @@ -105,8 +96,6 @@ void HU_LoadGraphics(void); // reset heads up when consoleplayer respawns. void HU_Start(void); -void HU_Shiftform(void); - boolean HU_Responder(event_t *ev); void HU_Ticker(void); void HU_TickSongCredits(void); @@ -115,8 +104,6 @@ void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_clearChatChars(void); void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags); // Lat': Ping drawer for scoreboard. -//void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer); -//void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer); void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 hilicol); void HU_DrawEmeralds(INT32 x, INT32 y, INT32 pemeralds); const char *HU_SkinColorToConsoleColor(skincolors_t color); diff --git a/src/m_menu.c b/src/m_menu.c index 7b20b8f41..a6790ff78 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -496,32 +496,6 @@ static consvar_t cv_dummystaff = {"dummystaff", "0", CV_HIDEN|CV_CALL, dummystaf // all the menu definitions and onchanges reside in here now #include "m_menudefs.c" -static INT32 M_ShiftChar(INT32 ch) -{ - if (I_UseNativeKeyboard()) - return ch; - - if (cv_keyboardlayout.value == 3) - { - if (ch >= 32 && ch <= 141) - { - if (shiftdown) - ch = shiftxform[ch]; - else if (altdown & 0x2) - ch = french_altgrxform[ch]; - else - ch = HU_FallBackFrSpecialLetter(ch); - } - } - else - { - if (shiftdown && ch >= 32 && ch <= 127) - ch = shiftxform[ch]; - } - - return ch; -} - // // M_GetGametypeColor // @@ -1250,7 +1224,7 @@ boolean M_Responder(event_t *ev) // Handle menuitems which need a specific key handling if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER) { - ch = M_ShiftChar(ch); + ch = CON_ShiftChar(ch); routine(ch); return true; } @@ -1280,6 +1254,7 @@ boolean M_Responder(event_t *ev) void (*otherroutine)(event_t *sev) = currentMenu->menuitems[itemOn].itemaction; otherroutine(ev); //Alam: what a hack } + return true; } } diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 813b6bfa0..aa0c5c72d 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -108,7 +108,6 @@ static void KeyboardLayout_OnChange(void) { if (cv_keyboardlayout.value != 2) SDL_StopTextInput(); - HU_Shiftform(); } static CV_PossibleValue_t keyboardlayout_cons_t[] = {{1,"Default US"}, {2, "Native"}, {3, "AZERTY"}, {0, NULL}}; From bb62fbfc126a8f72870738222b236a95e663466d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 15 Apr 2026 23:45:26 +0200 Subject: [PATCH 08/61] add "USEJEMALLOC" make flag to link against "jemalloc" allocator on my linux system and usual benchmark setup this improves performance quite significantly (+~12fps) this relies on jemalloc to be installed as a separate library for now and is more a convenience thing --- src/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Makefile b/src/Makefile index c930f87ed..4ee7cf1a9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -94,6 +94,7 @@ # NOSDLMAIN=1 - ? # SDLMAIN=1 - ? # NOLTO=1 - Disable link time optimizations +# USEJEMALLOC=1 Enable building with jemalloc Allocator to replace GLibc malloc, might improve performance # # Library configuration flags: # Everything here is an override. @@ -279,6 +280,10 @@ opts+=-O1 -fsanitize=undefined -fno-omit-frame-pointer libs+=-fsanitize=undefined endif +ifdef USEJEMALLOC +libs+=-ljemalloc +endif + ifneq (,$(filter $(CC) $(CXX),clang clang++)) libs+=-fuse-ld=lld endif From b46e5cb577e47dc1c9cba02642defc7152f4b02d Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 4 Apr 2026 00:27:42 -0500 Subject: [PATCH 09/61] gl: Fix sky dome VBO leak --- src/hardware/hw_main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 6e41a7d3b..e38b1b3c8 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5284,7 +5284,6 @@ void HWR_ClearSkyDome(void) sky->loops = NULL; sky->data = NULL; - sky->vbo = 0; sky->rows = sky->columns = 0; sky->loopcount = 0; From a59928221bf78027ddcad472617dc923e2777898 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 16 Apr 2026 17:39:01 +0200 Subject: [PATCH 10/61] few more cleanups and super tiny optimizations k_hud --- src/hu_stuff.c | 3 +- src/k_hud.c | 114 ++++++++++++++++++++++++----------------------- src/p_user.c | 11 ++++- src/r_draw.cpp | 17 ++++--- src/r_patch.cpp | 3 +- src/r_things.cpp | 7 +-- 6 files changed, 86 insertions(+), 69 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 4f84fad89..145ce240f 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -979,7 +979,8 @@ void HU_Ticker(void) } } - if (cechotimer > 0) --cechotimer; + if (cechotimer > 0) + --cechotimer; // Animate the desynch dots if (hu_resynching diff --git a/src/k_hud.c b/src/k_hud.c index bed4c36be..ce60d23c8 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1362,10 +1362,12 @@ INT32 K_getMinimapTrans(void) return -1; if (timeinmap <= 113) + { minimaptrans = ((((INT32)timeinmap) - 105)*minimaptrans)/(113-105); - if (!minimaptrans) - return -1; + if (!minimaptrans) + return -1; + } return (10-minimaptrans)<spectator || !player->mo) continue; @@ -2434,7 +2437,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I static boolean K_BigLap(void) { - return (cv_biglaps.value && (cv_numlaps.value > 9) && (K_UseColorHud() ? big_lap_color : big_lap) && (!stplyr->exiting)); + return (cv_biglaps.value && (cv_numlaps.value > 9) && !stplyr->exiting && (K_UseColorHud() ? big_lap_color : big_lap)); } static void K_drawKartLaps(void) @@ -2643,7 +2646,7 @@ static void K_drawKartSpeedometer(void) return; // index 0 is the raw value, index 1 is the converted value - fixed_t convSpeed[2] = {0,0}; + fixed_t convSpeed[2] = {0, 0}; #ifdef ROTSPRITE fixed_t dial_divisor = DIALSPDDIV; #endif @@ -2712,34 +2715,27 @@ static void K_drawKartSpeedometer(void) V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, metric); } - else if (speedostyle == SPEEDO_EXTRA) // why bother if we dont? + else if (speedostyle == SPEEDO_EXTRA || speedostyle == SPEEDO_ACHII) // why bother if we dont? { - if (K_UseColorSpeedo(SPEEDO_EXTRA)) //Colourized hud + patch_t *speedopat; + + if (K_UseColorSpeedo(speedostyle)) //Colourized hud { + speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_smallstickerclr : skp_smallstickerachiclr); UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerclr, colormap); + + V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat, colormap); } else - V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallsticker); + { + speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_smallsticker : skp_smallstickerachi); + V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat); + } V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); - V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatches[cv_kartspeedometer.value]); - } - else if (speedostyle == SPEEDO_ACHII) // why bother if we dont? - { - if (K_UseColorSpeedo(SPEEDO_ACHII)) //Colourized hud - { - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerachiclr, colormap); - V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); - V_DrawMappedPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachiclr[cv_kartspeedometer.value], colormap); - } - else - { - V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_smallstickerachi); - V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); - V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachi[cv_kartspeedometer.value]); - } + + speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_speedpatches[cv_kartspeedometer.value] : skp_speedpatchesachi[cv_kartspeedometer.value]); + V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat); } #ifdef ROTSPRITE else if (speedostyle == SPEEDO_DIAL) // why bother if we dont? @@ -2769,29 +2765,32 @@ static void K_drawKartSpeedometer(void) // Draw the Speed counter. else if ((speedostyle == SPEEDO_PMETER) || (speedostyle == SPEEDO_PMETERSMOL)) { - fixed_t fuspeed = 0; INT32 spdpatch = 0; - static const INT32 speedIntervals[22] = {2, 5, 7, 10, 12, 15, 17, - 20, 22, 25, 27, 30, 32, - 35, 37, 40, 42, 45, 47, - 50, 52, 55}; + static const INT32 spdinterval[22] = { 2, 5, 7, 10, + 12, 15, 17, 20, + 22, 25, 27, 30, + 32, 35, 37, 40, + 42, 45, 47, 50, + 52, 55}; - fuspeed = FixedDiv(stplyr->speed, mapobjectscale)/FRACUNIT; + const fixed_t spd = FixedDiv(stplyr->speed, mapobjectscale) / FRACUNIT; - for (INT32 i = 0; i < 22; ++i) + if (spd > 54) { - if (fuspeed < speedIntervals[i]) + spdpatch = (leveltime & 4) ? 24 : 23; + } + else + { + for (INT32 i = 0; i < 22; ++i) { - spdpatch = i; - break; + if (spd < spdinterval[i]) + { + spdpatch = i; + break; + } } } - if (((fuspeed < 57 && fuspeed > 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && (leveltime & 4)) - spdpatch = 24; - else if (((fuspeed < 57 && fuspeed > 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && !(leveltime & 4)) - spdpatch = 23; - V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, (speedostyle == SPEEDO_PMETER) ? kp_kartzspeedo[spdpatch] : kp_kartzspeedo_smol[spdpatch]); } } @@ -2911,10 +2910,12 @@ static boolean K_GetScreenCoords(vector2_t *vec, player_t *player, mobj_t *targe x = (fixed_t)(viewangle - R_PointToAngle(targx, targy)); distfact = FINECOSINE((x>>ANGLETOFINESHIFT) & FINEMASK); - if (!distfact) distfact = 1; + if (!distfact) + distfact = 1; if (encoremode) x = -x; + if (x < (fixed_t)ANGLE_270 || x > (fixed_t)ANGLE_90) return false; @@ -2996,7 +2997,7 @@ static boolean K_GetScreenCoords(vector2_t *vec, player_t *player, mobj_t *targe if (stplyrnum > 0) y = y + yres; } - if (splitscreen >= 2) // 3P or 4P + else if (splitscreen >= 2) // 3P or 4P { x = x>>1; y = y>>1; @@ -3056,9 +3057,11 @@ static void K_drawNameTags(void) if (players[i].kartstuff[k_hyudorotimer]) // player is invisible continue; if (maxdistance) + { distance = R_PointToDist(players[i].mo->x, players[i].mo->y); - if (distance > maxdistance) - continue; + if (distance > maxdistance) + continue; + } if (!P_CheckSightFast(stplyr->mo, players[i].mo)) continue; @@ -3267,13 +3270,12 @@ static void K_drawDriftGauge(void) if (!splitscreen && !camera->chase) return; - if (forceshowhud) - goto skipcrap; // i will skip the drift early return and you cant stop me! - - if (!stplyr->kartstuff[k_drift]) - return; - -skipcrap: + // i will skip the drift early return and you cant stop me! + if (!forceshowhud) + { + if (!stplyr->kartstuff[k_drift]) + return; + } if (P_MobjWasRemoved(stplyr->mo)) return; @@ -3637,7 +3639,7 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) V_DrawCenteredSmallStringAtFixed(amxpos + (4*FRACUNIT), amypos - (3*FRACUNIT), V_ALLOWLOWERCASE|flags|V_SkinColorToHighlightcolor(mo->color), player_names[player - players]); } - const boolean minihead = K_useSmallMinimapHead(mo->player); + const boolean minihead = K_useSmallMinimapHead(player); // thx wanted reticle for having weird offsets very cool wntdamxpos = minihead ? amxpos + (1<viewz > mo->ceilingz - FixedMul(FRACUNIT, mo->scale)) player->viewz = mo->ceilingz - FixedMul(FRACUNIT, mo->scale); } + return; } @@ -2271,7 +2272,8 @@ static void P_MovePlayer(player_t *player) } //CONS_Printf("applied turn: %d\n", angle_diff); - if (add_delta) { + if (add_delta) + { player->mo->angle += angle_diff << TICCMD_REDUCE; player->mo->angle &= ~0xFFFF; // Try to keep the turning somewhat similar to how it was before? //CONS_Printf("leftover turn (%s): %5d or %4d%%\n", @@ -2393,15 +2395,18 @@ static void P_MovePlayer(player_t *player) { mobj_t *water = P_SpawnMobj(player->mo->x, player->mo->y, ((player->mo->eflags & MFE_VERTICALFLIP) ? player->mo->waterbottom - FixedMul(mobjinfo[MT_SPLISH].height, player->mo->scale) : player->mo->watertop), MT_SPLISH); + if (player->mo->eflags & MFE_GOOWATER) S_StartSound(water, sfx_ghit); else S_StartSound(water, sfx_wslap); + if (player->mo->eflags & MFE_VERTICALFLIP) { water->flags2 |= MF2_OBJECTFLIP; water->eflags |= MFE_VERTICALFLIP; } + water->destscale = player->mo->scale; P_SetScale(water, player->mo->scale); } @@ -3970,9 +3975,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { fixed_t panmax = (dist/5); const INT32 sparkval = K_GetKartDriftSparkValue(player); + pan = FixedDiv(FixedMul(min((fixed_t)player->kartstuff[k_driftcharge], sparkval), panmax), sparkval); + if (pan > panmax) pan = panmax; + if (player->kartstuff[k_drift] < 0) pan *= -1; } @@ -4749,6 +4757,7 @@ void P_PlayerThink(player_t *player) player->mo->flags2 |= MF2_SHADOW; else player->mo->flags2 &= ~MF2_SHADOW; + P_DeathThink(player); LUA_HookPlayer(player, HOOK(PlayerThink)); return; diff --git a/src/r_draw.cpp b/src/r_draw.cpp index b8f3fc903..24073a4d4 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -532,9 +532,12 @@ typedef struct drawcolumndata_temp_s // e6y: resolution limitation is removed UINT8 *buf; - INT32 startx; - ColumnFlushType type; - INT32 commontop, commonbot; + INT32 startx; + + ColumnFlushType type; + + INT32 commontop, commonbot; + UINT8 *transmap; // SoM 7-28-04: Fix the fuzz problem. UINT8 *translation; @@ -562,8 +565,8 @@ FUNCNORETURN static ATTRNORETURN void R_QuadFlushError(void) } static void (*R_FlushWholeColumns)(void) = R_FlushWholeError; -static void (*R_FlushHTColumns)(void) = R_FlushHTError; -static void (*R_FlushQuadColumn)(void) = R_QuadFlushError; +static void (*R_FlushHTColumns)(void) = R_FlushHTError; +static void (*R_FlushQuadColumn)(void) = R_QuadFlushError; static void R_FlushColumns(void) { @@ -595,8 +598,8 @@ void R_ResetColumnBuffer(void) temp_dc.type = FLUSH_NONE; R_FlushWholeColumns = R_FlushWholeError; - R_FlushHTColumns = R_FlushHTError; - R_FlushQuadColumn = R_QuadFlushError; + R_FlushHTColumns = R_FlushHTError; + R_FlushQuadColumn = R_QuadFlushError; } /** \brief The R_InitViewBuffer function diff --git a/src/r_patch.cpp b/src/r_patch.cpp index bca733c8b..f578a8f32 100644 --- a/src/r_patch.cpp +++ b/src/r_patch.cpp @@ -161,7 +161,7 @@ static void R_ParseSpriteInfo(boolean spr2) if (i == NUMSPRITES) I_Error("Error parsing SPRTINFO lump: Unknown sprite name \"%s\"", newSpriteName); - if (!memcmp(newSpriteName,sprnames[i], 4)) + if (!memcmp(newSpriteName, sprnames[i], 4)) { sprnum = static_cast(i); break; @@ -443,6 +443,7 @@ void *Patch_AllocateHardwarePatch(patch_t *patch) GLPatch_t *glPatch = static_cast(Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, &patch->hardware)); glPatch->mipmap = static_cast(Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, &glPatch->mipmap)); } + return (void *)(patch->hardware); } diff --git a/src/r_things.cpp b/src/r_things.cpp index 2f7e1a992..787c35250 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -166,11 +166,13 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has rotations and a rot = 0 lump\n", spritename, cn); sprtemp[frame].rotate = SRF_SINGLE; + for (r = 0; r < 8; r++) { sprtemp[frame].lumppat[r] = lumppat; sprtemp[frame].lumpid[r] = lumpid; } + sprtemp[frame].flip = flipped ? UINT8_MAX : 0; // 11111111 in binary return; } @@ -267,8 +269,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 if (spritedef->numframes) // (then spriteframes is not null) { // copy the already defined sprite frames - memcpy(sprtemp, spritedef->spriteframes, - spritedef->numframes * sizeof (spriteframe_t)); + memcpy(sprtemp, spritedef->spriteframes, spritedef->numframes * sizeof (spriteframe_t)); maxframe = spritedef->numframes - 1; } @@ -1147,7 +1148,7 @@ fixed_t R_GetSpriteDirectionalLighting(angle_t angle) fixed_t extralight = 0; light = FixedMul(FINECOSINE(angle >> ANGLETOFINESHIFT), FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT)) - + FixedMul(FINESINE(angle >> ANGLETOFINESHIFT), FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); + + FixedMul(FINESINE(angle >> ANGLETOFINESHIFT), FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); light = (light + FRACUNIT) / 2; light = FixedMul(light, FRACUNIT - FSIN(abs(AngleDeltaSigned(angle, maplighting.angle)) / 2)); From a73f3a073c681b77cd61779c3a271ac736d1220b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Apr 2026 17:39:50 +0200 Subject: [PATCH 11/61] hw_main: dont need to do sprite billboarding stuff with shearing enabled within HWR_SplitSprite --- src/hardware/hw_main.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index e38b1b3c8..d2fc90472 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -3864,7 +3864,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) wallVerts[1].y = endbot; // The x and y only need to be adjusted in the case that it's not a papersprite - if (cv_glspritebillboarding.value && !papersprite) + if (cv_glspritebillboarding.value && !cv_glshearing.value && !papersprite) { // Get the x and z of the vertices so billboarding draws correctly realheight = realbot - realtop; @@ -4383,9 +4383,7 @@ static int CompareDrawNodePlanes(const void *p1, const void *p2) static void HWR_RenderDrawNodes(void) { size_t i = 0, run_start = 0; - static std::vector sortindex; - - sortindex.reserve(DRAWNODES_INIT_SIZE); + static std::vector sortindex(DRAWNODES_INIT_SIZE); // Array for storing the rendering order. // A list of indices into the drawnodes array. @@ -5712,7 +5710,7 @@ static void HWR_RenderFrame(boolean skybox, boolean drawsky) viewwindowy, (viewwindowx + viewwidth), (viewwindowy + viewheight), - ZCLIP_PLANE, clipping_distances[renderdist - 1]); + ZCLIP_PLANE, clipping_distances[renderdist - 1]); current_bsp_culling_distance = bsp_culling_distances[renderdist- 1]; } @@ -6091,7 +6089,8 @@ static void HWR_DoPostProcessor(void) } } - if (cv_glscreentextures.value != 2) // screen textures are needed for the rest of the effects + // screen textures are needed for the rest of the effects + if (cv_glscreentextures.value != 2) return; // Not supported in splitscreen - someone want to add support? From 4f9ddffe2acb468f81463aecf32b5b0f16098b14 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Apr 2026 17:40:41 +0200 Subject: [PATCH 12/61] d_cliserv: check for splitscreen nodes first in clientcmd handler so we dont always have to check a bunch of things that most of the time wont apply anyways --- src/d_clisrv.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5da2b4ee2..192a2cceb 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5617,7 +5617,7 @@ 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 + if ( netbuffer->packettype == PT_CLIENTMIS || netbuffer->packettype == PT_CLIENT2MIS || netbuffer->packettype == PT_CLIENT3MIS || netbuffer->packettype == PT_CLIENT4MIS || netbuffer->packettype == PT_NODEKEEPALIVEMIS || supposedtics[node] < realend) @@ -5660,10 +5660,10 @@ static void PT_ClientCmd(INT32 netconsole, SINT8 node) return; // Splitscreen cmd - if (((netbuffer->packettype == PT_CLIENT2CMD || netbuffer->packettype == PT_CLIENT2MIS) + if ((nodetoplayer2[node] >= 0) && + ((netbuffer->packettype == PT_CLIENT2CMD || netbuffer->packettype == PT_CLIENT2MIS) || (netbuffer->packettype == PT_CLIENT3CMD || netbuffer->packettype == PT_CLIENT3MIS) - || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)) - && (nodetoplayer2[node] >= 0)) + || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))) { G_MoveTiccmd(&playercmds[(UINT8)nodetoplayer2[node]], &netbuffer->u.client2pak.cmd2, 1); @@ -5671,9 +5671,9 @@ static void PT_ClientCmd(INT32 netconsole, SINT8 node) return; } - if (((netbuffer->packettype == PT_CLIENT3CMD || netbuffer->packettype == PT_CLIENT3MIS) - || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)) - && (nodetoplayer3[node] >= 0)) + if ((nodetoplayer3[node] >= 0) && + ((netbuffer->packettype == PT_CLIENT3CMD || netbuffer->packettype == PT_CLIENT3MIS) + || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS))) { G_MoveTiccmd(&playercmds[(UINT8)nodetoplayer3[node]], &netbuffer->u.client3pak.cmd3, 1); @@ -5681,8 +5681,8 @@ static void PT_ClientCmd(INT32 netconsole, SINT8 node) return; } - if ((netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS) - && (nodetoplayer4[node] >= 0)) + if ((nodetoplayer4[node] >= 0) && + (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)) { G_MoveTiccmd(&playercmds[(UINT8)nodetoplayer4[node]], &netbuffer->u.client4pak.cmd4, 1); From eed5943b0b66e97a5f0a67dcbcf5480ff6e6f3a5 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Apr 2026 17:42:48 +0200 Subject: [PATCH 13/61] optimize K_CheckOffroadCollide a little bit no need to always check both the mobjs floor and ceiling z coordinates, those are surprisingly complicated checks on slopes --- src/k_kart.c | 87 +++++++++++++++++++++++++++++------------------ src/m_textinput.c | 2 +- src/p_user.c | 2 +- 3 files changed, 56 insertions(+), 35 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index ec312cc3b..f4577eb03 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1600,8 +1600,10 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) sector_t *s2; // FOF sector shortcut ffloor_t *rover; // FOF - fixed_t flr; - fixed_t cel; // floor & ceiling for height checks to make sure we're touching the offroad sector. + fixed_t flr = 0, cel = 0; // floor & ceiling for height checks to make sure we're touching the offroad sector. + + boolean checkfloor = false; + boolean checkceiling = false; I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); @@ -1609,48 +1611,64 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { if (!node->m_sector) - break; // shouldn't happen. + break; // shouldn't happen. s = node->m_sector; // 1: Check for the main sector, make sure we're on the floor of that sector and see if we can apply offroad. // Make arbitrary Z checks because we want to check for 1 sector in particular, we don't want to affect the player if the offroad sector is way below them and they're lineriding a normal sector above. - flr = P_MobjFloorZ(mo, s, s, mo->x, mo->y, NULL, false, true); - cel = P_MobjCeilingZ(mo, s, s, mo->x, mo->y, NULL, true, true); // get Z coords of both floors and ceilings for this sector (this accounts for slopes properly.) + checkfloor = (s->flags & SF_FLIPSPECIAL_FLOOR); + checkceiling = (mo->eflags & MFE_VERTICALFLIP && (s->flags & SF_FLIPSPECIAL_CEILING)); + + if (checkfloor) + flr = P_MobjFloorZ(mo, s, s, mo->x, mo->y, NULL, false, true); + if (checkceiling) + cel = P_MobjCeilingZ(mo, s, s, mo->x, mo->y, NULL, true, true); // get Z coords of both floors and ceilings for this sector (this accounts for slopes properly.) // NOTE: we don't use P_GetZAt with our x/y directly because the mobj won't have the same height because of its hitbox on the slope. Complex garbage but tldr it doesn't work. - if ( ((s->flags & SF_FLIPSPECIAL_FLOOR) && mo->z == flr) // floor check - || ((mo->eflags & MFE_VERTICALFLIP && (s->flags & SF_FLIPSPECIAL_CEILING) && (mo->z + mo->height) == cel)) ) // ceiling check. - - for (i = 2; i < 5; i++) // check for sector special - - if (GETSECSPECIAL(s->special, 1) == i) - return i-1; // return offroad type + if ( (checkfloor && mo->z == flr) // floor check + || ((checkceiling && (mo->z + mo->height) == cel))) // ceiling check. + { + const INT32 special = GETSECSPECIAL(s->special, 1); + for (i = 2; i < 5; i++) // check for sector special + { + if (special == i) + return i-1; // return offroad type + } + } // 2: If we're here, we haven't found anything. So let's try looking for FOFs in the sectors using the same logic. for (rover = s->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS)) // This FOF doesn't exist anymore. + if (!(rover->flags & FF_EXISTS)) // This FOF doesn't exist anymore. continue; - s2 = §ors[rover->secnum]; // makes things easier for us + s2 = §ors[rover->secnum]; // makes things easier for us - flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL); - cel = P_GetFOFTopZ(mo, s, rover, mo->x, mo->y, NULL); // Z coords for fof top/bottom. + checkfloor = (s2->flags & SF_FLIPSPECIAL_FLOOR); + checkceiling = (s2->flags & SF_FLIPSPECIAL_CEILING); + + if (checkfloor) + flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL); + if (checkceiling) + cel = P_GetFOFTopZ(mo, s, rover, mo->x, mo->y, NULL); // Z coords for fof top/bottom. // we will do essentially the same checks as above instead of bothering with top/bottom height of the FOF. // Reminder that an FOF's floor is its bottom, silly! - if ( ((s2->flags & SF_FLIPSPECIAL_FLOOR) && mo->z == cel) // "floor" check - || ((s2->flags & SF_FLIPSPECIAL_CEILING) && (mo->z + mo->height) == flr) ) // "ceiling" check. - - for (i = 2; i < 5; i++) // check for sector special - - if (GETSECSPECIAL(s2->special, 1) == i) - return i-1; // return offroad type - + if ( (checkfloor && mo->z == cel) // "floor" check + || (checkceiling && (mo->z + mo->height) == flr)) // "ceiling" check. + { + const INT32 special = GETSECSPECIAL(s2->special, 1); + for (i = 2; i < 5; i++) // check for sector special + { + if (special == i) + return i-1; // return offroad type + } + } } } - return 0; // couldn't find any offroad + + return 0; // couldn't find any offroad } /** \brief Updates the Player's offroad value once per frame @@ -2317,10 +2335,13 @@ fixed_t K_3dKartMovement(player_t *player, boolean onground, fixed_t forwardmove finalspeed *= forwardmove/25; finalspeed /= 2; - if (forwardmove < 0 && finalspeed > mapobjectscale*2) - return finalspeed/2; - else if (forwardmove < 0) + if (forwardmove < 0) + { + if (finalspeed > mapobjectscale*2) + return finalspeed/2; + return -mapobjectscale/2; + } if (finalspeed < 0) finalspeed = 0; @@ -3693,7 +3714,7 @@ void K_DriftDustHandling(mobj_t *spawner) { angle_t anglediff; - if (!P_IsObjectOnGround(spawner) || leveltime % 2 != 0) + if (leveltime % 2 != 0 || !P_IsObjectOnGround(spawner)) return; if (spawner->player) @@ -4076,7 +4097,7 @@ static void K_DoThunderShield(player_t *player) mo->scale = player->mo->scale*3 + (player->mo->scale/2); // spawn horizontal bolts; - for (i=0; i<7; i++) + for (i = 0; i < 7; i++) { mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_THOK); mo->angle = P_RandomRange(0, 359)*ANG1; @@ -4087,7 +4108,7 @@ static void K_DoThunderShield(player_t *player) // spawn the radius thing: an = ANGLE_22h; - for (i=0; i<15; i++) + for (i = 0; i < 15; i++) { sx = player->mo->x + FixedMul((player->mo->scale*THUNDERRADIUS), FINECOSINE((an*i)>>ANGLETOFINESHIFT)); sy = player->mo->y + FixedMul((player->mo->scale*THUNDERRADIUS), FINESINE((an*i)>>ANGLETOFINESHIFT)); @@ -4179,12 +4200,12 @@ static void K_DoHyudoroSteal(player_t *player) void K_DoSneaker(player_t *player, INT32 type) { - const fixed_t intendedboost = K_GetSneakerBoostSpeed(); - if (!player->kartstuff[k_floorboost] || player->kartstuff[k_floorboost] == 3) { S_StartSound(player->mo, sfx_cdfm01); K_SpawnDashDustRelease(player); + + const fixed_t intendedboost = K_GetSneakerBoostSpeed(); if (intendedboost > player->kartstuff[k_speedboost]) player->kartstuff[k_destboostcam] = FixedMul(FRACUNIT, FixedDiv((intendedboost - player->kartstuff[k_speedboost]), intendedboost)); } diff --git a/src/m_textinput.c b/src/m_textinput.c index a7c048e66..0d68b2b5d 100644 --- a/src/m_textinput.c +++ b/src/m_textinput.c @@ -256,7 +256,7 @@ static boolean M_TextInputHandleBase(textinput_t *input, INT32 key, boolean emot return true; } - if (ctrldown && (cv_keyboardlayout.value!=3 || !altdown)) + if (ctrldown && (cv_keyboardlayout.value != 3 || !altdown)) { if (key == 'x' || key == 'X') { diff --git a/src/p_user.c b/src/p_user.c index a10da4fb3..9eddcc36d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -775,7 +775,7 @@ boolean P_IsObjectInGoop(mobj_t *mo) // boolean P_IsObjectOnGround(mobj_t *mo) { - if (UNLIKELY(P_IsObjectInGoop(mo))) + if (P_IsObjectInGoop(mo)) { // but I don't want you to ever 'stand' while submerged in goo. // You're in constant vertical momentum, even if you get stuck on something. From 64bed715097b172dbd1b0df9ebb2f45b15effb79 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Apr 2026 18:54:10 +0200 Subject: [PATCH 14/61] add toggle to allow controllers to control the game while window is unfocused can be toggled with "gamepadunfocused" or in the focus options --- src/d_netcmd.c | 1 + src/dedicated/i_system.c | 4 ++++ src/g_input.c | 1 + src/g_input.h | 1 + src/i_system.h | 2 ++ src/m_menudefs.c | 45 ++++++++++++++++++++-------------------- src/sdl/i_system.cpp | 5 +++++ 7 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 828ad136a..76495a09e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1010,6 +1010,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_gamepadled[i]); } + CV_RegisterVar(&cv_gamepadifunfocused); CV_RegisterVar(&cv_gamepadledifunfocused); CV_RegisterVar(&cv_rumbleifunfocused); diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 014533af8..9fe312eb7 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -735,6 +735,10 @@ const char *I_GetJoyName(INT32 joyindex) return NULL; } +void I_SetJoystickFocus(void) +{ +} + boolean I_GamepadHasLED(INT32 playernum) { (void)playernum; diff --git a/src/g_input.c b/src/g_input.c index 091027ada..c72ed6308 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -81,6 +81,7 @@ consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = { {"gamepadled4", "Skincolor", CV_SAVE|CV_CALL|CV_NOINIT, gamepadled_cons_t, led_off_handle4, 0, NULL, NULL, 0, 0, NULL} }; +consvar_t cv_gamepadifunfocused = {"gamepadunfocused", "Off", CV_SAVE|CV_CALL, CV_OnOff, I_SetJoystickFocus, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gamepadledifunfocused = {"gamepadledunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_rumbleifunfocused = {"rumbleifunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; diff --git a/src/g_input.h b/src/g_input.h index 154f0805d..1cf4b2956 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -116,6 +116,7 @@ extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_gamepadifunfocused; extern consvar_t cv_gamepadledifunfocused; extern consvar_t cv_rumbleifunfocused; diff --git a/src/i_system.h b/src/i_system.h index 88bb9c985..9457e9c6d 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -148,6 +148,8 @@ extern INT32 numcontrollers; */ const char *I_GetJoyName(INT32 joyindex); +void I_SetJoystickFocus(void); + boolean I_GamepadHasLED(INT32 playernum); boolean I_GamepadHasRumble(INT32 playernum); diff --git a/src/m_menudefs.c b/src/m_menudefs.c index af6deacb8..9c1da4e29 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1185,20 +1185,20 @@ static menuitem_t OP_FocusOptionsMenu[] = { {IT_HEADER, NULL, "Game Focus Options", NULL, 0}, - {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 30}, - {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 40}, + {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 10}, + {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 20}, - {IT_STRING|IT_CVAR, NULL, "Pause Game While Unfocused", &cv_pauseifunfocused, 60}, + {IT_STRING|IT_CVAR, NULL, "Pause Game While Unfocused", &cv_pauseifunfocused, 40}, - {IT_STRING|IT_CVAR, NULL, "Background FPS Cap", &cv_fpscapbg, 80}, + {IT_STRING|IT_CVAR, NULL, "Background FPS Cap", &cv_fpscapbg, 60}, - {IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 100}, + {IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 80}, - {IT_STRING|IT_CVAR, NULL, "Visible Mouse", &cv_mousevisible, 120}, - - {IT_STRING|IT_CVAR, NULL, "Gamepad LED Color While Unfocused ", &cv_gamepadledifunfocused, 140}, - {IT_STRING|IT_CVAR, NULL, "Gamepad Rumble While Unfocused", &cv_rumbleifunfocused, 150}, + {IT_STRING|IT_CVAR, NULL, "Visible Mouse", &cv_mousevisible, 100}, + {IT_STRING|IT_CVAR, NULL, "Gamepad Inputs While Unfocused", &cv_gamepadifunfocused, 120}, + {IT_STRING|IT_CVAR, NULL, "Gamepad LED Color While Unfocused ", &cv_gamepadledifunfocused, 130}, + {IT_STRING|IT_CVAR, NULL, "Gamepad Rumble While Unfocused", &cv_rumbleifunfocused, 140}, }; static const char* OP_FocusOptionsTooltips[] = @@ -1210,6 +1210,7 @@ static const char* OP_FocusOptionsTooltips[] = "Set manual framerate cap while the game is unfocused.", "Should the FOCUS LOST window appear\n while the game is unfocused?", "Displays the mouse cursor while the game is in focus.", + "Should gamepad still control the game when unfocused?", "Should gamepad LED indicator change color when unfocused?", "Should gamepad rumble apply when unfocused?", }; @@ -1304,29 +1305,29 @@ static menuitem_t OP_DiscordOptionsMenu[] = static menuitem_t OP_HUDOptionsMenu[] = { - {IT_STRING | IT_CVAR, NULL, "Show HUD (F3)", &cv_showhud, 10}, + {IT_STRING | IT_CVAR, NULL, "Show HUD (F3)", &cv_showhud, 10}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "HUD Visibility", &cv_translucenthud, 20}, + NULL, "HUD Visibility", &cv_translucenthud, 20}, - {IT_STRING | IT_SUBMENU, NULL, "Online HUD options...", &OP_ChatOptionsDef, 35}, - {IT_STRING | IT_CVAR, NULL, "Background Glass", &cons_backcolor, 45}, + {IT_STRING | IT_SUBMENU, NULL, "Online HUD options...", &OP_ChatOptionsDef, 35}, + {IT_STRING | IT_CVAR, NULL, "Background Glass", &cons_backcolor, 45}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Minimap Visibility", &cv_kartminimap, 60}, - {IT_STRING | IT_CVAR, NULL, "Speedometer Display", &cv_kartspeedometer, 70}, - {IT_STRING | IT_CVAR, NULL, "Show \"CHECK\"", &cv_kartcheck, 80}, + NULL, "Minimap Visibility", &cv_kartminimap, 60}, + {IT_STRING | IT_CVAR, NULL, "Speedometer Display", &cv_kartspeedometer, 70}, + {IT_STRING | IT_CVAR, NULL, "Show \"CHECK\"", &cv_kartcheck, 80}, - {IT_STRING | IT_CVAR, NULL, "Menu Highlights", &cons_menuhighlight, 95}, + {IT_STRING | IT_CVAR, NULL, "Menu Highlights", &cons_menuhighlight, 95}, // highlight info - (GOOD HIGHLIGHT, WARNING HIGHLIGHT) - 110 (see M_DrawHUDOptions) - {IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 120}, - {IT_STRING | IT_CVAR, NULL, "Show Console Prints in Menu",&cons_consoleprintinmenu, 130}, + {IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 120}, + {IT_STRING | IT_CVAR, NULL, "Show Console Prints in Menu",&cons_consoleprintinmenu, 130}, - {IT_STRING | IT_CVAR, NULL, "Show Track Addon Name", &cv_showtrackaddon, 145}, + {IT_STRING | IT_CVAR, NULL, "Show Track Addon Name", &cv_showtrackaddon, 145}, - {IT_STRING | IT_CVAR, NULL, "Show All Maps", &cv_showallmaps, 155}, + {IT_STRING | IT_CVAR, NULL, "Show All Maps", &cv_showallmaps, 155}, - {IT_STRING | IT_CVAR, NULL, "2D character select", &cv_skinselectmenu, 165}, + {IT_STRING | IT_CVAR, NULL, "2D character select", &cv_skinselectmenu, 165}, }; static menuitem_t OP_CamOptionsMenu[] = diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index ae11829c6..396c59b5b 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -961,6 +961,11 @@ static int joy_open(int playerIndex, int joyIndex) return SDL_CONTROLLER_AXIS_MAX; } +void I_SetJoystickFocus(void) +{ + SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, cv_gamepadifunfocused.value ? "1" : "0"); +} + // // I_InitJoystick // From ff3b73c49e2e1e18804f43a1d95f94491595291e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 17 Apr 2026 20:53:16 +0200 Subject: [PATCH 15/61] fix offroad oopsie causing desynch ye def not confusing at all to suddenly switch the meaning of floor and ceiling --- src/k_kart.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f4577eb03..53bcae3ef 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1648,9 +1648,10 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) checkfloor = (s2->flags & SF_FLIPSPECIAL_FLOOR); checkceiling = (s2->flags & SF_FLIPSPECIAL_CEILING); - if (checkfloor) - flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL); + // def not confusing at all..... if (checkceiling) + flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL); + if (checkfloor) cel = P_GetFOFTopZ(mo, s, rover, mo->x, mo->y, NULL); // Z coords for fof top/bottom. // we will do essentially the same checks as above instead of bothering with top/bottom height of the FOF. From 31ccf9c34ae23468bba83d6dcb7544b1f084b6ee Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 18 Apr 2026 18:45:35 +0200 Subject: [PATCH 16/61] optimize K_CheckOffroadCollide further also makes this alot more readable like this most of the time we dont have to ever check the players floorz nor ceilingz at all since we check if the sector the players mobj is in is even offroad at all nothing super big but i did see an improvement of around 1fps in my usual benchmark --- src/k_kart.c | 71 +++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 53bcae3ef..b87894dae 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1600,10 +1600,8 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) sector_t *s2; // FOF sector shortcut ffloor_t *rover; // FOF - fixed_t flr = 0, cel = 0; // floor & ceiling for height checks to make sure we're touching the offroad sector. - - boolean checkfloor = false; - boolean checkceiling = false; + fixed_t flr, cel; // floor & ceiling for height checks to make sure we're touching the offroad sector. + INT32 special; I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); @@ -1614,25 +1612,28 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) break; // shouldn't happen. s = node->m_sector; + // 1: Check for the main sector, make sure we're on the floor of that sector and see if we can apply offroad. // Make arbitrary Z checks because we want to check for 1 sector in particular, we don't want to affect the player if the offroad sector is way below them and they're lineriding a normal sector above. - checkfloor = (s->flags & SF_FLIPSPECIAL_FLOOR); - checkceiling = (mo->eflags & MFE_VERTICALFLIP && (s->flags & SF_FLIPSPECIAL_CEILING)); - - if (checkfloor) - flr = P_MobjFloorZ(mo, s, s, mo->x, mo->y, NULL, false, true); - if (checkceiling) - cel = P_MobjCeilingZ(mo, s, s, mo->x, mo->y, NULL, true, true); // get Z coords of both floors and ceilings for this sector (this accounts for slopes properly.) - // NOTE: we don't use P_GetZAt with our x/y directly because the mobj won't have the same height because of its hitbox on the slope. Complex garbage but tldr it doesn't work. - - if ( (checkfloor && mo->z == flr) // floor check - || ((checkceiling && (mo->z + mo->height) == cel))) // ceiling check. + special = GETSECSPECIAL(s->special, 1); + for (i = 2; i < 5; i++) // check for sector special { - const INT32 special = GETSECSPECIAL(s->special, 1); - for (i = 2; i < 5; i++) // check for sector special + if (special != i) + continue; + + if (s->flags & SF_FLIPSPECIAL_FLOOR) { - if (special == i) + flr = P_MobjFloorZ(mo, s, s, mo->x, mo->y, NULL, false, true); + if (mo->z == flr) // floor check + return i-1; // return offroad type + } + + if (mo->eflags & MFE_VERTICALFLIP && (s->flags & SF_FLIPSPECIAL_CEILING)) + { + cel = P_MobjCeilingZ(mo, s, s, mo->x, mo->y, NULL, true, true); + // NOTE: we don't use P_GetZAt with our x/y directly because the mobj won't have the same height because of its hitbox on the slope. Complex garbage but tldr it doesn't work. + if ((mo->z + mo->height) == cel) // ceiling check return i-1; // return offroad type } } @@ -1645,24 +1646,26 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) s2 = §ors[rover->secnum]; // makes things easier for us - checkfloor = (s2->flags & SF_FLIPSPECIAL_FLOOR); - checkceiling = (s2->flags & SF_FLIPSPECIAL_CEILING); - - // def not confusing at all..... - if (checkceiling) - flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL); - if (checkfloor) - cel = P_GetFOFTopZ(mo, s, rover, mo->x, mo->y, NULL); // Z coords for fof top/bottom. - - // we will do essentially the same checks as above instead of bothering with top/bottom height of the FOF. - // Reminder that an FOF's floor is its bottom, silly! - if ( (checkfloor && mo->z == cel) // "floor" check - || (checkceiling && (mo->z + mo->height) == flr)) // "ceiling" check. + special = GETSECSPECIAL(s2->special, 1); + for (i = 2; i < 5; i++) // check for sector special { - const INT32 special = GETSECSPECIAL(s2->special, 1); - for (i = 2; i < 5; i++) // check for sector special + if (special != i) + continue; + + // we will do essentially the same checks as above instead of bothering with top/bottom height of the FOF. + // Reminder that an FOF's floor is its bottom, silly! + + if (s2->flags & SF_FLIPSPECIAL_FLOOR) { - if (special == i) + cel = P_GetFOFTopZ(mo, s, rover, mo->x, mo->y, NULL); // Z coords for fof top/bottom. + if (mo->z == cel) // "floor" check + return i-1; // return offroad type + } + + if (s2->flags & SF_FLIPSPECIAL_CEILING) + { + flr = P_GetFOFBottomZ(mo, s, rover, mo->x, mo->y, NULL); + if ((mo->z + mo->height) == flr) // "ceiling" check return i-1; // return offroad type } } From 7931a82b233e097c762224ab261181011ba07cad Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 21 Apr 2026 20:48:56 +0200 Subject: [PATCH 17/61] attempt to fix a plethora of buffer overflows when trying to connect to a server that does not exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ex: if you typo´d the serveraddress this really aint pretty but idk how to make things not turn into limbo hell otherwise --- src/d_clisrv.c | 14 ++++++++++++++ src/i_tcp.c | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 192a2cceb..b62f97124 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3390,6 +3390,20 @@ static void Command_connect(void) } else CONS_Alert(CONS_ERROR, M_GetText("There is no network driver\n")); + + // invalid address + if (servernode == -1) + { + D_QuitNetGame(); // this will also call D_CloseConnection for us + CL_Reset(); + servernode = 0; // not sure if this is cool, but if this is -1 then bad things happen in alot of networking code + multiplayer = false; + netgame = false; + + D_StartTitle(); + M_StartMessage(M_GetText("Failed to connect to server\nMake sure you put in a valid Address!\n"), NULL, MM_NOTHING); + return; + } } CV_Set(&cv_lastserver, I_GetNodeAddress(servernode)); diff --git a/src/i_tcp.c b/src/i_tcp.c index 9723d5b2d..f7f4a3210 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -392,6 +392,9 @@ static const char *SOCK_GetNodeAddress(INT32 node) if (node == 0) return "self"; + if (node < 0 || node > MAXNETNODES) + return NULL; + if (!nodeconnected[node]) return NULL; From c343c524772c8a63ce1f9523006ca71a11de4439 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Apr 2026 10:07:35 +0200 Subject: [PATCH 18/61] remove "extra3" hud stuff decided to finally make smol stickers for the beta hud this was never a really great solution since it made things look pretty bad at certain resolutions/scales still keep the loading code for convenience but honestly not needed aswell at this point --- src/d_main.c | 17 ------------- src/d_main.h | 2 -- src/k_hud.c | 69 ++++++---------------------------------------------- src/k_kart.c | 3 ++- 4 files changed, 10 insertions(+), 81 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 9443c0a47..eb503b39f 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1416,8 +1416,6 @@ static inline void D_MakeTitleString(char *s) // extra graphic patches for saturn specific thingies boolean xtra_speedo = false; // extra speedometer check boolean xtra_speedo_clr = false; // extra speedometer colour check -boolean xtra_speedo3 = false; // 80x 11 extra speedometer check -boolean xtra_speedo_clr3 = false; // 80x 11 extra speedometer colour check boolean achi_speedo = false; // achiiro speedometer check boolean achi_speedo_clr = false; // extra speedometer colour check boolean dial_speedo = false; // dial speedometer check @@ -1447,7 +1445,6 @@ static void D_CheckSaturnExtraFiles(void) CV_PossibleValue_t minimapdot_cons_temp[NUMMINIMAPDOTSTUFF] = {{0, "Off"}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}; unsigned last_speedo_i = 0; - unsigned last_driftgauge_i = 3; unsigned last_inputdisplay_i = 2; unsigned last_minimapdot_i = 0; #define PUSHCONS(cons, i, id, name) { ++i; cons[i].value = id; cons[i].strvalue = name; } @@ -1606,20 +1603,6 @@ static void D_CheckSaturnExtraFiles(void) if (found_extra3_kart) { mainwads++; - - // 80x11 speedometer crap - if (W_LumpExists("SP_SM3TC")) - { - xtra_speedo3 = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 7, "Extra"); - PUSHCONS(driftgaugestyle_cons_temp, last_driftgauge_i, 5, "Extra"); - } - - // 80x11 speedometer crap but colour - if (W_LumpExists("SC_SM3TC")) - { - xtra_speedo_clr3 = true; - } } #undef PUSHCONS diff --git a/src/d_main.h b/src/d_main.h index 8f1475706..8bbf79df0 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -38,8 +38,6 @@ extern boolean found_extra3_kart; // for use in k_kart.c extern boolean xtra_speedo; // extra speedometer check extern boolean xtra_speedo_clr; // extra speedometer colour check -extern boolean xtra_speedo3; // 80x11 extra speedometer check -extern boolean xtra_speedo_clr3; // 80x11 extra speedometer colour check extern boolean achi_speedo; // achiiro speedometer check extern boolean achi_speedo_clr; // extra speedometer colour check extern boolean dial_speedo; // dial speedometer check diff --git a/src/k_hud.c b/src/k_hud.c index ce60d23c8..4e2f6477f 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -274,7 +274,6 @@ void K_RegisterKartHudStuff(void) // Smol speedo static patch_t *skp_smallsticker = NULL; -static patch_t *skp_smallsticker3 = NULL; static patch_t *skp_speedpatches[5] = {NULL}; @@ -312,7 +311,6 @@ static patch_t *kp_bumperstickerwideclr = NULL; static patch_t *kp_karmastickerclr = NULL; static patch_t *kp_timeoutstickerclr = NULL; static patch_t *skp_smallstickerclr = NULL; -static patch_t *skp_smallstickerclr3 = NULL; static patch_t *kp_itemmulstickerclr[2] = {NULL}; static patch_t *kp_itembgclr[4] = {NULL}; @@ -478,11 +476,6 @@ static void K_LoadSaturnHUDGraphics(void) skp_smallstickerclr = (patch_t *)W_CachePatchName("SC_SMSTC", PU_HUDGFX); } - if (xtra_speedo_clr3) - { - skp_smallstickerclr3 = (patch_t *)W_CachePatchName("SC_SM3TC", PU_HUDGFX); - } - if (achi_speedo_clr) { skp_smallstickerachiclr = (patch_t *)W_CachePatchName("SC_AMSTC", PU_HUDGFX); @@ -537,14 +530,6 @@ static void K_LoadSaturnHUDGraphics(void) kp_itemmulstickerclr[0] = (patch_t *)W_CachePatchName("K_ITMULC", PU_HUDGFX); } } - - if (found_extra3_kart) - { - if (xtra_speedo3) // 80x11 patch scaled to size - { - skp_smallsticker3 = (patch_t *)W_CachePatchName("SP_SM3TC", PU_HUDGFX); - } - } } // -- Kart patches -- @@ -879,7 +864,7 @@ void K_LoadKartHUDGraphics(void) kp_yougotem = (patch_t *)W_CachePatchName("YOUGOTEM", PU_HUDGFX); - if (found_extra_kart || found_extra2_kart || found_extra3_kart) + if (found_extra_kart || found_extra2_kart) K_LoadSaturnHUDGraphics(); } @@ -1149,7 +1134,6 @@ enum SPEEDO_DIAL, SPEEDO_PMETER, SPEEDO_PMETERSMOL, - SPEEDO_EXTRA3, }; static SINT8 K_GetSpeedometerStyle(void) @@ -1164,8 +1148,6 @@ static SINT8 K_GetSpeedometerStyle(void) return SPEEDO_PMETER; else if (cv_newspeedometer.value == 6 && kartz_speedo_smol) return SPEEDO_PMETERSMOL; - else if (cv_newspeedometer.value == 7 && xtra_speedo3) - return SPEEDO_EXTRA3; else return SPEEDO_VANILLA; } @@ -1183,8 +1165,6 @@ static boolean K_UseColorSpeedo(int speedostyle) return achi_speedo_clr; case SPEEDO_DIAL: return dial_speedo_clr; - case SPEEDO_EXTRA3: - return xtra_speedo_clr3; default: return false; } @@ -1196,7 +1176,6 @@ enum GAUGE_SMALL, GAUGE_BIGNUM, GAUGE_NUMONLY, - GAUGE_EXTRA, }; static SINT8 K_GetDriftgaugeStyle(void) @@ -1209,8 +1188,6 @@ static SINT8 K_GetDriftgaugeStyle(void) return GAUGE_SMALL; else if (cv_driftgaugestyle.value == 3) return GAUGE_BIGNUM; - else if (cv_driftgaugestyle.value == 5 && xtra_speedo3) - return GAUGE_EXTRA; } // Fallback @@ -1409,7 +1386,6 @@ static void K_drawKartStats(void) { case SPEEDO_EXTRA: case SPEEDO_ACHII: - case SPEEDO_EXTRA3: spdoffset = -10; break; case SPEEDO_DIAL: @@ -2748,19 +2724,6 @@ static void K_drawKartSpeedometer(void) (K_UseColorSpeedo(SPEEDO_DIAL))); } #endif - else if (speedostyle == SPEEDO_EXTRA3) // why bother if we dont? - { - if (K_UseColorSpeedo(SPEEDO_EXTRA3)) //Colourized hud - { - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((SPDM_X-1)<= driftval*4) // rainbow sparks { diff --git a/src/k_kart.c b/src/k_kart.c index b87894dae..5d8b9b37c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6225,7 +6225,8 @@ void K_KartUpdatePosition(player_t *player) players[i].kartstuff[k_prevcheck] += imo; ipcd++; } - if (isnextcheckpointi ) + + if (isnextcheckpointi) { players[i].kartstuff[k_nextcheck] += imo; incd++; From 6949ce82ab4d169270c547f8a819455d763f7bb4 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 23 Apr 2026 10:03:36 +0200 Subject: [PATCH 19/61] k_hud: fix achii speedometer not being properly coloured with colourhud oopsie smol oversight from me --- src/k_hud.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 4e2f6477f..ebbf2d0b2 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2694,24 +2694,25 @@ static void K_drawKartSpeedometer(void) else if (speedostyle == SPEEDO_EXTRA || speedostyle == SPEEDO_ACHII) // why bother if we dont? { patch_t *speedopat; + UINT8 *colormap = NULL; if (K_UseColorSpeedo(speedostyle)) //Colourized hud { - speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_smallstickerclr : skp_smallstickerachiclr); - UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_smallstickerclr : skp_smallstickerachiclr); V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat, colormap); + speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_speedpatches[cv_kartspeedometer.value] : skp_speedpatchesachiclr[cv_kartspeedometer.value]); } else { speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_smallsticker : skp_smallstickerachi); V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat); + speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_speedpatches[cv_kartspeedometer.value] : skp_speedpatchesachi[cv_kartspeedometer.value]); } V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); - - speedopat = ((speedostyle == SPEEDO_EXTRA) ? skp_speedpatches[cv_kartspeedometer.value] : skp_speedpatchesachi[cv_kartspeedometer.value]); - V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat); + V_DrawMappedPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, speedopat, colormap); } #ifdef ROTSPRITE else if (speedostyle == SPEEDO_DIAL) // why bother if we dont? From 3b00a69615b6cdc021f23f057f1ca6bc139a9fde Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Apr 2026 22:00:36 +0200 Subject: [PATCH 20/61] prevent buffer underflow within holepunching --- src/d_clisrv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b62f97124..e6ca41ab9 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2231,7 +2231,12 @@ static void CL_ReloadReceivedSavegame(void) static void SendAskInfo(INT32 node) { tic_t asktime; - doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); + doomdata_t *netbuffer; + + if (node == -1) + return; + + netbuffer = DOOMCOM_DATA(doomcom); #ifdef HOLEPUNCH if (node != 0 && node != BROADCASTADDR && From 568cb8b8c7a98725daed5a4ab240824744ef9159 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 27 Apr 2026 22:01:50 +0200 Subject: [PATCH 21/61] check I_GetNodeAddress is set before use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this might´ve not been init yet at that point --- src/d_clisrv.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e6ca41ab9..7811b55b3 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3402,16 +3402,14 @@ static void Command_connect(void) D_QuitNetGame(); // this will also call D_CloseConnection for us CL_Reset(); servernode = 0; // not sure if this is cool, but if this is -1 then bad things happen in alot of networking code - multiplayer = false; - netgame = false; - D_StartTitle(); M_StartMessage(M_GetText("Failed to connect to server\nMake sure you put in a valid Address!\n"), NULL, MM_NOTHING); return; } } - CV_Set(&cv_lastserver, I_GetNodeAddress(servernode)); + if (I_GetNodeAddress) + CV_Set(&cv_lastserver, I_GetNodeAddress(servernode)); if (splitscreen != cv_splitplayers.value-1) { From 8868445c3c78709e0f4875052f532bd9c714206b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Apr 2026 17:49:42 +0200 Subject: [PATCH 22/61] S_UpdateSounds: init listenmobj not sure why but ubsan did complain about it sometimes S_StartSoundAtVolume also just memsets it so why not do the same here anyways --- src/s_sound.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 40efbe909..f81690b24 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -722,12 +722,12 @@ void S_UpdateSounds(void) if (dedicated || sound_disabled) return; + memset(listenmobj, 0, sizeof(listenmobj)); + for (i = 0; i <= splitscreen; i++) { player_t *player = &players[displayplayers[i]]; - listenmobj[i] = NULL; - if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; From dbf67a9670d45f0b6bef7d4e582ae18664f53265 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Apr 2026 17:51:10 +0200 Subject: [PATCH 23/61] remove some branch hints in some places should really only use those for things that are basically dead but gotta be kept for compat reasons and such --- src/hardware/hw_main.cpp | 12 ++++++------ src/lua_script.c | 10 +++++----- src/p_map.c | 6 +++--- src/p_mobj.c | 35 ++++++++++++++++++++--------------- src/r_things.cpp | 14 +++++++------- 5 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index d2fc90472..ce683bda7 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -4857,9 +4857,9 @@ static void HWR_ProjectSprite(mobj_t *thing) flip ^= (1<lumpid[0]; flip = sprframe->flip; // Will only be 0x00 or 0xFF - spr_width = spritecachedinfo[lumpoff].width; - spr_height = spritecachedinfo[lumpoff].height; - spr_offset = spritecachedinfo[lumpoff].offset; + spr_width = spritecachedinfo[lumpoff].width; + spr_height = spritecachedinfo[lumpoff].height; + spr_offset = spritecachedinfo[lumpoff].offset; spr_topoffset = spritecachedinfo[lumpoff].topoffset; if (flip) diff --git a/src/lua_script.c b/src/lua_script.c index 8982688a1..8e07f87e3 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -979,7 +979,7 @@ static void ArchiveExtVars(UINT8 **p, void *pointer, const char *ptype) if (!gL) { - if (fastcmp(ptype,"player")) // players must always be included, even if no vars + if (fastcmp(ptype, "player")) // players must always be included, even if no vars WRITEUINT16(*p, 0); return; } @@ -995,7 +995,7 @@ static void ArchiveExtVars(UINT8 **p, void *pointer, const char *ptype) if (!lua_istable(gL, -1)) { // no extra values table lua_pop(gL, 1); - if (fastcmp(ptype,"player")) // players must always be included, even if no vars + if (fastcmp(ptype, "player")) // players must always be included, even if no vars WRITEUINT16(*p, 0); return; } @@ -1007,13 +1007,13 @@ static void ArchiveExtVars(UINT8 **p, void *pointer, const char *ptype) // skip anything that has an empty table and isn't a player. if (i == 0) { - if (fastcmp(ptype,"player")) // always include players even if they have no extra variables + if (fastcmp(ptype, "player")) // always include players even if they have no extra variables WRITEUINT16(*p, 0); lua_pop(gL, 1); return; } - if (fastcmp(ptype,"mobj")) // mobjs must write their mobjnum as a header + if (fastcmp(ptype, "mobj")) // mobjs must write their mobjnum as a header WRITEUINT32(*p, ((mobj_t *)pointer)->mobjnum); WRITEUINT16(*p, i); @@ -1083,8 +1083,8 @@ static void ArchiveTables(UINT8 **p) CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1)); lua_pop(gL, 1); - } + lua_pop(gL, 1); WRITEUINT8(*p, ARCH_TEND); } diff --git a/src/p_map.c b/src/p_map.c index e51930bef..da71b169f 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -189,12 +189,12 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) } if (vertispeed) - object->momz = FixedMul(vertispeed,FixedSqrt(FixedMul(vscale, spring->scale))); + object->momz = FixedMul(vertispeed, FixedSqrt(FixedMul(vscale, spring->scale))); if (horizspeed) { if (!object->player) - P_InstaThrustEvenIn2D(object, spring->angle, FixedMul(horizspeed,FixedSqrt(FixedMul(hscale, spring->scale)))); + P_InstaThrustEvenIn2D(object, spring->angle, FixedMul(horizspeed, FixedSqrt(FixedMul(hscale, spring->scale)))); else { fixed_t finalSpeed = FixedDiv(horizspeed, hscale); @@ -203,7 +203,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (pSpeed > finalSpeed) finalSpeed = pSpeed; - P_InstaThrustEvenIn2D(object, spring->angle, FixedMul(finalSpeed,FixedSqrt(FixedMul(hscale, spring->scale)))); + P_InstaThrustEvenIn2D(object, spring->angle, FixedMul(finalSpeed, FixedSqrt(FixedMul(hscale, spring->scale)))); } } diff --git a/src/p_mobj.c b/src/p_mobj.c index a413feda8..9bd6e65dd 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -890,6 +890,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f else // Well, that makes it easy. Just get the ceiling height return sector->ceilingheight; } + static void P_PlayerFlip(mobj_t *mo) { if (!mo->player) @@ -2443,6 +2444,7 @@ static void P_PlayerZMovement(mobj_t *mo) } goto nightsdone; } + // Get up if you fell. if ((mo->state == &states[mo->info->painstate] || mo->state == &states[S_KART_SPIN]) && mo->player->kartstuff[k_spinouttimer] == 0 && mo->player->kartstuff[k_squishedtimer] == 0) // SRB2kart @@ -2495,7 +2497,7 @@ static void P_PlayerZMovement(mobj_t *mo) polyobj_t *po = newsubsec->polyList; sector_t *polysec; - while(po) + while (po) { if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) { @@ -3375,20 +3377,23 @@ static void P_PlayerMobjThinker(mobj_t *mobj) mobj->eflags &= ~MFE_JUSTSTEPPEDDOWN; // Zoom tube - if (UNLIKELY(mobj->tracer && mobj->tracer->type == MT_TUBEWAYPOINT)) + if (mobj->tracer) { - P_UnsetThingPosition(mobj); - mobj->x += mobj->momx; - mobj->y += mobj->momy; - mobj->z += mobj->momz; - P_SetThingPosition(mobj); - P_CheckPosition(mobj, mobj->x, mobj->y); - goto animonly; - } - else if (UNLIKELY(mobj->player->pflags & PF_MACESPIN && mobj->tracer)) - { - P_CheckPosition(mobj, mobj->x, mobj->y); - goto animonly; + if (mobj->tracer->type == MT_TUBEWAYPOINT) + { + P_UnsetThingPosition(mobj); + mobj->x += mobj->momx; + mobj->y += mobj->momy; + mobj->z += mobj->momz; + P_SetThingPosition(mobj); + P_CheckPosition(mobj, mobj->x, mobj->y); + goto animonly; + } + else if (UNLIKELY(mobj->player->pflags & PF_MACESPIN)) + { + P_CheckPosition(mobj, mobj->x, mobj->y); + goto animonly; + } } // Needed for gravity boots @@ -3404,7 +3409,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) else P_TryMove(mobj, mobj->x, mobj->y, true); - if (LIKELY(!(netgame && mobj->player->spectator))) + if (!(netgame && mobj->player->spectator)) { // Crumbling platforms for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) diff --git a/src/r_things.cpp b/src/r_things.cpp index 787c35250..52f8be112 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1357,9 +1357,9 @@ static void R_ProjectSprite(mobj_t *thing) I_Assert(lump < max_spritelumps); - spr_width = spritecachedinfo[lump].width; - spr_height = spritecachedinfo[lump].height; - spr_offset = spritecachedinfo[lump].offset; + spr_width = spritecachedinfo[lump].width; + spr_height = spritecachedinfo[lump].height; + spr_offset = spritecachedinfo[lump].offset; spr_topoffset = spritecachedinfo[lump].topoffset; #ifdef ROTSPRITE @@ -1400,10 +1400,10 @@ static void R_ProjectSprite(mobj_t *thing) if (rotsprite != NULL) { - spr_width = rotsprite->width << FRACBITS; - spr_height = rotsprite->height << FRACBITS; - spr_offset = rotsprite->leftoffset << FRACBITS; - spr_topoffset = rotsprite->topoffset << FRACBITS; + spr_width = rotsprite->width << FRACBITS; + spr_height = rotsprite->height << FRACBITS; + spr_offset = rotsprite->leftoffset << FRACBITS; + spr_topoffset = rotsprite->topoffset << FRACBITS; spr_topoffset += FEETADJUST; // flip -> rotate, not rotate -> flip From 010b6c0361a6476233cb1d389704c1d6e4f0e9c7 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Apr 2026 17:52:23 +0200 Subject: [PATCH 24/61] use destructor attribute for W_Shutdown makes sure this is always called in any case also just simpler --- src/dedicated/i_system.c | 4 ---- src/sdl/i_system.cpp | 4 ---- src/w_wad.c | 2 +- src/w_wad.h | 2 -- 4 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 9fe312eb7..12932295d 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1458,7 +1458,6 @@ void I_Quit(void) free(myargv); // Deallocate allocated memory death: - W_Shutdown(); exit(0); } @@ -1504,7 +1503,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) I_OutputMsg("SRB2Kart %s Recursive Error", buffer); - W_Shutdown(); exit(-1); // recursive errors detected } } @@ -1539,8 +1537,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) I_ShutdownGraphics(); I_ShutdownSystem(); - W_Shutdown(); - #if defined (PARANOIA) && defined (__CYGWIN__) *(INT32 *)2 = 4; //Alam: Debug! #endif diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 396c59b5b..bf09ab0ca 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -2019,7 +2019,6 @@ FUNCNORETURN void ATTRNORETURN I_Quit(void) if (myargmalloc) free(myargv); // Deallocate allocated memory - W_Shutdown(); exit(0); } @@ -2079,7 +2078,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) sigttl = "SRB2Kart " VERSIONSTRING " Recursive Error"; I_ShowSimpleErrorBox(sigttl, buffer); - W_Shutdown(); exit(-1); // recursive errors detected } } @@ -2121,8 +2119,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) //I_ShowSimpleErrorBox(sigttl, buffer); I_ShowErrorBox(sigttl, buffer); - W_Shutdown(); - #if defined (PARANOIA) && defined (__CYGWIN__) *(INT32 *)2 = 4; //Alam: Debug! #endif diff --git a/src/w_wad.c b/src/w_wad.c index 53b0ed65b..1099667e0 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -128,7 +128,7 @@ wadfile_t *wadfiles[MAX_WADFILES] = {}; // 0 to numwadfiles-1 are valid // If not done on a Mac then open wad files // can prevent removable media they are on from // being ejected -void W_Shutdown(void) +DESTRUCTOR static void W_Shutdown(void) { lumpnum_map_cleanup(&lumpnumcache); diff --git a/src/w_wad.h b/src/w_wad.h index 474f72c23..a17023821 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -154,8 +154,6 @@ extern wadfile_t *wadfiles[MAX_WADFILES]; // ========================================================================= -void W_Shutdown(void); - // Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened FILE *W_OpenWadFile(const char **filename, boolean useerrors); // Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error From 9df7f3cd3f32fde37757a5063b64ce7314ae324e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Apr 2026 17:54:25 +0200 Subject: [PATCH 25/61] dont let saltyhop overwrite the players spriteyoffset let it add to it instead otherwise if we ever use it for smth else in hardcode saltyhop will work with it --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 5d8b9b37c..f7fdba2ad 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3445,7 +3445,7 @@ static void K_QuiteSaltyHop(player_t *player) pmo->spritexscale -= (FRACUNIT/8); } - pmo->spriteyoffset = FixedMul(psalt->zoffset, cv_saltyheight.value); + pmo->spriteyoffset += FixedMul(psalt->zoffset, cv_saltyheight.value); if (cv_saltyhopsfx.value) { From 1bada2810a076ebfc77c3d12df05e6496c26287b Mon Sep 17 00:00:00 2001 From: minenice55 Date: Sun, 26 Apr 2026 19:36:07 -0400 Subject: [PATCH 26/61] cap download size to total size in the connection UI --- 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 7811b55b3..ffb43ee86 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1491,8 +1491,8 @@ static void CL_DrawConnectionStatus(void) static char tempname[28]; fileneeded_t *file = &fileneeded[filedownload.current]; char *filename = file->filename; - UINT32 currentsize = file->currentsize; UINT32 totalsize = file->totalsize; + UINT32 currentsize = min(file->currentsize, file->totalsize); // Draw the bottom box. M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); From 093ed023ef36bb2e8608116ef39d7710366ccf84 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Apr 2026 17:47:55 +0200 Subject: [PATCH 27/61] cleanup CL_DrawConnectionStatus a little --- src/d_clisrv.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ffb43ee86..2228eb172 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1255,20 +1255,18 @@ static void CL_DrawConnectionStatus(void) case CL_DOWNLOADSAVEGAME: if (filedownload.current != -1) { - INT32 dldlength = 0; + UINT32 dldlength = 0; fileneeded_t *file = &fileneeded[filedownload.current]; - UINT32 currentsize = file->currentsize; UINT32 totalsize = file->totalsize; + UINT32 currentsize = min(file->currentsize, totalsize); cltext = M_GetText("Downloading game state..."); Net_GetNetStat(); if (totalsize != 0) - dldlength = (INT32)((currentsize/(double)totalsize) * 256); - if (dldlength > 256) - dldlength = 256; + dldlength = (UINT32)((currentsize/(double)totalsize) * 256); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 111); - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, dldlength, 8, 96); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, (INT32)dldlength, 8, 96); V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, va(" %4uK/%4uK", currentsize>>10, totalsize>>10)); @@ -1485,14 +1483,14 @@ static void CL_DrawConnectionStatus(void) } else if (filedownload.current != -1) { - INT32 dldlength = 0; - INT32 totalfileslength = 0; + UINT32 dldlength = 0; UINT32 totaldldsize = 0; + UINT32 totalfileslength = filedownload.totalsize; static char tempname[28]; fileneeded_t *file = &fileneeded[filedownload.current]; char *filename = file->filename; UINT32 totalsize = file->totalsize; - UINT32 currentsize = min(file->currentsize, file->totalsize); + UINT32 currentsize = min(file->currentsize, totalsize); // Draw the bottom box. M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); @@ -1500,11 +1498,9 @@ static void CL_DrawConnectionStatus(void) Net_GetNetStat(); if (totalsize != 0) - dldlength = (INT32)((currentsize/(double)totalsize) * 256); - if (dldlength > 256) - dldlength = 256; + dldlength = (UINT32)((currentsize/(double)totalsize) * 256); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, 256, 8, 175); - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, dldlength, 8, 160); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, (INT32)dldlength, 8, 160); memset(tempname, 0, sizeof(tempname)); @@ -1545,18 +1541,18 @@ static void CL_DrawConnectionStatus(void) totaldldsize = filedownload.completedsize; V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP|MENUCAPS, "Overall Download Progress"); - if (filedownload.totalsize != 0) - totalfileslength = (INT32)((totaldldsize/(double)filedownload.totalsize) * 256); + if (totalfileslength != 0) + totalfileslength = (UINT32)((totaldldsize/(double)totalfileslength) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); - V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, (INT32)totalfileslength, 8, 160); - if (filedownload.totalsize>>20 >= 10) // display in MB if over 10MB + if (totalfileslength>>20 >= 10) // display in MB if over 10MB V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uM/%4uM", totaldldsize>>20, filedownload.totalsize>>20)); + va(" %4uM/%4uM", (INT32)(totaldldsize>>20), (INT32)(totalfileslength>>20))); else V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uK/%4uK", totaldldsize>>10, filedownload.totalsize>>10)); + va(" %4uK/%4uK", (INT32)(totaldldsize>>10), (INT32)(totalfileslength>>10))); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va("%2u/%2u Files ", filedownload.completednum, filedownload.totalnum)); From 6460ae94f119b224291a9addd0132e135dd45d6b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 29 Apr 2026 17:43:10 +0200 Subject: [PATCH 28/61] remove magic number for P_CalculatePrecipFloor stuff --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 9bd6e65dd..605395816 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3627,7 +3627,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj) return true; // only recalc this twice a second (doubt anyone will notice this lulul) - if ((leveltime % 17) == 0) + if ((leveltime % (TICRATE/2)) == 0) P_CalculatePrecipFloor(mobj); // adjust height From 535c2073f1512311c2a9fb64b6cd615070e106b1 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 1 May 2026 03:51:28 +0200 Subject: [PATCH 29/61] move palshader code out of HWR_DrawScreenFinalTexture and make the whole handling safer so we have less chance of ending up with blackscreens should the palette render shader fail --- src/hardware/hw_gl.h | 3 ++- src/hardware/hw_main.h | 4 ++-- src/hardware/r_opengl/r_opengl.c | 15 ++++++++------- src/sdl/ogl_sdl.c | 15 +++++++++++++-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/hardware/hw_gl.h b/src/hardware/hw_gl.h index de5ac6338..351b36353 100644 --- a/src/hardware/hw_gl.h +++ b/src/hardware/hw_gl.h @@ -63,7 +63,7 @@ void GL_FlushScreenTextures(void); void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags); void GL_DoScreenWipe(int wipeStart, int wipeEnd); void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize); -void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean useshader); +void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height); void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]); @@ -72,6 +72,7 @@ void GL_LoadShader(int slot, char *code, hwdshaderstage_t stage); boolean GL_CompileShader(int slot); void GL_SetShader(int slot); void GL_UnSetShader(void); +void GL_EnableShader(void); void GL_SetShaderInfo(hwdshaderinfo_t info, INT32 value); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index cbd8e11e7..a632946c1 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -161,9 +161,9 @@ FUNCINLINE static ATTRINLINE void HWR_MakeScreenFinalTexture(void) GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); } -FUNCINLINE static ATTRINLINE void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader) +FUNCINLINE static ATTRINLINE void HWR_DrawScreenFinalTexture(INT32 width, INT32 height) { - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height, useshader); + GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height); } // hw_main.c: Segs diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index a759b8b2b..1a8e2a8c4 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1068,6 +1068,13 @@ void GL_SetShader(int slot) gl_shadersenabled = false; } +void GL_EnableShader(void) +{ + // we can just use GL_Shader_SetUniforms as itll enable the shader for us + // and handle any failures + GL_Shader_SetUniforms(NULL, NULL, NULL, NULL); +} + void GL_UnSetShader(void) { if (gl_shadersenabled) // don't repeatedly call glUseProgram if not needed @@ -3718,7 +3725,7 @@ void GL_MakeScreenTexture(int tex) tex_downloaded = screenTextures[tex]; } -void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean useshader) +void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height) { float xfix, yfix; float origaspect, newaspect; @@ -3771,9 +3778,6 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh pglBindTexture(GL_TEXTURE_2D, screenTextures[tex]); - if (useshader) - pglUseProgram(gl_shaders[SHADER_PALETTE_POSTPROCESS].program); // Final postprocess step of palette rendering, after everything else has been drawn. - pglColor4ubv(white); pglTexCoordPointer(2, GL_FLOAT, 0, fix); @@ -3781,9 +3785,6 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); - if (useshader) - pglUseProgram(0); - tex_downloaded = screenTextures[tex]; } diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 46af6e178..f5e7f2aea 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -240,7 +240,18 @@ void OglSdlFinishUpdate(SDL_Window *window) } #endif - HWR_DrawScreenFinalTexture(sdlw, sdlh, HWR_ShouldUsePaletteRendering()); + if (HWR_ShouldUsePaletteRendering()) + { + // Final postprocess step of palette rendering, after everything else has been drawn. + GL_SetShader(HWR_GetShaderFromTarget(SHADER_PALETTE_POSTPROCESS)); + GL_EnableShader(); + HWR_DrawScreenFinalTexture(sdlw, sdlh); + GL_UnSetShader(); + } + else + { + HWR_DrawScreenFinalTexture(sdlw, sdlh); + } #ifdef USE_FBO_OGL if (usefbo) @@ -261,7 +272,7 @@ void OglSdlFinishUpdate(SDL_Window *window) #else if (!I_CheckNativeRes() || WipeInAction) #endif - HWR_DrawScreenFinalTexture(realwidth, realheight, false); + HWR_DrawScreenFinalTexture(realwidth, realheight); } #endif //HWRENDER From 370ed1583bd9838401926c71c348f58d4afb4620 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 2 May 2026 21:02:38 +0200 Subject: [PATCH 30/61] comment out unused spritescale/offset fields from gl_vissprite_t yes those are in fact unused not deleting since they might be useful for something sometime.... --- src/hardware/hw_glob.h | 4 ++-- src/hardware/hw_main.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index e6b6734a5..fa8993b4c 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -34,8 +34,8 @@ typedef struct gl_vissprite_s float gz, gzt; float tz; float scale; - float spritexscale, spriteyscale; - float spritexoffset, spriteyoffset; + //float spritexscale, spriteyscale; + //float spritexoffset, spriteyoffset; patch_t *gpatch; boolean flip; UINT8 translucency; //alpha level 0-255 diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index ce683bda7..971627477 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5008,10 +5008,10 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->flip = flip; vis->scale = thing_scale; - vis->spritexscale = spritexscale; + /*vis->spritexscale = spritexscale; vis->spriteyscale = spriteyscale; vis->spritexoffset = FixedToFloat(spr_offset); - vis->spriteyoffset = FixedToFloat(spr_topoffset); + vis->spriteyoffset = FixedToFloat(spr_topoffset);*/ #ifdef ROTSPRITE if (rotsprite != NULL) From 45067e00a5113ab4c8b70836602e4247670bfd77 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 May 2026 08:04:00 +0200 Subject: [PATCH 31/61] fix compiler warnings + "support" gcc16 --- src/Makefile.d/detect.mk | 3 ++- src/hardware/hw_md3load.c | 7 +++---- src/y_inter.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk index 0816c5a03..766b497c3 100644 --- a/src/Makefile.d/detect.mk +++ b/src/Makefile.d/detect.mk @@ -64,6 +64,7 @@ endif # This must have high to low order. gcc_versions:=\ + 161 160 16\ 152 151 150 15\ 142 141 140 14\ 133 132 131 130 13\ @@ -77,7 +78,7 @@ gcc_versions:=\ 55 54 53 52 51 50\ 49 48 47 46 45 44 43 42 41 40 -latest_gcc_version:=15.2 +latest_gcc_version:=16.1 # Automatically set version flag, but not if one was # manually set. And don't bother if this is a clean only diff --git a/src/hardware/hw_md3load.c b/src/hardware/hw_md3load.c index b536c7e73..06aa6507e 100644 --- a/src/hardware/hw_md3load.c +++ b/src/hardware/hw_md3load.c @@ -154,7 +154,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) char *buffer; int surfEnd; int i, t; - int matCount; + //int matCount; FILE *f; if (!latlnginit) @@ -227,7 +227,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, NULL); - matCount = 0; + //matCount = 0; for (i = 0, surfEnd = 0; i < mdh->numSurfaces; i++) { int j; @@ -237,7 +237,7 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) mdShader = (md3Shader*)((char*)mdS + mdS->offsetShaders); - for (j = 0; j < mdS->numShaders; j++, matCount++) + for (j = 0; j < mdS->numShaders; j++ /*, matCount++*/) { size_t len = strlen(mdShader[j].name); mdShader[j].name[len-1] = 'z'; @@ -503,7 +503,6 @@ model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) } }*/ - free(buffer); return retModel; diff --git a/src/y_inter.c b/src/y_inter.c index 684797999..5fbd4d86e 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -330,7 +330,7 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) V_DrawCenteredString(x+6, y, 0, va("%d", standings->pos[i])); // localskins are amazing - if (standings->color[i] != SKINCOLOR_NONE) + if (*standings->color[i] != SKINCOLOR_NONE) { UINT8 *colormap = R_GetTranslationColormap(*standings->character[i], *standings->color[i], GTC_CACHE); INT32 skinnum = (player->localskin ? (player->localskin - 1) : *standings->character[i]); From 3c409b4a4670d57784c19c1c39c93d9ac574e8cf Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 May 2026 10:01:14 +0200 Subject: [PATCH 32/61] detect kill signal when printing signal from signalhandler bit more informative than "signal number 9" --- src/dedicated/i_system.c | 9 +++++++-- src/sdl/i_system.cpp | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 12932295d..f2c6c76ef 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1023,8 +1023,13 @@ static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_ms sigmsg = ("SIGSEGV - SRB2Kart-Saturn has attempted to access a memory location that it shouldn't and needs to close."); break; #ifdef SIGTERM - case SIGTERM: // Software termination signal from kill - sigmsg = ("SIGTERM - SRB2Kart-Saturn was terminated by a kill signal."); + case SIGTERM: // Software termination signal from terminate + sigmsg = ("SIGTERM - SRB2Kart-Saturn was terminated by a terminate signal."); + break; +#endif +#ifdef SIGKILL + case SIGKILL: // Software termination signal from kill + sigmsg = ("SIGKILL - SRB2Kart-Saturn was terminated by a kill signal."); break; #endif #ifdef SIGBREAK diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index bf09ab0ca..9b9e49305 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1662,11 +1662,17 @@ static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_ms signame = "SIGSEGV"; break; #ifdef SIGTERM - case SIGTERM: // Software termination signal from kill - sigmsg = ("SRB2Kart-Saturn was terminated by a kill signal."); + case SIGTERM: // Software termination signal from terminate + sigmsg = ("SRB2Kart-Saturn was terminated by a terminate signal."); signame = "SIGTERM"; break; #endif +#ifdef SIGKILL + case SIGKILL: // Software termination signal from kill + sigmsg = ("SRB2Kart-Saturn was terminated by a kill signal."); + signame = "SIGKILL"; + break; +#endif #ifdef SIGBREAK case SIGBREAK: // Ctrl-Break sequence sigmsg =("SIGBREAK - SRB2Kart-Saturn was terminated by a Ctrl-Break sequence."); From 4fe34956523ea453afec48a7c93965c2f4794e25 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 May 2026 10:25:52 +0200 Subject: [PATCH 33/61] fallback to srb2back instead of hoping the map is still loaded for intermission bg timescale and replay fastforward caused stuff to crash and well this is better than a whitescreen ig --- src/d_main.c | 21 +++++---------------- src/doomstat.h | 1 + src/hardware/hw_main.cpp | 5 ++--- src/screen.c | 5 +---- src/y_inter.c | 2 ++ 5 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index eb503b39f..c1e96ebc9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -138,6 +138,7 @@ boolean devparm = false; // started game with -devparm boolean singletics = false; // timedemo boolean lastdraw = false; +boolean intermissionbginit = false; #ifdef MOTIONBLUR INT32 postimgparam[MAXSPLITSCREENPLAYERS]; @@ -370,23 +371,10 @@ static void D_MakeIntermissionBG(void) if (rendermode == render_none) { lastdraw = false; + intermissionbginit = false; return; } - // no more valid map - // shouldnt happen at this point, but better safe than sorry! - if (!numsectors) - { - lastdraw = false; - return; - } - - // need to render level again for this - // should be fine since at this point we did not unload it yet - if (cv_renderview.value) - { - D_Renderview(); - } #ifdef HWRENDER if (rendermode == render_opengl) { @@ -399,6 +387,7 @@ static void D_MakeIntermissionBG(void) } lastdraw = false; + intermissionbginit = true; } static boolean D_Display(void) @@ -558,8 +547,6 @@ static boolean D_Display(void) break; } - D_MakeIntermissionBG(); - if (gamestate == GS_LEVEL) { // draw the view directly @@ -568,6 +555,8 @@ static boolean D_Display(void) PS_START_TIMING(ps_rendercalltime); D_Renderview(); PS_STOP_TIMING(ps_rendercalltime); + + D_MakeIntermissionBG(); } PS_START_TIMING(ps_uitime); diff --git a/src/doomstat.h b/src/doomstat.h index e8eae7a4f..86d742183 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -113,6 +113,7 @@ extern UINT8 window_notinfocus; // are we in focus? (backend independant -- hand extern boolean nodrawers; extern boolean lastdraw; +extern boolean intermissionbginit; #ifdef MOTIONBLUR extern INT32 postimgparam[MAXSPLITSCREENPLAYERS]; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 971627477..f603b58a2 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -258,9 +258,7 @@ static void CV_screentextures_OnChange(void) if (cv_glframebuffer.value != 0) CV_SetValue(&cv_glframebuffer, 0); #endif - // HACK: set lastdraw so intermission bg can refresh after toggling screentextures - if (gamestate == GS_INTERMISSION) - lastdraw = true; + intermissionbginit = false; } GL_SetSpecialState(HWD_SET_SCREEN_TEXTURES, cv_glscreentextures.value); M_UpdateOGLMenu(); @@ -277,6 +275,7 @@ static void CV_glframebuffer_OnChange(void) I_DownSample(); RefreshOGLSDLSurface(); M_UpdateOGLMenu(); + intermissionbginit = false; } #endif diff --git a/src/screen.c b/src/screen.c index 84e81617a..a874ed530 100644 --- a/src/screen.c +++ b/src/screen.c @@ -277,10 +277,7 @@ void SCR_Recalc(void) // vid.recalc lasts only for the next refresh... con_recalc = true; am_recalc = true; - - // HACK: set lastdraw so intermission bg can refresh after resolution change - if (gamestate == GS_INTERMISSION) - lastdraw = true; + intermissionbginit = false; } // Check for screen cmd-line parms: to force a resolution. diff --git a/src/y_inter.c b/src/y_inter.c index 5fbd4d86e..19b696b0e 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -433,6 +433,7 @@ void Y_IntermissionDrawer(void) return; if (cv_betainterscreen.value == 1 + || !intermissionbginit #ifdef HWRENDER || (rendermode == render_opengl && cv_glscreentextures.value != 2) // use the neato kart bg for intermission on disabled screen textures #endif @@ -794,6 +795,7 @@ void Y_EndIntermission(void) endtic = -1; sorttic = -1; intertype = int_none; + intermissionbginit = false; // not sure if this is the right place to reset, but i guess it works for now.... } // From 7f4804f98c2e3099be946887e3dfe9a9329cbc10 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 May 2026 14:10:39 +0200 Subject: [PATCH 34/61] fix super rare underflow within FixedHypot if input is -2147483648 this has an insanely rare chance of happening in certain cases (train rush map has a few spots where this is somewhat likely) abs does not really handle -2147483648 and its result is pretty much implementation defined/ub, since we compile with fwrapv flag it would just return -2147483648 which will cause this to try and access tantoangle at a negative index we can just return INT32_MAX here since treating either as 2147483647 would return 2147483647 eitherways --- src/m_fixed.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/m_fixed.c b/src/m_fixed.c index d7aa13254..3bab22815 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -62,6 +62,9 @@ FUNCMATH fixed_t FixedHypot(fixed_t x, fixed_t y) angle_t angle; fixed_t dist; + I_Assert(x != INT32_MIN); + I_Assert(y != INT32_MIN); + x = abs(x); y = abs(y); @@ -77,6 +80,10 @@ FUNCMATH fixed_t FixedHypot(fixed_t x, fixed_t y) if (!y) return x; + // prevent underflow + if (y == INT32_MIN) + return INT32_MAX; + angle = (tantoangle[FixedDiv(y, x)>>DBITS] + ANGLE_90) >> ANGLETOFINESHIFT; // use as cosine From d0ea4d20d095f2325a81e707b0475f25c3b51766 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 May 2026 22:59:39 +0200 Subject: [PATCH 35/61] fix parent process being killed before child per interrupt/terminate signals by ignoring those signals otherwise the terminal will be left in a weird state, aswell as the parent exit stuff wont be properly run this was "fine" before https://github.com/Indev450/SRB2Kart-Saturn/commit/f4dc161831a988e725e8639b9674984ebdf5f6bb but now needs to be handled like this --- src/dedicated/i_system.c | 12 ++++++++++++ src/sdl/i_system.cpp | 17 ++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index f2c6c76ef..2e32b2b11 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1362,6 +1362,18 @@ static void I_Fork(void) I_RegisterChildSignals(); break; default: + // ignore those, those are handled by child process + // otherwise parent might exit before it + // and the below stuff wont run and your terminal will be left in an awkward state +#ifdef SIGINT + signal(SIGINT, SIG_IGN); +#endif +#ifdef SIGBREAK + signal(SIGBREAK, SIG_IGN); +#endif +#ifdef SIGTERM + signal(SIGTERM, SIG_IGN); +#endif if (logstream) fclose(logstream);/* the child has this */ diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 9b9e49305..87fec2f2f 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1868,9 +1868,7 @@ static void I_RegisterChildSignals(void) signal(SIGABRT, signal_handler_child); signal(SIGFPE, signal_handler_child); } -#endif -#ifdef NEWSIGNALHANDLER FUNCNORETURN static ATTRNORETURN void newsignalhandler_Warn(const char *pr) { char text[128]; @@ -1906,6 +1904,18 @@ static void I_Fork(void) I_RegisterChildSignals(); break; default: + // ignore those, those are handled by child process + // otherwise parent might exit before it + // and the below stuff wont run and your terminal will be left in an awkward state +#ifdef SIGINT + signal(SIGINT, SIG_IGN); +#endif +#ifdef SIGBREAK + signal(SIGBREAK, SIG_IGN); +#endif +#ifdef SIGTERM + signal(SIGTERM, SIG_IGN); +#endif #ifdef LOGMESSAGES if (logstream) fclose(logstream);/* the child has this */ @@ -1914,6 +1924,8 @@ static void I_Fork(void) #ifdef LOGMESSAGES /* By the way, exit closes files. */ logstream = fopen(logfilename, "at"); +#else + logstream = 0; #endif if (c == -1) { @@ -2325,7 +2337,6 @@ char *I_GetUserName(void) strncpy(username, p, MAXPLAYERNAME); } - if (!fastcmp(username, "")) return username; From b1620a3fce888ee085457d31197f2fab699b9f00 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 4 May 2026 23:01:43 +0200 Subject: [PATCH 36/61] delet I_ShutdownConsole spam without process forking I_ShutdownSystem will handle it, otherwise the parent process calls it before exiting --- src/dedicated/i_system.c | 10 +++------- src/sdl/i_system.cpp | 3 --- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 2e32b2b11..fb3cc2731 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1378,14 +1378,12 @@ static void I_Fork(void) fclose(logstream);/* the child has this */ c = wait(&status); - #ifdef LOGMESSAGES /* By the way, exit closes files. */ logstream = fopen(logfilename, "at"); #else logstream = 0; #endif - if (c == -1) { kill(child, SIGKILL); @@ -1447,7 +1445,6 @@ void I_Quit(void) goto death; quiting = false; - I_ShutdownConsole(); M_SaveConfig(NULL); //save game config, cvars.. D_SaveBan(); // save the ban list G_SaveGameData(false); // Tails 12-08-2002 @@ -1537,8 +1534,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) #endif // --- - I_ShutdownConsole(); - M_SaveConfig(NULL); // save game config, cvars.. D_SaveBan(); // save the ban list G_SaveGameData(false); // Tails 12-08-2002 @@ -1659,9 +1654,10 @@ void I_ShutdownSystem(void) { INT32 c; -#ifndef NEWSIGNALHANDLER - I_ShutdownConsole(); +#ifdef NEWSIGNALHANDLER + if (M_CheckParm("-nofork")) #endif + I_ShutdownConsole(); for (c = MAX_QUIT_FUNCS-1; c >= 0; c--) if (quit_funcs[c]) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 87fec2f2f..7e1a93835 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -2008,7 +2008,6 @@ FUNCNORETURN void ATTRNORETURN I_Quit(void) is_quitting = true; SDL_ShowCursor(SDL_TRUE); - I_ShutdownConsole(); M_SaveConfig(NULL); //save game config, cvars.. D_SaveBan(); // save the ban list G_SaveGameData(false); // Tails 12-08-2002 @@ -2114,8 +2113,6 @@ FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...) // --- - I_ShutdownConsole(); - M_SaveConfig(NULL); // save game config, cvars.. D_SaveBan(); // save the ban list G_SaveGameData(false); // Tails 12-08-2002 From f1ded992625fd046279d399054cfc376a6c4b248 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 6 May 2026 12:28:05 +0200 Subject: [PATCH 37/61] some code style cleanups --- src/d_main.c | 8 ++++---- src/hardware/hw_clip.c | 11 +++++----- src/hardware/hw_draw.c | 40 ++++++++++++++++++++----------------- src/hardware/hw_main.cpp | 43 ++++++++++++++++++++-------------------- src/p_map.c | 28 +++++++++++++++----------- src/p_mobj.c | 24 ++++++++++++++-------- 6 files changed, 85 insertions(+), 69 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index c1e96ebc9..e24c66fea 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -722,13 +722,15 @@ void D_SRB2Loop(void) precise_t elapsed; precise_t enterprecise, finishprecise; + boolean ranwipe = false; + + enterprecise = I_GetPreciseTime(); + if (I_Interrupted()) { I_Quit(); } - enterprecise = I_GetPreciseTime(); - memset(&g_dc, 0, sizeof(g_dc)); Z_Frame_Reset(); @@ -736,8 +738,6 @@ void D_SRB2Loop(void) const UINT32 framecap = R_GetFramerateCap(); capbudget = (framecap == 0) ? 0 : (precise_t)((double)precision / (double)framecap + 0.5); // + 0.5 instead of round - boolean ranwipe = false; - I_UpdateTime(cv_timescale.value); if (lastwipetic) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 6790823f2..68bbc98e3 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -319,16 +319,17 @@ angle_t gld_FrustumAngle(angle_t tiltangle) double clipfov; double floatangle; angle_t a1; - - float tilt = fabsf(((float)(int)tiltangle) / (float)ANG1); - - if (tilt > 90.0f) - tilt = 90.0f; + float tilt; // If the pitch is larger than this you can look all around at a FOV of 90 if (abs((signed)tiltangle) > 46 * ANG1) return 0xffffffff; + tilt = fabsf(((float)(int)tiltangle) / (float)ANG1); + + if (tilt > 90.0f) + tilt = 90.0f; + // ok, this is a gross hack that barely works... // but at least it doesn't overestimate too much... clipfov = atan(1 / (GLdouble)projMatrix[0]) * 360.0 / M_PI; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 7bccbe198..981e54f0a 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -32,20 +32,6 @@ #include -typedef struct -{ - UINT8 id_field_length ; // 1 - UINT8 color_map_type ; // 2 - UINT8 image_type ; // 3 - UINT8 dummy[5] ; // 4, 8 - INT16 x_origin ; // 9, 10 - INT16 y_origin ; //11, 12 - INT16 width ; //13, 14 - INT16 height ; //15, 16 - UINT8 image_pix_size ; //17 - UINT8 image_descriptor; //18 -} ATTRPACK TGAHeader; // sizeof is 18 - static const UINT8 softwaretranstogl[11] = { 0, 25, 51, 76,102,127,153,178,204,229,255}; static const UINT8 softwaretranstogl_hi[11] = { 0, 51,102,153,204,255,255,255,255,255,255}; static const UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111,127}; @@ -57,8 +43,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p { FOutVector v[4]; FBITFIELD flags; - float cx = FIXED_TO_FLOAT(x); - float cy = FIXED_TO_FLOAT(y); + float cx, cy; UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); UINT8 blendmode = ((bflags & V_BLENDMASK) >> V_BLENDSHIFT); GLPatch_t *hwrPatch; @@ -72,6 +57,9 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p if (alphalevel >= 10 && alphalevel < 13) return; + cx = FIXED_TO_FLOAT(x); + cy = FIXED_TO_FLOAT(y); + const float fvw = (float)vid.width; const float fvh = (float)vid.height; @@ -244,8 +232,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, { FOutVector v[4]; FBITFIELD flags; - float cx = FIXED_TO_FLOAT(x); - float cy = FIXED_TO_FLOAT(y); + float cx, cy; UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); GLPatch_t *hwrPatch; @@ -258,6 +245,9 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, if (alphalevel >= 10 && alphalevel < 13) return; + cx = FIXED_TO_FLOAT(x); + cy = FIXED_TO_FLOAT(y); + const float fvw = (float)vid.width; const float fvh = (float)vid.height; @@ -964,6 +954,20 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) #endif #ifndef USE_PNG +typedef struct +{ + UINT8 id_field_length ; // 1 + UINT8 color_map_type ; // 2 + UINT8 image_type ; // 3 + UINT8 dummy[5] ; // 4, 8 + INT16 x_origin ; // 9, 10 + INT16 y_origin ; //11, 12 + INT16 width ; //13, 14 + INT16 height ; //15, 16 + UINT8 image_pix_size ; //17 + UINT8 image_descriptor; //18 +} ATTRPACK TGAHeader; // sizeof is 18 + // -------------------------------------------------------------------------- // save screenshots with TGA format // -------------------------------------------------------------------------- diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index f603b58a2..e106454aa 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -511,7 +511,7 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg, extracolormap_t *colo { INT16 finallight = lightnum; - if (cv_glfakecontrast.value == 0 || (HWR_ShouldUsePaletteRendering() && colormap)) + if (cv_glfakecontrast.value == 0 || (colormap && HWR_ShouldUsePaletteRendering())) return (FUINT)finallight; if (seg != NULL && P_ApplyLightOffsetFine(lightnum, seg->frontsector)) @@ -3801,7 +3801,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) { const fixed_t h = P_GetLightZAt(§or->lightlist[i], sprmo->x, sprmo->y); - if (!(h <= temp)) + if (h > temp) continue; if (!lightset) @@ -3936,7 +3936,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) mobj_t *sprmo = spr->mobj; - if (UNLIKELY(!sprmo->subsector)) + if (!sprmo->subsector) return; const boolean papersprite = (sprmo->frame & FF_PAPERSPRITE); @@ -4100,7 +4100,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) const precipmobj_t *sprmo = spr->precip; - if (UNLIKELY(!sprmo->subsector)) + if (!sprmo->subsector) return; // cache sprite graphics @@ -4300,22 +4300,23 @@ static std::vector drawnodes; static void *HWR_CreateDrawNode(gl_drawnode_type_t type) { - // if we didnt alloc anything yet, reserve atleast 64 nodes - // dont declare with it as we want our size to be 0! + gl_drawnode_t *drawnode; drawnodes.reserve(DRAWNODES_INIT_SIZE); drawnodes.emplace_back(); - drawnodes.back().type = type; + + drawnode = &drawnodes.back(); + drawnode->type = type; // not sure if returning different pointers to a union is necessary switch (type) { case DRAWNODE_PLANE: - return &drawnodes.back().u.plane; + return &drawnode->u.plane; case DRAWNODE_POLYOBJECT_PLANE: - return &drawnodes.back().u.polyplane; + return &drawnode->u.polyplane; case DRAWNODE_WALL: - return &drawnodes.back().u.wall; + return &drawnode->u.wall; } return NULL; @@ -4817,11 +4818,9 @@ static void HWR_ProjectSprite(mobj_t *thing) ) { ang = R_PointToAngle(interp.x, interp.y); - #ifdef ROTSPRITE camang = ang; #endif - ang -= interp.angle; if (mirrored) @@ -4944,11 +4943,11 @@ static void HWR_ProjectSprite(mobj_t *thing) // if the sprite is out of our view, dont need to draw it X) if (!gld_SphereInFrustum( (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, - FixedToFloat(interp.z) + (y1 + y2) / 2.0f, - FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, - //1.5 == sqrt(2) + small delta for MF_FOREGROUND - std::max(FixedToFloat(spr_width) * spritexscale, - FixedToFloat(spr_height) * spriteyscale) / 2.0f * 1.5f)) + FixedToFloat(interp.z) + (y1 + y2) / 2.0f, + FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + //1.5 == sqrt(2) + small delta for MF_FOREGROUND + std::max(FixedToFloat(spr_width) * spritexscale, + FixedToFloat(spr_height) * spriteyscale) / 2.0f * 1.5f)) { return; } @@ -5164,11 +5163,11 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) if (!gld_SphereInFrustum( (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, - FixedToFloat(interp.z) + (y1 + y2) / 2.0f, - FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, - //1.5 == sqrt(2) + small delta for MF_FOREGROUND - std::max(FixedToFloat(spr_width) * thing_scale, - FixedToFloat(spr_height) * thing_scale) / 2.0f * 1.5f)) + FixedToFloat(interp.z) + (y1 + y2) / 2.0f, + FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + //1.5 == sqrt(2) + small delta for MF_FOREGROUND + std::max(FixedToFloat(spr_width) * thing_scale, + FixedToFloat(spr_height) * thing_scale) / 2.0f * 1.5f)) { return; } diff --git a/src/p_map.c b/src/p_map.c index da71b169f..10b55f65b 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -321,7 +321,7 @@ static boolean PIT_CheckThing(mobj_t *thing) // Ignore spectators if ((tmthing->player && tmthing->player->spectator) - || (thing->player && thing->player->spectator)) + || (thing->player && thing->player->spectator)) return true; #ifdef SEENAMES @@ -1509,14 +1509,14 @@ static boolean PIT_CheckThing(mobj_t *thing) // Adjusts tmfloorz and tmceilingz as lines are contacted - FOR CAMERA ONLY static boolean PIT_CheckCameraLine(line_t *ld) { - if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) + if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return true; - if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - { + if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return true; - } if (P_BoxOnLineSide(tmbbox, ld) != -1) return true; @@ -1571,11 +1571,13 @@ static boolean PIT_CheckCameraLine(line_t *ld) // static boolean PIT_CheckLine(line_t *ld) { - if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) + if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return true; - if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) return true; if (P_BoxOnLineSide(tmbbox, ld) != -1) @@ -1584,10 +1586,12 @@ static boolean PIT_CheckLine(line_t *ld) if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag. { fixed_t cosradius, sinradius; + cosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT)); sinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT)); + if (P_PointOnLineSide(tmx - cosradius, tmy - sinradius, ld) - == P_PointOnLineSide(tmx + cosradius, tmy + sinradius, ld)) + == P_PointOnLineSide(tmx + cosradius, tmy + sinradius, ld)) return true; // the line doesn't cross between collider's start or end } @@ -4001,10 +4005,10 @@ static inline boolean PIT_GetSectors(line_t *ld) tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) return true; - if (P_BoxOnLineSide(tmbbox, ld) != -1) + if (ld->polyobj) // line belongs to a polyobject, don't add it return true; - if (ld->polyobj) // line belongs to a polyobject, don't add it + if (P_BoxOnLineSide(tmbbox, ld) != -1) return true; // This line crosses through the object. diff --git a/src/p_mobj.c b/src/p_mobj.c index 605395816..cdc25a3e0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -596,8 +596,10 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t fixed_t highline; ld = boundsec->lines[i]; - if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) continue; if (P_BoxOnLineSide(bbox, ld) != -1) @@ -683,8 +685,10 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed fixed_t highline; ld = boundsec->lines[i]; - if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) continue; if (P_BoxOnLineSide(bbox, ld) != -1) @@ -771,8 +775,10 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix fixed_t highline; ld = boundsec->lines[i]; - if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) continue; if (P_BoxOnLineSide(bbox, ld) != -1) @@ -858,8 +864,10 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f fixed_t highline; ld = boundsec->lines[i]; - if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || + bbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || + bbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || + bbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) continue; if (P_BoxOnLineSide(bbox, ld) != -1) From 50c1263e7d4ff1a44d3676615a36422b90951bea Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 6 May 2026 12:27:06 +0200 Subject: [PATCH 38/61] OpenGL: only enable stencil testing during level render MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit not 100% sure if this is the most correct thing, but this causes issues with Nvidia Gpu´s under x11 should fix https://github.com/Indev450/SRB2Kart-Saturn/issues/226 --- src/hardware/hw_gl.h | 4 ++++ src/hardware/hw_main.cpp | 4 ++++ src/hardware/r_opengl/r_opengl.c | 12 +++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_gl.h b/src/hardware/hw_gl.h index 351b36353..b808ed09a 100644 --- a/src/hardware/hw_gl.h +++ b/src/hardware/hw_gl.h @@ -32,8 +32,12 @@ void GL_SetSpecialState(hwdspecialstate_t IdState, INT32 Value); void GL_SetTransform(FTransform *stransform); void GL_SetBlend(FBITFIELD PolyFlags); void GL_SetPalette(RGBA_t *palette); + void GL_ClearBuffer(FBOOLEAN ColorMask, FBOOLEAN DepthMask, FBOOLEAN StencilMask, FRGBAFloat * ClearColor); +void GL_EnableStencilTest(void); +void GL_DisableStencilTest(void); + void GL_DrawPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags); void GL_DrawIndexedTriangles(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags, unsigned int *IndexArray); void GL_Draw2DLine(F2DCoord *v1, F2DCoord *v2, RGBA_t Color); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index e106454aa..8919e3ed4 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5691,6 +5691,8 @@ extern "C" { // ========================================================================== static void HWR_RenderFrame(boolean skybox, boolean drawsky) { + GL_EnableStencilTest(); + // Clear view, set viewport (glViewport), set perspective... HWR_ClearView(); @@ -5721,6 +5723,8 @@ static void HWR_RenderFrame(boolean skybox, boolean drawsky) else HWR_RenderViewpoint(NULL, 0, !skybox); + GL_DisableStencilTest(); + // Check for new console commands. NetUpdate(); } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 1a8e2a8c4..518181f69 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1284,7 +1284,7 @@ void GL_SetStates(void) pglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - pglEnable(GL_STENCIL_TEST); + pglDisable(GL_STENCIL_TEST); pglEnable(GL_DEPTH_TEST); // check the depth buffer pglDepthMask(GL_TRUE); // enable writing to depth buffer pglClearDepth(1.0f); @@ -1314,6 +1314,16 @@ void GL_SetStates(void) #endif } +void GL_EnableStencilTest(void) +{ + pglEnable(GL_STENCIL_TEST); +} + +void GL_DisableStencilTest(void) +{ + pglDisable(GL_STENCIL_TEST); +} + // -----------------+ // DeleteTexture : Deletes a texture from the GPU and frees its data // -----------------+ From 2344552ba8b96f13287e9b6b60ecd1c53426c4f7 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 7 May 2026 16:26:30 +0200 Subject: [PATCH 39/61] Opengl: enable stencil testing only when portals are used maybe a bit of perf on non portal maps, prob neglible but why not --- src/hardware/hw_main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 8919e3ed4..7de18f756 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -5691,7 +5691,11 @@ extern "C" { // ========================================================================== static void HWR_RenderFrame(boolean skybox, boolean drawsky) { - GL_EnableStencilTest(); + // NetUpdate below may cause this to be false midrender if toggled + const boolean useportals = HWR_UsePortals(); + + if (useportals) + GL_EnableStencilTest(); // Clear view, set viewport (glViewport), set perspective... HWR_ClearView(); @@ -5718,12 +5722,13 @@ static void HWR_RenderFrame(boolean skybox, boolean drawsky) NetUpdate(); portalclipline = NULL; - if (UNLIKELY(HWR_UsePortals())) + if (useportals) HWR_RenderViewpoint(NULL, 0, !skybox); else HWR_RenderViewpoint(NULL, 0, !skybox); - GL_DisableStencilTest(); + if (useportals) + GL_DisableStencilTest(); // Check for new console commands. NetUpdate(); From 1b3050028e182bbf68ce8c1c87f7a41997fa2091 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 8 May 2026 14:36:42 +0200 Subject: [PATCH 40/61] save a few mobjfloorz/ceilingz calls in some cases gave a small speedup on my test setup (+~3fps) on slopes those are rather expensive --- src/p_maputl.cpp | 14 +++++++++----- src/p_user.c | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 37b31c4ac..3bb205afa 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -823,16 +823,20 @@ void P_SetThingPosition(mobj_t *thing) // sector's floor is the same height. if (thing->player && oldsec != NULL && thing->subsector && oldsec != thing->subsector->sector) { - tfloorz = P_GetFloorZ(thing, ss->sector, thing->x, thing->y, NULL); - tceilz = P_GetCeilingZ(thing, ss->sector, thing->x, thing->y, NULL); - if (thing->eflags & MFE_VERTICALFLIP) { + tceilz = P_GetCeilingZ(thing, ss->sector, thing->x, thing->y, NULL); + if (thing->z + thing->height >= tceilz) thing->eflags |= MFE_JUSTSTEPPEDDOWN; } - else if (thing->z <= tfloorz) - thing->eflags |= MFE_JUSTSTEPPEDDOWN; + else + { + tfloorz = P_GetFloorZ(thing, ss->sector, thing->x, thing->y, NULL); + + if (thing->z <= tfloorz) + thing->eflags |= MFE_JUSTSTEPPEDDOWN; + } } } diff --git a/src/p_user.c b/src/p_user.c index 9eddcc36d..3b2f90dd7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1513,11 +1513,12 @@ static void P_CheckBouncySectors(player_t *player) continue; // this sector type is required for FOFs to be bouncy topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); - bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); if (player->mo->z > topheight) continue; + bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); + if (player->mo->z + player->mo->height < bottomheight) continue; From ce982d170fd8e80c2ad605d19073eeb7b010ace7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 8 May 2026 14:38:40 +0200 Subject: [PATCH 41/61] change "important" hook_state field to be bool type matches the others prob no diff in practice at all --- src/lua_hooklib.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index af15120ba..6294a5ab7 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -293,17 +293,17 @@ typedef struct Hook_State Hook_State; typedef void (*Hook_Callback)(Hook_State *); struct Hook_State { - INT32 status;/* return status to calling function */ - void * userdata; - int hook_type; - mobjtype_t mobj_type;/* Date: Sat, 9 May 2026 15:31:51 +0200 Subject: [PATCH 42/61] add "HAVE_IPV6" to passtrough compiler flags to allow compiling with ipv6 support to note this is unsupported from our side, as purely ipv6 servers are unreachable from vanilla clients --- src/Makefile.d/features.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk index b191ae2c1..410077939 100644 --- a/src/Makefile.d/features.mk +++ b/src/Makefile.d/features.mk @@ -8,6 +8,7 @@ passthru_opts+=\ HAVE_MINIUPNPC\ HAVE_DISCORDRPC DEVELOP\ NOHOLEPUNCH\ + HAVE_IPV6\ # build with debugging information ifdef DEBUGMODE From 9328825a7c93d9f191ee847eb8e727cff19b5b16 Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 9 May 2026 19:50:15 +0200 Subject: [PATCH 43/61] fix potential null pointer deref in P_MobjFloorZ/CeilingZ dont think this ever really hit, but boundsec indeed can be null it also gets checked if its null above anyways, so why not here? --- src/p_mobj.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index cdc25a3e0..71dd21996 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -577,7 +577,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point - if (perfect) + if (perfect && boundsec) { size_t i; line_t *ld; @@ -666,7 +666,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point - if (perfect) + if (perfect && boundsec) { size_t i; line_t *ld; @@ -756,7 +756,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point - if (perfect) + if (perfect && boundsec) { size_t i; line_t *ld; @@ -845,7 +845,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f return P_GetSlopeZAt(slope, testx, testy); // If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point - if (perfect) + if (perfect && boundsec) { size_t i; line_t *ld; From 88116368bb2091dadbe8df392f9b144f65c6e72c Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 9 May 2026 19:58:28 +0200 Subject: [PATCH 44/61] fix potential null pointer deref in P_LineOpening again ive never seen this hit, but the mobj gets checked right below its radius get dereferenced within the floorz/ceilingz functions which kinda annoyed me lol as a fallback i just the floor/ceiling sectorheights, which were used before the addition of slopes --- src/p_maputl.cpp | 101 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 70 insertions(+), 31 deletions(-) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 3bb205afa..ebf4a08fa 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -423,40 +423,42 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // Set open and high/low values here fixed_t frontheight, backheight; - frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); - - if (frontheight < backheight) - { - opentop = frontheight; - highceiling = backheight; - opentopslope = front->c_slope; - } - else - { - opentop = backheight; - highceiling = frontheight; - opentopslope = back->c_slope; - } - - frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); - - if (frontheight > backheight) - { - openbottom = frontheight; - lowfloor = backheight; - openbottomslope = front->f_slope; - } - else - { - openbottom = backheight; - lowfloor = frontheight; - openbottomslope = back->f_slope; - } + I_Assert(mobj != NULL); if (mobj) { + frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); + + if (frontheight < backheight) + { + opentop = frontheight; + highceiling = backheight; + opentopslope = front->c_slope; + } + else + { + opentop = backheight; + highceiling = frontheight; + opentopslope = back->c_slope; + } + + frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); + + if (frontheight > backheight) + { + openbottom = frontheight; + lowfloor = backheight; + openbottomslope = front->f_slope; + } + else + { + openbottom = backheight; + lowfloor = frontheight; + openbottomslope = back->f_slope; + } + fixed_t thingtop = mobj->z + mobj->height; // Check for collision with front side's midtexture if Effect 4 is set @@ -650,6 +652,43 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) lowfloor = lowestfloor; } } + else + { + // this is what P_LineOpening did before the addition of slopes + // so i´ll just use it as the fallback case + // not that we will ever likely hit this + frontheight = front->ceilingheight; + backheight = back->ceilingheight; + + if (frontheight < backheight) + { + opentop = frontheight; + highceiling = backheight; + opentopslope = front->c_slope; + } + else + { + opentop = backheight; + highceiling = frontheight; + opentopslope = back->c_slope; + } + + frontheight = front->floorheight; + backheight = back->floorheight; + + if (frontheight > backheight) + { + openbottom = frontheight; + lowfloor = backheight; + openbottomslope = front->f_slope; + } + else + { + openbottom = backheight; + lowfloor = frontheight; + openbottomslope = back->f_slope; + } + } openrange = opentop - openbottom; } From 54f3d7b5e0e5817c18c6c9b5be1ec4b72bcc719b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 10 May 2026 16:33:12 +0200 Subject: [PATCH 45/61] move lua_tostring out of the loop in mapheaderinfo_get does not need to be reevaluated constantly --- src/lua_maplib.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 606d54383..279b02883 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1658,17 +1658,22 @@ static int mapheaderinfo_get(lua_State *L) { // Read custom vars now // (note: don't include the "LUA." in your lua scripts!) - UINT8 j = 0; - for (;j < header->numCustomOptions && !fastcmp(lua_tostring(L, 2), header->customopts[j].option); ++j); + if (!header->numCustomOptions) { + lua_pushnil(L); + break; + } - if(j < header->numCustomOptions) + UINT8 j = 0; + const char *cusoptstr = lua_tostring(L, 2); + for (;j < header->numCustomOptions && !fastcmp(cusoptstr, header->customopts[j].option); ++j); + + if (j < header->numCustomOptions) lua_pushstring(L, header->customopts[j].value); else lua_pushnil(L); } } return 1; - } int LUA_MapLib(lua_State *L) From 39fd31c4b93e5775dc0b454a2c3112c4e09b713c Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 10 May 2026 20:15:24 +0200 Subject: [PATCH 46/61] p_mobj: potentially save a few more floor/ceiling z checks in some cases + some other crap --- src/p_mobj.c | 178 +++++++++++++++++++++++++++++---------------------- 1 file changed, 102 insertions(+), 76 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 71dd21996..b30e4ecd4 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -420,14 +420,18 @@ boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover) if (!(rover->flags & FF_EXISTS)) return false; - if ((((rover->flags & FF_BLOCKPLAYER) && mobj->player) - || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) + if ((((rover->flags & FF_BLOCKPLAYER) && mobj->player) || + ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) + return false; + + topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + + if (mobj->z > topheight) return false; - topheight = P_GetFFloorTopZAt (rover, mobj->x, mobj->y); bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); - if (mobj->z > topheight || (mobj->z + mobj->height < bottomheight)) + if (mobj->z + mobj->height < bottomheight) return false; return true; @@ -1420,7 +1424,7 @@ void P_XYMovement(mobj_t *mo) // blocked move moved = false; - if (player && player->bot) + if (UNLIKELY(player && player->bot)) { B_MoveBlocked(player); } @@ -1455,24 +1459,24 @@ void P_XYMovement(mobj_t *mo) else fx->eflags &= ~MFE_VERTICALFLIP; fx->scale = mo->scale; - } - if (mo->type == MT_ORBINAUT) // Orbinaut speed decreasing - { - if (mo->health > 1) + if (mo->type == MT_ORBINAUT) // Orbinaut speed decreasing { - S_StartSound(mo, mo->info->attacksound); - mo->health--; - mo->threshold = 0; - } - else if (mo->health == 1) - { - // This Item Damage - S_StartSound(mo, mo->info->deathsound); - P_KillMobj(mo, NULL, NULL); + if (mo->health > 1) + { + S_StartSound(mo, mo->info->attacksound); + mo->health--; + mo->threshold = 0; + } + else if (mo->health == 1) + { + // This Item Damage + S_StartSound(mo, mo->info->deathsound); + P_KillMobj(mo, NULL, NULL); - P_SetObjectMomZ(mo, 8*FRACUNIT, false); - P_InstaThrust(mo, R_PointToAngle2(mo->x, mo->y, mo->x, mo->y)+ANGLE_90, 16*FRACUNIT); + P_SetObjectMomZ(mo, 8*FRACUNIT, false); + P_InstaThrust(mo, R_PointToAngle2(mo->x, mo->y, mo->x, mo->y)+ANGLE_90, 16*FRACUNIT); + } } } //} @@ -1576,43 +1580,46 @@ void P_XYMovement(mobj_t *mo) if (P_MobjWasRemoved(mo)) // MF_SPECIAL touched a player! O_o;; return; - if (moved && oldslope) // Check to see if we ran off + if (moved) { - if (oldslope != mo->standingslope) // First, compare different slopes + if (oldslope) // Check to see if we ran off { - angle_t oldangle, newangle; - angle_t moveangle = R_PointToAngle2(0, 0, mo->momx, mo->momy); + if (oldslope != mo->standingslope) // First, compare different slopes + { + angle_t oldangle, newangle; + angle_t moveangle = R_PointToAngle2(0, 0, mo->momx, mo->momy); - oldangle = FixedMul((signed)oldslope->zangle, FINECOSINE((moveangle - oldslope->xydirection) >> ANGLETOFINESHIFT)); + oldangle = FixedMul((signed)oldslope->zangle, FINECOSINE((moveangle - oldslope->xydirection) >> ANGLETOFINESHIFT)); - if (mo->standingslope) - newangle = FixedMul((signed)mo->standingslope->zangle, FINECOSINE((moveangle - mo->standingslope->xydirection) >> ANGLETOFINESHIFT)); - else - newangle = 0; + if (mo->standingslope) + newangle = FixedMul((signed)mo->standingslope->zangle, FINECOSINE((moveangle - mo->standingslope->xydirection) >> ANGLETOFINESHIFT)); + else + newangle = 0; - // Now compare the Zs of the different quantizations - if (oldangle-newangle > ANG30 && oldangle-newangle < ANGLE_180) // Allow for a bit of sticking - this value can be adjusted later + // Now compare the Zs of the different quantizations + if (oldangle-newangle > ANG30 && oldangle-newangle < ANGLE_180) // Allow for a bit of sticking - this value can be adjusted later + { + mo->standingslope = oldslope; + P_SlopeLaunch(mo); + } + } + else if (predictedz-mo->z > abs(slopemom.z/2) // Sryder 2018-11-26: Don't launch here if it's a slope without physics, we stick to those like glue anyway + && !(mo->standingslope->flags & SL_NOPHYSICS)) // Now check if we were supposed to stick to this slope { - mo->standingslope = oldslope; P_SlopeLaunch(mo); } } - else if (predictedz-mo->z > abs(slopemom.z/2) // Sryder 2018-11-26: Don't launch here if it's a slope without physics, we stick to those like glue anyway - && !(mo->standingslope->flags & SL_NOPHYSICS)) // Now check if we were supposed to stick to this slope + else if (mo->standingslope && predictedz) { - P_SlopeLaunch(mo); - } - } - else if (moved && mo->standingslope && predictedz) - { - angle_t moveangle = R_PointToAngle2(0, 0, mo->momx, mo->momy); - angle_t newangle = FixedMul((signed)mo->standingslope->zangle, FINECOSINE((moveangle - mo->standingslope->xydirection) >> ANGLETOFINESHIFT)); + angle_t moveangle = R_PointToAngle2(0, 0, mo->momx, mo->momy); + angle_t newangle = FixedMul((signed)mo->standingslope->zangle, FINECOSINE((moveangle - mo->standingslope->xydirection) >> ANGLETOFINESHIFT)); - if (ANGLE_MAX-newangle > ANG30 && newangle > ANGLE_180) - { - mo->momz = P_MobjFlip(mo)*FRACUNIT/2; - mo->z = predictedz + P_MobjFlip(mo); - mo->standingslope = NULL; + if (ANGLE_MAX-newangle > ANG30 && newangle > ANGLE_180) + { + mo->momz = P_MobjFlip(mo)*FRACUNIT/2; + mo->z = predictedz + P_MobjFlip(mo); + mo->standingslope = NULL; + } } } @@ -1821,7 +1828,7 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec) while (po) { - if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) + if (!(po->flags & POF_SOLID) || !P_MobjInsidePolyobj(po, mo)) { po = (polyobj_t *)(po->link.next); continue; @@ -2733,6 +2740,7 @@ static boolean P_SceneryZMovement(mobj_t *mo) P_RemoveMobj(mo); return false; } + if ((!(mo->eflags & MFE_VERTICALFLIP) && mo->z <= mo->floorz) || (mo->eflags & MFE_VERTICALFLIP && mo->z+mo->height >= mo->ceilingz)) // Hit the floor, so split! { @@ -2770,6 +2778,7 @@ static boolean P_SceneryZMovement(mobj_t *mo) P_RemoveMobj(mo); return false; } + // Soniccd seed turns into a flower! if ((!(mo->eflags & MFE_VERTICALFLIP) && mo->z <= mo->floorz) || (mo->eflags & MFE_VERTICALFLIP && mo->z+mo->height >= mo->ceilingz)) @@ -2880,22 +2889,29 @@ void P_MobjCheckWater(mobj_t *mobj) || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) continue; - topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); - bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); + fixed_t topcheck, bottomcheck; if (mobj->eflags & MFE_VERTICALFLIP) { - if (topheight < (thingtop - FixedMul(mobj->info->height/2, mobj->scale)) - || bottomheight > thingtop) - continue; + topcheck = (thingtop - FixedMul(mobj->info->height/2, mobj->scale)); + bottomcheck = thingtop; } else { - if (topheight < mobj->z - || bottomheight > (mobj->z + FixedMul(mobj->info->height/2, mobj->scale))) - continue; + topcheck = mobj->z; + bottomcheck = (mobj->z + FixedMul(mobj->info->height/2, mobj->scale)); } + topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + + if (topheight < topcheck) + continue; + + bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); + + if (bottomheight > bottomcheck) + continue; + // Set the watertop and waterbottom mobj->watertop = topheight; mobj->waterbottom = bottomheight; @@ -3101,11 +3117,14 @@ static void P_SceneryCheckWater(mobj_t *mobj) if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKOTHERS) continue; - topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + + if (topheight <= mobj->z) + continue; + bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); - if (topheight <= mobj->z - || bottomheight > (mobj->z + FixedMul(mobj->info->height >> 1, mobj->scale))) + if (bottomheight > (mobj->z + FixedMul(mobj->info->height >> 1, mobj->scale))) continue; if (mobj->z + FixedMul(mobj->info->height, mobj->scale) > topheight) @@ -3422,19 +3441,25 @@ static void P_PlayerMobjThinker(mobj_t *mobj) // Crumbling platforms for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next) { - fixed_t topheight, bottomheight; ffloor_t *rover; for (rover = node->m_sector->ffloors; rover; rover = rover->next) { + boolean oncrumble; + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_CRUMBLE)) continue; - topheight = P_GetSpecialTopZ(mobj, sectors + rover->secnum, node->m_sector); - bottomheight = P_GetSpecialBottomZ(mobj, sectors + rover->secnum, node->m_sector); + if (mobj->eflags & MFE_VERTICALFLIP) + { + oncrumble = P_GetSpecialBottomZ(mobj, sectors + rover->secnum, node->m_sector) == mobj->z + mobj->height; // You nut. + } + else + { + oncrumble = P_GetSpecialTopZ(mobj, sectors + rover->secnum, node->m_sector) == mobj->z; + } - if ((topheight == mobj->z && !(mobj->eflags & MFE_VERTICALFLIP)) - || (bottomheight == mobj->z + mobj->height && mobj->eflags & MFE_VERTICALFLIP)) // You nut. + if (oncrumble) EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), mobj->player, rover->alpha, !(rover->flags & FF_NORETURN)); } } @@ -3537,11 +3562,9 @@ animonly: static void P_CalculatePrecipFloor(precipmobj_t *mobj) { // recalculate floorz each time - const sector_t *sec; + const sector_t *sec = (mobj && mobj->subsector) ? mobj->subsector->sector : NULL; - if (mobj && mobj->subsector && mobj->subsector->sector) - sec = mobj->subsector->sector; - else + if (!sec) return; mobj->floorz = P_GetSectorFloorZAt(sec, mobj->x, mobj->y); @@ -3636,7 +3659,9 @@ boolean P_PrecipThinker(precipmobj_t *mobj) // only recalc this twice a second (doubt anyone will notice this lulul) if ((leveltime % (TICRATE/2)) == 0) + { P_CalculatePrecipFloor(mobj); + } // adjust height if ((mobj->z += mobj->momz) <= mobj->floorz) @@ -4299,7 +4324,7 @@ static void P_Boss4PopSpikeballs(mobj_t *mobj) { mobj_t *base = mobj->tracer, *seg, *next; P_SetTarget(&mobj->tracer, NULL); - while(base) + while (base) { next = base->tracer; P_SetTarget(&base->tracer, NULL); @@ -9023,7 +9048,7 @@ void P_MobjThinker(mobj_t *mobj) I_Assert(mobj != NULL); I_Assert(!P_MobjWasRemoved(mobj)); - if (UNLIKELY(mobj->flags & MF_NOTHINK)) + if (mobj->flags & MF_NOTHINK) return; // Remove dead target/tracer. @@ -9284,12 +9309,13 @@ void P_PushableThinker(mobj_t *mobj) x = mobj->spawnpoint->x << FRACBITS; y = mobj->spawnpoint->y << FRACBITS; - ss = R_PointInSubsector(x, y); - if (mobj->spawnpoint->z != 0) z = mobj->spawnpoint->z << FRACBITS; else + { + ss = R_PointInSubsector(x, y); z = ss->sector->floorheight; + } spawnmo = P_SpawnMobj(x, y, z, mobj->type); if (spawnmo) @@ -10270,7 +10296,7 @@ void P_SpawnPrecipitation(void) if (curWeather == PRECIP_BLANK) rainmo->precipflags |= PCF_INVISIBLE; - floorz = rainmo->floorz >> FRACBITS; + floorz = rainmo->floorz >> FRACBITS; ceilingz = rainmo->ceilingz >> FRACBITS; if (floorz < ceilingz) @@ -10337,8 +10363,6 @@ void P_PrecipitationEffects(void) return; } - boolean sounds_rain = ((cv_drawdist_precip.value != 0) && rainsfx && (!leveltime || leveltime % 80 == 1)); - // Currently thunderstorming with lightning, and we're sounding the thunder... // and where there's thunder, there's gotta be lightning! if (effects_lightning && lightningStrike) @@ -10360,6 +10384,8 @@ void P_PrecipitationEffects(void) if (sound_disabled) return; // Sound off? D'aw, no fun. + const boolean sounds_rain = ((cv_drawdist_precip.value != 0) && rainsfx && (!leveltime || leveltime % 80 == 1)); + if (!sounds_rain && !sounds_thunder) return; // no need to calculate volume at ALL @@ -11848,8 +11874,6 @@ void P_SpawnHoops(mapthing_t *mthing) x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; - sec = R_PointInSubsector(x, y)->sector; - // Save our flags! if (mthing->type == 1713) z = (mthing->options >> ZSHIFT) << FRACBITS; @@ -11861,6 +11885,8 @@ void P_SpawnHoops(mapthing_t *mthing) if (P_MobjWasRemoved(hoopcenter)) return; + sec = R_PointInSubsector(x, y)->sector; + hoopcenter->spawnpoint = mthing; z += P_GetSectorFloorZAt(sec, x, y); From a868844bdf0c2ac42e483d1f7bd02631309a94fa Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 10 May 2026 20:14:28 +0200 Subject: [PATCH 47/61] remove outdated comment about precipmobj --- src/d_netcmd.c | 1 - src/p_mobj.h | 4 ---- src/p_slopes.c | 3 ++- src/p_user.c | 3 ++- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 76495a09e..42f14f3cc 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -5816,7 +5816,6 @@ static void BaseNumLaps_OnChange(void) } } - static void KartFrantic_OnChange(void) { if ((boolean)cv_kartfrantic.value != franticitems && gamestate == GS_LEVEL && leveltime > starttime) diff --git a/src/p_mobj.h b/src/p_mobj.h index 892ffdad4..682b2fb1b 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -421,10 +421,6 @@ typedef struct mobj_s // // For precipitation // -// Sometimes this is casted to a mobj_t, -// so please keep the start of the -// structure the same. -// typedef struct precipmobj_s { // List: thinker links. diff --git a/src/p_slopes.c b/src/p_slopes.c index 627052236..ac3a56c17 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -166,7 +166,8 @@ static void P_ReconfigureVertexSlope(pslope_t *slope) slope->real_xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180; slope->real_zangle = InvAngle(R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta)); - if (slope->normal.x == 0 && slope->normal.y == 0) // Set some defaults for a non-sloped "slope" + // Set some defaults for a non-sloped "slope" + if (slope->normal.x == 0 && slope->normal.y == 0) { slope->zangle = slope->xydirection = 0; slope->zdelta = slope->d.x = slope->d.y = 0; diff --git a/src/p_user.c b/src/p_user.c index 3b2f90dd7..ae5983935 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1393,7 +1393,8 @@ static void P_CheckBustableBlocks(player_t *player) for (rover = node->m_sector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS)) continue; + if (!(rover->flags & FF_EXISTS)) + continue; if ((rover->flags & FF_BUSTUP)/* && !rover->master->frontsector->crumblestate*/) { From d6946d4d4455b6c464698d6f47bc77869ca8ee0f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 May 2026 15:07:51 +0200 Subject: [PATCH 48/61] fix HWR_RenderPolyObjectPlane smol oopsie that was supposed to be float fixes the rotating skybox thing in Zero Space --- src/hardware/hw_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 7de18f756..2587055c5 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -2673,7 +2673,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, float anglef = 0.0f, cosangf = 0.0f, sinangf = 0.0f; angle_t angle = 0; FSurfaceInfo Surf = {}; - fixed_t tempxsow, tempytow; + float tempxsow, tempytow; size_t nrPlaneVerts; static FOutVector *planeVerts = NULL; From 9aaa7cc5bff21d25765b403d8485d72febfde57e Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 12 May 2026 03:52:56 +0300 Subject: [PATCH 49/61] Don't break non-string keys in ArchiveTables when printing error message --- src/lua_script.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index 8e07f87e3..2649a57c7 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1065,8 +1065,9 @@ static void ArchiveTables(UINT8 **p) n++; // the table contained a new table we'll have to archive. :( else if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise) { - CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i); - lua_pop(gL, 1); + lua_pushvalue(gL, -2); // copy key for error message (lua_tostring may mutate it which confuses lua_next) + CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -1), luaL_typename(gL, -1), i); + lua_pop(gL, 2); // pop key copy and value continue; } else if (e == 3) // nil key due to invalid userdata. NOT an error. @@ -1080,7 +1081,11 @@ static void ArchiveTables(UINT8 **p) if (e == 1) n++; // the table contained a new table we'll have to archive. :( else if (e == 2) // invalid value type - CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1)); + { + lua_pushvalue(gL, -2); // copy key for error message (same as above) + CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -1), luaL_typename(gL, -2)); + lua_pop(gL, 1); // pop key copy + } lua_pop(gL, 1); } From 6aabdc86c0e01fec78c2a418e9df209826360e54 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 12 May 2026 15:02:44 +0200 Subject: [PATCH 50/61] P_TryMove: reduce the amount of R_PointInSubsector per call and also P_PlayerTouchingSectorSpecial since either are in a loop that often runs multiple times per call improves perf a bit per usual testing --- src/p_floor.c | 1 - src/p_map.c | 33 ++++++++++++++++++--------------- src/p_mobj.c | 2 +- src/p_spec.c | 3 ++- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index bd7a2655e..ef42b02a3 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -1894,7 +1894,6 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies) { if (nobaddies->sector->lines[i]->special == 223) { - upperbound = nobaddies->sector->ceilingheight; lowerbound = nobaddies->sector->floorheight; diff --git a/src/p_map.c b/src/p_map.c index 10b55f65b..1befc4933 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2373,6 +2373,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) fixed_t radius = thing->radius; fixed_t thingtop ;//= thing->z + thing->height; fixed_t startingonground = P_IsObjectOnGround(thing); + INT32 special = -1; floatok = false; if (radius < MAXRADIUS/2) @@ -2406,21 +2407,31 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (!(thing->flags & MF_NOCLIP)) { - //All things are affected by their scale. - fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale); - INT32 special = 0; + // All things are affected by their scale. + fixed_t maxstep; + + if (tmceilingz - tmfloorz < thing->height) + { + if (tmfloorthing) + tmhitthing = tmfloorthing; + + return false; // doesn't fit + } + + maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale); if (thing->player) { - special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1); + if (special == -1) + special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1); // If using type Section1:13, double the maxstep. - if (P_PlayerTouchingSectorSpecial(thing->player, 1, 13) || special == 13) + if (special == 13 || P_PlayerTouchingSectorSpecial(thing->player, 1, 13)) { maxstep <<= 1; } // If using type Section1:12, no maxstep. For ledges you don't want the player to climb! (see: Egg Zeppelin & SMK port walls) - else if (P_PlayerTouchingSectorSpecial(thing->player, 1, 12) || special == 12) + else if (special == 12 || P_PlayerTouchingSectorSpecial(thing->player, 1, 12)) { maxstep = 0; } @@ -2431,14 +2442,6 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) maxstep = 0; } - if (tmceilingz - tmfloorz < thing->height) - { - if (tmfloorthing) - tmhitthing = tmfloorthing; - - return false; // doesn't fit - } - floatok = true; thingtop = thing->z + thing->height; @@ -2469,7 +2472,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) } } else if (maxstep > 0 && !(thing->player && - (P_PlayerTouchingSectorSpecial(thing->player, 1, 14) || special == 14))) // Step down + (special == 14 || P_PlayerTouchingSectorSpecial(thing->player, 1, 14)))) // Step down { // If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS // step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more. diff --git a/src/p_mobj.c b/src/p_mobj.c index b30e4ecd4..614797247 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1828,7 +1828,7 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec) while (po) { - if (!(po->flags & POF_SOLID) || !P_MobjInsidePolyobj(po, mo)) + if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) { po = (polyobj_t *)(po->link.next); continue; diff --git a/src/p_spec.c b/src/p_spec.c index 919be8031..605a34861 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4441,12 +4441,13 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) } f_affectpoint = P_GetSpecialBottomZ(player->mo, sector, sector); - c_affectpoint = P_GetSpecialTopZ(player->mo, sector, sector); // Only go further if on the ground if ((sector->flags & SF_FLIPSPECIAL_FLOOR) && !(sector->flags & SF_FLIPSPECIAL_CEILING) && player->mo->z != f_affectpoint) return; + c_affectpoint = P_GetSpecialTopZ(player->mo, sector, sector); + if ((sector->flags & SF_FLIPSPECIAL_CEILING) && !(sector->flags & SF_FLIPSPECIAL_FLOOR) && player->mo->z + player->mo->height != c_affectpoint) return; From 55a57a10368b60a5dbe558d077c5d1c7e509bf2f Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 12 May 2026 20:48:30 +0200 Subject: [PATCH 51/61] fix checking for fbo completeness too early this should come after everything apparently all this shit really needs to be cleaned up again --- src/hardware/r_opengl/r_opengl.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 518181f69..c8d60871b 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3260,14 +3260,6 @@ static void GL_Framebuffer_Generate(void) if (!framebufferobject.fboobj) pglGenFramebuffers(1, &framebufferobject.fboobj); - if (pglCheckFramebufferStatus(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) - { - // if this fails, dont retry it a gazillion times - // this wouldnt recover - supportFBO = false; - return; - } - // Bind the framebuffer pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj); @@ -3319,6 +3311,18 @@ static void GL_Framebuffer_Generate(void) pglBindRenderbuffer(GL_RENDERBUFFER_EXT, 0); } + if (pglCheckFramebufferStatus(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) + { + //pglGetError(); TODO:implement this or smth + GL_MSG_Error("GL_Framebuffer_Generate: Failed to create Framebuffer Object"); + + // if this fails, dont retry it a gazillion times + // this wouldnt recover + supportFBO = false; + pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); + return; + } + // Unbind the framebuffer pglBindFramebuffer(GL_FRAMEBUFFER_EXT, 0); @@ -3341,6 +3345,10 @@ void GL_Framebuffer_Enable(void) GL_Framebuffer_Generate(); + // failed + if (!supportFBO || !framebufferobject.init) + return; + pglBindFramebuffer(GL_FRAMEBUFFER_EXT, framebufferobject.fboobj); pglBindRenderbuffer(GL_RENDERBUFFER_EXT, framebufferobject.rboobj); } From 2ce4e866e33de86a5e0d6b8a8a66a1c53b6c60a9 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 14 May 2026 18:53:52 +0200 Subject: [PATCH 52/61] reorder seg_t struct a bit fixes a 4byte hole so we can fit everything important into cacheline 1 even when compiled without HWRENDER this should be a better layout checked per pahole --- src/r_defs.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/r_defs.h b/src/r_defs.h index e6c5866c6..217314028 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -531,11 +531,10 @@ typedef struct seg_s vertex_t *v1; vertex_t *v2; - INT32 side; - - fixed_t offset; - - angle_t angle; +#ifdef HWRENDER + floatvertex_t fv1; // v1 in floats - precalculated + floatvertex_t fv2; // v2 in floats - precalculated +#endif side_t *sidedef; line_t *linedef; @@ -545,11 +544,13 @@ typedef struct seg_s sector_t *frontsector; sector_t *backsector; + INT32 side; + fixed_t length; // precalculated seg length -#ifdef HWRENDER - floatvertex_t fv1; // v1 in floats - precalculated - floatvertex_t fv2; // v2 in floats - precalculated -#endif + fixed_t offset; + + angle_t angle; + polyobj_t *polyseg; // Fake contrast calculated on level load From e113027ce6799060e7e7b82efc7aae0e8e2a6c78 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 14 May 2026 21:11:45 +0200 Subject: [PATCH 53/61] d_netcmd: fix snacpending stuff also move all of it behind PARANOIA define, since nothing else was using it eitherway --- src/d_netcmd.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 42f14f3cc..7501234d7 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1496,7 +1496,9 @@ static void ForceAllSkins(INT32 forcedskin) } static INT32 chmappending; +#ifdef PARANOIA static INT32 snacpending[MAXSPLITSCREENPLAYERS]; +#endif // wonky compat, idk if anything uses this.... #define playerisbot (splitplayer == 1 && botingame) @@ -1596,7 +1598,9 @@ static void SendNameAndColor(UINT8 splitplayer) return; } +#ifdef PARANOIA snacpending[splitplayer]++; +#endif // Don't change name if muted if (player_name_changes[pnum] >= MAXNAMECHANGES) @@ -1632,7 +1636,7 @@ static void SendNameAndColor(UINT8 splitplayer) static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) { - player_t *player = &players[playernum]; + player_t *player; char name[MAXPLAYERNAME+1] = {}; UINT8 color, skin; @@ -1641,14 +1645,18 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) I_Error("There is no player %d!", playernum); #endif + player = &players[playernum]; + +#ifdef PARANOIA if (P_IsLocalPlayer(player)) { - snacpending[playernum]--; -#ifdef PARANOIA - if (snacpending[playernum] < 0) + const INT32 localpnum = P_GetLocalPlayerNumForPlayer(player); + snacpending[localpnum]--; + + if (snacpending[localpnum] < 0) I_Error("snacpending negative!"); -#endif } +#endif READSTRINGN(*cp, name, MAXPLAYERNAME); color = READUINT8(*cp); @@ -2189,7 +2197,6 @@ void D_SetupVote(void) WRITEUINT8(p, secondgt); secondgt &= ~0x80; - for (i = 0; i < 4; i++) { UINT16 m; From e75a696ee55dbce8e92570c21174abe9b1a94dff Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 15 May 2026 01:06:04 +0300 Subject: [PATCH 54/61] Remove outdated PARANOIA assert in P_SetMobjState, it uses P_SetPlayerMobjState automatically for players now --- src/p_mobj.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 614797247..e740dfc94 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -222,11 +222,6 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) INT32 recursion = 0; -#ifdef PARANOIA - if (mobj->player != NULL) - I_Error("P_SetMobjState used for player mobj. Use P_SetPlayerMobjState instead!\n(State called: %d)", state); -#endif - if (mobj->player != NULL) return P_SetPlayerMobjState(mobj, state); From a28d79818927adc505fc9337400c67b61ce1cb1a Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 15 May 2026 01:24:14 +0300 Subject: [PATCH 55/61] Remove some redundant mo != NULL asserts if they are followed by !P_MobjWasRemoved(mo) asserts --- src/k_kart.c | 7 ------- src/p_enemy.c | 2 -- src/p_maputl.cpp | 4 ---- src/p_mobj.c | 20 -------------------- src/p_user.c | 1 - 5 files changed, 34 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f7fdba2ad..eed4ebfed 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1603,7 +1603,6 @@ static UINT8 K_CheckOffroadCollide(mobj_t *mo) fixed_t flr, cel; // floor & ceiling for height checks to make sure we're touching the offroad sector. INT32 special; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) @@ -1743,7 +1742,6 @@ static void K_SpawnDashDustRelease(player_t *player) INT32 i; I_Assert(player != NULL); - I_Assert(player->mo != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); if (!player->speed && !player->kartstuff[k_startboost]) @@ -1781,7 +1779,6 @@ static void K_SpawnBrakeDriftSparks(player_t *player) // Be sure to update the m mobj_t *sparks; I_Assert(player != NULL); - I_Assert(player->mo != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); // Position & etc are handled in its thinker, and its spawned invisible. @@ -3181,7 +3178,6 @@ static void K_SpawnDriftSparks(player_t *player) INT32 i; I_Assert(player != NULL); - I_Assert(player->mo != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); if (leveltime % 2 == 1) @@ -3553,7 +3549,6 @@ void K_SpawnBoostTrail(player_t *player) INT32 i; I_Assert(player != NULL); - I_Assert(player->mo != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); if (!P_IsObjectOnGround(player->mo) @@ -3635,7 +3630,6 @@ void K_SpawnSparkleTrail(mobj_t *mo) mobj_t *sparkle; INT32 i; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); const boolean shouldblend = (mo->player && K_PlayerEffectsShouldBlend(mo->player)); @@ -3669,7 +3663,6 @@ mobj_t *K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) mobj_t *dust; angle_t aoff; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); if (mo->player) diff --git a/src/p_enemy.c b/src/p_enemy.c index f1a0ed535..15410747a 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -306,7 +306,6 @@ void P_NewChaseDir(mobj_t *actor) dirtype_t d[3]; dirtype_t tdir = DI_NODIR, olddir, turnaround; - I_Assert(actor->target != NULL); I_Assert(!P_MobjWasRemoved(actor->target)); olddir = actor->movedir; @@ -619,7 +618,6 @@ void A_Chase(void *thing) if (LUA_CallAction(A_CHASE, actor)) return; - I_Assert(actor != NULL); I_Assert(!P_MobjWasRemoved(actor)); if (actor->reactiontime) diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index ebf4a08fa..592f57e92 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -423,8 +423,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // Set open and high/low values here fixed_t frontheight, backheight; - I_Assert(mobj != NULL); - if (mobj) { frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); @@ -707,7 +705,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // void P_UnsetThingPosition(mobj_t *thing) { - I_Assert(thing != NULL); I_Assert(!P_MobjWasRemoved(thing)); if (!(thing->flags & MF_NOSECTOR)) @@ -811,7 +808,6 @@ void P_SetThingPosition(mobj_t *thing) sector_t *oldsec = NULL; fixed_t tfloorz, tceilz; - I_Assert(thing != NULL); I_Assert(!P_MobjWasRemoved(thing)); if (thing->player && thing->z <= thing->floorz && thing->subsector) diff --git a/src/p_mobj.c b/src/p_mobj.c index e740dfc94..d9b4a08ba 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -334,7 +334,6 @@ void P_ExplodeMissile(mobj_t *mo) { mobj_t *explodemo; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); mo->momx = mo->momy = mo->momz = 0; @@ -948,7 +947,6 @@ fixed_t P_GetMobjGravity(mobj_t *mo) boolean goopgravity = false; boolean wasflip; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); wasflip = (mo->eflags & MFE_VERTICALFLIP) != 0; @@ -1121,7 +1119,6 @@ void P_CheckGravity(mobj_t *mo, boolean affect) // static void P_SceneryXYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) { - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); const fixed_t fric_scale = FixedMul(FRACUNIT/32, mo->scale); @@ -1165,7 +1162,6 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) { player_t *player; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); player = mo->player; @@ -1217,7 +1213,6 @@ static void P_PushableCheckBustables(mobj_t *mo) fixed_t oldx; fixed_t oldy; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); if (netgame && mo->player && mo->player->spectator) @@ -1336,7 +1331,6 @@ void P_XYMovement(mobj_t *mo) vector3_t slopemom = {0, 0, 0}; fixed_t predictedz = 0; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); // if it's stopped @@ -1690,7 +1684,6 @@ void P_XYMovement(mobj_t *mo) static void P_RingXYMovement(mobj_t *mo) { - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); if (!P_SceneryTryMove(mo, mo->x + mo->momx, mo->y + mo->momy)) @@ -1701,7 +1694,6 @@ static void P_SceneryXYMovement(mobj_t *mo) { fixed_t oldx, oldy; // reducing bobbing/momentum on ice when up against walls - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); oldx = mo->x; @@ -1739,7 +1731,6 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp fixed_t delta1, delta2, thingtop; fixed_t topheight, bottomheight; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); thingtop = mo->z + mo->height; @@ -1816,7 +1807,6 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec) fixed_t delta1, delta2, thingtop; fixed_t polytop, polybottom; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); thingtop = mo->z + mo->height; @@ -1860,7 +1850,6 @@ static void P_AdjustMobjFloorZ_PolyObjs(mobj_t *mo, subsector_t *subsec) static void P_RingZMovement(mobj_t *mo) { - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); // Intercept the stupid 'fall through 3dfloors' bug @@ -1895,7 +1884,6 @@ static void P_RingZMovement(mobj_t *mo) boolean P_CheckDeathPitCollide(mobj_t *mo) { - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); const INT32 secspecial = GETSECSPECIAL(mo->subsector->sector->special, 1); @@ -1912,7 +1900,6 @@ boolean P_CheckDeathPitCollide(mobj_t *mo) boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover) { - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3 @@ -1931,7 +1918,6 @@ static boolean P_ZMovement(mobj_t *mo) { fixed_t dist, delta; - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); // Intercept the stupid 'fall through 3dfloors' bug @@ -2388,7 +2374,6 @@ static boolean P_ZMovement(mobj_t *mo) static void P_PlayerZMovement(mobj_t *mo) { - I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); if (!mo->player) @@ -3384,7 +3369,6 @@ static void P_PlayerMobjThinker(mobj_t *mobj) { msecnode_t *node; - I_Assert(mobj != NULL); I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); @@ -9040,7 +9024,6 @@ static void P_FiringThink(mobj_t *mobj) // void P_MobjThinker(mobj_t *mobj) { - I_Assert(mobj != NULL); I_Assert(!P_MobjWasRemoved(mobj)); if (mobj->flags & MF_NOTHINK) @@ -9144,7 +9127,6 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->fuse && !P_FuseThink(mobj)) return; - I_Assert(mobj != NULL); I_Assert(!P_MobjWasRemoved(mobj)); if (mobj->momx || mobj->momy || (mobj->flags2 & MF2_SKULLFLY)) @@ -9240,7 +9222,6 @@ boolean P_RailThinker(mobj_t *mobj) { fixed_t x, y, z; - I_Assert(mobj != NULL); I_Assert(!P_MobjWasRemoved(mobj)); x = mobj->x, y = mobj->y, z = mobj->z; @@ -9266,7 +9247,6 @@ void P_PushableThinker(mobj_t *mobj) { sector_t *sec; - I_Assert(mobj != NULL); I_Assert(!P_MobjWasRemoved(mobj)); if (!mobj) diff --git a/src/p_user.c b/src/p_user.c index ae5983935..9df7d2735 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2112,7 +2112,6 @@ void P_ElementalFireTrail(player_t *player) INT32 i; I_Assert(player != NULL); - I_Assert(player->mo != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); if (player->mo->eflags & MFE_VERTICALFLIP) From 459beeb000ffbb768d36f427fc9b5e25bdb8f15e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 00:36:22 +0200 Subject: [PATCH 56/61] fix oopsie from https://github.com/Indev450/SRB2Kart-Saturn/commit/093ed023ef36bb2e8608116ef39d7710366ccf84 --- src/d_clisrv.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2228eb172..fb163acfa 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1485,12 +1485,13 @@ static void CL_DrawConnectionStatus(void) { UINT32 dldlength = 0; UINT32 totaldldsize = 0; - UINT32 totalfileslength = filedownload.totalsize; + UINT32 totalfileslength = 0; static char tempname[28]; fileneeded_t *file = &fileneeded[filedownload.current]; char *filename = file->filename; UINT32 totalsize = file->totalsize; UINT32 currentsize = min(file->currentsize, totalsize); + UINT32 fdtotalsize = filedownload.totalsize; // Draw the bottom box. M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-58-8, 32, 1); @@ -1541,18 +1542,18 @@ static void CL_DrawConnectionStatus(void) totaldldsize = filedownload.completedsize; V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP|MENUCAPS, "Overall Download Progress"); - if (totalfileslength != 0) - totalfileslength = (UINT32)((totaldldsize/(double)totalfileslength) * 256); + if (fdtotalsize != 0) + totalfileslength = (UINT32)((totaldldsize/(double)fdtotalsize) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, (INT32)totalfileslength, 8, 160); - if (totalfileslength>>20 >= 10) // display in MB if over 10MB + if ((fdtotalsize>>20) >= 10) // display in MB if over 10MB V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uM/%4uM", (INT32)(totaldldsize>>20), (INT32)(totalfileslength>>20))); + va(" %4uM/%4uM", (INT32)(totaldldsize>>20), (INT32)(fdtotalsize>>20))); else V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uK/%4uK", (INT32)(totaldldsize>>10), (INT32)(totalfileslength>>10))); + va(" %4uK/%4uK", (INT32)(totaldldsize>>10), (INT32)(fdtotalsize>>10))); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va("%2u/%2u Files ", filedownload.completednum, filedownload.totalnum)); From b652d802f5927f4b5efe253b99c4bb4773fbcfa7 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 01:08:53 +0200 Subject: [PATCH 57/61] blua: fix copy paste error for "slow path" in auxgetstr/lua_getfield lets hope this fixes the random crashes from gc sometime stimky from https://github.com/Indev450/SRB2Kart-Saturn/pull/223/changes/e4e51f0f80fb7deb9213c72bb374d0a7e4c3f03b --- src/blua/lapi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index bca24a90f..e494e9fc9 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -526,13 +526,12 @@ static void auxgetstr (lua_State *L, TValue *t, const char *k) { api_checkvalidindex(L, t); if (luaV_fastget(L, t, str, slot, luaH_getstr)) { setobj2s(L, L->top, slot); - api_incr_top(L); } else { setsvalue(L, &key, str); - luaV_finishget(L, t, L->top, L->top, slot); - api_incr_top(L); + luaV_finishget(L, t, &key, L->top, slot); } + api_incr_top(L); lua_unlock(L); } From 24c9f88262efba801c2e272c81bfb0f5be1ed41d Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 01:27:55 +0200 Subject: [PATCH 58/61] make snacpending error print player number bit more informative :chaosleep: --- src/d_netcmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7501234d7..7121c3e6b 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1654,7 +1654,7 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum) snacpending[localpnum]--; if (snacpending[localpnum] < 0) - I_Error("snacpending negative!"); + I_Error("snacpending negative for player %d!", localpnum); } #endif From 3d9d14b353abbf5b3a41a3e31eeff1d120b74357 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 18 Mar 2024 19:24:42 +0000 Subject: [PATCH 59/61] EnsurePlayerNameIsGood: Remove trailing whitespace, instead of just failing on it Interesting error with its recursive duplication resolving exposed by the previous commit! --- src/d_netcmd.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7121c3e6b..a0ee1607c 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1214,13 +1214,22 @@ static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum) if (len == 0 || len > MAXPLAYERNAME) return false; // Empty or too long. - if (name[0] == ' ' || name[len-1] == ' ') - return false; // Starts or ends with a space. + if (name[0] == ' ') + return false; // Starts with a space. if (isdigit(name[0])) return false; // Starts with a digit. if (name[0] == '@' || name[0] == '~') return false; // Starts with an admin symbol. + // Clean up trailing whitespace. + while (len && name[len-1] == ' ') + { + name[len-1] = '\0'; + len--; + } + if (len == 0) + return false; + // Check if it contains a non-printing character. // Note: ANSI C isprint() considers space a printing character. // Also don't allow semicolons, since they are used as From 83a60ea8577405b71193afebdcaae062b6bcb08b Mon Sep 17 00:00:00 2001 From: toaster Date: Tue, 30 Nov 2021 21:24:00 +0000 Subject: [PATCH 60/61] Some fixes for bad player info on joining servers. * Don't overwrite the first player's name when joining with multiple local splitscreen players. (resolves #151) * The defaults for unprovided names are now consistently "Player A/B/C/D" as opposed to some being letter-based and some being number-based. * Send local player info once per local splitscreen player, rather than n^2 times (where n is the number of local splitscreen players). * Since the packet *requires* four names to be sent every time you join a server, send dummy names for local splitscreen players who aren't connecting, instead of your actual cvars (no data leakage you didn't ask for!) --- src/d_clisrv.c | 4 ++-- src/d_netcmd.c | 50 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index fb163acfa..e29a559d1 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2200,7 +2200,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXPLAYERS; i++) { LUA_InvalidatePlayer(&players[i]); - sprintf(player_names[i], "Player %d", i + 1); + sprintf(player_names[i], "Player %c", 'A' + i); } CL_LoadReceivedSavegame(true); @@ -4436,7 +4436,7 @@ void SV_ResetServer(void) for (i = 0; i < MAXPLAYERS; i++) { LUA_InvalidatePlayer(&players[i]); - sprintf(player_names[i], "Player %d", i + 1); + sprintf(player_names[i], "Player %c", 'A' + i); } memset(player_name_changes, 0, sizeof(player_name_changes)); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index a0ee1607c..8fbac60a6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1282,7 +1282,8 @@ static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum) * is restored to what it was before. * * We assume that if playernum is ::consoleplayer or ::secondarydisplayplayer - * the console variable ::cv_playername or ::cv_playername2 respectively is + * (unless clientjoin is true, a necessary evil) + * the console variable ::cv_playername to ::cv_playername4 respectively is * already set to newname. However, the player name table is assumed to * contain the old name. * @@ -1302,6 +1303,10 @@ static void CleanupPlayerName(INT32 playernum, const char *newname) char *tmpname = NULL; INT32 i; boolean namefailed = true; + boolean clientjoin = !!(playernum >= MAXPLAYERS); + + if (clientjoin) + playernum -= MAXPLAYERS; buf = Z_StrDup(newname); @@ -1358,17 +1363,20 @@ static void CleanupPlayerName(INT32 playernum, const char *newname) } // no stealing another player's name - for (i = 0; i < MAXPLAYERS; i++) + if (!clientjoin) { - if (i != playernum && playeringame[i] - && fasticmp(tmpname, player_names[i])) + for (i = 0; i < MAXPLAYERS; i++) { - break; + if (i != playernum && playeringame[i] + && fasticmp(tmpname, player_names[i])) + { + break; + } } - } - if (i < MAXPLAYERS) - break; + if (i < MAXPLAYERS) + break; + } // name is okay then namefailed = false; @@ -1379,15 +1387,23 @@ static void CleanupPlayerName(INT32 playernum, const char *newname) // set consvars whether namefailed or not, because even if it succeeded, // spaces may have been removed - if (playernum == consoleplayer) - CV_StealthSet(&cv_playername, tmpname); - else if (playernum == displayplayers[1] || (!netgame && playernum == 1)) - CV_StealthSet(&cv_playername2, tmpname); - else if (playernum == displayplayers[2] || (!netgame && playernum == 2)) - CV_StealthSet(&cv_playername3, tmpname); - else if (playernum == displayplayers[3] || (!netgame && playernum == 3)) - CV_StealthSet(&cv_playername4, tmpname); - else I_Assert(((void)"CleanupPlayerName used on non-local player", 0)); + if (clientjoin) + { + consvar_t *namevars[] = {&cv_playername, &cv_playername2, &cv_playername3, &cv_playername4}; + CV_StealthSet(namevars[playernum], tmpname); + } + else + { + if (playernum == consoleplayer) + CV_StealthSet(&cv_playername, tmpname); + else if (playernum == displayplayers[1] || (!netgame && playernum == 1)) + CV_StealthSet(&cv_playername2, tmpname); + else if (playernum == displayplayers[2] || (!netgame && playernum == 2)) + CV_StealthSet(&cv_playername3, tmpname); + else if (playernum == displayplayers[3] || (!netgame && playernum == 3)) + CV_StealthSet(&cv_playername4, tmpname); + else I_Assert(((void)"CleanupPlayerName used on non-local player", 0)); + } Z_Free(buf); } From e854096ca0609ed4312146668be2d62382cacf7a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 15 May 2026 03:10:08 +0200 Subject: [PATCH 61/61] revert back to number based player names fallbacks well need our player 1-16 not player a-z :chonkbuncle: --- 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 e29a559d1..fb163acfa 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2200,7 +2200,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXPLAYERS; i++) { LUA_InvalidatePlayer(&players[i]); - sprintf(player_names[i], "Player %c", 'A' + i); + sprintf(player_names[i], "Player %d", i + 1); } CL_LoadReceivedSavegame(true); @@ -4436,7 +4436,7 @@ void SV_ResetServer(void) for (i = 0; i < MAXPLAYERS; i++) { LUA_InvalidatePlayer(&players[i]); - sprintf(player_names[i], "Player %c", 'A' + i); + sprintf(player_names[i], "Player %d", i + 1); } memset(player_name_changes, 0, sizeof(player_name_changes));