From 8cab07a4b21c3fa148cbd143f5ca3e2271beae5c Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 3 Feb 2026 15:39:58 +0100 Subject: [PATCH 01/54] add missing "ifdef LOGMESSAGES" --- src/http-mserv.c | 3 ++- src/sdl/i_system.cpp | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/http-mserv.c b/src/http-mserv.c index fd63c5f69..9e4374353 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -225,9 +225,10 @@ HMS_connect (const char *format, ...) { cc = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf); - +#ifdef LOGMESSAGES cc = curl_easy_setopt(curl, CURLOPT_STDERR, logstream); if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf); +#endif } if (M_CheckParm("-bindaddr") && M_IsNextParm()) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 4dd32161e..b90fbf898 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1841,18 +1841,15 @@ static void I_Fork(void) I_RegisterChildSignals(); break; default: +#ifdef LOGMESSAGES if (logstream) fclose(logstream);/* the child has this */ - +#endif 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); From 16e0c6f0f6b348bfa83cc2b2795cec9e2071fbf8 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Feb 2026 18:25:13 +0100 Subject: [PATCH 02/54] dont constantly fetch lookback joyaxis in p_ticker if replay recording is enabled minuscule optimization lul --- src/p_tick.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 88e8fb2fd..9365f5669 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -728,11 +728,12 @@ void P_Ticker(boolean run) if (cv_recordmultiplayerdemos.value) { - const INT32 axis = JoyAxis(AXISLOOKBACK, 1); - if (demo.savemode == DSM_NOTSAVING || demo.savemode == DSM_WILLAUTOSAVE) - if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && (InputDown(gc_lookback, 1) || (cv_usejoystick[0].value && axis > 0))) + { + const INT32 axis = cv_usejoystick[0].value ? JoyAxis(AXISLOOKBACK, 1) : -1; + if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && (InputDown(gc_lookback, 1) || (axis > 0))) demo.savemode = DSM_TITLEENTRY; + } // if there are no players left at all, stop demo recording // Demos that that dont have any players crash during playback, which can happen with dedicated servers From 0fbde146a973bdf696c9ab1a48959fd47c6fb99f Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Feb 2026 20:07:28 +0100 Subject: [PATCH 03/54] remove some unused fields from precipmobj_t we do not have animating precip nor do we cast it to mobj_t anymore, so we can just get rid of this stuff reducing the struct size by 16bytes wowie --- src/p_mobj.c | 8 ++++---- src/p_mobj.h | 7 ++----- src/p_spec.c | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index d1b8b850a..11f12b5c5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -335,7 +335,7 @@ static boolean P_SetPrecipMobjState(precipmobj_t *mobj, statenum_t state) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + //mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set return true; } @@ -3620,7 +3620,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj) mobj->lastThink = leveltime; R_ResetPrecipitationMobjInterpolationState(mobj); - P_CycleStateAnimation((mobj_t *)mobj); + //P_CycleStateAnimation((mobj_t *)mobj); // if we ever want animated precip, readd a specific function which does not need casting if (mobj->state == &states[S_RAINRETURN]) { @@ -10034,7 +10034,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->x = x; mobj->y = y; - mobj->flags = info->flags; + //mobj->flags = info->flags; // do not set the state with P_SetMobjState, // because action routines can not be called yet @@ -10044,7 +10044,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + //mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set // set subsector and/or block links P_SetPrecipitationThingPosition(mobj); diff --git a/src/p_mobj.h b/src/p_mobj.h index 38bbe2e37..278c40d18 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -444,12 +444,10 @@ typedef struct precipmobj_s // More drawing info: to determine current sprite. spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h - UINT16 anim_duration; // for FF_ANIMATE states + //UINT16 anim_duration; // for FF_ANIMATE states INT16 lightlevel; // Add to sector lightlevel, -255 - 255 - struct mprecipsecnode_s *touching_sectorlist; // a linked list of sectors where this object appears - struct subsector_s *subsector; // Subsector the mobj resides in. // The closest interval over all contacted sectors (or things). @@ -458,11 +456,10 @@ typedef struct precipmobj_s // Momentums, used to update position. fixed_t momx, momy, momz; - fixed_t precipflags; // fixed_t so it uses the same spot as "pmomz" even as we use precipflags_t for it + precipflag_t precipflags; state_t *state; INT32 tics; // state tic counter - UINT32 flags; // flags from mobjinfo tables tic_t lastThink; } precipmobj_t; diff --git a/src/p_spec.c b/src/p_spec.c index b313f77a1..9c3c0c0c3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1702,7 +1702,7 @@ void P_SwitchWeather(INT32 weathernum) precipmobj->type = type; // proper set the type precipmobj->info = &mobjinfo[type]; - precipmobj->flags = mobjinfo[type].flags; + //precipmobj->flags = mobjinfo[type].flags; st = &states[mobjinfo[type].spawnstate+z]; From 6ba97bc43cd4c2f7d8f5fbd73606f368eff7bd1d Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Feb 2026 21:00:54 +0100 Subject: [PATCH 04/54] only do the anim texture maths if we need it idk why but this showed up during profiling best would be just to redo the whole system since it sucks lol --- src/p_spec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 9c3c0c0c3..99584bb3d 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4532,9 +4532,12 @@ void P_UpdateSpecials(void) { for (i = 0; i < anim->numpics; i++) { - pic = anim->basepic + ((leveltime/anim->speed + i) % anim->numpics); if (anim->istexture) + { + pic = anim->basepic + ((leveltime/anim->speed + i) % anim->numpics); texturetranslation[anim->basepic+i] = pic; + } + } } From 277b202020cfd02eb721a5927fc1890143fe4c5c Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Feb 2026 23:31:04 +0100 Subject: [PATCH 05/54] hooklib: init all the hook states idk i aint trusting any of this lul --- src/lua_hooklib.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index e571f7649..59d1bc1f8 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -615,7 +615,7 @@ FUNCINLINE static ATTRINLINE void res_hud(Hook_State *hook) int LUA_HookMobj(mobj_t *mobj, int hook_type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_mobj_hook(&hook, false, hook_type, mobj)) { LUA_PushUserdata(gL, mobj, META_MOBJ); @@ -626,7 +626,7 @@ int LUA_HookMobj(mobj_t *mobj, int hook_type) int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_mobj_hook(&hook, 0, hook_type, t1)) { LUA_PushUserdata(gL, t1, META_MOBJ); @@ -638,14 +638,14 @@ int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type) void LUA_HookVoid(int type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, type)) call_hooks(&hook, 0, res_none); } void LUA_HookInt(INT32 number, int hook_type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, hook_type)) { lua_pushinteger(gL, number); @@ -655,7 +655,7 @@ void LUA_HookInt(INT32 number, int hook_type) /*void LUA_HookBool(boolean value, int hook_type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, hook_type)) { //lua_pushboolean(gL, value); @@ -665,7 +665,7 @@ void LUA_HookInt(INT32 number, int hook_type) int LUA_HookPlayer(player_t *player, int hook_type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, false, hook_type)) { LUA_PushUserdata(gL, player, META_PLAYER); @@ -676,7 +676,7 @@ int LUA_HookPlayer(player_t *player, int hook_type) int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, false, hook_type)) { LUA_PushUserdata(gL, player, META_PLAYER); @@ -695,7 +695,7 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type) void LUA_HookHUD(int hook_type, huddrawlist_h list) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hud_hook(&hook, hook_type)) { LUA_SetHudHook(hook_type, list); @@ -723,7 +723,7 @@ static void hook_think_frame(int type) int hook_index = 0; precise_t time_taken = 0; - Hook_State hook; + Hook_State hook = {}; const hook_t * map = &hookIds[type]; int k; @@ -783,7 +783,7 @@ void LUA_HookPostThinkFrame(void) int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher) { - Hook_State hook; + Hook_State hook = {}; if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(TouchSpecial), special)) { LUA_PushUserdata(gL, special, META_MOBJ); @@ -802,7 +802,7 @@ static int damage_hook int hook_type, Hook_Callback results_handler ){ - Hook_State hook; + Hook_State hook = {}; if (prepare_mobj_hook(&hook, 0, hook_type, target)) { LUA_PushUserdata(gL, target, META_MOBJ); @@ -890,8 +890,8 @@ int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) { const char *skin = ((skin_t *)tails->skin)->name; - Hook_State hook; - BotAI_State botai; + Hook_State hook = {}; + BotAI_State botai = {}; if (prepare_string_hook(&hook, false, STRING_HOOK(BotAI), skin)) { @@ -911,7 +911,7 @@ int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) { - Hook_State hook; + Hook_State hook = {}; if (prepare_string_hook (&hook, 0, STRING_HOOK(LinedefExecute), line->text)) { @@ -924,7 +924,7 @@ void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, false, HOOK(PlayerMsg))) { LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player @@ -953,7 +953,7 @@ int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute) int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source) { - Hook_State hook; + Hook_State hook = {}; if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(HurtMsg), inflictor)) { LUA_PushUserdata(gL, player, META_PLAYER); @@ -967,7 +967,7 @@ int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source) void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save) { const hook_t * map = &hookIds[HOOK(NetVars)]; - Hook_State hook; + Hook_State hook = {}; /* this is a remarkable case where the stack isn't reset */ if (map->numHooks > 0) { @@ -997,7 +997,7 @@ void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save) void LUA_HookPlayerQuit(player_t *plr, int reason) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, HOOK(PlayerQuit))) { LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit @@ -1060,7 +1060,7 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param) const int type = HOOK(MusicChange); const hook_t * map = &hookIds[type]; - Hook_State hook; + Hook_State hook = {}; int k; @@ -1096,7 +1096,7 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param) int LUA_HookMusicCredit(musicdef_t *musicdef) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, HOOK(MusicCredit))) { LUA_PushUserdata(gL, musicdef, META_MUSICDEF); @@ -1114,7 +1114,7 @@ static int kartdamage_hook int hook_type, Hook_Callback results_handler ){ - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, hook_type)) { LUA_PushUserdata(gL, player, META_PLAYER); @@ -1163,7 +1163,7 @@ boolean LUA_HookPlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *sourc void LUA_HookSetupVote(INT16 result[], INT16 maxresults, UINT8 gt, UINT8 secondgt) { - Hook_State hook; + Hook_State hook = {}; if (prepare_hook(&hook, 0, HOOK(SetupVote))) { // { 0, 0, 0, 0, } From ecef8913b1220dcd577d60563baa324073ed9d8e Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Feb 2026 17:06:33 +0100 Subject: [PATCH 06/54] remove some more dead code as reported by clang-tidy --- src/k_hud.c | 2 -- src/k_kart.c | 1 - src/m_anigif.c | 2 +- src/m_menu.c | 9 --------- src/p_inter.c | 1 - src/p_mobj.c | 2 +- src/p_spec.c | 32 +++++++++++++------------------- src/p_user.c | 10 ---------- src/sdl/i_video.c | 4 ++-- src/w_wad.c | 2 +- 10 files changed, 18 insertions(+), 47 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index d0146a38e..4f10bf749 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1415,8 +1415,6 @@ static void K_drawKartStats(void) break; } } - else - spdoffset = 0; if (G_BattleGametype() && ((speedostyle != SPEEDO_DIAL) || splitscreen)) spdoffset += ((stplyr->kartstuff[k_bumper] ? -5 : -8)); diff --git a/src/k_kart.c b/src/k_kart.c index 6496f3e8e..747a032b2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1480,7 +1480,6 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) fixed_t nx = FixedDiv(distx, dist); fixed_t ny = FixedDiv(disty, dist); - dist = dist ? dist : 1; distx = FixedMul(mobj1->radius+mobj2->radius, nx); disty = FixedMul(mobj1->radius+mobj2->radius, ny); diff --git a/src/m_anigif.c b/src/m_anigif.c index cd37b08d6..c9cda476e 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -556,7 +556,7 @@ static void GIF_framewrite(void) } else if (gif_dynamicdelay ==(UINT8) 1) { - float delayf = ceil(100.0f/NEWTICRATE); + float delayf = ceilf(100.0f/NEWTICRATE); delay = (UINT16)((I_GetPreciseTime() - gif_prevframetime)) / (I_GetPrecisePrecision() / 1000000) /10/1000; diff --git a/src/m_menu.c b/src/m_menu.c index 83c2dce77..5a2b92d92 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5522,7 +5522,6 @@ static void M_DrawChecklist(void) if (conditionSets[unlockables[i].conditionset - 1].numconditions) { - c = 0; lastid = -1; for (c = 0; c < conditionSets[unlockables[i].conditionset - 1].numconditions; c++) @@ -5682,9 +5681,6 @@ static void M_DrawMusicTest(void) { INT32 x, y, i; - x = 90<kartstuff[k_sneakertimer] = 0; K_SpinPlayer(player, source, 1, inflictor, false); - damage = player->mo->health - 1; P_RingDamage(player, inflictor, source); P_PlayerRingBurst(player, 5); diff --git a/src/p_mobj.c b/src/p_mobj.c index 11f12b5c5..acc09ab58 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6986,7 +6986,7 @@ static boolean P_MobjDeadThink(mobj_t *mobj) fixed_t ns; mobj_t *mo2; - i = P_RandomByte(); + i = P_RandomByte(); // grrrrrr z = mobj->subsector->sector->floorheight + ((P_RandomByte()&63)*FRACUNIT); for (j = 0; j < 2; j++) diff --git a/src/p_spec.c b/src/p_spec.c index 99584bb3d..e537e17e6 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3161,11 +3161,6 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers INT32 section1, section2, section3, section4; INT32 special; - section1 = GETSECSPECIAL(sector->special, 1); - section2 = GETSECSPECIAL(sector->special, 2); - section3 = GETSECSPECIAL(sector->special, 3); - section4 = GETSECSPECIAL(sector->special, 4); - // Ignore spectators if (player->spectator) return; @@ -3176,6 +3171,11 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers if (player->playerstate == PST_DEAD) return; + section1 = GETSECSPECIAL(sector->special, 1); + section2 = GETSECSPECIAL(sector->special, 2); + section3 = GETSECSPECIAL(sector->special, 3); + section4 = GETSECSPECIAL(sector->special, 4); + // Conveyor stuff if (section3 == 2 || section3 == 4) player->onconveyor = section3; @@ -4381,8 +4381,6 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector) } } -#define VDOORSPEED (FRACUNIT*2) - // // P_RunSpecialSectorCheck // @@ -4512,9 +4510,7 @@ void P_UpdateSpecials(void) { anim_t *anim; INT32 i; - INT32 pic; size_t j; - levelflat_t *foundflats; // for flat animation // LEVEL TIMER @@ -4534,10 +4530,9 @@ void P_UpdateSpecials(void) { if (anim->istexture) { - pic = anim->basepic + ((leveltime/anim->speed + i) % anim->numpics); - texturetranslation[anim->basepic+i] = pic; + texturetranslation[anim->basepic+i] = anim->basepic + + ((leveltime/anim->speed + i) % anim->numpics); } - } } @@ -4632,8 +4627,8 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if (sec2->numattached == 0) { - sec2->attached = Z_Malloc(sizeof (*sec2->attached) * sec2->maxattached, PU_STATIC, NULL); - sec2->attachedsolid = Z_Malloc(sizeof (*sec2->attachedsolid) * sec2->maxattached, PU_STATIC, NULL); + sec2->attached = Z_Malloc(sizeof(*sec2->attached) * sec2->maxattached, PU_STATIC, NULL); + sec2->attachedsolid = Z_Malloc(sizeof(*sec2->attachedsolid) * sec2->maxattached, PU_STATIC, NULL); sec2->attached[0] = sec - sectors; sec2->numattached = 1; sec2->attachedsolid[0] = (flags & FF_SOLID); @@ -4647,8 +4642,8 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if (sec2->numattached >= sec2->maxattached) { sec2->maxattached *= 2; - sec2->attached = Z_Realloc(sec2->attached, sizeof (*sec2->attached) * sec2->maxattached, PU_STATIC, NULL); - sec2->attachedsolid = Z_Realloc(sec2->attachedsolid, sizeof (*sec2->attachedsolid) * sec2->maxattached, PU_STATIC, NULL); + sec2->attached = Z_Realloc(sec2->attached, sizeof(*sec2->attached) * sec2->maxattached, PU_STATIC, NULL); + sec2->attachedsolid = Z_Realloc(sec2->attachedsolid, sizeof(*sec2->attachedsolid) * sec2->maxattached, PU_STATIC, NULL); } sec2->attached[sec2->numattached] = sec - sectors; sec2->attachedsolid[sec2->numattached] = (flags & FF_SOLID); @@ -4656,7 +4651,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f } // Add the floor - ffloor = Z_Calloc(sizeof (*ffloor), PU_LEVEL, NULL); + ffloor = Z_Calloc(sizeof(*ffloor), PU_LEVEL, NULL); ffloor->secnum = sec2 - sectors; ffloor->target = sec; ffloor->bottomheight = &sec2->floorheight; @@ -5471,7 +5466,6 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) break; case 10: // Vertical culling plane for sprites and FOFs - sec = sides[*lines[i].sidenum].sector - sectors; for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) sectors[s].cullheight = &lines[i]; // This allows it to change in realtime! break; @@ -5992,7 +5986,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) if (!virt) virt = vres_GetMap(lastloadedmaplumpnum); - data = (UINT8*) vres_Find(virt, "SIDEDEFS")->data; + data = (UINT8*)vres_Find(virt, "SIDEDEFS")->data; for (b = 0; b < (INT16)numsides; b++) { diff --git a/src/p_user.c b/src/p_user.c index 2a3ccc300..a930ec6a1 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1894,7 +1894,6 @@ static void P_3dMovement(player_t *player) ticcmd_t *cmd; angle_t movepushangle, movepushsideangle; // Analog fixed_t movepushforward = 0, movepushside = 0; - angle_t dangle; // replaces old quadrants bits boolean analogmove = false; fixed_t oldMagnitude, newMagnitude; vector3_t totalthrust; @@ -1952,15 +1951,6 @@ static void P_3dMovement(player_t *player) // Calculates player's speed based on distance-of-a-line formula player->speed = R_PointToDist2(0, 0, player->rmomx, player->rmomy); - // Monster Iestyn - 04-11-13 - // Quadrants are stupid, excessive and broken, let's do this a much simpler way! - // Get delta angle from rmom angle and player angle first - dangle = R_PointToAngle2(0,0, player->rmomx, player->rmomy) - player->mo->angle; - if (dangle > ANGLE_180) //flip to keep to one side - { - dangle = InvAngle(dangle); - } - // When sliding, don't allow forward/back if (player->pflags & PF_SLIDING) cmd->forwardmove = 0; diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 8b2adfa7b..e367b612f 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1164,8 +1164,8 @@ void I_GetEvent(void) SDL_GetWindowSize(window, &wwidth, &wheight); event.type = ev_mouse; event.data1 = 0; - event.data2 = (INT32)lround(mousemovex * ((float)wwidth / (float)realwidth)); - event.data3 = (INT32)lround(mousemovey * ((float)wheight / (float)realheight)); + event.data2 = (INT32)lroundf(mousemovex * ((float)wwidth / (float)realwidth)); + event.data3 = (INT32)lroundf(mousemovey * ((float)wheight / (float)realheight)); D_PostEvent(&event); } diff --git a/src/w_wad.c b/src/w_wad.c index 20a2ccc87..3009d503f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -455,7 +455,7 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena header.infotableofs = LONG(header.infotableofs); // read wad file directory - i = header.numlumps * sizeof (*fileinfo); + i = header.numlumps * sizeof(*fileinfo); fileinfov = fileinfo = malloc(i); if (fseek(handle, header.infotableofs, SEEK_SET) == -1 From 86b286fb0bd6284c2ed41bfa375effe3ca29778b Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 6 Feb 2026 20:03:54 +0100 Subject: [PATCH 07/54] fix few more cases of using potentially uninitialized garbage --- src/command.c | 2 +- src/g_demo.c | 2 +- src/hardware/hw_main.cpp | 3 +-- src/hu_stuff.c | 3 +++ src/m_menu.c | 2 +- src/s_sound.c | 3 +-- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/command.c b/src/command.c index 6b71dce73..0b1578381 100644 --- a/src/command.c +++ b/src/command.c @@ -1793,7 +1793,7 @@ void CV_AddValue(consvar_t *var, INT32 increment) if (newvalue == oldvalue) break; // don't loop forever if there's none of a certain gametype - if (newvalue >= 0 && !mapheaderinfo[newvalue]) + if (newvalue >= 0 && newvalue < NUMMAPS && !mapheaderinfo[newvalue]) continue; // Don't allocate the header. That just makes memory usage skyrocket. } while (!M_CanShowLevelInList(newvalue, gt)); diff --git a/src/g_demo.c b/src/g_demo.c index ede5adf18..9662ce517 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2605,7 +2605,7 @@ void G_DoPlayDemo(char *defdemoname) boolean skiperrors = false; #endif boolean spectator; - UINT8 slots[MAXPLAYERS], kartspeed[MAXPLAYERS], kartweight[MAXPLAYERS], numslots = 0; + UINT8 slots[MAXPLAYERS] = {}, kartspeed[MAXPLAYERS] = {}, kartweight[MAXPLAYERS] = {}, numslots = 0; G_InitDemoRewind(); diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 5cc8eacf7..e9aa0532d 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1378,8 +1378,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom FSurfaceInfo Surf; - if (gl_frontsector) - Surf.PolyColor.s.alpha = 255; + Surf.PolyColor.s.alpha = 255; const INT32 gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture); GLMapTexture_t *glTex = NULL; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 653529bf4..6ede89fc6 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -497,7 +497,9 @@ static void HU_removeChatText_Log(void) { chat_log[i] = chat_log[i+1]; } + chat_nummsg_log--; // lost 1 msg. + chat_log[chat_nummsg_log] = NULL; } static void Chatlogsize_OnChange(void) @@ -516,6 +518,7 @@ static void Chatlogsize_OnChange(void) if (new_chat_log == NULL) { free(chat_log); + chat_log = NULL; return; } chat_log = new_chat_log; diff --git a/src/m_menu.c b/src/m_menu.c index 5a2b92d92..0e753f621 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2936,7 +2936,7 @@ static void M_PrepareLevelSelect(void) boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt) { // invalid mapnum - if (mapnum < -1) + if (mapnum < -1 || mapnum >= NUMMAPS) return false; // Random map! diff --git a/src/s_sound.c b/src/s_sound.c index 7f931671d..f2ee1dc03 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -473,13 +473,12 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) return; memset(listener, 0, sizeof(listener)); + 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 02f2464a00987624babbf527d378383eda36ddc7 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 8 Feb 2026 23:13:16 +0100 Subject: [PATCH 08/54] HWR_CreateBlendedTexture: init a bunch of stuff --- src/hardware/hw_md2.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 56082e0fc..2fd33f65b 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -693,17 +693,15 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi GLPatch_t *hwrBlendPatch = blendgpatch->hardware; UINT16 w = gpatch->width, h = gpatch->height; UINT32 size = w*h; - RGBA_t *image, *blendimage, *cur, blendcolor; + RGBA_t *image, *blendimage, *cur; + RGBA_t blendcolor = {}; RGBA_t *palette = HWR_GetTexturePalette(); - UINT8 translation[17]; // First the color index - UINT8 cutoff[17]; // Brightness cutoff before using the next color + UINT8 translation[17] = {}; // First the color index + UINT8 cutoff[17] = {}; // Brightness cutoff before using the next color UINT8 translen = 0; UINT8 i; - UINT8 colorbrightnesses[17]; - UINT8 color_match_lookup[256]; // optimization attempt - - memset(translation, 0, sizeof(translation)); - memset(cutoff, 0, sizeof(cutoff)); + UINT8 colorbrightnesses[17] = {}; + UINT8 color_match_lookup[256] = {}; // optimization attempt if (glMipmap->width == 0) { @@ -716,14 +714,10 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi glMipmap->format = GL_TEXFMT_RGBA; } - if (glMipmap->data) - { - Z_Free(glMipmap->data); - glMipmap->data = NULL; - } + Z_Free(glMipmap->data); + glMipmap->data = NULL; - cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &glMipmap->data); - memset(cur, 0x00, size*4); + cur = Z_Calloc(size*4, PU_HWRMODELTEXTURE, &glMipmap->data); image = hwrPatch->mipmap->data; blendimage = hwrBlendPatch->mipmap->data; @@ -1037,7 +1031,6 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk GLPatch_t *glPatch = patch->hardware; GLMipmap_t *glMipmap, *newMipmap; - if (blendgpatch == NULL || colormap == colormaps || colormap == NULL) { // Don't do any blending From 38fc6d6ba173478f7bd5ae88946df9f5ffd7a8c5 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Feb 2026 16:09:26 +0100 Subject: [PATCH 09/54] remove screen texture toggle from accessability menu + new tooltip --- src/m_menudefs.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 1a21ec455..00b927efd 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -986,7 +986,7 @@ static const char* OP_ExpTooltips[] = "Skips rendering frames if game logic takes too long\npreventing gameplay issues during performance drops.", // idk im shit as describing things "Different methods of scaling the votescreen backgrounds.", #ifdef HWRENDER - "Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.", + "Disabling Screen Textures may result in a performance boost\nbut will break certain effects.\nScreen textures are required at resolutions lower than your desktop resolution!" #ifdef USE_FBO_OGL "Allows the game to downsample from a higher resolution\nthan your display in OpenGL renderer mode.\nRequires a GPU with atleast OpenGL 2.1 support.", #endif @@ -1644,29 +1644,25 @@ static menuitem_t OP_AccessibilityMenu[] = {IT_STRING|IT_CVAR, NULL, "Minimum Sector Brightness", &cv_secbright, 45}, -#ifdef HWRENDER - {IT_STRING|IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 50}, -#endif + {IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 50}, - {IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 55}, + {IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 55}, - {IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 60}, + {IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 60}, - {IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 65}, + {IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 65}, - {IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 70}, + {IT_HEADER, NULL, "Audio", NULL, 75}, - {IT_HEADER, NULL, "Audio", NULL, 80}, + {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 85}, + {IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 90}, - {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 90}, - {IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 95}, + {IT_HEADER, NULL, "Controls", NULL, 100}, - {IT_HEADER, NULL, "Controls", NULL, 105}, - - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 115}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 120}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 125}, - {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 130}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 110}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 115}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 120}, + {IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 125}, }; static const char* OP_AccessibilityTooltips[] = @@ -1679,9 +1675,6 @@ static const char* OP_AccessibilityTooltips[] = "Reduces or disables certain effects players might be sensitive to\nSuch as flashing, flickering, certain screen effects and more.", "Disables the flicker effect on Midnight Channel.", "Sets minimum sector brightness, useful for dark areas", -#ifdef HWRENDER - "Disabling Screen Textures will disable the Underwater and Heat screen effects.", -#endif "Toggles the ripple effect on water surfaces", "Fades other Players that are close to the camera in and out", "Toggles the screen shake effect during Earthquakes", From 6f75fab7ffbda9050e3102d5fc2d77583e59c3d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 9 Feb 2026 19:39:29 +0100 Subject: [PATCH 10/54] move gamepad led ticker after render logic this does not really matter but save a tiny little amount of time before rendering a frame --- src/d_main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 90ff81cc9..b0a269ae9 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -783,11 +783,6 @@ void D_SRB2Loop(void) doDisplay = true; } - - if (!dedicated) - { - G_DeviceLEDTick(); - } } if (interp) @@ -829,6 +824,13 @@ void D_SRB2Loop(void) if (takescreenshot) M_DoScreenShot(); +#ifndef DEDICATED + if (!dedicated && renderisnewtic) + { + G_DeviceLEDTick(); + } +#endif + // consoleplayer -> displayplayers (hear sounds from viewpoint) S_UpdateSounds(); // move positional sounds From 513e5a7e3f46460a31811bc4ae3b021fbb1692eb Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 10 Feb 2026 16:38:11 +0100 Subject: [PATCH 11/54] remove even more dead code lol --- src/d_main.c | 43 +++++++++++++++---------------------------- src/p_user.c | 3 +-- src/r_things.cpp | 3 --- src/st_stuff.c | 2 -- src/st_stuff.h | 2 -- 5 files changed, 16 insertions(+), 37 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index b0a269ae9..9d5b23f59 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -274,21 +274,17 @@ static void D_Renderview(void) R_ApplyLevelInterpolators(R_GetTimeFrac(RTF_LEVEL)); - if (rendermode == render_soft) + if (rendermode == render_soft && cv_homremoval.value) { - // if this is display player 1 - if (cv_homremoval.value) + if (cv_homremoval.value == 1) { - if (cv_homremoval.value == 1) - { - // Clear the software screen buffer to remove HOM - memset(vid.screens[0], 31, vid.width * vid.height); - } - else if (cv_homremoval.value == 2) - { - //'development' HOM removal -- makes it blindingly obvious if HOM is spotted. - memset(vid.screens[0], 32+(timeinmap&15), vid.width * vid.height); - } + // Clear the software screen buffer to remove HOM + memset(vid.screens[0], 31, vid.width * vid.height); + } + else if (cv_homremoval.value == 2) + { + //'development' HOM removal -- makes it blindingly obvious if HOM is spotted. + memset(vid.screens[0], 32+(timeinmap&15), vid.width * vid.height); } } @@ -322,7 +318,6 @@ static void D_Renderview(void) break; default: // Initialize for P1 viewwindowy = viewwindowx = 0; - objectsdrawn = 0; break; } @@ -333,19 +328,17 @@ static void D_Renderview(void) } else if (rendermode == render_soft) #endif + { R_RenderPlayerView(&players[displayplayers[i]]); - } - - if (rendermode == render_soft) - { - if (i == 0) - R_ApplyViewMorph(); + if (i == 0) + R_ApplyViewMorph(); #ifdef MOTIONBLUR - V_DoPostProcessor(i, postimgparam[i]); + V_DoPostProcessor(i, postimgparam[i]); #else - V_DoPostProcessor(i, 0); + V_DoPostProcessor(i, 0); #endif + } } } @@ -1645,12 +1638,6 @@ void D_SRB2Main(void) strcpy(srb2, "SRB2Kart"); D_MakeTitleString(srb2); -#if defined (__OS2__) && !defined (HAVE_SDL) - // set PM window title - snprintf(pmData->title, sizeof (pmData->title), "SRB2Kart" VERSIONSTRING ": %s", title); - pmData->title[sizeof (pmData->title) - 1] = '\0'; -#endif - if (devparm) CONS_Printf(M_GetText("Development mode ON.\n")); diff --git a/src/p_user.c b/src/p_user.c index a930ec6a1..15a71ebc8 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1822,7 +1822,6 @@ void P_DoJumpShield(player_t *player) player->pflags &= ~PF_JUMPED; //P_DoJump(player, false); - player->pflags &= ~PF_JUMPED; player->secondjump = 0; player->jumping = 0; player->pflags |= PF_THOKKED; @@ -4454,7 +4453,7 @@ static INT32 Quaketilt(player_t *player) lowb = FixedMul(lowb, player->mo->scale); moma = FixedMul(FixedDiv(delta, ANGLE_90), tilt); - speed = abs( player->mo->momx + player->mo->momy ); + speed = abs(player->mo->momx + player->mo->momy); if (speed < lowb) { diff --git a/src/r_things.cpp b/src/r_things.cpp index 58a838eea..60b0bbd52 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1855,9 +1855,6 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->subsector->sector->numlights) R_SplitSprite(vis); - - // Debug - ++objectsdrawn; } static void R_ProjectPrecipitationSprite(precipmobj_t *thing) diff --git a/src/st_stuff.c b/src/st_stuff.c index 5ca3f9d91..6dc7111f3 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -52,8 +52,6 @@ #include "r_fps.h" -UINT16 objectsdrawn = 0; - // dumb fade thing for director toggle tic_t directortoggletimer = 0; diff --git a/src/st_stuff.h b/src/st_stuff.h index 8e7f8fa41..24202646a 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -134,8 +134,6 @@ typedef enum extern hudinfo_t hudinfo[NUMHUDITEMS]; -extern UINT16 objectsdrawn; - // variable to stop mayonaka static from flickering extern consvar_t cv_lessflicker; extern consvar_t cv_stagetitle; From d49001143f487e3b1d6e0894d82f7b346e2561c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 11 Feb 2026 17:44:31 +0100 Subject: [PATCH 12/54] fix new compiler warnings from new gcc version just throw const at everything :blobthumbsup: --- src/d_main.c | 2 +- src/doomtype.h | 2 +- src/g_game.c | 6 +++--- src/hardware/hw_shaders.c | 2 +- src/hardware/r_opengl/r_opengl.c | 6 +++--- src/m_misc.c | 2 +- src/strcasestr.c | 37 ++++++++++++++++---------------- 7 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 9d5b23f59..a04334a5f 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -2018,7 +2018,7 @@ void D_SRB2Main(void) if (M_CheckProtoParam("replay")) { const char *replayurl = M_GetProtoParam(); - char *replayname = strrchr(replayurl, '/'); + const char *replayname = strrchr(replayurl, '/'); if (!replayname || !replayurl) I_Error("REPLAY: Invalid URL."); diff --git a/src/doomtype.h b/src/doomtype.h index ed6248129..0f76500fd 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -68,7 +68,7 @@ extern "C" { #define strnicmp(x,y,n) strncasecmp(x,y,n) #endif -char *nongnu_strcasestr(const char *in, const char *what); +const char *nongnu_strcasestr(const char *in, const char *what); #ifndef _GNU_SOURCE #define strcasestr nongnu_strcasestr #endif diff --git a/src/g_game.c b/src/g_game.c index a79a957ef..a498bde0a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4152,7 +4152,7 @@ static void measurekeywords(mapsearchfreq_t *fr, const char *s, const char *q, boolean wanttable) { char *qp; - char *sp; + const char *sp; if (wanttable) (*dimp) = Z_Realloc((*dimp), 255 * sizeof (struct searchdim), PU_STATIC, NULL); @@ -4197,9 +4197,9 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, size_t mapnamelen; char *realmapname = NULL; - char *newmapname = NULL; + char *newmapname = NULL; char *apromapname = NULL; - char *aprop = NULL; + const char *aprop = NULL; mapsearchfreq_t *freq; boolean wanttable; diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 28f8e46d7..80f070099 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -109,7 +109,7 @@ boolean HWR_InitShaders(void) // returns INT32_MAX if not found static INT32 strstr_int(const char *str1, const char *str2) { - char *location = strstr(str1, str2); + const char *location = strstr(str1, str2); if (location) return location - str1; else diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index eeb40a8dc..9f5098002 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1383,19 +1383,19 @@ void GL_Flush(void) // -----------------+ INT32 GL_isExtAvailable(const char *extension, const GLubyte *start) { - GLubyte *where, *terminator; + const GLubyte *where, *terminator; if (!extension || !start) return 0; - where = (GLubyte *) strchr(extension, ' '); + where = (const GLubyte *)strchr(extension, ' '); if (where || *extension == '\0') return 0; for (;;) { - where = (GLubyte *) strstr((const char *) start, extension); + where = (const GLubyte *)strstr((const char *) start, extension); if (!where) break; diff --git a/src/m_misc.c b/src/m_misc.c index 3a456d7a7..c11514524 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1454,7 +1454,7 @@ INT32 axtoi(const char *hexStg) void CopyCaretColors(char *p, const char *s, int n) { - char *t; + const char *t; int m; int c; diff --git a/src/strcasestr.c b/src/strcasestr.c index f05449778..5859e57bd 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -28,10 +28,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include static inline int -trycmp (char **pp, char *cp, +trycmp (const char **pp, const char *cp, const char *q, size_t qn) { - char *p; + const char *p; p = (*pp); if (strncasecmp(p, q, qn) == 0) return 0; @@ -40,10 +40,10 @@ trycmp (char **pp, char *cp, } static inline void -swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) +swapp (const char ***ppap, const char ***ppbp, const char **cpap, const char **cpbp) { - char **pp; - char *p; + const char **pp; + const char *p; pp = *ppap; *ppap = *ppbp; @@ -54,28 +54,27 @@ swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) *cpbp = p; } -char * -nongnu_strcasestr (const char *s, const char *q) +const char *nongnu_strcasestr(const char *in, const char *what) { size_t qn; char uc; char lc; - char *up; - char *lp; + const char *up; + const char *lp; - char **ppa; - char **ppb; + const char **ppa; + const char **ppb; - char *cpa; - char *cpb; + const char *cpa; + const char *cpb; - uc = toupper(*q); - lc = tolower(*q); + uc = toupper(*what); + lc = tolower(*what); - up = strchr(s, uc); - lp = strchr(s, lc); + up = strchr(in, uc); + lp = strchr(in, lc); if (up == NULL && lp == NULL) return NULL; @@ -97,11 +96,11 @@ nongnu_strcasestr (const char *s, const char *q) cpb = &uc; } - qn = strlen(q); + qn = strlen(what); for (;;) { - if (trycmp(ppa, cpa, q, qn) == 0) + if (trycmp(ppa, cpa, what, qn) == 0) return (*ppa); if (up == NULL && lp == NULL) From 5c28f6afd8e237660c9f4cd927701119238277d6 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 16 Feb 2026 19:04:51 +0100 Subject: [PATCH 13/54] Revert "fix new compiler warnings from new gcc version" This reverts commit d49001143f487e3b1d6e0894d82f7b346e2561c8. --- src/d_main.c | 2 +- src/doomtype.h | 2 +- src/g_game.c | 6 +++--- src/hardware/hw_shaders.c | 2 +- src/hardware/r_opengl/r_opengl.c | 6 +++--- src/m_misc.c | 2 +- src/strcasestr.c | 37 ++++++++++++++++---------------- 7 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index a04334a5f..9d5b23f59 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -2018,7 +2018,7 @@ void D_SRB2Main(void) if (M_CheckProtoParam("replay")) { const char *replayurl = M_GetProtoParam(); - const char *replayname = strrchr(replayurl, '/'); + char *replayname = strrchr(replayurl, '/'); if (!replayname || !replayurl) I_Error("REPLAY: Invalid URL."); diff --git a/src/doomtype.h b/src/doomtype.h index 0f76500fd..ed6248129 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -68,7 +68,7 @@ extern "C" { #define strnicmp(x,y,n) strncasecmp(x,y,n) #endif -const char *nongnu_strcasestr(const char *in, const char *what); +char *nongnu_strcasestr(const char *in, const char *what); #ifndef _GNU_SOURCE #define strcasestr nongnu_strcasestr #endif diff --git a/src/g_game.c b/src/g_game.c index a498bde0a..a79a957ef 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4152,7 +4152,7 @@ static void measurekeywords(mapsearchfreq_t *fr, const char *s, const char *q, boolean wanttable) { char *qp; - const char *sp; + char *sp; if (wanttable) (*dimp) = Z_Realloc((*dimp), 255 * sizeof (struct searchdim), PU_STATIC, NULL); @@ -4197,9 +4197,9 @@ INT32 G_FindMap(const char *mapname, char **foundmapnamep, size_t mapnamelen; char *realmapname = NULL; - char *newmapname = NULL; + char *newmapname = NULL; char *apromapname = NULL; - const char *aprop = NULL; + char *aprop = NULL; mapsearchfreq_t *freq; boolean wanttable; diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 80f070099..28f8e46d7 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -109,7 +109,7 @@ boolean HWR_InitShaders(void) // returns INT32_MAX if not found static INT32 strstr_int(const char *str1, const char *str2) { - const char *location = strstr(str1, str2); + char *location = strstr(str1, str2); if (location) return location - str1; else diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 9f5098002..eeb40a8dc 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1383,19 +1383,19 @@ void GL_Flush(void) // -----------------+ INT32 GL_isExtAvailable(const char *extension, const GLubyte *start) { - const GLubyte *where, *terminator; + GLubyte *where, *terminator; if (!extension || !start) return 0; - where = (const GLubyte *)strchr(extension, ' '); + where = (GLubyte *) strchr(extension, ' '); if (where || *extension == '\0') return 0; for (;;) { - where = (const GLubyte *)strstr((const char *) start, extension); + where = (GLubyte *) strstr((const char *) start, extension); if (!where) break; diff --git a/src/m_misc.c b/src/m_misc.c index c11514524..3a456d7a7 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1454,7 +1454,7 @@ INT32 axtoi(const char *hexStg) void CopyCaretColors(char *p, const char *s, int n) { - const char *t; + char *t; int m; int c; diff --git a/src/strcasestr.c b/src/strcasestr.c index 5859e57bd..f05449778 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -28,10 +28,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include static inline int -trycmp (const char **pp, const char *cp, +trycmp (char **pp, char *cp, const char *q, size_t qn) { - const char *p; + char *p; p = (*pp); if (strncasecmp(p, q, qn) == 0) return 0; @@ -40,10 +40,10 @@ trycmp (const char **pp, const char *cp, } static inline void -swapp (const char ***ppap, const char ***ppbp, const char **cpap, const char **cpbp) +swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) { - const char **pp; - const char *p; + char **pp; + char *p; pp = *ppap; *ppap = *ppbp; @@ -54,27 +54,28 @@ swapp (const char ***ppap, const char ***ppbp, const char **cpap, const char **c *cpbp = p; } -const char *nongnu_strcasestr(const char *in, const char *what) +char * +nongnu_strcasestr (const char *s, const char *q) { size_t qn; char uc; char lc; - const char *up; - const char *lp; + char *up; + char *lp; - const char **ppa; - const char **ppb; + char **ppa; + char **ppb; - const char *cpa; - const char *cpb; + char *cpa; + char *cpb; - uc = toupper(*what); - lc = tolower(*what); + uc = toupper(*q); + lc = tolower(*q); - up = strchr(in, uc); - lp = strchr(in, lc); + up = strchr(s, uc); + lp = strchr(s, lc); if (up == NULL && lp == NULL) return NULL; @@ -96,11 +97,11 @@ const char *nongnu_strcasestr(const char *in, const char *what) cpb = &uc; } - qn = strlen(what); + qn = strlen(q); for (;;) { - if (trycmp(ppa, cpa, what, qn) == 0) + if (trycmp(ppa, cpa, q, qn) == 0) return (*ppa); if (up == NULL && lp == NULL) From 53321d33d57eaae56e6af1c7fa031fb836b6cddb Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 12 Feb 2026 18:41:53 +0100 Subject: [PATCH 14/54] mark some nightsmode stuff with likely/unlikely i missed and in some cases move around the conditionals i love backwards compat Zzz.... --- src/d_clisrv.c | 4 +++- src/p_inter.c | 4 ++-- src/p_local.h | 6 ------ src/p_mobj.c | 18 +++++++++--------- src/p_spec.c | 6 +++--- src/p_user.c | 2 +- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 68ab08c5a..2f3440362 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3350,7 +3350,7 @@ void CL_ClearPlayer(INT32 playernum) if (players[playernum].mo) { // Don't leave a NiGHTS ghost! - if ((players[playernum].pflags & PF_NIGHTSMODE) && players[playernum].mo->tracer) + if (UNLIKELY((players[playernum].pflags & PF_NIGHTSMODE) && players[playernum].mo->tracer)) P_RemoveMobj(players[playernum].mo->tracer); P_RemoveMobj(players[playernum].mo); } @@ -3496,6 +3496,7 @@ static void Command_GetPlayerNum(void) INT32 i; for (i = 0; i < MAXPLAYERS; i++) + { if (playeringame[i]) { if (serverplayer == i) @@ -3503,6 +3504,7 @@ static void Command_GetPlayerNum(void) else CONS_Printf(M_GetText("\x82num:%2d node:%2d %s\n"), i, playernode[i], player_names[i]); } + } } SINT8 nametonum(const char *name) diff --git a/src/p_inter.c b/src/p_inter.c index 127f31c10..e11329b79 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -831,7 +831,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { S_StartSound(toucher, special->info->seesound); - if (player->pflags & PF_NIGHTSMODE) + if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) { player->bumpertime = TICRATE/2; if (special->threshold > 0) @@ -1131,7 +1131,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) S_StartSound(toucher, special->info->painsound); return; } - else if (((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) + else if (UNLIKELY((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? { // Shatter the shield! diff --git a/src/p_local.h b/src/p_local.h index 82e3fb673..518bc12cb 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -30,8 +30,6 @@ extern "C" { #define FLOATSPEED (FRACUNIT*4) -//#define VIEWHEIGHTS "41" - // Maximum player score. #define MAXSCORE 999999990 @@ -239,14 +237,10 @@ void P_InstaThrustEvenIn2D(mobj_t *mo, angle_t angle, fixed_t move); boolean P_LookForEnemies(player_t *player); void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius); void P_HomingAttack(mobj_t *source, mobj_t *enemy); /// \todo doesn't belong in p_user -//boolean P_SuperReady(player_t *player); boolean P_AnalogMove(player_t *player); -/*boolean P_TransferToNextMare(player_t *player); -UINT8 P_FindLowestMare(void);*/ UINT8 P_FindLowestLap(void); UINT8 P_FindHighestLap(void); void P_FindEmerald(void); -//void P_TransferToAxis(player_t *player, INT32 axisnum); boolean P_PlayerMoving(INT32 pnum); void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range); diff --git a/src/p_mobj.c b/src/p_mobj.c index acc09ab58..d44a48f1c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -919,12 +919,7 @@ static void P_PlayerFlip(mobj_t *mo) G_GhostAddFlip((INT32) (mo->player - players)); // Flip aiming to match! - if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) // NiGHTS doesn't use flipcam - { - if (mo->tracer) - mo->tracer->eflags ^= MFE_VERTICALFLIP; - } - else if (mo->player->pflags & PF_FLIPCAM) + if (mo->player->pflags & PF_FLIPCAM) { UINT8 i; @@ -946,6 +941,11 @@ static void P_PlayerFlip(mobj_t *mo) camera[i].z += FixedMul(20*FRACUNIT, mo->scale); } } + else if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) // NiGHTS doesn't use flipcam + { + if (mo->tracer) + mo->tracer->eflags ^= MFE_VERTICALFLIP; + } } // @@ -3252,7 +3252,7 @@ void P_CalcChasePostImg(player_t *player, camera_t *thiscam) player_flipcam = cv_flipcam[pnum].value; } - const boolean flipcam = (player_flipcam && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); + const boolean flipcam = (player_flipcam && player->mo->eflags & MFE_VERTICALFLIP && LIKELY(!(player->pflags & PF_NIGHTSMODE))); UINT8 postimgtype = 0; if (encoremode) @@ -8553,7 +8553,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (mobj->tracer && mobj->tracer->player) { - if (!(mobj->tracer->player->pflags & PF_NIGHTSMODE)) + if (LIKELY(!(mobj->tracer->player->pflags & PF_NIGHTSMODE))) { mobj->flags &= ~MF_NOGRAVITY; mobj->flags2 &= ~MF2_DONTDRAW; @@ -8577,7 +8577,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_SetTarget(&mobj->target, NULL); } - if (mobj->tracer->player->pflags & PF_NIGHTSMODE) + if (UNLIKELY(mobj->tracer->player->pflags & PF_NIGHTSMODE)) { if (mobj->tracer->player->bonustime) { diff --git a/src/p_spec.c b/src/p_spec.c index e537e17e6..919be8031 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4399,7 +4399,7 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) // The list of specials that activate without floor touch // Check Section 1 - switch(GETSECSPECIAL(sector->special, 1)) + switch (GETSECSPECIAL(sector->special, 1)) { //case 2: // Damage (water) case 8: // Instant kill @@ -4410,7 +4410,7 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) } // Check Section 2 - switch(GETSECSPECIAL(sector->special, 2)) + switch (GETSECSPECIAL(sector->special, 2)) { case 2: // Linedef executor (All players needed) case 4: // Linedef executor @@ -4421,7 +4421,7 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) } // Check Section 4 - switch(GETSECSPECIAL(sector->special, 4)) + switch (GETSECSPECIAL(sector->special, 4)) { case 2: // Level Exit / GOAL Sector / Flag Return case 1: // Starpost activator diff --git a/src/p_user.c b/src/p_user.c index 15a71ebc8..99566aa24 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4109,7 +4109,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall angle -= (angle - thiscam->pitch)/2; } - if (player->playerstate != PST_DEAD && !((player->pflags & PF_NIGHTSMODE) && player->exiting)) + if (player->playerstate != PST_DEAD && LIKELY(!((player->pflags & PF_NIGHTSMODE) && player->exiting))) angle += (focusaiming < ANGLE_180 ? focusaiming/2 : InvAngle(InvAngle(focusaiming)/2)); // overcomplicated version of '((signed)focusaiming)/2;' if (!camstill && !timeover) // Keep the view still... From d77508f4819b1380f829b413c5580977e5ba9b88 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 15 Feb 2026 18:07:20 +0100 Subject: [PATCH 15/54] init superactions global was missed before --- src/command.c | 2 +- src/dehacked.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/command.c b/src/command.c index 0b1578381..c37b8f1d3 100644 --- a/src/command.c +++ b/src/command.c @@ -1178,7 +1178,7 @@ consvar_t *CV_FindVar(const char *name) consvar_t *cvar; for (cvar = consvar_vars; cvar; cvar = cvar->next) - if (fasticmp(name,cvar->name)) + if (fasticmp(name, cvar->name)) return cvar; return NULL; diff --git a/src/dehacked.c b/src/dehacked.c index a3540fdff..a3513fbbe 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -173,7 +173,7 @@ FUNCPRINTF static void deh_warning(const char *first, ...) vsnprintf(buf, 1000, first, argptr); // sizeof only returned 4 here. it didn't like that pointer. va_end(argptr); - if(dbg_line == -1) // Not in a SOC, line number unknown. + if (dbg_line == -1) // Not in a SOC, line number unknown. CONS_Alert(CONS_WARNING, "%s\n", buf); else CONS_Alert(CONS_WARNING, "Line %u: %s\n", dbg_line, buf); @@ -8545,7 +8545,7 @@ static inline int lib_action(lua_State *L) // Hardcoded A_Action name to call for super() or NULL if super() would be invalid. // Set in lua_infolib. -const char *superactions[MAXRECURSION]; +const char *superactions[MAXRECURSION] = {}; UINT8 superstack = 0; static int lib_dummysuper(lua_State *L) From 22a4fe63db1bf696769b4d2efbdb1233cedbc978 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Feb 2026 13:28:00 +0100 Subject: [PATCH 16/54] Fix minimap angle display colour for skins that use non default startcolor i.e. they use a different colour than "green" to remap their skincolor on --- src/k_hud.c | 27 ++++++++++++++++++++++----- src/k_kart.c | 11 ++++++++++- src/r_draw.cpp | 3 +-- src/r_skins.h | 1 + 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 4f10bf749..3df6f7af7 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -3816,7 +3816,7 @@ static void K_drawKartMinimap(void) if (cv_showminimapangle.value && (minidoticon || minilighticon) && !playertimedout) { - UINT8 *colormap; + UINT8 *colormap = NULL; drawinfo_t dims; fixed_t interpx, interpy; fixed_t xoff = 0, yoff = 0; @@ -3827,10 +3827,27 @@ static void K_drawKartMinimap(void) if (encoremode) ang = ANGLE_180 - ang; - if (mobj->colorized) - colormap = R_GetTranslationColormap(TC_RAINBOW, mobj->color, GTC_CACHE); - else - colormap = R_GetLocalTranslationColormap(mobj->skin, mobj->localskin, mobj->color, GTC_CACHE, mobj->skinlocal); + if (mobj->color) + { + if (mobj->colorized) + { + colormap = R_GetTranslationColormap(TC_RAINBOW, mobj->color, GTC_CACHE); + } + else + { + const INT32 skinnum = K_GetMobjLocalSkinNum(mobj->skin, mobj->localskin, mobj->skinlocal); + + // special case if startcolor is not the default (160 / Green) + if (skinnum && skins[skinnum].starttranscolor != skins[0].starttranscolor) + { + colormap = R_GetTranslationColormap(TC_DEFAULT, mobj->color, GTC_CACHE); + } + else + { + colormap = R_GetLocalTranslationColormap(mobj->skin, mobj->localskin, mobj->color, GTC_CACHE, mobj->skinlocal); + } + } + } interpx = lerp(mobj->old_x, mobj->x); interpy = lerp(mobj->old_y, mobj->y); diff --git a/src/k_kart.c b/src/k_kart.c index 747a032b2..0efd3a48b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -660,13 +660,22 @@ INT32 K_GetSkinNum(player_t *player) // // returns the mobj skinnumber -// accounts for localskins +// accounts for localskins ? // INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local) { return skin - K_GetSkinArray(local); } +// +// returns the mobj skinnumber +// accounts for localskins +// +INT32 K_GetMobjLocalSkinNum(const skin_t *skin, const skin_t *localskin, boolean local) +{ + return localskin ? (localskin - K_GetSkinArray(local)) : (skin - skins); +} + // // returns the players skinnumber // accounts for localskins diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 639107daa..97872aee1 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -437,8 +437,7 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags) UINT8* R_GetLocalTranslationColormap(skin_t *skin, skin_t *localskin, skincolors_t color, UINT8 flags, boolean local) { - const INT32 skinnum = localskin ? (localskin - K_GetSkinArray(local)) : (skin - skins); - return RGetTranslationColormap(skinnum, color, flags, (localskin && local)); + return RGetTranslationColormap(K_GetMobjLocalSkinNum(skin, localskin, local), color, flags, (localskin && local)); } patch_t* R_GetSkinFaceRank(player_t* ply) diff --git a/src/r_skins.h b/src/r_skins.h index 6231e8a18..929753855 100644 --- a/src/r_skins.h +++ b/src/r_skins.h @@ -92,6 +92,7 @@ INT32 R_LocalSkinAvailable(const char *name, boolean local); // had to move those here Zzz... INT32 K_GetSkinNum(player_t *player); INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local); +INT32 K_GetMobjLocalSkinNum(const skin_t *skin, const skin_t *localskin, boolean local); skin_t *K_GetPlayerSkin(player_t *player); skin_t *K_GetMobjSkin(const mobj_t *mobj); patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum); From 90a88983f1265333aa7b8a62ad331966670c3b51 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Feb 2026 13:28:48 +0100 Subject: [PATCH 17/54] k_hud: make the hud offset vars static --- src/k_hud.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 3df6f7af7..3fc83c10b 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -931,21 +931,21 @@ const char *K_GetItemPatch(UINT8 item, boolean tiny) //} -INT32 ITEM_X, ITEM_Y; // Item Window -INT32 TIME_X, TIME_Y; // Time Sticker -INT32 LAPS_X, LAPS_Y; // Lap Sticker -INT32 SPDM_X, SPDM_Y; // Speedometer -INT32 POSI_X, POSI_Y; // Position Number -INT32 FACE_X, FACE_Y; // Top-four Faces -INT32 STCD_X, STCD_Y; // Starting countdown -INT32 CHEK_Y; // CHECK graphic -INT32 MINI_X, MINI_Y; // Minimap -INT32 WANT_X, WANT_Y; // Battle WANTED poster +static INT32 ITEM_X, ITEM_Y; // Item Window +static INT32 TIME_X, TIME_Y; // Time Sticker +static INT32 LAPS_X, LAPS_Y; // Lap Sticker +static INT32 SPDM_X, SPDM_Y; // Speedometer +static INT32 POSI_X, POSI_Y; // Position Number +static INT32 FACE_X, FACE_Y; // Top-four Faces +static INT32 STCD_X, STCD_Y; // Starting countdown +static INT32 CHEK_Y; // CHECK graphic +static INT32 MINI_X, MINI_Y; // Minimap +static INT32 WANT_X, WANT_Y; // Battle WANTED poster // This is for the P2 and P4 side of splitscreen. Then we'll flip P1's and P2's to the bottom with V_SPLITSCREEN. -INT32 ITEM2_X, ITEM2_Y; -INT32 LAPS2_X, LAPS2_Y; -INT32 POSI2_X, POSI2_Y; +static INT32 ITEM2_X, ITEM2_Y; +static INT32 LAPS2_X, LAPS2_Y; +static INT32 POSI2_X, POSI2_Y; static void K_initKartHUD(void) { From 7746e494cf87c8aca6444cffced42f5d9ef1de4f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Feb 2026 13:32:04 +0100 Subject: [PATCH 18/54] fix memory leak within http masterserver handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit errbuf gets malloc“d! --- src/http-mserv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/http-mserv.c b/src/http-mserv.c index 9e4374353..7b5fac188 100644 --- a/src/http-mserv.c +++ b/src/http-mserv.c @@ -318,6 +318,7 @@ static void HMS_end (struct HMS_buffer *buffer) { curl_easy_cleanup(buffer->curl); + free(buffer->errbuf); free(buffer->buffer); free(buffer); } From 009df228d62a661024ed08c61aa580e4a5992aca Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Feb 2026 13:33:10 +0100 Subject: [PATCH 19/54] fix memory leak when fetching masterserver rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit strdup returns a malloc“d string! --- src/mserv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mserv.c b/src/mserv.c index 01af521e6..c91dacfcf 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -262,6 +262,7 @@ Finish_registration (void) { CONS_Printf("\n"); CONS_Alert(CONS_NOTICE, "%s\n", rules); + free(rules); } if (registered) From 1d6c27bacacf667130116049121e8da840d2e3d4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 22 Feb 2026 14:01:27 +0100 Subject: [PATCH 20/54] lua_pushlstring: prefer luaS_newlstr over luaS_new the latter calls strlen which is not needed as the empty string has no length --- src/blua/lapi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blua/lapi.c b/src/blua/lapi.c index 557896f43..6a33983fe 100644 --- a/src/blua/lapi.c +++ b/src/blua/lapi.c @@ -434,7 +434,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { lua_lock(L); luaC_checkGC(L); - setsvalue2s(L, L->top, (len == 0) ? luaS_new(L, "") : luaS_newlstr(L, s, len)); + setsvalue2s(L, L->top, (len == 0) ? luaS_newlstr(L, "", 0) : luaS_newlstr(L, s, len)); api_incr_top(L); lua_unlock(L); } From f4dc161831a988e725e8639b9674984ebdf5f6bb Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 15:56:42 +0100 Subject: [PATCH 21/54] dont let SIGINT/SIGTERM do work in signal handler take 2 the earlier approach still raised the default signal within this, which basically just skipped everything and ended up NOT calling I_Quit at all Basically this is to ensure we dont call I_Quit at all from a signal handler as it is NOT async safe and can cause serious issues like deadlocks and such, instead SIGINT and SIGTERM will just signal the main loop/thread to safely call I_Quit instead --- src/d_main.c | 5 +++++ src/dedicated/i_system.c | 14 ++++++++++---- src/i_system.h | 4 ++++ src/sdl/i_system.cpp | 24 ++++++++++-------------- src/sdl/i_video.c | 3 ++- src/sdl/mixer_sound.c | 3 ++- 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 9d5b23f59..8bae5ea91 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -697,6 +697,11 @@ void D_SRB2Loop(void) for (;;) { + if (I_Interrupted()) + { + I_Quit(); + } + // capbudget is the minimum precise_t duration of a single loop iteration precise_t capbudget; precise_t elapsed; diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 437439010..311e936f3 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -1067,11 +1067,17 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -FUNCNORETURN static ATTRNORETURN void quit_handler(int num) +static volatile sig_atomic_t interrupted = 0; + +boolean I_Interrupted(void) { - signal(num, SIG_DFL); //default signal action - raise(num); - I_Quit(); + return interrupted; +} + +static void quit_handler(int num) +{ + (void)num; + interrupted = 1; } #ifdef HAVE_LIBBACKTRACE diff --git a/src/i_system.h b/src/i_system.h index 97dfae9a1..958703a35 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -195,6 +195,10 @@ INT32 I_StartupSystem(void); */ void I_ShutdownSystem(void); +/** \brief To check if a Interrupt or Terminate Signal was fired + */ +boolean I_Interrupted(void); + /** \brief The I_GetDiskFreeSpace function \param freespace a INT64 pointer to hold the free space amount diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index b90fbf898..063b140e1 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1741,21 +1741,17 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -FUNCNORETURN static ATTRNORETURN void quit_handler(int num) -{ -#ifdef HAVE_THREADS - if (g_main_thread_id != std::this_thread::get_id()) - { - // Do not attempt any sort of recovery if this signal triggers off the main thread - signal(num, SIG_DFL); - raise(num); - exit(-2); - } -#endif +static volatile sig_atomic_t interrupted = 0; - signal(num, SIG_DFL); //default signal action - raise(num); - I_Quit(); +boolean I_Interrupted(void) +{ + return interrupted; +} + +static void quit_handler(int num) +{ + (void)num; + interrupted = 1; } static void I_RegisterSignals(void) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index e367b612f..813b6bfa0 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -2027,7 +2027,8 @@ void I_ShutdownGraphics(void) SDL_DestroyWindow(window); window = NULL; - SDL_QuitSubSystem(SDL_INIT_VIDEO); + if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO) + SDL_QuitSubSystem(SDL_INIT_VIDEO); framebuffer = SDL_FALSE; } diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 8de4eb746..7dccd9673 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -237,7 +237,8 @@ void I_ShutdownSound(void) Mix_Quit(); #endif - SDL_QuitSubSystem(SDL_INIT_AUDIO); + if (SDL_WasInit(SDL_INIT_AUDIO) == SDL_INIT_AUDIO) + SDL_QuitSubSystem(SDL_INIT_AUDIO); #ifdef HAVE_LIBGME if (gme) From e35dc9e0974da23276d6938e82f2e1057ed4fb92 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 16:20:48 +0100 Subject: [PATCH 22/54] fix g_in_exiting_signal_handler every "flag" set by signal handlers must be of type "volatile sig_atomic_t" everything else may fail to be correctly set, read or get optimized away which rendered this basically useless --- src/console.c | 10 +++++----- src/dedicated/i_system.c | 7 ++++++- src/i_system.h | 2 +- src/m_menu.c | 10 +++++----- src/sdl/i_system.cpp | 11 ++++++++--- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/console.c b/src/console.c index 88fe25000..09ac2e36d 100644 --- a/src/console.c +++ b/src/console.c @@ -46,16 +46,16 @@ #ifdef HAVE_THREADS I_mutex con_mutex; -// g_in_exiting_signal_handler is an evil hack +// I_In_Exiting_Signal_Handler is an evil hack // to avoid infinite SIGABRT recursion in the signal handler // due to poisoned locks or mach-o kernel not supporting locks in signals // or something like that. idk -# define Lock_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&con_mutex); } -# define Unlock_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(con_mutex); } -#else/*HAVE_THREADS*/ +# define Lock_state() if (!I_In_Exiting_Signal_Handler()) { I_LockMutex(&con_mutex); } +# define Unlock_state() if (!I_In_Exiting_Signal_Handler()) { I_UnlockMutex(con_mutex); } +#else /*HAVE_THREADS*/ # define Lock_state() # define Unlock_state() -#endif/*HAVE_THREADS*/ +#endif /*HAVE_THREADS*/ static boolean con_started = false; // console has been initialised boolean con_startup = false; // true at game startup, screen need refreshing diff --git a/src/dedicated/i_system.c b/src/dedicated/i_system.c index 311e936f3..f6450134c 100644 --- a/src/dedicated/i_system.c +++ b/src/dedicated/i_system.c @@ -984,7 +984,7 @@ void I_SleepDuration(precise_t duration) #endif } -boolean g_in_exiting_signal_handler = false; +static volatile sig_atomic_t g_in_exiting_signal_handler = false; static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg) { @@ -1048,6 +1048,11 @@ static void I_ReportSignal(int num, int coredumped) I_OutputMsg("\nProcess killed by signal: %s\n\n", sigmsg); } +boolean I_In_Exiting_Signal_Handler(void) +{ + return g_in_exiting_signal_handler; +} + #ifndef NEWSIGNALHANDLER FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) { diff --git a/src/i_system.h b/src/i_system.h index 958703a35..45767f1f7 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -43,7 +43,7 @@ extern UINT8 graphics_started; extern UINT8 keyboard_started; /** \brief Set to true when inside a signal handler that will exit the program. */ -extern boolean g_in_exiting_signal_handler; +boolean I_In_Exiting_Signal_Handler(void); /** \brief The I_GetFreeMem function diff --git a/src/m_menu.c b/src/m_menu.c index 0e753f621..f2b3ac1bb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4016,16 +4016,16 @@ boolean replaynamesloaded = false; #ifdef HAVE_THREADS I_mutex replayquerymutex; -// g_in_exiting_signal_handler is an evil hack +// I_In_Exiting_Signal_Handler is an evil hack // to avoid infinite SIGABRT recursion in the signal handler // due to poisoned locks or mach-o kernel not supporting locks in signals // or something like that. idk -# define Lock_search_state() if (!g_in_exiting_signal_handler) { I_lock_mutex(&replayquerymutex); } -# define Unlock_search_state() if (!g_in_exiting_signal_handler) { I_unlock_mutex(replayquerymutex); } -#else/*HAVE_THREADS*/ +# define Lock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_LockMutex(&replayquerymutex); } +# define Unlock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_UnlockMutex(replayquerymutex); } +#else /*HAVE_THREADS*/ # define Lock_search_state() # define Unlock_search_state() -#endif/*HAVE_THREADS*/ +#endif /*HAVE_THREADS*/ #define MAXREPLAYQUERY 37 diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 063b140e1..5310cc855 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -1577,7 +1577,7 @@ static void write_backtrace(bt_crash_reason_t reason) static std::thread::id g_main_thread_id; #endif -boolean g_in_exiting_signal_handler = false; +static volatile sig_atomic_t g_in_exiting_signal_handler = false; static void I_PrintSignal(INT32 signal_num, boolean core_dumped, char *signal_msg, char *signal_name) { @@ -1712,6 +1712,11 @@ static void I_ReportSignal(int num, int coredumped) I_ShowErrorBox(sigttl, sigmsg); } +boolean I_In_Exiting_Signal_Handler(void) +{ + return g_in_exiting_signal_handler; +} + #ifndef NEWSIGNALHANDLER FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) { @@ -1741,7 +1746,7 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) } #endif -static volatile sig_atomic_t interrupted = 0; +static volatile sig_atomic_t interrupted = false; boolean I_Interrupted(void) { @@ -1751,7 +1756,7 @@ boolean I_Interrupted(void) static void quit_handler(int num) { (void)num; - interrupted = 1; + interrupted = true; } static void I_RegisterSignals(void) From fdccf868cc388614df67b4d6c9be483f768a808f Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 17:09:21 +0100 Subject: [PATCH 23/54] disable player fade if viewplayer is spectator fixes some wonky stuff like players disappearing when they were close to the invisible spectator player and you werent watching someone else --- src/r_things.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index 60b0bbd52..9da1f4c3e 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2960,7 +2960,7 @@ fixed_t R_DoPlayerFade(mobj_t *thing) fixed_t fadealpha = FRACUNIT; static constexpr tic_t countdownstarttime = (15 * TICRATE) / 4; // starttime - (3*TICRATE) - if (thing->player == viewplayer || viewplayer->exiting || camera[R_GetViewNumber()].freecam || leveltime < countdownstarttime) + if (thing->player == viewplayer || viewplayer->exiting || viewplayer->spectator || camera[R_GetViewNumber()].freecam || leveltime < countdownstarttime) return fadealpha; const INT32 playerdist = (FixedMul((thing->x - viewx), viewcos) + FixedMul((thing->y - viewy), viewsin)) >> FRACBITS; From 1265bbba2efd8352512d527838c6f6803edf40c5 Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 23 Feb 2026 19:12:42 +0300 Subject: [PATCH 24/54] Rename I_LockMutex back into I_lock_mutex for now --- src/console.c | 4 ++-- src/m_menu.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/console.c b/src/console.c index 09ac2e36d..7276b59c8 100644 --- a/src/console.c +++ b/src/console.c @@ -50,8 +50,8 @@ I_mutex con_mutex; // to avoid infinite SIGABRT recursion in the signal handler // due to poisoned locks or mach-o kernel not supporting locks in signals // or something like that. idk -# define Lock_state() if (!I_In_Exiting_Signal_Handler()) { I_LockMutex(&con_mutex); } -# define Unlock_state() if (!I_In_Exiting_Signal_Handler()) { I_UnlockMutex(con_mutex); } +# define Lock_state() if (!I_In_Exiting_Signal_Handler()) { I_lock_mutex(&con_mutex); } +# define Unlock_state() if (!I_In_Exiting_Signal_Handler()) { I_unlock_mutex(con_mutex); } #else /*HAVE_THREADS*/ # define Lock_state() # define Unlock_state() diff --git a/src/m_menu.c b/src/m_menu.c index f2b3ac1bb..79879032e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4020,8 +4020,8 @@ I_mutex replayquerymutex; // to avoid infinite SIGABRT recursion in the signal handler // due to poisoned locks or mach-o kernel not supporting locks in signals // or something like that. idk -# define Lock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_LockMutex(&replayquerymutex); } -# define Unlock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_UnlockMutex(replayquerymutex); } +# define Lock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_lock_mutex(&replayquerymutex); } +# define Unlock_search_state() if (!I_In_Exiting_Signal_Handler()) { I_unlock_mutex(replayquerymutex); } #else /*HAVE_THREADS*/ # define Lock_search_state() # define Unlock_search_state() From 4623f8aff2ff16edf4a112230dfed2af95c6e9d2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 17:56:41 +0100 Subject: [PATCH 25/54] explicitly set "std=gnu17" we *rely* on a bunch of gnu extensions so its better to explicitly set this yes in theory we fully comply with c23/gnu23 and saturn compiles fine under that, but since its still fairly new theres alot of maschines that still dont support it :chaosleep: --- src/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile b/src/Makefile index 0456990f3..be4f995db 100644 --- a/src/Makefile +++ b/src/Makefile @@ -295,6 +295,7 @@ opts+=$(debug_opts) opts+=$(foreach v,$(passthru_opts),$(if $($(v)),-D$(v))) +CWFLAGS+=-std=gnu17 CXXFLAGS+=-std=c++17 # force c17 for c++ since most vpss run older ubuntu versions with old compilers opts+=$(WFLAGS) $(CFLAGS) From 355c78e07529c074620a72a1b9d1a6ab529a2418 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 17:51:06 +0100 Subject: [PATCH 26/54] check for _GNU_SOURCE for nongnu_strcasestr idk we dont need it and it throws warnings on new glibc so i dont want it tbh --- src/doomtype.h | 2 +- src/strcasestr.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index ed6248129..0e6b6ef5d 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -68,8 +68,8 @@ extern "C" { #define strnicmp(x,y,n) strncasecmp(x,y,n) #endif -char *nongnu_strcasestr(const char *in, const char *what); #ifndef _GNU_SOURCE +char *nongnu_strcasestr(const char *in, const char *what); #define strcasestr nongnu_strcasestr #endif diff --git a/src/strcasestr.c b/src/strcasestr.c index f05449778..84bc0671e 100644 --- a/src/strcasestr.c +++ b/src/strcasestr.c @@ -23,24 +23,26 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef _GNU_SOURCE + #include #include #include -static inline int -trycmp (char **pp, char *cp, - const char *q, size_t qn) +static inline int trycmp(char **pp, char *cp, const char *q, size_t qn) { char *p; p = (*pp); + if (strncasecmp(p, q, qn) == 0) return 0; + (*pp) = strchr(&p[1], (*cp)); + return 1; } -static inline void -swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) +static inline void swapp(char ***ppap, char ***ppbp, char **cpap, char **cpbp) { char **pp; char *p; @@ -54,8 +56,7 @@ swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) *cpbp = p; } -char * -nongnu_strcasestr (const char *s, const char *q) +char *nongnu_strcasestr(const char *s, const char *q) { size_t qn; @@ -113,3 +114,5 @@ nongnu_strcasestr (const char *s, const char *q) return NULL; } + +#endif From a9a0d4bed8bf92319ef34ca8e49b55157555ddd1 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 17:54:51 +0100 Subject: [PATCH 27/54] fix compiler warnings for glibc 2.43 and newer this version changed so that many standard functions now propagate the constness of its input pointers to not cause warnings for everyone on older versions this is now a really dumb macro lol --- src/d_main.c | 2 +- src/doomtype.h | 9 +++++++++ src/g_game.c | 3 +++ src/hardware/hw_shaders.c | 2 +- src/hardware/r_opengl/r_opengl.c | 6 +++--- src/m_misc.c | 6 +++--- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 8bae5ea91..2832d6c6a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -2023,7 +2023,7 @@ void D_SRB2Main(void) if (M_CheckProtoParam("replay")) { const char *replayurl = M_GetProtoParam(); - char *replayname = strrchr(replayurl, '/'); + gconst char *replayname = strrchr(replayurl, '/'); if (!replayname || !replayurl) I_Error("REPLAY: Invalid URL."); diff --git a/src/doomtype.h b/src/doomtype.h index 0e6b6ef5d..b7f8a73e5 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -68,6 +68,15 @@ extern "C" { #define strnicmp(x,y,n) strncasecmp(x,y,n) #endif +// glibc 2.43 made alot of standard lib functions propagate the constness of its input pointers +// to not cause warnings or compile issues on older glibc versions we do this silly thing +// to not have a gazillion glibc version checks +#if __GLIBC_PREREQ(2, 43) + #define gconst const +#else + #define gconst +#endif + #ifndef _GNU_SOURCE char *nongnu_strcasestr(const char *in, const char *what); #define strcasestr nongnu_strcasestr diff --git a/src/g_game.c b/src/g_game.c index a79a957ef..e4e0601f0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4153,6 +4153,7 @@ static void measurekeywords(mapsearchfreq_t *fr, { char *qp; char *sp; + if (wanttable) (*dimp) = Z_Realloc((*dimp), 255 * sizeof (struct searchdim), PU_STATIC, NULL); @@ -4167,10 +4168,12 @@ static void measurekeywords(mapsearchfreq_t *fr, (*dimp)[(*cuntp)].pos = sp - s; (*dimp)[(*cuntp)].siz = strlen(qp); } + (*cuntp)++; fr->total++; } } + if (wanttable) (*dimp) = Z_Realloc((*dimp), (*cuntp) * sizeof (struct searchdim), PU_STATIC, NULL); diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 28f8e46d7..90d019b2b 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -109,7 +109,7 @@ boolean HWR_InitShaders(void) // returns INT32_MAX if not found static INT32 strstr_int(const char *str1, const char *str2) { - char *location = strstr(str1, str2); + gconst char *location = strstr(str1, str2); if (location) return location - str1; else diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index eeb40a8dc..a759b8b2b 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1383,19 +1383,19 @@ void GL_Flush(void) // -----------------+ INT32 GL_isExtAvailable(const char *extension, const GLubyte *start) { - GLubyte *where, *terminator; + gconst GLubyte *where, *terminator; if (!extension || !start) return 0; - where = (GLubyte *) strchr(extension, ' '); + where = (gconst GLubyte *)strchr(extension, ' '); if (where || *extension == '\0') return 0; for (;;) { - where = (GLubyte *) strstr((const char *) start, extension); + where = (gconst GLubyte *)strstr((const char *)start, extension); if (!where) break; diff --git a/src/m_misc.c b/src/m_misc.c index 3a456d7a7..ee17e2098 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1454,9 +1454,9 @@ INT32 axtoi(const char *hexStg) void CopyCaretColors(char *p, const char *s, int n) { - char *t; - int m; - int c; + gconst char *t; + int m; + int c; if (!n) return; From 6f2aba7ee3c47a9cedbd45fc177300f793555961 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 23 Feb 2026 18:10:05 +0100 Subject: [PATCH 28/54] Windows is such a cool Operating System idk why we just dont use int32 there aswell and rely on whatever tf windows supplies which i dont trust ffs --- src/doomtype.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index b7f8a73e5..7d6017e27 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -71,11 +71,15 @@ extern "C" { // glibc 2.43 made alot of standard lib functions propagate the constness of its input pointers // to not cause warnings or compile issues on older glibc versions we do this silly thing // to not have a gazillion glibc version checks +#if defined(__GLIBC_PREREQ) #if __GLIBC_PREREQ(2, 43) #define gconst const #else #define gconst #endif +#else + #define gconst +#endif #ifndef _GNU_SOURCE char *nongnu_strcasestr(const char *in, const char *what); @@ -136,9 +140,9 @@ size_t strlcpy(char *dst, const char *src, size_t dsize); #define STRBUFCPY(dst,src) strlcpy(dst, src, sizeof dst) /* Boolean type definition */ +#include #ifndef _WIN32 -#include // dont use stdbools _BOOL type // its smaller (1 byte) than the old interger bool (4 bytes) // which results in packed struct sizes being mismatched between vanilla and this @@ -146,9 +150,7 @@ size_t strlcpy(char *dst, const char *src, size_t dsize); // which we cant use as enumeration constants typedef int32_t boolean; #else -#define false FALSE -#define true TRUE -#define boolean BOOL +#define boolean int32_t #endif /* 7.18.2.1 Limits of exact-width integer types */ From a287a6419f6a5857ecf163ad4bc46a98eb0da8df Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 23 Feb 2026 22:42:57 +0300 Subject: [PATCH 29/54] Use strncpy for zip entry filename because it might not be null-terminated inside zip --- src/w_wad.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 3009d503f..8cc3fd214 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -696,7 +696,8 @@ static lumpinfo_t* ResGetLumpsZip(FILE* handle, UINT16* nlmp) lump_p->size = LONG(zentry->size); fullname = (char*)(malloc(SHORT(zentry->namelen) + 1)); - strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); + strncpy(fullname, (char *)(zentry + 1), SHORT(zentry->namelen)); + fullname[zentry->namelen] = 0; // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != NULL) @@ -2237,7 +2238,8 @@ static int W_VerifyPK3(FILE *fp, lumpchecklist_t *checklist, boolean status) if (verified == true) { fullname = (char*)(malloc(SHORT(zentry->namelen) + 1)); - strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); + strncpy(fullname, (char *)(zentry + 1), SHORT(zentry->namelen)); + fullname[zentry->namelen] = 0; // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != NULL) @@ -2482,7 +2484,8 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist) } fullname = (char*)(malloc(SHORT(zentry->namelen) + 1)); - strlcpy(fullname, (char*)(zentry + 1), SHORT(zentry->namelen) + 1); + strncpy(fullname, (char *)(zentry + 1), SHORT(zentry->namelen)); + fullname[zentry->namelen] = 0; // Strip away file address and extension for the 8char name. if ((trimname = strrchr(fullname, '/')) != NULL) From 2f684bba95a11f85961b7be842f7e0411415ac68 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 24 Feb 2026 12:34:11 +0100 Subject: [PATCH 30/54] ensure SIGINT/SIGTERM can quit out from wipes and serverconnection ticker --- src/d_clisrv.c | 5 +++++ src/f_wipe.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2f3440362..0241f06e0 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2782,6 +2782,11 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic { INT32 key; + if (I_Interrupted()) + { + I_Quit(); + } + I_OsPolling(); if (cl_mode == CL_CONFIRMCONNECT) diff --git a/src/f_wipe.c b/src/f_wipe.c index 6615cb53c..18100da4c 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -361,6 +361,11 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu) // on for fade-to-black for (;;) { + if (I_Interrupted()) + { + I_Quit(); + } + // get fademask first so we can tell if it exists or not fmask = F_GetFadeMask(wipetype, wipeframe++); From 7c24d92613ef93affeb3fd5b571df14560b64d76 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 16:45:17 +0100 Subject: [PATCH 31/54] delet V_GetSkincolorChar this was unused and broken anyways think this came from snowy kart or smth --- src/v_video.c | 161 -------------------------------------------------- src/v_video.h | 2 - 2 files changed, 163 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index fde09cc0b..9898e9c29 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3309,167 +3309,6 @@ INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option) return max(i-1, 0); } -char V_GetSkincolorChar(INT32 color) -{ - char cstart = 0x80; - - switch (color) - { - case SKINCOLOR_WHITE: - case SKINCOLOR_SILVER: - case SKINCOLOR_SLATE: - cstart = 0x80; // White - break; - - case SKINCOLOR_GREY: - case SKINCOLOR_NICKEL: - case SKINCOLOR_BLACK: - case SKINCOLOR_SKUNK: - case SKINCOLOR_JET: - cstart = 0x86; // V_GRAYMAP - break; - - case SKINCOLOR_SEPIA: - case SKINCOLOR_BEIGE: - case SKINCOLOR_WALNUT: - case SKINCOLOR_BROWN: - case SKINCOLOR_LEATHER: - case SKINCOLOR_RUST: - case SKINCOLOR_WRISTWATCH: - cstart = 0x8e; // V_BROWNMAP - break; - - case SKINCOLOR_FAIRY: - case SKINCOLOR_SALMON: - case SKINCOLOR_PINK: - case SKINCOLOR_ROSE: - case SKINCOLOR_BRICK: - case SKINCOLOR_LEMONADE: - case SKINCOLOR_BUBBLEGUM: - case SKINCOLOR_LILAC: - cstart = 0x8d; // V_PINKMAP - break; - - case SKINCOLOR_CINNAMON: - case SKINCOLOR_RUBY: - case SKINCOLOR_RASPBERRY: - case SKINCOLOR_CHERRY: - case SKINCOLOR_RED: - case SKINCOLOR_CRIMSON: - case SKINCOLOR_MAROON: - case SKINCOLOR_FLAME: - case SKINCOLOR_SCARLET: - case SKINCOLOR_KETCHUP: - cstart = 0x85; // V_REDMAP - break; - - case SKINCOLOR_DAWN: - case SKINCOLOR_SUNSET: - case SKINCOLOR_CREAMSICLE: - case SKINCOLOR_ORANGE: - case SKINCOLOR_PUMPKIN: - case SKINCOLOR_ROSEWOOD: - case SKINCOLOR_BURGUNDY: - case SKINCOLOR_TANGERINE: - cstart = 0x87; // V_ORANGEMAP - break; - - case SKINCOLOR_PEACH: - case SKINCOLOR_CARAMEL: - case SKINCOLOR_CREAM: - cstart = 0x8f; // V_PEACHMAP - break; - - case SKINCOLOR_GOLD: - case SKINCOLOR_ROYAL: - case SKINCOLOR_BRONZE: - case SKINCOLOR_COPPER: - case SKINCOLOR_THUNDER: - cstart = 0x8a; // V_GOLDMAP - break; - - case SKINCOLOR_POPCORN: - case SKINCOLOR_QUARRY: - case SKINCOLOR_YELLOW: - case SKINCOLOR_MUSTARD: - case SKINCOLOR_CROCODILE: - case SKINCOLOR_OLIVE: - cstart = 0x82; // V_YELLOWMAP - break; - - case SKINCOLOR_ARTICHOKE: - case SKINCOLOR_VOMIT: - case SKINCOLOR_GARDEN: - case SKINCOLOR_TEA: - case SKINCOLOR_PISTACHIO: - cstart = 0x8b; // V_TEAMAP - break; - - case SKINCOLOR_LIME: - case SKINCOLOR_HANDHELD: - case SKINCOLOR_MOSS: - case SKINCOLOR_CAMOUFLAGE: - case SKINCOLOR_ROBOHOOD: - case SKINCOLOR_MINT: - case SKINCOLOR_GREEN: - case SKINCOLOR_PINETREE: - case SKINCOLOR_EMERALD: - case SKINCOLOR_SWAMP: - case SKINCOLOR_DREAM: - case SKINCOLOR_PLAGUE: - case SKINCOLOR_ALGAE: - cstart = 0x83; // V_GREENMAP - break; - - case SKINCOLOR_CARIBBEAN: - case SKINCOLOR_AZURE: - case SKINCOLOR_AQUA: - case SKINCOLOR_TEAL: - case SKINCOLOR_CYAN: - case SKINCOLOR_JAWZ: - case SKINCOLOR_CERULEAN: - case SKINCOLOR_NAVY: - case SKINCOLOR_SAPPHIRE: - cstart = 0x88; // V_SKYMAP - break; - - case SKINCOLOR_PIGEON: - case SKINCOLOR_PLATINUM: - case SKINCOLOR_STEEL: - cstart = 0x8c; // V_STEELMAP - break; - - case SKINCOLOR_PERIWINKLE: - case SKINCOLOR_BLUE: - case SKINCOLOR_BLUEBERRY: - case SKINCOLOR_NOVA: - cstart = 0x84; // V_BLUEMAP - break; - - case SKINCOLOR_ULTRAVIOLET: - case SKINCOLOR_PURPLE: - case SKINCOLOR_FUCHSIA: - cstart = 0x81; // V_PURPLEMAP - break; - - case SKINCOLOR_PASTEL: - case SKINCOLOR_MOONSLAM: - case SKINCOLOR_DUSK: - case SKINCOLOR_TOXIC: - case SKINCOLOR_MAUVE: - case SKINCOLOR_LAVENDER: - case SKINCOLOR_BYZANTIUM: - case SKINCOLOR_POMEGRANATE: - cstart = 0x89; // V_LAVENDERMAP - break; - - default: - break; - } - - return cstart; -} - INT32 V_SkinColorToHighlightcolor(skincolors_t color) { switch (color) diff --git a/src/v_video.h b/src/v_video.h index 7eea1468c..0a77c4bc2 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -287,8 +287,6 @@ INT32 V_ThinSubStringWidth(const char *string, INT32 length, INT32 option); // Find maximum length for substring taken from current string to fit into given width INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option); -char V_GetSkincolorChar(INT32 color); - INT32 V_SkinColorToHighlightcolor(skincolors_t color); // this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol From 3e327263c9e11a938cbebcad727f7a06e65c798e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 16:46:37 +0100 Subject: [PATCH 32/54] fix faulty papersprite flipping in opengl lol --- 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 e9aa0532d..15434ec20 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -4850,7 +4850,7 @@ static void HWR_ProjectSprite(mobj_t *thing) flip = sprframe->flip; // Will only be 0x00 or 0xFF if (papersprite && ang < ANGLE_180) - flip ^= 0xFFFF; + flip ^= 0xFF; } else { From 1b22c3af19cd9460564a976e8520cc334353608d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 16:52:39 +0100 Subject: [PATCH 33/54] those should be boolean just for correctness! --- src/d_clisrv.c | 8 ++++---- src/d_clisrv.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0241f06e0..29dea3d19 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -173,11 +173,11 @@ static UINT16 resynch_delay[MAXNETNODES]; // delay time before the player can be static UINT32 resynch_status[MAXNETNODES]; // 0 bit means synched for that player, 1 means possibly desynched static UINT8 resynch_sent[MAXNETNODES][MAXPLAYERS]; // what synch packets have we attempted to send to the player static UINT8 resynch_inprogress[MAXNETNODES]; -static UINT8 resynch_local_inprogress = false; // WE are desynched and getting packets to fix it. -UINT8 hu_resynching = 0; +static boolean resynch_local_inprogress = false; // WE are desynched and getting packets to fix it. +boolean hu_resynching = false; #ifdef SATURNPAK -UINT8 hu_redownloadinggamestate = 0; +boolean hu_redownloadinggamestate = false; static UINT8 gamestate_resend_counter[MAXNETNODES]; #endif @@ -192,7 +192,7 @@ static UINT8 mynode; // my address pointofview server #ifdef SATURNPAK static boolean cl_redownloadinggamestate = false; -boolean is_client_saturn[MAXNETNODES]; +static boolean is_client_saturn[MAXNETNODES]; #endif #ifdef SATURNJOIN diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 430729bc2..396b2190c 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -654,9 +654,9 @@ void D_ResetTiccmds(void); tic_t GetLag(INT32 node); -extern UINT8 hu_resynching; +extern boolean hu_resynching; #ifdef SATURNPAK -extern UINT8 hu_redownloadinggamestate; +extern boolean hu_redownloadinggamestate; #endif extern boolean hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player From 2084cdc6d5679a779948d5002475b64866ec0d6b Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 17:07:27 +0100 Subject: [PATCH 34/54] hw_md2: remove pointless float casts durs and tics are int32. and so is var2, anim_duration is uint16 but that still makes no sense lul --- src/hardware/hw_md2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 2fd33f65b..d9bf41645 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1336,8 +1336,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr) if (spr->mobj->frame & FF_ANIMATE) { // set duration and tics to be the correct values for FF_ANIMATE states - durs = (float)spr->mobj->state->var2; - tics = (float)spr->mobj->anim_duration; + durs = spr->mobj->state->var2; + tics = (INT32)spr->mobj->anim_duration; } //FIXME: this is not yet correct From 94026e43317cd66498022c7b2e687ffd557866c0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 17:44:56 +0100 Subject: [PATCH 35/54] makefile: comment out all the "Wno" flags we effectively fixed all of them, so this does not throw any warnings for me atleast in case we may screw up id rather have those warnings appear --- src/Makefile.d/versions.mk | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index c3989bb4f..cb13c286c 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -20,7 +20,8 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ CXXFLAGS+= -Wno-aggregate-return # -W -Wno-unused -WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference +WFLAGS:=-Wall -Wnull-dereference +#WFLAGS+=-Wno-trigraphs ifdef GCC152 WFLAGS+=-Wzero-as-null-pointer-constant endif @@ -31,7 +32,7 @@ ifndef RELAXWARNINGS WFLAGS+=-W #WFLAGS+=-Wno-sign-compare ifndef GCC295 - WFLAGS+=-Wno-div-by-zero +# WFLAGS+=-Wno-div-by-zero endif #WFLAGS+=-Wsystem-headers WFLAGS+=-Wfloat-equal @@ -62,7 +63,7 @@ endif endif WFLAGS+=-Wsign-compare ifdef GCC91 - WFLAGS+=-Wno-error=address-of-packed-member +# WFLAGS+=-Wno-error=address-of-packed-member endif ifdef GCC45 WFLAGS+=-Wlogical-op @@ -105,14 +106,14 @@ endif endif WFLAGS+=-Wformat-y2k ifdef GCC71 -WFLAGS+=-Wno-error=format-overflow=2 +#WFLAGS+=-Wno-error=format-overflow=2 endif WFLAGS+=-Wformat-security ifndef GCC29 #WFLAGS+=-Winit-self endif ifdef GCC46 -WFLAGS+=-Wno-suggest-attribute=noreturn +#WFLAGS+=-Wno-suggest-attribute=noreturn endif ifdef NOLDWARNING @@ -130,21 +131,21 @@ ifdef GCC44 #WFLAGS+=-Wno-error=array-bounds endif ifdef GCC46 - WFLAGS+=-Wno-error=suggest-attribute=noreturn +# WFLAGS+=-Wno-error=suggest-attribute=noreturn endif ifdef GCC54 - WFLAGS+=-Wno-logical-op -Wno-error=logical-op +# WFLAGS+=-Wno-logical-op -Wno-error=logical-op endif ifdef GCC61 - WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare +# WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare endif ifdef GCC71 WFLAGS+=-Wimplicit-fallthrough=4 endif ifdef GCC81 - WFLAGS+=-Wno-error=format-overflow - WFLAGS+=-Wno-format-overflow - WFLAGS+=-Wno-error=multistatement-macros +# WFLAGS+=-Wno-error=format-overflow +# WFLAGS+=-Wno-format-overflow +# WFLAGS+=-Wno-error=multistatement-macros endif ifneq (,$(filter $(CC) $(CXX),clang clang++)) @@ -183,6 +184,6 @@ endif # Lua ifdef GCC43 ifndef GCC44 -WFLAGS+=-Wno-logical-op +#WFLAGS+=-Wno-logical-op endif endif From 1e51365cadaa3d6075b00eb8214a59618224755e Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 17:43:08 +0100 Subject: [PATCH 36/54] add comment about K_KartUpdatePosition --- src/k_kart.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/k_kart.c b/src/k_kart.c index 0efd3a48b..2aa0377b2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6175,6 +6175,13 @@ void K_KartUpdatePosition(player_t *player) } } + // the player should NOT be checked against themselves! lol + // otherwise prevcheck will effectively be halved + // sadly this stuff is exposed to lua and atleast one script uses those so we cant fix it + // oh well + //if (player == &players[i]) + //continue; + const boolean isprevcheckpointi = mo->health == players[i].starpostnum; const boolean isnextcheckpointi = mo->health == (players[i].starpostnum + 1); From 1ec29c1c94579ffb9fc263bd202531b48daad8f0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 25 Feb 2026 21:27:02 +0100 Subject: [PATCH 37/54] better flags for ASAN and UBSAN compile with -O1 and -fno-omit-frame-pointer -fno-common for ASAN --- src/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index be4f995db..372594384 100644 --- a/src/Makefile +++ b/src/Makefile @@ -269,13 +269,13 @@ endif ifdef USEASAN # compile with asan -opts+=-fsanitize=address +opts+=-O1 -fsanitize=address -fno-omit-frame-pointer -fno-common libs+=-fsanitize=address endif ifdef USEUBSAN -# compile with asan -opts+=-fsanitize=undefined +# compile with ubsan +opts+=-O1 -fsanitize=undefined -fno-omit-frame-pointer libs+=-fsanitize=undefined endif From db4cd73912b65e26ea2542b845ae6b2671db8455 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 26 Feb 2026 01:05:08 +0100 Subject: [PATCH 38/54] fix keepmusic resuming not resetting with "tunes" command this code sucks ass wtf was i cooking if this breaks again i will just wipe it lmao --- src/s_sound.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index f2ee1dc03..1e19c83fe 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1438,7 +1438,7 @@ void S_LoadMusicDefs(UINT16 wadnum) stoken = strtok(stoken, " "); if (stoken) { - if (! ReadMusicDefFields(wadnum, line, stoken, &def)) + if (!ReadMusicDefFields(wadnum, line, stoken, &def)) break; } @@ -1982,7 +1982,7 @@ static void S_SetKeepMusResume(void) { keepmusic.resume = 0; - if (fasticmp(music.name, mapmusic.name)) + if (fasticmp(music.name, keepmusic.name)) { keepmusic.resume = I_GetSongPosition(); } @@ -2078,9 +2078,12 @@ void S_InitMapMusic(void) S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, keepmusic.resume, 0, 500); } + keepmusic.resume = 0; return; } + keepmusic.resume = 0; + // Starting ambience should always be restarted // lug: but not when we keep the map music lol S_StopMusic(); @@ -2208,6 +2211,8 @@ static void Command_Tunes_f(void) mapmusic.position = position; mapmusic.resume = 0; + keepmusic.resume = 0; + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); if (argc > 3) From 6ff1cbf4b03c61ca2e4eac92834edec6347c7aee Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 26 Feb 2026 01:11:37 +0100 Subject: [PATCH 39/54] ok actually just remove keepmusic resume stuff well now it just broke with dynmusic this sucks, its probably fixable but the code was abysmal so shrug --- src/s_sound.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 1e19c83fe..546c183a8 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -116,9 +116,7 @@ consvar_t cv_skipintromusic = {"skipintromusic", "No", CV_SAVE, CV_YesNo, NULL, boolean keepmapmusic = false; // keep the current music on map restart boolean skipintromus = false; // skip the intro fanfare -static boolean resumekeepmusic = false; static music_t keepmusic; -static void S_SetKeepMusResume(void); #ifdef HAVE_OPENMPT openmpt_module *openmpt_mhandle = NULL; @@ -1848,8 +1846,6 @@ void S_StopMusic(void) mapmusic.resume = (cv_resume.value && fasticmp(music.name, mapmusic.name)) ? I_GetSongPosition() : 0; - S_SetKeepMusResume(); - if (I_SongPaused()) I_ResumeSong(); @@ -1976,17 +1972,6 @@ void S_ResetKeepAndSpecialMus(void) keepmapmusic = skipintromus = false; } -// saves the current song position everytime a song stops -// so we can resume it in some cases -static void S_SetKeepMusResume(void) -{ - keepmusic.resume = 0; - - if (fasticmp(music.name, keepmusic.name)) - { - keepmusic.resume = I_GetSongPosition(); - } -} // determine if we should keep the music on a map restart // this gets called BEFORE the level gets loaded in G_DoLoadLevel @@ -1995,7 +1980,7 @@ void S_KeepMusic(void) static INT16 oldmap = -1; static boolean oldencore = false; - keepmapmusic = resumekeepmusic = false; + keepmapmusic = false; if (!cv_keepmusic.value) { @@ -2009,9 +1994,7 @@ void S_KeepMusic(void) if (oldmap == gamemap && oldencore == encoremode) { - const boolean musicchanged = S_CheckMusicException(); - resumekeepmusic = (musicchanged && keepmusic.resume); - keepmapmusic = (!musicchanged || resumekeepmusic); + keepmapmusic = (S_CheckMusicException() == false); } oldencore = encoremode; @@ -2072,18 +2055,9 @@ void S_InitMapMusic(void) if (keepmapmusic) { - // this is kinda silly, but we can use it to fade back into the map song at the saved point, should the current music be different from the map music - if (resumekeepmusic) - { - S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, keepmusic.resume, 0, 500); - } - - keepmusic.resume = 0; return; } - keepmusic.resume = 0; - // Starting ambience should always be restarted // lug: but not when we keep the map music lol S_StopMusic(); @@ -2211,8 +2185,6 @@ static void Command_Tunes_f(void) mapmusic.position = position; mapmusic.resume = 0; - keepmusic.resume = 0; - S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); if (argc > 3) From 5577ba4c7ac98cb11339f4b416801ac100430c82 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Mar 2026 00:03:19 +0100 Subject: [PATCH 40/54] Autoload: dont add wads that contain maps --- src/d_main.c | 11 ++++++++++- src/w_wad.c | 13 ++++++++++++- src/w_wad.h | 1 + 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 2832d6c6a..1a03b1972 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1124,9 +1124,18 @@ static void D_FindAddonsToAutoload(void) if (newline) *newline = '\0'; + // ok so theres still issues with players adding stuff to autoload by accident + // sometimes this stuff contains maps + // you can probably imagine how that goes in a netgame.... + if (W_CheckAutoLoadContainsMap(wadsToAutoload)) + { + CONS_Printf("Autoload: file %s contains map data! skipping...", wadsToAutoload); + continue; + } + if (!postload && W_CheckPostLoadList(wadsToAutoload)) { - CONS_Printf("forcing postload for file %s\n", wadsToAutoload); + CONS_Printf("Autoload: forcing postload for file %s\n", wadsToAutoload); postload = true; } diff --git a/src/w_wad.c b/src/w_wad.c index 8cc3fd214..4a1c1247a 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2576,6 +2576,18 @@ static int W_CheckFileContains(const char *filename, lumpchecklist_t *checklist) return contains; } +int W_CheckAutoLoadContainsMap(const char *filename) +{ + // for now this checks for map marker + static lumpchecklist_t autoloadblacklist[] = + { + {"MAP", 3}, + {NULL, 0}, + }; + + return W_CheckFileContains(filename, autoloadblacklist); +} + int W_CheckPostLoadList(const char *filename) { static lumpchecklist_t postloadlist[] = @@ -2588,7 +2600,6 @@ int W_CheckPostLoadList(const char *filename) {"SOC_", 4}, {"MAINCFG", 7}, {"OBJCTCFG", 8}, - {"MAP", 3}, {NULL, 0}, }; diff --git a/src/w_wad.h b/src/w_wad.h index 6240c31f3..98c57173e 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -243,6 +243,7 @@ void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5); int W_VerifyNMUSlumps(const char *filename, FILE *handle, boolean exit_on_error); +int W_CheckAutoLoadContainsMap(const char *filename); int W_CheckPostLoadList(const char *filename); #ifdef __cplusplus From 1cf04514b3b67685789182c83b95907be80a2154 Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 1 Mar 2026 02:31:11 +0300 Subject: [PATCH 41/54] Fix W_MakeFileMD5 printing incorrect time --- src/w_wad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 4a1c1247a..3c37bf185 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -339,7 +339,7 @@ static inline INT32 W_MakeFileMD5(const char *filename, void *resblock) if ((fhandle = fopen(filename, "rb")) != NULL) { - tic_t t = I_GetTime(); + precise_t t = I_GetPreciseTime(); CONS_Debug(DBG_SETUP, "Making MD5 for %s\n",filename); @@ -350,7 +350,7 @@ static inline INT32 W_MakeFileMD5(const char *filename, void *resblock) } CONS_Debug(DBG_SETUP, "MD5 calc for %s took %f seconds\n", - filename, (float)(I_GetTime() - t)/NEWTICRATE); + filename, (float)(I_GetPreciseTime() - t)/I_GetPrecisePrecision()); fclose(fhandle); return 0; From 5ca3ab5966f2d221db802d0ed1c0d99d6a1e100a Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Mar 2026 00:57:44 +0100 Subject: [PATCH 42/54] Autoload: fix incorrectly incrementing wad count those should only be incremented if we actually add something to the filearray and not instantly execute or error out --- src/d_main.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 1a03b1972..85ef4d226 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -130,8 +130,8 @@ static size_t startuppwadcount = 0; // autoloading static char *autoloadwadfiles[MAX_WADFILES]; static char *autoloadwadfilespost[MAX_WADFILES]; -static size_t autoloadcount = 0; -static size_t postloadcount = 0; +static size_t autoloadwadcount = 0; +static size_t postloadwadcount = 0; // boolean devparm = false; // started game with -devparm @@ -1037,7 +1037,7 @@ static INT32 D_DetectFileType(const char* filename) } // autoload that shit -static void D_AutoloadFile(const char *file, char **filearray, size_t index) +static void D_AutoloadFile(const char *file, char **filearray, size_t *index) { char *newfile; INT32 fileType = D_DetectFileType(file); @@ -1052,10 +1052,11 @@ static void D_AutoloadFile(const char *file, char **filearray, size_t index) { newfile = malloc(strlen(file) + 1); if (!newfile) - I_Error("No more free memory to AutoloadFile %s",file); + I_Error("D_AutoloadFile: No more free memory to autoload file %s", file); strcpy(newfile, file); - filearray[index] = newfile; + filearray[*index] = newfile; + (*index)++; } else { @@ -1098,7 +1099,7 @@ static void D_FindAddonsToAutoload(void) // If the file is found, run our shit if (!autoloadconfigfile) // nope outta here { - autoloadcount = postloadcount = 0; // so D_AddAutoloadFiles can skip everything since nothings there to autoload + autoloadwadcount = postloadwadcount = 0; // so D_AddAutoloadFiles can skip everything since nothings there to autoload return; } @@ -1142,18 +1143,16 @@ static void D_FindAddonsToAutoload(void) // LOAD IT if (!postload) { - D_AutoloadFile(wadsToAutoload, autoloadwadfiles, autoloadcount); - autoloadcount++; + D_AutoloadFile(wadsToAutoload, autoloadwadfiles, &autoloadwadcount); } else { - D_AutoloadFile(wadsToAutoload, autoloadwadfilespost, postloadcount); - postloadcount++; + D_AutoloadFile(wadsToAutoload, autoloadwadfilespost, &postloadwadcount); } } - autoloadwadfiles[autoloadcount] = NULL; - autoloadwadfilespost[postloadcount] = NULL; + autoloadwadfiles[autoloadwadcount] = NULL; + autoloadwadfilespost[postloadwadcount] = NULL; // we dont want memory leaks around here do we? fclose(autoloadconfigfile); @@ -1162,7 +1161,7 @@ static void D_FindAddonsToAutoload(void) static void D_AddAutoloadFiles(void) { // nothing to autoload - if (autoloadcount == 0) + if (autoloadwadcount == 0) return; CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); @@ -1170,15 +1169,15 @@ static void D_AddAutoloadFiles(void) if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0) CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); - D_CleanFile(autoloadwadfiles, autoloadcount); + D_CleanFile(autoloadwadfiles, autoloadwadcount); - autoloadcount = 0; + autoloadwadcount = 0; } void D_AddPostloadFiles(void) { // nothing to postload - if (postloadcount == 0 || !netgame) + if (postloadwadcount == 0 || !netgame) return; CONS_Printf("D_AddPostloadFiles(): Loading postloaded addons...\n"); @@ -1186,9 +1185,9 @@ void D_AddPostloadFiles(void) if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0) CONS_Printf("D_AddPostloadFiles(): Are you sure you put in valid files or what?\n"); - D_CleanFile(autoloadwadfilespost, postloadcount); + D_CleanFile(autoloadwadfilespost, postloadwadcount); - postloadcount = 0; + postloadwadcount = 0; } // ========================================================================== From e8c7cc6a9b57ffba849ff6ccaa3935ea2633baa0 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Mar 2026 00:59:51 +0100 Subject: [PATCH 43/54] D_AutoloadFile: add overflow safeguard --- src/d_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index 85ef4d226..c312e3f59 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1042,6 +1042,12 @@ static void D_AutoloadFile(const char *file, char **filearray, size_t *index) char *newfile; INT32 fileType = D_DetectFileType(file); + if (*index >= MAX_WADFILES) + { + CONS_Printf("D_AutoloadFile: Failed to add file %s! Too many autoloaded files\n", file); + return; + } + if (!fileType) { CONS_Printf("D_AutoloadFile: File %s is unknown or invalid\n", file); From 1a9fa94cbd44d129af33b395bfe09acc3785f9fb Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Mar 2026 01:01:20 +0100 Subject: [PATCH 44/54] Autoload: dont attempt to load directories lol --- src/d_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index c312e3f59..0ecce2047 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1054,6 +1054,12 @@ static void D_AutoloadFile(const char *file, char **filearray, size_t *index) return; } + if (fileType == 1) + { + CONS_Printf("D_AutoloadFile: File %s is a directory\n", file); + return; + } + if (fileType <= 6) { newfile = malloc(strlen(file) + 1); From 397fb071e5eb9edfc4ca10b92770ae48d95d3c4b Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Mar 2026 21:24:09 +0100 Subject: [PATCH 45/54] fix compiling with valgrind support --- src/z_zone.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/z_zone.cpp b/src/z_zone.cpp index 9e5b4f41e..f25f99e43 100644 --- a/src/z_zone.cpp +++ b/src/z_zone.cpp @@ -523,11 +523,19 @@ void Z_CheckHeap(INT32 tag) #ifdef VALGRIND_MEMPOOL_EXISTS if (!VALGRIND_MEMPOOL_EXISTS(block)) { - I_Error("Z_CheckHeap %d: block %u" + I_Error("Z_CheckHeap :" +#ifdef ZDEBUG + " %s %d" +#endif + " block %u" #ifdef ZDEBUG " (owned by %s:%d)" #endif - " should not exist", i, blocknumon + " should not exist" +#ifdef ZDEBUG + , file, line +#endif + , blocknumon #ifdef ZDEBUG , block->ownerfile, block->ownerline #endif From 82471339664b62115eb15cd9f1d44e7144acb4d5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 1 Mar 2026 21:32:25 +0100 Subject: [PATCH 46/54] w_wad: use strnlen to check lump length for map marker lump name may not be null terminated here, so strlen may read out of bounds garbo using strnlen ensures we read max 8 characters which is the name buffer size --- src/w_wad.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/w_wad.c b/src/w_wad.c index 3c37bf185..ef9bd471e 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -2660,11 +2660,12 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) { if (vsizecache[realentry] == 0) continue; + vlumps[i].size = vsizecache[realentry]; const char *name = (fileinfo + realentry)->name; - if (strlen(name) == 5 && memcmp(name, "MAP", 3) == 0) + if (strnlen(name, 8) == 5 && memcmp(name, "MAP", 3) == 0) { numlumps--; // We skip map marker, so 1 of entries becomes empty continue; // This will skip i++ so we will write to same entry From f2b46fd1484e573babc3ab0f6e6da1843c942408 Mon Sep 17 00:00:00 2001 From: "X.organic" Date: Tue, 6 Apr 2021 01:01:33 +0200 Subject: [PATCH 47/54] Fix myhashfgets-related buffer overflows in deh_soc.c --- src/dehacked.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index a3513fbbe..6b09f0d5b 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -115,20 +115,25 @@ char *myfgets(char *buf, size_t bufsize, MYFILE *f) size_t i = 0; if (myfeof(f)) return NULL; + // we need one byte for a null terminated string bufsize--; + while (i < bufsize && !myfeof(f)) { char c = *f->curpos++; + if (c == '^') buf[i++] = myfget_color(f); else if (c == '\\') buf[i++] = myfget_hex(f); else if (c != '\r') buf[i++] = c; + if (c == '\n') break; } + buf[i] = '\0'; dbg_line++; @@ -138,25 +143,31 @@ char *myfgets(char *buf, size_t bufsize, MYFILE *f) static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f) { size_t i = 0; + if (myfeof(f)) return NULL; + // we need one byte for a null terminated string bufsize--; + while (i < bufsize && !myfeof(f)) { char c = *f->curpos++; + if (c == '^') buf[i++] = myfget_color(f); else if (c == '\\') buf[i++] = myfget_hex(f); else if (c != '\r') buf[i++] = c; + if (c == '\n') // Ensure debug line is right... dbg_line++; + if (c == '#') break; } - i++; + buf[i] = '\0'; return buf; @@ -315,7 +326,10 @@ static void readPlayer(MYFILE *f, INT32 num) goto done; PlayerMenu[num].status = IT_CALL; - for (i = 0; i < MAXLINELEN-3; i++) + // A friendly neighborhood alias for brevity's sake + const size_t note_size = sizeof(description[num].notes); + + for (i = 0; i < (INT32)(MAXLINELEN-note_size-3); i++) { if (s[i] == '=') { @@ -323,10 +337,12 @@ static void readPlayer(MYFILE *f, INT32 num) break; } } + if (playertext) { - strcpy(description[num].notes, playertext); - strcat(description[num].notes, myhashfgets(playertext, sizeof (description[num].notes), f)); + strlcpy(description[num].notes, playertext, note_size); + strlcat(description[num].notes, + myhashfgets(playertext, note_size, f), note_size); } else strcpy(description[num].notes, ""); @@ -335,7 +351,7 @@ static void readPlayer(MYFILE *f, INT32 num) // It works down here, though. { INT32 numline = 0; - for (i = 0; (size_t)i < sizeof(description[num].notes)-1; i++) + for (i = 0; (size_t)i < note_size-1; i++) { if (numline < 20 && description[num].notes[i] == '\n') numline++; @@ -344,6 +360,7 @@ static void readPlayer(MYFILE *f, INT32 num) break; } } + description[num].notes[strlen(description[num].notes)-1] = '\0'; description[num].notes[i] = '\0'; continue; From 07fc0eb03abd21ef36f96d345baf83f773ae7192 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Mar 2026 00:34:58 +0100 Subject: [PATCH 48/54] v_video: fix cv_palettenum bounds check mhhm yeah --- src/v_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v_video.c b/src/v_video.c index 9898e9c29..fcbeded5f 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -555,7 +555,7 @@ void V_SetPalette(INT32 palettenum) { palettenum = cv_palettenum.value; - if (palettenum * 256U > currentPaletteSize - 256) + if (palettenum * 256U > (currentPaletteSize - 256) / 3) { CONS_Alert(CONS_WARNING, "cv_palettenum %d out of range\n", palettenum); palettenum = 0; From efe873218811aea5d718a96dc63726c96aeb4347 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Mar 2026 00:43:33 +0100 Subject: [PATCH 49/54] fix flashpals throwing random garbage into the renderer in some cases iirc, if the provided palette currently in use did not provide subpalettes, this will read past the bounds of allocated memory, which aint good lol i just dumped the white flashpal and threw it into there since idk if -file or autoload gets called before the palette gets initialised, which would carry a risk of copying more garbage, hence this big ass array --- src/v_video.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 2 deletions(-) diff --git a/src/v_video.c b/src/v_video.c index fcbeded5f..2aa680153 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -92,6 +92,97 @@ consvar_t cv_menucaps = {"menucaps", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NUL RGBA_t *pLocalPalette = NULL; RGBA_t *pGammaCorrectedPalette = NULL; +// huge ass array les gooooooo! +// this is basically the white flashpal byte for byte from our main palette lmao +static RGBA_t pFallbackFlashPal[] = { + {.s={253, 253, 253, 255}}, {.s={251, 251, 251, 255}}, {.s={249, 249, 249, 255}}, + {.s={247, 247, 247, 255}}, {.s={245, 245, 245, 255}}, {.s={243, 243, 243, 255}}, + {.s={241, 241, 241, 255}}, {.s={239, 239, 239, 255}}, {.s={237, 237, 237, 255}}, + {.s={235, 235, 235, 255}}, {.s={233, 233, 233, 255}}, {.s={231, 231, 231, 255}}, + {.s={229, 229, 229, 255}}, {.s={227, 227, 227, 255}}, {.s={225, 225, 225, 255}}, + {.s={223, 223, 223, 255}}, {.s={221, 221, 221, 255}}, {.s={219, 219, 219, 255}}, + {.s={217, 217, 217, 255}}, {.s={215, 215, 215, 255}}, {.s={213, 213, 213, 255}}, + {.s={211, 211, 211, 255}}, {.s={209, 209, 209, 255}}, {.s={207, 207, 207, 255}}, + {.s={205, 205, 205, 255}}, {.s={203, 203, 203, 255}}, {.s={201, 201, 201, 255}}, + {.s={199, 199, 199, 255}}, {.s={197, 197, 197, 255}}, {.s={195, 195, 195, 255}}, + {.s={193, 193, 193, 255}}, {.s={192, 192, 192, 255}}, {.s={239, 233, 227, 255}}, + {.s={237, 231, 225, 255}}, {.s={235, 229, 223, 255}}, {.s={233, 227, 221, 255}}, + {.s={231, 225, 219, 255}}, {.s={229, 223, 217, 255}}, {.s={227, 221, 215, 255}}, + {.s={225, 220, 214, 255}}, {.s={223, 218, 212, 255}}, {.s={220, 216, 210, 255}}, + {.s={218, 214, 208, 255}}, {.s={216, 212, 206, 255}}, {.s={214, 210, 204, 255}}, + {.s={212, 208, 202, 255}}, {.s={210, 206, 200, 255}}, {.s={208, 204, 198, 255}}, + {.s={239, 222, 210, 255}}, {.s={236, 220, 209, 255}}, {.s={234, 219, 208, 255}}, + {.s={232, 218, 207, 255}}, {.s={230, 216, 206, 255}}, {.s={227, 215, 205, 255}}, + {.s={225, 213, 204, 255}}, {.s={223, 212, 203, 255}}, {.s={221, 211, 202, 255}}, + {.s={218, 209, 201, 255}}, {.s={215, 208, 200, 255}}, {.s={212, 207, 199, 255}}, + {.s={210, 205, 198, 255}}, {.s={207, 203, 197, 255}}, {.s={204, 202, 196, 255}}, + {.s={202, 200, 195, 255}}, {.s={255, 250, 247, 255}}, {.s={255, 248, 244, 255}}, + {.s={255, 246, 241, 255}}, {.s={255, 244, 238, 255}}, {.s={255, 243, 236, 255}}, + {.s={255, 241, 233, 255}}, {.s={255, 239, 230, 255}}, {.s={255, 238, 228, 255}}, + {.s={255, 236, 224, 255}}, {.s={253, 234, 222, 255}}, {.s={251, 232, 220, 255}}, + {.s={249, 230, 218, 255}}, {.s={247, 228, 216, 255}}, {.s={245, 226, 214, 255}}, + {.s={243, 224, 212, 255}}, {.s={242, 223, 211, 255}}, {.s={255, 250, 246, 255}}, + {.s={255, 246, 237, 255}}, {.s={255, 242, 229, 255}}, {.s={255, 237, 220, 255}}, + {.s={255, 233, 213, 255}}, {.s={255, 229, 205, 255}}, {.s={255, 225, 198, 255}}, + {.s={255, 220, 192, 255}}, {.s={252, 218, 192, 255}}, {.s={248, 216, 192, 255}}, + {.s={245, 214, 192, 255}}, {.s={242, 213, 192, 255}}, {.s={238, 211, 192, 255}}, + {.s={235, 209, 192, 255}}, {.s={232, 207, 192, 255}}, {.s={229, 205, 192, 255}}, + {.s={255, 255, 251, 255}}, {.s={255, 255, 243, 255}}, {.s={255, 255, 235, 255}}, + {.s={255, 255, 227, 255}}, {.s={255, 255, 219, 255}}, {.s={255, 255, 211, 255}}, + {.s={255, 255, 203, 255}}, {.s={255, 255, 195, 255}}, {.s={255, 255, 192, 255}}, + {.s={243, 243, 192, 255}}, {.s={235, 235, 192, 255}}, {.s={227, 227, 192, 255}}, + {.s={219, 219, 192, 255}}, {.s={211, 211, 192, 255}}, {.s={203, 203, 192, 255}}, + {.s={195, 195, 192, 255}}, {.s={255, 255, 220, 255}}, {.s={250, 246, 213, 255}}, + {.s={245, 238, 208, 255}}, {.s={240, 230, 203, 255}}, {.s={235, 222, 199, 255}}, + {.s={230, 214, 196, 255}}, {.s={225, 208, 193, 255}}, {.s={220, 202, 192, 255}}, + {.s={255, 255, 255, 255}}, {.s={255, 247, 247, 255}}, {.s={255, 239, 239, 255}}, + {.s={255, 231, 231, 255}}, {.s={255, 223, 223, 255}}, {.s={255, 215, 215, 255}}, + {.s={255, 207, 207, 255}}, {.s={255, 199, 199, 255}}, {.s={255, 192, 192, 255}}, + {.s={251, 192, 192, 255}}, {.s={247, 192, 192, 255}}, {.s={243, 192, 192, 255}}, + {.s={239, 192, 192, 255}}, {.s={235, 192, 192, 255}}, {.s={231, 192, 192, 255}}, + {.s={227, 192, 192, 255}}, {.s={223, 192, 192, 255}}, {.s={219, 192, 192, 255}}, + {.s={215, 192, 192, 255}}, {.s={211, 192, 192, 255}}, {.s={207, 192, 192, 255}}, + {.s={203, 192, 192, 255}}, {.s={199, 192, 192, 255}}, {.s={195, 192, 192, 255}}, + {.s={255, 237, 237, 255}}, {.s={252, 232, 232, 255}}, {.s={249, 227, 227, 255}}, + {.s={246, 222, 222, 255}}, {.s={242, 218, 218, 255}}, {.s={239, 214, 214, 255}}, + {.s={236, 211, 211, 255}}, {.s={233, 207, 207, 255}}, {.s={227, 203, 192, 255}}, + {.s={225, 201, 192, 255}}, {.s={223, 199, 192, 255}}, {.s={220, 198, 192, 255}}, + {.s={218, 196, 192, 255}}, {.s={216, 194, 192, 255}}, {.s={214, 193, 192, 255}}, + {.s={213, 192, 192, 255}}, {.s={221, 255, 211, 255}}, {.s={219, 251, 210, 255}}, + {.s={217, 247, 209, 255}}, {.s={215, 243, 208, 255}}, {.s={214, 239, 206, 255}}, + {.s={212, 235, 205, 255}}, {.s={210, 231, 204, 255}}, {.s={208, 227, 203, 255}}, + {.s={206, 223, 201, 255}}, {.s={205, 219, 200, 255}}, {.s={203, 215, 199, 255}}, + {.s={201, 211, 198, 255}}, {.s={199, 207, 196, 255}}, {.s={197, 203, 195, 255}}, + {.s={195, 199, 194, 255}}, {.s={193, 195, 192, 255}}, {.s={246, 255, 233, 255}}, + {.s={241, 248, 228, 255}}, {.s={234, 241, 223, 255}}, {.s={228, 234, 218, 255}}, + {.s={222, 228, 213, 255}}, {.s={216, 221, 208, 255}}, {.s={210, 214, 203, 255}}, + {.s={204, 207, 199, 255}}, {.s={192, 255, 192, 255}}, {.s={192, 247, 192, 255}}, + {.s={192, 239, 192, 255}}, {.s={192, 231, 192, 255}}, {.s={192, 223, 192, 255}}, + {.s={192, 215, 192, 255}}, {.s={192, 207, 192, 255}}, {.s={192, 199, 192, 255}}, + {.s={255, 219, 255, 255}}, {.s={255, 192, 255, 255}}, {.s={247, 192, 247, 255}}, + {.s={239, 192, 239, 255}}, {.s={231, 192, 231, 255}}, {.s={223, 192, 223, 255}}, + {.s={215, 192, 215, 255}}, {.s={207, 192, 207, 255}}, {.s={249, 249, 252, 255}}, + {.s={240, 240, 247, 255}}, {.s={230, 230, 242, 255}}, {.s={221, 221, 238, 255}}, + {.s={212, 212, 233, 255}}, {.s={208, 208, 224, 255}}, {.s={203, 203, 214, 255}}, + {.s={198, 198, 204, 255}}, {.s={244, 251, 255, 255}}, {.s={239, 250, 255, 255}}, + {.s={234, 248, 255, 255}}, {.s={228, 246, 255, 255}}, {.s={223, 244, 255, 255}}, + {.s={218, 243, 255, 255}}, {.s={213, 241, 255, 255}}, {.s={207, 239, 255, 255}}, + {.s={205, 230, 247, 255}}, {.s={203, 227, 239, 255}}, {.s={201, 221, 231, 255}}, + {.s={199, 215, 223, 255}}, {.s={192, 239, 239, 255}}, {.s={192, 223, 223, 255}}, + {.s={192, 215, 215, 255}}, {.s={192, 207, 207, 255}}, {.s={249, 249, 255, 255}}, + {.s={240, 240, 255, 255}}, {.s={234, 234, 255, 255}}, {.s={226, 226, 255, 255}}, + {.s={220, 220, 255, 255}}, {.s={212, 212, 255, 255}}, {.s={204, 204, 255, 255}}, + {.s={197, 197, 255, 255}}, {.s={192, 192, 255, 255}}, {.s={192, 192, 249, 255}}, + {.s={192, 192, 242, 255}}, {.s={192, 192, 236, 255}}, {.s={192, 192, 230, 255}}, + {.s={192, 192, 224, 255}}, {.s={192, 192, 218, 255}}, {.s={192, 192, 212, 255}}, + {.s={192, 192, 211, 255}}, {.s={192, 192, 207, 255}}, {.s={192, 192, 205, 255}}, + {.s={192, 192, 201, 255}}, {.s={192, 192, 199, 255}}, {.s={192, 192, 195, 255}}, + {.s={192, 192, 193, 255}}, {.s={192, 255, 255, 255}}, {.s={243, 223, 243, 255}}, + {.s={237, 219, 237, 255}}, {.s={231, 215, 231, 255}}, {.s={225, 211, 225, 255}}, + {.s={219, 207, 219, 255}}, {.s={213, 203, 213, 255}}, {.s={207, 199, 207, 255}}, + {.s={201, 195, 201, 255}} +}; + static size_t currentPaletteSize; /* @@ -543,6 +634,7 @@ void V_ReloadPalette(void) // -------------+ void V_SetPalette(INT32 palettenum) { + RGBA_t *pal = NULL; if (!pLocalPalette) V_ReloadPalette(); @@ -563,15 +655,31 @@ void V_SetPalette(INT32 palettenum) } } + // if the palettenum goes beyond our current palette, then just fallback to the white flash pal + // our srb2 palette mostly just contains that as subpalettes, so everything uses this + // and makes it a good fallback case + // otherwise we will throw random garbage to the renderer which calls memcpy on it + // which is not really a good thing lol + // we probably could just memcpy from localpalette, but i dont trust -file nor autoload so + if (palettenum * 256U > (currentPaletteSize - 256) / 3) + { + CONS_Debug(DBG_RENDER, "palettenum %d out of range\n", palettenum); + pal = pFallbackFlashPal; + } + else + { + pal = &pLocalPalette[palettenum*256]; + } + #ifdef HWRENDER if (rendermode == render_opengl) - HWR_SetPalette(&pLocalPalette[palettenum*256]); + HWR_SetPalette(pal); #if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) else #endif #endif if (rendermode != render_none) - I_SetPalette(&pLocalPalette[palettenum*256]); + I_SetPalette(pal); } void V_SetPaletteLump(const char *pal) From 16cf4ede89f511967808b5e8737a9529ba891aa8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Mar 2026 08:31:27 +0100 Subject: [PATCH 50/54] v_video: generate missing flashpals instead not sure if this is more sane than the huge ass array from before but atleast this is more accurate and can basically generate flashpals from any palette while also still working with all the colour and gamma adjustments prob needs some cleanup idk this is all rather messy lol --- src/hardware/hw_main.cpp | 4 +- src/hardware/hw_main.h | 6 - src/m_menudefs.c | 2 - src/st_stuff.c | 2 +- src/v_paldeltas.h | 525 +++++++++++++++++++++++++++++++++++++++ src/v_video.c | 196 +++++++-------- 6 files changed, 614 insertions(+), 121 deletions(-) create mode 100644 src/v_paldeltas.h diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 15434ec20..e6ce072cf 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -242,7 +242,6 @@ consvar_t cv_glportals = {"gr_portals", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, consvar_t cv_glpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_glpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gltexturedepth = {"gr_texturedepth", "32 bits", CV_CALL|CV_SAVE, gltexdepth_cons_t, CV_gltextureformat_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -5913,7 +5912,6 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_glpaletterendering); CV_RegisterVar(&cv_glpalettedepth); - CV_RegisterVar(&cv_glflashpal); } // -------------------------------------------------------------------------- @@ -6070,7 +6068,7 @@ static void HWR_DoPostProcessor(void) { // Armageddon Blast Flash! // Could this even be considered postprocessor? - if (!HWR_PalRenderFlashpal()) + if (!HWR_ShouldUsePaletteRendering()) { const player_t *player = &players[displayplayers[viewssnum]]; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 8b5284acb..8a501f727 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -208,7 +208,6 @@ extern consvar_t cv_glportals; extern consvar_t cv_glpaletterendering; extern consvar_t cv_glpalettedepth; -extern consvar_t cv_glflashpal; FUNCINLINE static ATTRINLINE boolean HWR_UseShader(void) { @@ -220,11 +219,6 @@ FUNCINLINE static ATTRINLINE boolean HWR_ShouldUsePaletteRendering(void) return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader()); } -FUNCINLINE static ATTRINLINE boolean HWR_PalRenderFlashpal(void) -{ - return (cv_glflashpal.value && HWR_ShouldUsePaletteRendering()); -} - // Returns a pointer to the palette which should be used for caching textures. FUNCINLINE static ATTRINLINE RGBA_t *HWR_GetTexturePalette(void) { diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 00b927efd..aa3f186c8 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1023,8 +1023,6 @@ static menuitem_t OP_OpenGLOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Fallback Player 3D Model", &cv_glfallbackplayermodel, 20}, {IT_STRING | IT_CVAR, NULL, "Shaders", &cv_glshaders, 25}, {IT_STRING | IT_CVAR, NULL, "Palette Rendering", &cv_glpaletterendering, 30}, - {IT_STRING | IT_CVAR, NULL, "Palette Rendering Flashpals",&cv_glflashpal, 35}, - //{IT_STRING | IT_CVAR, NULL, "Min Shader Brightness", &cv_glsecbright, 40}, {IT_STRING | IT_CVAR, NULL, "Texture Quality", &cv_gltexturedepth, 45}, {IT_STRING | IT_CVAR, NULL, "Texture Filter", &cv_glfiltermode, 50}, diff --git a/src/st_stuff.c b/src/st_stuff.c index 6dc7111f3..64bc4dc00 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -180,7 +180,7 @@ static void ST_doPaletteStuff(void) INT32 palette = 0; #ifdef HWRENDER - if (rendermode == render_opengl && !HWR_PalRenderFlashpal()) + if (rendermode == render_opengl && !HWR_ShouldUsePaletteRendering()) return; #endif diff --git a/src/v_paldeltas.h b/src/v_paldeltas.h new file mode 100644 index 000000000..30fc86dfc --- /dev/null +++ b/src/v_paldeltas.h @@ -0,0 +1,525 @@ +#ifndef H_PALDELTA +#define H_PALDELTA + +// those are the differences in palette indices between the main srb2 playpal and its white and nuke subpalettes +// this is probably not the best way of doing any of this, but it works lol + +static const INT16 pPaletteDeltaFlash[256][3] = { + { 6, 6, 6}, + { 12, 12, 12}, + { 18, 18, 18}, + { 24, 24, 24}, + { 30, 30, 30}, + { 36, 36, 36}, + { 42, 42, 42}, + { 48, 48, 48}, + { 54, 54, 54}, + { 60, 60, 60}, + { 66, 66, 66}, + { 72, 72, 72}, + { 78, 78, 78}, + { 84, 84, 84}, + { 90, 90, 90}, + { 95, 95, 95}, + { 101, 101, 101}, + { 107, 107, 107}, + { 113, 113, 113}, + { 119, 119, 119}, + { 125, 125, 125}, + { 131, 131, 131}, + { 137, 137, 137}, + { 143, 143, 143}, + { 149, 149, 149}, + { 155, 155, 155}, + { 161, 161, 161}, + { 167, 167, 167}, + { 173, 173, 173}, + { 179, 179, 179}, + { 185, 185, 185}, + { 191, 191, 191}, + { 48, 66, 84}, + { 54, 71, 89}, + { 60, 77, 95}, + { 66, 83, 100}, + { 72, 88, 105}, + { 79, 94, 111}, + { 85, 99, 117}, + { 91, 105, 123}, + { 96, 111, 129}, + { 102, 117, 135}, + { 108, 123, 141}, + { 114, 128, 146}, + { 120, 134, 152}, + { 127, 140, 158}, + { 133, 145, 163}, + { 140, 152, 170}, + { 48, 98, 134}, + { 57, 104, 137}, + { 63, 107, 140}, + { 69, 110, 143}, + { 75, 116, 146}, + { 84, 119, 149}, + { 90, 125, 152}, + { 95, 128, 155}, + { 101, 131, 158}, + { 110, 137, 161}, + { 119, 140, 164}, + { 128, 143, 167}, + { 134, 149, 170}, + { 143, 155, 173}, + { 152, 158, 176}, + { 158, 164, 179}, + { 0, 15, 24}, + { 0, 21, 33}, + { 0, 27, 42}, + { 0, 33, 51}, + { 0, 36, 57}, + { 0, 42, 66}, + { 0, 48, 75}, + { 0, 51, 81}, + { 0, 57, 93}, + { 6, 63, 98}, + { 12, 69, 104}, + { 18, 75, 110}, + { 24, 81, 116}, + { 30, 87, 122}, + { 36, 93, 128}, + { 39, 95, 131}, + { 0, 12, 26}, + { 0, 26, 52}, + { 0, 39, 78}, + { 0, 52, 102}, + { 0, 65, 127}, + { 0, 78, 150}, + { 0, 91, 172}, + { 0, 102, 191}, + { 9, 108, 191}, + { 19, 114, 191}, + { 29, 120, 191}, + { 39, 127, 191}, + { 48, 133, 191}, + { 58, 139, 191}, + { 68, 145, 191}, + { 78, 150, 191}, + { 0, 0, 12}, + { 0, 0, 36}, + { 0, 0, 60}, + { 0, 0, 84}, + { 0, 0, 107}, + { 0, 0, 131}, + { 0, 0, 155}, + { 0, 0, 179}, + { 0, 0, 191}, + { 36, 36, 191}, + { 60, 60, 191}, + { 84, 84, 191}, + { 107, 107, 191}, + { 131, 131, 191}, + { 155, 155, 191}, + { 179, 179, 191}, + { 0, 0, 104}, + { 15, 27, 125}, + { 30, 51, 140}, + { 45, 75, 155}, + { 60, 98, 167}, + { 75, 122, 176}, + { 90, 140, 185}, + { 104, 158, 191}, + { 0, 0, 0}, + { 0, 24, 24}, + { 0, 48, 48}, + { 0, 72, 72}, + { 0, 95, 95}, + { 0, 119, 119}, + { 0, 143, 143}, + { 0, 167, 167}, + { 0, 191, 191}, + { 12, 191, 191}, + { 24, 191, 191}, + { 36, 191, 191}, + { 48, 191, 191}, + { 60, 191, 191}, + { 72, 191, 191}, + { 84, 191, 191}, + { 95, 191, 191}, + { 107, 191, 191}, + { 119, 191, 191}, + { 131, 191, 191}, + { 143, 191, 191}, + { 155, 191, 191}, + { 167, 191, 191}, + { 179, 191, 191}, + { 0, 54, 54}, + { 9, 69, 69}, + { 18, 84, 84}, + { 27, 98, 98}, + { 39, 110, 110}, + { 48, 122, 122}, + { 57, 131, 131}, + { 66, 143, 143}, + { 85, 156, 191}, + { 91, 161, 191}, + { 96, 166, 191}, + { 102, 172, 191}, + { 108, 177, 191}, + { 114, 182, 191}, + { 120, 187, 191}, + { 127, 191, 191}, + { 101, 0, 131}, + { 106, 11, 134}, + { 111, 23, 138}, + { 117, 35, 142}, + { 123, 47, 145}, + { 129, 59, 149}, + { 134, 71, 153}, + { 140, 83, 157}, + { 145, 95, 160}, + { 151, 106, 164}, + { 157, 118, 168}, + { 162, 130, 172}, + { 168, 142, 175}, + { 173, 154, 179}, + { 179, 166, 183}, + { 185, 179, 187}, + { 24, 0, 65}, + { 42, 20, 80}, + { 61, 41, 95}, + { 79, 61, 110}, + { 97, 82, 124}, + { 115, 101, 139}, + { 135, 123, 154}, + { 153, 143, 169}, + { 191, 0, 191}, + { 191, 24, 191}, + { 191, 48, 191}, + { 191, 72, 191}, + { 191, 95, 191}, + { 191, 119, 191}, + { 191, 143, 191}, + { 191, 167, 191}, + { 0, 107, 0}, + { 0, 191, 0}, + { 24, 191, 24}, + { 48, 191, 48}, + { 72, 191, 72}, + { 95, 191, 95}, + { 119, 191, 119}, + { 143, 191, 143}, + { 16, 16, 9}, + { 44, 44, 22}, + { 73, 73, 36}, + { 101, 101, 51}, + { 127, 127, 66}, + { 142, 142, 93}, + { 156, 156, 121}, + { 170, 170, 151}, + { 31, 10, 0}, + { 48, 15, 0}, + { 64, 21, 0}, + { 79, 25, 0}, + { 95, 30, 0}, + { 111, 36, 0}, + { 127, 41, 0}, + { 143, 48, 0}, + { 149, 73, 24}, + { 155, 84, 48}, + { 161, 101, 72}, + { 167, 119, 95}, + { 191, 48, 48}, + { 191, 95, 95}, + { 191, 119, 119}, + { 191, 143, 143}, + { 18, 18, 0}, + { 42, 42, 0}, + { 61, 61, 0}, + { 86, 86, 0}, + { 104, 104, 0}, + { 129, 129, 0}, + { 154, 154, 0}, + { 172, 172, 0}, + { 191, 191, 0}, + { 191, 191, 18}, + { 191, 191, 36}, + { 191, 191, 55}, + { 191, 191, 74}, + { 191, 191, 92}, + { 191, 191, 110}, + { 191, 191, 129}, + { 191, 191, 131}, + { 191, 191, 143}, + { 191, 191, 149}, + { 191, 191, 161}, + { 191, 191, 167}, + { 191, 191, 179}, + { 191, 191, 185}, + { 191, 0, 0}, + { 36, 95, 36}, + { 54, 107, 54}, + { 72, 119, 72}, + { 90, 131, 90}, + { 107, 143, 107}, + { 125, 155, 125}, + { 143, 167, 143}, + { 161, 179, 161} +}; + +static const INT16 pPaletteDeltaNuke[256][3] = { + { 6,-133,-133}, + { 12,-125,-125}, + { 18,-117,-117}, + { 24,-109,-109}, + { 30,-101,-101}, + { 36, -93, -93}, + { 42, -85, -85}, + { 48, -77, -77}, + { 54, -69, -69}, + { 60, -61, -61}, + { 66, -53, -53}, + { 72, -45, -45}, + { 78, -37, -37}, + { 84, -29, -29}, + { 90, -21, -21}, + { 95, -14, -14}, + { 101, -6, -6}, + { 107, 2, 2}, + { 113, 10, 10}, + { 119, 18, 18}, + { 125, 26, 26}, + { 131, 34, 34}, + { 137, 42, 42}, + { 143, 50, 50}, + { 149, 58, 58}, + { 155, 66, 66}, + { 161, 74, 74}, + { 167, 82, 82}, + { 173, 90, 90}, + { 179, 98, 98}, + { 185, 106, 106}, + { 191, 113, 113}, + { 48, -53, -29}, + { 54, -46, -22}, + { 60, -38, -14}, + { 66, -30, -7}, + { 72, -23, 0}, + { 79, -15, 8}, + { 85, -8, 16}, + { 91, -1, 23}, + { 96, 7, 31}, + { 102, 15, 39}, + { 108, 23, 47}, + { 114, 30, 54}, + { 120, 38, 62}, + { 127, 46, 70}, + { 133, 53, 77}, + { 140, 62, 86}, + { 48, -10, 38}, + { 57, -2, 42}, + { 63, 2, 46}, + { 69, 6, 50}, + { 75, 14, 54}, + { 84, 18, 58}, + { 90, 26, 62}, + { 95, 30, 66}, + { 101, 34, 70}, + { 110, 42, 74}, + { 119, 46, 78}, + { 128, 50, 82}, + { 134, 58, 86}, + { 143, 66, 90}, + { 152, 70, 94}, + { 158, 78, 98}, + { 0,-121,-109}, + { 0,-113, -97}, + { 0,-105, -85}, + { 0, -97, -73}, + { 0, -93, -65}, + { 0, -85, -53}, + { 0, -77, -41}, + { 0, -73, -33}, + { 0, -65, -17}, + { 6, -57, -10}, + { 12, -49, -2}, + { 18, -41, 6}, + { 24, -33, 14}, + { 30, -25, 22}, + { 36, -17, 30}, + { 39, -14, 34}, + { 0,-124,-106}, + { 0,-106, -71}, + { 0, -89, -37}, + { 0, -71, -4}, + { 0, -54, 28}, + { 0, -37, 59}, + { 0, -20, 88}, + { 0, -4, 113}, + { 9, 4, 113}, + { 19, 12, 113}, + { 29, 20, 113}, + { 39, 28, 113}, + { 48, 36, 113}, + { 58, 44, 113}, + { 68, 52, 113}, + { 78, 59, 113}, + { 0,-141,-125}, + { 0,-141, -93}, + { 0,-141, -61}, + { 0,-141, -29}, + { 0,-141, 2}, + { 0,-141, 34}, + { 0,-141, 66}, + { 0,-141, 98}, + { 0,-141, 113}, + { 36, -93, 113}, + { 60, -61, 113}, + { 84, -29, 113}, + { 107, 2, 113}, + { 131, 34, 113}, + { 155, 66, 113}, + { 179, 98, 113}, + { 0,-141, -2}, + { 15,-105, 26}, + { 30, -73, 46}, + { 45, -41, 66}, + { 60, -10, 82}, + { 75, 22, 94}, + { 90, 46, 106}, + { 104, 70, 113}, + { 0,-141,-141}, + { 0,-109,-109}, + { 0, -77, -77}, + { 0, -45, -45}, + { 0, -14, -14}, + { 0, 18, 18}, + { 0, 50, 50}, + { 0, 82, 82}, + { 0, 113, 113}, + { 12, 113, 113}, + { 24, 113, 113}, + { 36, 113, 113}, + { 48, 113, 113}, + { 60, 113, 113}, + { 72, 113, 113}, + { 84, 113, 113}, + { 95, 113, 113}, + { 107, 113, 113}, + { 119, 113, 113}, + { 131, 113, 113}, + { 143, 113, 113}, + { 155, 113, 113}, + { 167, 113, 113}, + { 179, 113, 113}, + { 0, -69, -69}, + { 9, -49, -49}, + { 18, -29, -29}, + { 27, -10, -10}, + { 39, 6, 6}, + { 48, 22, 22}, + { 57, 34, 34}, + { 66, 50, 50}, + { 85, 67, 113}, + { 91, 74, 113}, + { 96, 81, 113}, + { 102, 88, 113}, + { 108, 95, 113}, + { 114, 102, 113}, + { 120, 108, 113}, + { 127, 113, 113}, + { 101,-141, 34}, + { 106,-126, 38}, + { 111,-110, 43}, + { 117, -94, 48}, + { 123, -78, 53}, + { 129, -62, 58}, + { 134, -46, 63}, + { 140, -30, 68}, + { 145, -14, 73}, + { 151, 1, 78}, + { 157, 17, 83}, + { 162, 33, 88}, + { 168, 49, 93}, + { 173, 65, 98}, + { 179, 81, 103}, + { 185, 98, 109}, + { 24,-141, -54}, + { 42,-114, -34}, + { 61, -86, -14}, + { 79, -59, 6}, + { 97, -32, 25}, + { 115, -6, 45}, + { 135, 23, 65}, + { 153, 50, 84}, + { 191,-141, 113}, + { 191,-109, 113}, + { 191, -77, 113}, + { 191, -45, 113}, + { 191, -14, 113}, + { 191, 18, 113}, + { 191, 50, 113}, + { 191, 82, 113}, + { 0, 2,-141}, + { 0, 113,-141}, + { 24, 113,-109}, + { 48, 113, -77}, + { 72, 113, -45}, + { 95, 113, -14}, + { 119, 113, 18}, + { 143, 113, 50}, + { 16,-119,-129}, + { 44, -82,-111}, + { 73, -43, -92}, + { 101, -6, -73}, + { 127, 29, -53}, + { 142, 48, -17}, + { 156, 67, 21}, + { 170, 86, 61}, + { 31,-127,-141}, + { 48,-121,-141}, + { 64,-113,-141}, + { 79,-107,-141}, + { 95,-100,-141}, + { 111, -93,-141}, + { 127, -86,-141}, + { 143, -77,-141}, + { 149, -43,-109}, + { 155, -29, -77}, + { 161, -6, -45}, + { 167, 18, -14}, + { 191, -77, -77}, + { 191, -14, -14}, + { 191, 18, 18}, + { 191, 50, 50}, + { 18,-117,-141}, + { 42, -84,-141}, + { 61, -59,-141}, + { 86, -26,-141}, + { 104, -2,-141}, + { 129, 31,-141}, + { 154, 64,-141}, + { 172, 89,-141}, + { 191, 113,-141}, + { 191, 113,-117}, + { 191, 113, -92}, + { 191, 113, -67}, + { 191, 113, -42}, + { 191, 113, -18}, + { 191, 113, 6}, + { 191, 113, 31}, + { 191, 113, 34}, + { 191, 113, 50}, + { 191, 113, 58}, + { 191, 113, 74}, + { 191, 113, 82}, + { 191, 113, 98}, + { 191, 113, 106}, + { 191,-141,-141}, + { 36, -14, -93}, + { 54, 2, -69}, + { 72, 18, -45}, + { 90, 34, -21}, + { 107, 50, 2}, + { 125, 66, 26}, + { 143, 82, 50}, + { 161, 98, 74} +}; + +#endif diff --git a/src/v_video.c b/src/v_video.c index 2aa680153..940dd190d 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -91,97 +91,7 @@ consvar_t cv_menucaps = {"menucaps", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NUL // local copy of the palette for V_GetColor() RGBA_t *pLocalPalette = NULL; RGBA_t *pGammaCorrectedPalette = NULL; - -// huge ass array les gooooooo! -// this is basically the white flashpal byte for byte from our main palette lmao -static RGBA_t pFallbackFlashPal[] = { - {.s={253, 253, 253, 255}}, {.s={251, 251, 251, 255}}, {.s={249, 249, 249, 255}}, - {.s={247, 247, 247, 255}}, {.s={245, 245, 245, 255}}, {.s={243, 243, 243, 255}}, - {.s={241, 241, 241, 255}}, {.s={239, 239, 239, 255}}, {.s={237, 237, 237, 255}}, - {.s={235, 235, 235, 255}}, {.s={233, 233, 233, 255}}, {.s={231, 231, 231, 255}}, - {.s={229, 229, 229, 255}}, {.s={227, 227, 227, 255}}, {.s={225, 225, 225, 255}}, - {.s={223, 223, 223, 255}}, {.s={221, 221, 221, 255}}, {.s={219, 219, 219, 255}}, - {.s={217, 217, 217, 255}}, {.s={215, 215, 215, 255}}, {.s={213, 213, 213, 255}}, - {.s={211, 211, 211, 255}}, {.s={209, 209, 209, 255}}, {.s={207, 207, 207, 255}}, - {.s={205, 205, 205, 255}}, {.s={203, 203, 203, 255}}, {.s={201, 201, 201, 255}}, - {.s={199, 199, 199, 255}}, {.s={197, 197, 197, 255}}, {.s={195, 195, 195, 255}}, - {.s={193, 193, 193, 255}}, {.s={192, 192, 192, 255}}, {.s={239, 233, 227, 255}}, - {.s={237, 231, 225, 255}}, {.s={235, 229, 223, 255}}, {.s={233, 227, 221, 255}}, - {.s={231, 225, 219, 255}}, {.s={229, 223, 217, 255}}, {.s={227, 221, 215, 255}}, - {.s={225, 220, 214, 255}}, {.s={223, 218, 212, 255}}, {.s={220, 216, 210, 255}}, - {.s={218, 214, 208, 255}}, {.s={216, 212, 206, 255}}, {.s={214, 210, 204, 255}}, - {.s={212, 208, 202, 255}}, {.s={210, 206, 200, 255}}, {.s={208, 204, 198, 255}}, - {.s={239, 222, 210, 255}}, {.s={236, 220, 209, 255}}, {.s={234, 219, 208, 255}}, - {.s={232, 218, 207, 255}}, {.s={230, 216, 206, 255}}, {.s={227, 215, 205, 255}}, - {.s={225, 213, 204, 255}}, {.s={223, 212, 203, 255}}, {.s={221, 211, 202, 255}}, - {.s={218, 209, 201, 255}}, {.s={215, 208, 200, 255}}, {.s={212, 207, 199, 255}}, - {.s={210, 205, 198, 255}}, {.s={207, 203, 197, 255}}, {.s={204, 202, 196, 255}}, - {.s={202, 200, 195, 255}}, {.s={255, 250, 247, 255}}, {.s={255, 248, 244, 255}}, - {.s={255, 246, 241, 255}}, {.s={255, 244, 238, 255}}, {.s={255, 243, 236, 255}}, - {.s={255, 241, 233, 255}}, {.s={255, 239, 230, 255}}, {.s={255, 238, 228, 255}}, - {.s={255, 236, 224, 255}}, {.s={253, 234, 222, 255}}, {.s={251, 232, 220, 255}}, - {.s={249, 230, 218, 255}}, {.s={247, 228, 216, 255}}, {.s={245, 226, 214, 255}}, - {.s={243, 224, 212, 255}}, {.s={242, 223, 211, 255}}, {.s={255, 250, 246, 255}}, - {.s={255, 246, 237, 255}}, {.s={255, 242, 229, 255}}, {.s={255, 237, 220, 255}}, - {.s={255, 233, 213, 255}}, {.s={255, 229, 205, 255}}, {.s={255, 225, 198, 255}}, - {.s={255, 220, 192, 255}}, {.s={252, 218, 192, 255}}, {.s={248, 216, 192, 255}}, - {.s={245, 214, 192, 255}}, {.s={242, 213, 192, 255}}, {.s={238, 211, 192, 255}}, - {.s={235, 209, 192, 255}}, {.s={232, 207, 192, 255}}, {.s={229, 205, 192, 255}}, - {.s={255, 255, 251, 255}}, {.s={255, 255, 243, 255}}, {.s={255, 255, 235, 255}}, - {.s={255, 255, 227, 255}}, {.s={255, 255, 219, 255}}, {.s={255, 255, 211, 255}}, - {.s={255, 255, 203, 255}}, {.s={255, 255, 195, 255}}, {.s={255, 255, 192, 255}}, - {.s={243, 243, 192, 255}}, {.s={235, 235, 192, 255}}, {.s={227, 227, 192, 255}}, - {.s={219, 219, 192, 255}}, {.s={211, 211, 192, 255}}, {.s={203, 203, 192, 255}}, - {.s={195, 195, 192, 255}}, {.s={255, 255, 220, 255}}, {.s={250, 246, 213, 255}}, - {.s={245, 238, 208, 255}}, {.s={240, 230, 203, 255}}, {.s={235, 222, 199, 255}}, - {.s={230, 214, 196, 255}}, {.s={225, 208, 193, 255}}, {.s={220, 202, 192, 255}}, - {.s={255, 255, 255, 255}}, {.s={255, 247, 247, 255}}, {.s={255, 239, 239, 255}}, - {.s={255, 231, 231, 255}}, {.s={255, 223, 223, 255}}, {.s={255, 215, 215, 255}}, - {.s={255, 207, 207, 255}}, {.s={255, 199, 199, 255}}, {.s={255, 192, 192, 255}}, - {.s={251, 192, 192, 255}}, {.s={247, 192, 192, 255}}, {.s={243, 192, 192, 255}}, - {.s={239, 192, 192, 255}}, {.s={235, 192, 192, 255}}, {.s={231, 192, 192, 255}}, - {.s={227, 192, 192, 255}}, {.s={223, 192, 192, 255}}, {.s={219, 192, 192, 255}}, - {.s={215, 192, 192, 255}}, {.s={211, 192, 192, 255}}, {.s={207, 192, 192, 255}}, - {.s={203, 192, 192, 255}}, {.s={199, 192, 192, 255}}, {.s={195, 192, 192, 255}}, - {.s={255, 237, 237, 255}}, {.s={252, 232, 232, 255}}, {.s={249, 227, 227, 255}}, - {.s={246, 222, 222, 255}}, {.s={242, 218, 218, 255}}, {.s={239, 214, 214, 255}}, - {.s={236, 211, 211, 255}}, {.s={233, 207, 207, 255}}, {.s={227, 203, 192, 255}}, - {.s={225, 201, 192, 255}}, {.s={223, 199, 192, 255}}, {.s={220, 198, 192, 255}}, - {.s={218, 196, 192, 255}}, {.s={216, 194, 192, 255}}, {.s={214, 193, 192, 255}}, - {.s={213, 192, 192, 255}}, {.s={221, 255, 211, 255}}, {.s={219, 251, 210, 255}}, - {.s={217, 247, 209, 255}}, {.s={215, 243, 208, 255}}, {.s={214, 239, 206, 255}}, - {.s={212, 235, 205, 255}}, {.s={210, 231, 204, 255}}, {.s={208, 227, 203, 255}}, - {.s={206, 223, 201, 255}}, {.s={205, 219, 200, 255}}, {.s={203, 215, 199, 255}}, - {.s={201, 211, 198, 255}}, {.s={199, 207, 196, 255}}, {.s={197, 203, 195, 255}}, - {.s={195, 199, 194, 255}}, {.s={193, 195, 192, 255}}, {.s={246, 255, 233, 255}}, - {.s={241, 248, 228, 255}}, {.s={234, 241, 223, 255}}, {.s={228, 234, 218, 255}}, - {.s={222, 228, 213, 255}}, {.s={216, 221, 208, 255}}, {.s={210, 214, 203, 255}}, - {.s={204, 207, 199, 255}}, {.s={192, 255, 192, 255}}, {.s={192, 247, 192, 255}}, - {.s={192, 239, 192, 255}}, {.s={192, 231, 192, 255}}, {.s={192, 223, 192, 255}}, - {.s={192, 215, 192, 255}}, {.s={192, 207, 192, 255}}, {.s={192, 199, 192, 255}}, - {.s={255, 219, 255, 255}}, {.s={255, 192, 255, 255}}, {.s={247, 192, 247, 255}}, - {.s={239, 192, 239, 255}}, {.s={231, 192, 231, 255}}, {.s={223, 192, 223, 255}}, - {.s={215, 192, 215, 255}}, {.s={207, 192, 207, 255}}, {.s={249, 249, 252, 255}}, - {.s={240, 240, 247, 255}}, {.s={230, 230, 242, 255}}, {.s={221, 221, 238, 255}}, - {.s={212, 212, 233, 255}}, {.s={208, 208, 224, 255}}, {.s={203, 203, 214, 255}}, - {.s={198, 198, 204, 255}}, {.s={244, 251, 255, 255}}, {.s={239, 250, 255, 255}}, - {.s={234, 248, 255, 255}}, {.s={228, 246, 255, 255}}, {.s={223, 244, 255, 255}}, - {.s={218, 243, 255, 255}}, {.s={213, 241, 255, 255}}, {.s={207, 239, 255, 255}}, - {.s={205, 230, 247, 255}}, {.s={203, 227, 239, 255}}, {.s={201, 221, 231, 255}}, - {.s={199, 215, 223, 255}}, {.s={192, 239, 239, 255}}, {.s={192, 223, 223, 255}}, - {.s={192, 215, 215, 255}}, {.s={192, 207, 207, 255}}, {.s={249, 249, 255, 255}}, - {.s={240, 240, 255, 255}}, {.s={234, 234, 255, 255}}, {.s={226, 226, 255, 255}}, - {.s={220, 220, 255, 255}}, {.s={212, 212, 255, 255}}, {.s={204, 204, 255, 255}}, - {.s={197, 197, 255, 255}}, {.s={192, 192, 255, 255}}, {.s={192, 192, 249, 255}}, - {.s={192, 192, 242, 255}}, {.s={192, 192, 236, 255}}, {.s={192, 192, 230, 255}}, - {.s={192, 192, 224, 255}}, {.s={192, 192, 218, 255}}, {.s={192, 192, 212, 255}}, - {.s={192, 192, 211, 255}}, {.s={192, 192, 207, 255}}, {.s={192, 192, 205, 255}}, - {.s={192, 192, 201, 255}}, {.s={192, 192, 199, 255}}, {.s={192, 192, 195, 255}}, - {.s={192, 192, 193, 255}}, {.s={192, 255, 255, 255}}, {.s={243, 223, 243, 255}}, - {.s={237, 219, 237, 255}}, {.s={231, 215, 231, 255}}, {.s={225, 211, 225, 255}}, - {.s={219, 207, 219, 255}}, {.s={213, 203, 213, 255}}, {.s={207, 199, 207, 255}}, - {.s={201, 195, 201, 255}} -}; +static RGBA_t *pFallbackFlashPal = NULL; static size_t currentPaletteSize; @@ -500,6 +410,58 @@ UINT32 V_GammaCorrect(UINT32 input, double power) return result.rgba; } +#include "v_paldeltas.h" +// remaps a palette with given "deltas" +// this is used with premade deltas between the srb2 palette and its both flashpals +// so we may approximate generate our own, should the current palette miss them +static void ApplyPaletteDelta(const RGBA_t *pal_in, RGBA_t *pal_out, const INT16 pal_delta[][3]) +{ + size_t i; + + for (i = 0; i < 256; i++) + { + INT16 r = (INT16)pal_in[i].s.red + pal_delta[i][0]; + INT16 g = (INT16)pal_in[i].s.green + pal_delta[i][1]; + INT16 b = (INT16)pal_in[i].s.blue + pal_delta[i][2]; + pal_out[i].s.red = (UINT8)CLAMP(r, 0 , 255); + pal_out[i].s.green = (UINT8)CLAMP(g, 0 , 255); + pal_out[i].s.blue = (UINT8)CLAMP(b, 0 , 255); + pal_out[i].s.alpha = 0xFF; // pal_in[i].s.alpha + } +} + +static void GenerateFlashPalettes(void) +{ + size_t i, palsize; + RGBA_t *pFlashPalGammaCorrectedPalette = NULL; + + // generate flashpalettes if the current palette does not provide any subpalettes + if (currentPaletteSize >= (14 * (256 * 3))) // 14 palettes are in playpal + return; + + palsize = (2*256); + + pFallbackFlashPal = Z_Malloc(sizeof(*pFallbackFlashPal)*palsize, PU_STATIC, NULL); + pFlashPalGammaCorrectedPalette = Z_Malloc(sizeof (*pFlashPalGammaCorrectedPalette)*palsize, PU_STATIC, NULL); + + // apply our deltas to the palettes to get the white and red "flashes" + ApplyPaletteDelta(pLocalPalette, pFallbackFlashPal, pPaletteDeltaFlash); + ApplyPaletteDelta(pLocalPalette, pFallbackFlashPal+256, pPaletteDeltaNuke); + + // apply colour and gamma correction if needed + if (Cubeapply) + { + for (i = 0; i < palsize; i++) + { + pFlashPalGammaCorrectedPalette[i].rgba = V_GammaDecode(pFallbackFlashPal[i].rgba); + V_CubeApply(&pFlashPalGammaCorrectedPalette[i]); + pFallbackFlashPal[i].rgba = V_GammaEncode(pFlashPalGammaCorrectedPalette[i].rgba); + } + } + + Z_Free(pFlashPalGammaCorrectedPalette); +} + // keep a copy of the palette so that we can get the RGB value for a color index at any time. static void LoadPalette(const char *lumpname) { @@ -519,6 +481,8 @@ static void LoadPalette(const char *lumpname) Z_Free(pLocalPalette); Z_Free(pGammaCorrectedPalette); + Z_Free(pFallbackFlashPal); + pFallbackFlashPal = NULL; pLocalPalette = Z_Malloc(sizeof (*pLocalPalette)*palsize, PU_STATIC, NULL); pGammaCorrectedPalette = Z_Malloc(sizeof (*pGammaCorrectedPalette)*palsize, PU_STATIC, NULL); @@ -538,12 +502,19 @@ static void LoadPalette(const char *lumpname) pLocalPalette[i].s.alpha = 0xFF; pGammaCorrectedPalette[i].rgba = V_GammaDecode(pLocalPalette[i].rgba); + } - if (!Cubeapply) - continue; + GenerateFlashPalettes(); - V_CubeApply(&pGammaCorrectedPalette[i]); - pLocalPalette[i].rgba = V_GammaEncode(pGammaCorrectedPalette[i].rgba); + // gotta apply any colour and gamma adjustments afterwards + // so we dont double apply it to the generated flashpals + if (Cubeapply) + { + for (i = 0; i < palsize; i++) + { + V_CubeApply(&pGammaCorrectedPalette[i]); + pLocalPalette[i].rgba = V_GammaEncode(pGammaCorrectedPalette[i].rgba); + } } } @@ -646,25 +617,32 @@ void V_SetPalette(INT32 palettenum) if (palettenum == 0) { palettenum = cv_palettenum.value; - - if (palettenum * 256U > (currentPaletteSize - 256) / 3) - { - CONS_Alert(CONS_WARNING, "cv_palettenum %d out of range\n", palettenum); - palettenum = 0; - } } } - // if the palettenum goes beyond our current palette, then just fallback to the white flash pal - // our srb2 palette mostly just contains that as subpalettes, so everything uses this - // and makes it a good fallback case - // otherwise we will throw random garbage to the renderer which calls memcpy on it - // which is not really a good thing lol - // we probably could just memcpy from localpalette, but i dont trust -file nor autoload so - if (palettenum * 256U > (currentPaletteSize - 256) / 3) + // in many cases custom palettes do not provide the needed subpalettes for flashpals to work + // before this would mean the renderer gets passed random data out of allocated memory bounds + // which was not very cool :chonkbuncle: + // gladly 2.1 only actually has 2 different subpalettes + // one for "white flash" and one red/pinkish one for nuke + // since we checked the palette earlier we should have generated those ourselves + if (((size_t)palettenum >= currentPaletteSize / (256 * 3))) { CONS_Debug(DBG_RENDER, "palettenum %d out of range\n", palettenum); - pal = pFallbackFlashPal; + + // if for some reason we did not generate flashpals + // just fall back to the main palette i guess? + if (pFallbackFlashPal != NULL) + { + if (palettenum == PAL_NUKE) + pal = &pFallbackFlashPal[256]; + else + pal = pFallbackFlashPal; + } + else + { + pal = pLocalPalette; + } } else { From 6430150b63b9503e7e6cc97b3af13ec5125edbd5 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 2 Mar 2026 17:53:16 +0100 Subject: [PATCH 51/54] fix parts of png info text for screenshots not being null terminated in some cases --- src/m_misc.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/m_misc.c b/src/m_misc.c index ee17e2098..97777a979 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -788,10 +788,10 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png else snprintf(locationtxt, 40, "Unknown"); - memset(png_infotext,0x00,sizeof (png_infotext)); + memset(png_infotext, 0x00, sizeof(png_infotext)); for (i = 0; i < SRB2PNGTXT; i++) - png_infotext[i].key = keytxt[i]; + png_infotext[i].key = keytxt[i]; png_infotext[0].text = titletxt; if (movie) @@ -804,9 +804,15 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png png_infotext[5].text = locationtxt; png_infotext[6].text = interfacetxt; png_infotext[7].text = rendermodetxt; - png_infotext[8].text = strncpy(ctrevision, comprevision, sizeof(ctrevision)-1); - png_infotext[9].text = strncpy(ctdate, compdate, sizeof(ctdate)-1); - png_infotext[10].text = strncpy(cttime, comptime, sizeof(cttime)-1); + strncpy(ctrevision, comprevision, sizeof(ctrevision)-1); + ctrevision[sizeof(ctrevision)-1] = '\0'; + png_infotext[8].text = ctrevision; + strncpy(ctdate, compdate, sizeof(ctdate)-1); + ctdate[sizeof(ctdate)-1] = '\0'; + png_infotext[9].text = ctdate; + strncpy(cttime, comptime, sizeof(cttime)-1); + cttime[sizeof(cttime)-1] = '\0'; + png_infotext[10].text = cttime; png_set_text(png_ptr, png_info_ptr, png_infotext, SRB2PNGTXT); #undef SRB2PNGTXT @@ -1564,6 +1570,7 @@ char *M_GetToken(const char *inputString) { startPos = endPos; } + if (stringToUse == NULL) return NULL; @@ -1634,7 +1641,8 @@ char *M_GetToken(const char *inputString) } // If the end of the string is reached, no token is to be read - if (startPos == stringLength) { + if (startPos == stringLength) + { endPos = stringLength; return NULL; } @@ -1644,7 +1652,7 @@ char *M_GetToken(const char *inputString) || stringToUse[startPos] == '}') { endPos = startPos + 1; - texturesToken = (char *)Z_Malloc(2*sizeof(char),PU_STATIC,NULL); + texturesToken = (char *)Z_Malloc(2*sizeof(char), PU_STATIC, NULL); texturesToken[0] = stringToUse[startPos]; texturesToken[1] = '\0'; return texturesToken; @@ -1855,8 +1863,10 @@ int M_PathParts(const char *path) int n; const char *p; const char *t; + if (path == NULL) return 0; + for (n = 0, p = path ;; ++n) { t = p; @@ -1869,6 +1879,7 @@ int M_PathParts(const char *path) break; } } + return n; } @@ -1911,7 +1922,9 @@ void M_MkdirEachUntil(const char *cpath, int start, int end, int mode) if (!( p = strchr(p, PATHSEP[0]) )) return; } + p += strspn(p, PATHSEP); + for (;;) { if (end > 0 && !--end) From 9ee535066e8aa44a4fc07d0ebb21ac809ca33642 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 3 Mar 2026 02:22:02 +0100 Subject: [PATCH 52/54] =?UTF-8?q?OpenGL:=20initialize=20all=20FSurfaceInfo?= =?UTF-8?q?=C2=B4s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit seen this a bunch of times now that occasionally something tries to access uninit values from a surface info since those are really small we just always init them now --- src/hardware/hw_draw.c | 14 +++++++------- src/hardware/hw_main.cpp | 22 ++++++++++------------ src/hardware/hw_md2.c | 5 ++--- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 4797f21de..3602cef1b 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -222,7 +222,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p if (alphalevel) { - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; switch (alphalevel) @@ -385,7 +385,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, // clip it since it is used for bunny scroll in doom I if (alphalevel) { - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; switch (alphalevel) @@ -490,7 +490,7 @@ void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum) void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) { FOutVector v[4]; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; FBITFIELD poly_flags = PF_NoTexture|PF_Modulated|PF_NoDepthTest; v[0].x = v[3].x = -1.0f; @@ -543,7 +543,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) void HWR_DrawConsoleBack(UINT32 color, INT32 height) { FOutVector v[4]; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; // setup some neat-o translucency effect if (!height) //cool hack 0 height is full height @@ -598,7 +598,7 @@ void HWR_drawAMline(const fline_t *fl, INT32 color) void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) { FOutVector v[4]; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; float fx, fy, fw, fh, fwait = 0; RGBA_t *palette; @@ -702,7 +702,7 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options) { FOutVector v[4]; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; float fx, fy, fw, fh; if (w < 0 || h < 0) @@ -820,7 +820,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) { FOutVector v[4]; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; float fx, fy, fw, fh; if (w < 0 || h < 0) diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index e6ce072cf..bf11f0c7c 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -550,7 +550,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t // Render a floor or ceiling convex polygon static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap) { - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; FOutVector *v3d; polyvertex_t *pv; pslope_t *slope = NULL; @@ -1375,7 +1375,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom extracolormap_t *colormap = gl_frontsector->extra_colormap; lightnum = HWR_CalcWallLight(lightnum, gl_curline, colormap); - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; Surf.PolyColor.s.alpha = 255; @@ -2674,7 +2674,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, float scrollx = 0.0f, scrolly = 0.0f; float anglef = 0.0f, cosangf = 0.0f, sinangf = 0.0f; angle_t angle = 0; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; fixed_t tempxsow, tempytow; size_t nrPlaneVerts; @@ -2841,9 +2841,8 @@ static void HWR_AddPolyObjectPlanes(void) light = R_GetPlaneLight(gl_frontsector, polyobjsector->floorheight, true); if (po_ptrs[i]->translucency > 0) { - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; FBITFIELD blendmode; - memset(&Surf, 0x00, sizeof(Surf)); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight, (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap)); @@ -2864,9 +2863,8 @@ static void HWR_AddPolyObjectPlanes(void) light = R_GetPlaneLight(gl_frontsector, polyobjsector->ceilingheight, true); if (po_ptrs[i]->translucency > 0) { - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; FBITFIELD blendmode; - memset(&Surf, 0x00, sizeof(Surf)); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight, (light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap)); @@ -3418,7 +3416,7 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t { float this_scale = 1.0f; FOutVector swallVerts[4]; - FSurfaceInfo sSurf; + FSurfaceInfo sSurf = {}; FBITFIELD blendmode = 0; fixed_t floorheight, mobjfloor; pslope_t *floorslope; @@ -3654,7 +3652,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) FOutVector baseWallVerts[4]; // This is what the verts should end up as patch_t *gpatch; GLPatch_t *hwrpatch; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; extracolormap_t *colormap; INT32 lightlevel; boolean lightset = true; @@ -3939,7 +3937,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) FOutVector wallVerts[4]; patch_t *gpatch; // sprite patch converted to hardware GLPatch_t *hwrpatch; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; FBITFIELD blend = 0; INT32 shader = SHADER_NONE; @@ -4104,7 +4102,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) FOutVector wallVerts[4]; patch_t *gpatch; // sprite patch converted to hardware GLPatch_t *hwrpatch; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; INT32 shader = SHADER_NONE; @@ -6081,7 +6079,7 @@ static void HWR_DoPostProcessor(void) {-4.0f, -4.0f, 4.0f, 0.0f, 0.0f} }; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; // This won't change if the flash palettes are changed unfortunately, but it works for its purpose if (player->flashpal == PAL_NUKE) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index d9bf41645..2aefecea1 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1099,7 +1099,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) INT32 frame = 0; INT32 nextFrame = -1; FTransform p; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; if (!cv_glmdls.value || spr->precip) return; @@ -1475,7 +1475,7 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c patch_t *gpatch, *blendgpatch; GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; FTransform p; - FSurfaceInfo Surf; + FSurfaceInfo Surf = {}; if (!md2->model) { @@ -1526,7 +1526,6 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c if (blendgpatch) hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware); - memset(&Surf, 0x00, sizeof(FSurfaceInfo)); Surf.PolyColor.rgba = 0xFFFFFFFF; Surf.PolyFlags = PF_Occlude | PF_Modulated; From 7b408a33d7f0413b1645f16c9fa4235767446f84 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 3 Mar 2026 02:19:29 +0100 Subject: [PATCH 53/54] fix openmpt versions strings leaking from https://lib.openmpt.org/doc/libopenmpt_c_overview.html "All strings returned from libopenmpt are dynamically allocated and must be freed with openmpt_free_string()." didnt knew this tbh lol --- src/sdl/mixer_sound.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 7dccd9673..f177412e7 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -216,8 +216,13 @@ void I_StartupSound(void) SDLmixlinked->major, SDLmixlinked->minor, SDLmixlinked->patch); #ifdef HAVE_OPENMPT - I_OutputMsg("libopenmpt version: %s\n", openmpt_get_string("library_version")); - I_OutputMsg("libopenmpt build date: %s\n", openmpt_get_string("build")); + const char *openmptstr; + openmptstr = openmpt_get_string("library_version"); + I_OutputMsg("libopenmpt version: %s\n", openmptstr); + openmpt_free_string(openmptstr); + openmptstr = openmpt_get_string("build"); + I_OutputMsg("libopenmpt build date: %s\n", openmptstr); + openmpt_free_string(openmptstr); #endif sound_started = true; From a1666704e51447667e7d2ce2795d70bdab40ea8b Mon Sep 17 00:00:00 2001 From: Indev Date: Mon, 9 Mar 2026 14:51:24 +0300 Subject: [PATCH 54/54] Hide offroad particles when player is doing saltyhop --- src/k_kart.c | 12 ++++++++++-- src/k_kart.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 2aa0377b2..3ba8ce8a2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2159,7 +2159,13 @@ static void K_GetKartBoostPower(player_t *player) && player->speed > 0 && !player->spectator) { - K_SpawnWipeoutTrail(player->mo, true); + mobj_t *dust = K_SpawnWipeoutTrail(player->mo, true); + + // Technically, all mobjs that think can cause desynchs if they are spawned conditionally, so best we can do + // is to hide them if you are in saltyhop jump + if (dust && player->mo->salty.jump) + dust->flags2 |= MF2_DONTDRAW; + if (leveltime % 6 == 0) S_StartSound(player->mo, sfx_cdfm70); } @@ -3634,7 +3640,7 @@ void K_SpawnSparkleTrail(mobj_t *mo) P_SetMobjState(sparkle, S_KARTINVULN_LARGE1); } -void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) +mobj_t *K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) { mobj_t *dust; angle_t aoff; @@ -3675,6 +3681,8 @@ void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) if (translucent) dust->flags2 |= MF2_SHADOW; + + return dust; } // K_DriftDustHandling diff --git a/src/k_kart.h b/src/k_kart.h index ab0d8bd14..9307ce273 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -57,7 +57,7 @@ boolean K_ShouldSlopeRoll(mobj_t *mobj); void K_RollMobjBySlopes(mobj_t *mo, pslope_t *slope); void K_SpawnBoostTrail(player_t *player); void K_SpawnSparkleTrail(mobj_t *mo); -void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent); +mobj_t *K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent); void K_DriftDustHandling(mobj_t *spawner); void K_PuntMine(mobj_t *mine, mobj_t *punter); void K_DoSneaker(player_t *player, INT32 type);