From 77f4d4ef3bd55528043cfcc52b730bc023b03364 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 22 Oct 2025 13:42:33 +0200 Subject: [PATCH] fix replays occasionally crashing when stopping due to R_ReInitColormaps our extra_colormaps pointer may be freed so ensure it only gets called after gamestate has been set to GS_NULL so we dont risk doing this mid renderframe fixes crashes in software and palette render mode --- src/g_demo.c | 11 ++++++----- src/r_main.cpp | 3 ++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 6b2c8f1c9..de8523ae9 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -3411,11 +3411,6 @@ void G_StopDemo(void) demo.rewinding = false; CL_ClearRewinds(); - if (gamestate == GS_LEVEL && rendermode != render_none) - { - V_SetPaletteLump("PLAYPAL"); // Reset the palette - R_ReInitColormaps(0, LUMPERROR); - } if (gamestate == GS_INTERMISSION) Y_EndIntermission(); // cleanup if (gamestate == GS_VOTING) @@ -3427,6 +3422,12 @@ void G_StopDemo(void) wipegamestate = GS_NULL; SV_StopServer(); SV_ResetServer(); + + if (gamestate == GS_LEVEL && rendermode != render_none) + { + V_SetPaletteLump("PLAYPAL"); // Reset the palette + R_ReInitColormaps(0, LUMPERROR); + } } // Stops timing a demo. diff --git a/src/r_main.cpp b/src/r_main.cpp index a340ef29c..5313357d6 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -943,9 +943,10 @@ void R_ExecuteSetViewSize(void) memset(scalelight, 0xFF, sizeof(scalelight)); // Calculate the light levels to use for each level/scale combination. - for (i = 0; i< LIGHTLEVELS; i++) + for (i = 0; i < LIGHTLEVELS; i++) { startmapl = ((LIGHTLEVELS - 1 - i)*2)*NUMCOLORMAPS/LIGHTLEVELS; + for (j = 0; j < MAXLIGHTSCALE; j++) { level = startmapl - j*vid.width/(viewwidth)/DISTMAP;