From caff071a1b62a2d8bc469e211d617fcadd1d25bf Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 7 Aug 2025 22:09:43 +0200 Subject: [PATCH 01/15] fix spacing in Z_CheckHeap errors --- src/z_zone.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/z_zone.c b/src/z_zone.c index 8647f91fa..b9150115a 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -503,7 +503,7 @@ void Z_CheckHeap(INT32 tag) { I_Error("Z_CheckHeap %d: block %u" #ifdef ZDEBUG - "(owned by %s:%d)" + " (owned by %s:%d)" #endif " should not exist", i, blocknumon #ifdef ZDEBUG @@ -514,13 +514,13 @@ void Z_CheckHeap(INT32 tag) #endif if (block->user != NULL && *(block->user) != given) { - I_Error("Z_CheckHeap" + I_Error("Z_CheckHeap :" #ifdef ZDEBUG - "at %s %d :" + " %s %d" #endif - "block %u" + " block %u" #ifdef ZDEBUG - "(owned by %s:%d)" + " (owned by %s:%d)" #endif " doesn't have a proper user" #ifdef ZDEBUG @@ -534,13 +534,13 @@ void Z_CheckHeap(INT32 tag) } if (block->next->prev != block) { - I_Error("Z_CheckHeap" + I_Error("Z_CheckHeap :" #ifdef ZDEBUG - "at %s %d :" + " %s %d" #endif - "block %u" + " block %u" #ifdef ZDEBUG - "(owned by %s:%d)" + " (owned by %s:%d)" #endif " lacks proper backlink" #ifdef ZDEBUG @@ -554,13 +554,13 @@ void Z_CheckHeap(INT32 tag) } if (block->prev->next != block) { - I_Error("Z_CheckHeap" + I_Error("Z_CheckHeap :" #ifdef ZDEBUG - "at %s %d :" + " %s %d" #endif - "block %u" + " block %u" #ifdef ZDEBUG - "(owned by %s:%d)" + " (owned by %s:%d)" #endif " lacks proper forward link" #ifdef ZDEBUG @@ -574,13 +574,13 @@ void Z_CheckHeap(INT32 tag) } if (block->id != ZONEID) { - I_Error("Z_CheckHeap" + I_Error("Z_CheckHeap :" #ifdef ZDEBUG - "at %s %d :" + " %s %d" #endif - "block %u" + " block %u" #ifdef ZDEBUG - "(owned by %s:%d)" + " (owned by %s:%d)" #endif " have the wrong ID" #ifdef ZDEBUG From 2653b59af45e22664ca8bc51fc47bea19d893f7c Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 7 Aug 2025 22:22:56 +0200 Subject: [PATCH 02/15] dont double free our vote patches those may point to the same thing so uhhhh PU_PATCH_LOWPRIORITY will ensure the memory will be freed on mapload --- src/y_inter.c | 76 ++++++++++----------------------------------------- 1 file changed, 15 insertions(+), 61 deletions(-) diff --git a/src/y_inter.c b/src/y_inter.c index 068115f4f..0c096127a 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -73,7 +73,6 @@ static huddrawlist_h luahuddrawlist_intermission = NULL; static huddrawlist_h luahuddrawlist_vote = NULL; static void Y_FollowIntermission(void); -static void Y_UnloadData(void); // SRB2Kart: voting stuff // Level images @@ -112,8 +111,6 @@ static y_voteclient voteclient; static INT32 votetic; static INT32 voteendtic = -1; -static void Y_UnloadVoteData(void); - // // SRB2Kart - Y_CalculateMatchData and ancillary functions // @@ -789,7 +786,7 @@ void Y_StartIntermission(void) break; } - bgtile = W_CachePatchName("SRB2BACK", PU_PATCH); + bgtile = W_CachePatchName("SRB2BACK", PU_PATCH_LOWPRIORITY); LUA_HUD_DestroyDrawList(luahuddrawlist_intermission); luahuddrawlist_intermission = LUA_HUD_CreateDrawList(); @@ -802,9 +799,6 @@ void Y_StartIntermission(void) // void Y_EndIntermission(void) { - if (!dedicated) - Y_UnloadData(); - endtic = -1; sorttic = -1; intertype = int_none; @@ -821,20 +815,6 @@ static void Y_FollowIntermission(void) G_AfterIntermission(); } -#define UNLOAD(x) {if ((x) != NULL) {Patch_Free(x);} x = NULL;} - -// -// Y_UnloadData -// -static void Y_UnloadData(void) -{ - // unload the background patches - UNLOAD(VoteScreen.bgpatch); - UNLOAD(VoteScreen.widebgpatch); - UNLOAD(bgtile); - //UNLOAD(interpic); -} - // SRB2Kart: Voting! // @@ -877,8 +857,8 @@ static void Y_VoteScreenCheck(void) // non lua vote background handling boolean prefbattletype = ((votelevels[0][1] & ~0x80) == GT_MATCH); - VoteScreen.widebgpatch = W_CachePatchName((prefbattletype ? "BATTLSCW" : "INTERSCW"), PU_PATCH); - VoteScreen.bgpatch = W_CachePatchName((prefbattletype ? "BATTLSCR" : "INTERSCR"), PU_PATCH); + VoteScreen.widebgpatch = W_CachePatchName((prefbattletype ? "BATTLSCW" : "INTERSCW"), PU_PATCH_LOWPRIORITY); + VoteScreen.bgpatch = W_CachePatchName((prefbattletype ? "BATTLSCR" : "INTERSCR"), PU_PATCH_LOWPRIORITY); } // @@ -926,7 +906,7 @@ static void Y_DrawLuaVoteScreenPatch(boolean widePatch) // Draw non animated patch if (!tempfoundAnimLuaVoteFrames) { - votebg = W_CachePatchName(va("%s1", tempPrefix), PU_PATCH); + votebg = W_CachePatchName(va("%s1", tempPrefix), PU_PATCH_LOWPRIORITY); Y_VoteBackgroundDrawer(votebg); return; } @@ -939,7 +919,7 @@ static void Y_DrawLuaVoteScreenPatch(boolean widePatch) nextframe = (VoteScreen.currentAnimFrame + 1); - votebg = W_CachePatchName(va("%s%d", tempPrefix, nextframe), PU_PATCH); + votebg = W_CachePatchName(va("%s%d", tempPrefix, nextframe), PU_PATCH_LOWPRIORITY); Y_VoteBackgroundDrawer(votebg); @@ -1481,14 +1461,14 @@ static void Y_InitVoteDrawing(void) // setup the background patches Y_VoteScreenCheck(); - VoteScreen.cursor[0] = W_CachePatchName("M_CURSOR", PU_PATCH); - VoteScreen.cursor[1] = W_CachePatchName("P1CURSOR", PU_PATCH); - VoteScreen.cursor[2] = W_CachePatchName("P2CURSOR", PU_PATCH); - VoteScreen.cursor[3] = W_CachePatchName("P3CURSOR", PU_PATCH); - VoteScreen.cursor[4] = W_CachePatchName("P4CURSOR", PU_PATCH); + VoteScreen.cursor[0] = W_CachePatchName("M_CURSOR", PU_PATCH_LOWPRIORITY); + VoteScreen.cursor[1] = W_CachePatchName("P1CURSOR", PU_PATCH_LOWPRIORITY); + VoteScreen.cursor[2] = W_CachePatchName("P2CURSOR", PU_PATCH_LOWPRIORITY); + VoteScreen.cursor[3] = W_CachePatchName("P3CURSOR", PU_PATCH_LOWPRIORITY); + VoteScreen.cursor[4] = W_CachePatchName("P4CURSOR", PU_PATCH_LOWPRIORITY); - VoteScreen.randomlvl = W_CachePatchName("RANDOMLV", PU_PATCH); - VoteScreen.rubyicon = W_CachePatchName("RUBYICON", PU_PATCH); + VoteScreen.randomlvl = W_CachePatchName("RANDOMLV", PU_PATCH_LOWPRIORITY); + VoteScreen.rubyicon = W_CachePatchName("RUBYICON", PU_PATCH_LOWPRIORITY); } void Y_StartVote(void) @@ -1573,9 +1553,9 @@ void Y_StartVote(void) { lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(votelevels[i][0]+1))); if (lumpnum != LUMPERROR) - levelinfo[i].pic = W_CachePatchName(va("%sP", G_BuildMapName(votelevels[i][0]+1)), PU_PATCH); + levelinfo[i].pic = W_CachePatchName(va("%sP", G_BuildMapName(votelevels[i][0]+1)), PU_PATCH_LOWPRIORITY); else - levelinfo[i].pic = W_CachePatchName("BLANKLVL", PU_PATCH); + levelinfo[i].pic = W_CachePatchName("BLANKLVL", PU_PATCH_LOWPRIORITY); } } @@ -1589,35 +1569,9 @@ void Y_StartVote(void) // Y_EndVote // void Y_EndVote(void) -{ - Y_UnloadVoteData(); - voteendtic = -1; -} - -// -// Y_UnloadVoteData -// -static void Y_UnloadVoteData(void) { voteclient.loaded = false; - - if (dedicated) - return; - - UNLOAD(VoteScreen.widebgpatch); - UNLOAD(VoteScreen.bgpatch); - UNLOAD(VoteScreen.cursor[0]); - UNLOAD(VoteScreen.cursor[1]); - UNLOAD(VoteScreen.cursor[2]); - UNLOAD(VoteScreen.cursor[3]); - UNLOAD(VoteScreen.cursor[4]); - UNLOAD(VoteScreen.randomlvl); - UNLOAD(VoteScreen.rubyicon); - - UNLOAD(levelinfo[3].pic); - UNLOAD(levelinfo[2].pic); - UNLOAD(levelinfo[1].pic); - UNLOAD(levelinfo[0].pic); + voteendtic = -1; } // From e85d91e68245bb5296443598c68c6188ca595a19 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 7 Aug 2025 22:27:19 +0200 Subject: [PATCH 03/15] save a few checks for st debug drawer if we dont use it --- src/st_stuff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 680127286..aa1d6a81e 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -367,7 +367,7 @@ static void ST_drawDebugInfo(void) { INT32 height = 192; - if (!stplyr->mo) + if (!cv_debug || !stplyr->mo) return; if (cv_debug & DBG_BASIC) @@ -803,5 +803,6 @@ void ST_Drawer(void) else V_DrawFadeScreen(120, 15-timeinmap); // Then gradually fade out from there } + ST_drawDebugInfo(); } From cb3638e3abb84d6ce0eb768ac54d86912877e4f4 Mon Sep 17 00:00:00 2001 From: Indev Date: Thu, 7 Aug 2025 23:48:03 +0300 Subject: [PATCH 04/15] Add SetupVote hook --- LUASTUFF.md | 12 ++++++++++++ src/d_netcmd.c | 13 ++++++++++++- src/lua_hook.h | 6 ++++++ src/lua_hooklib.c | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) diff --git a/LUASTUFF.md b/LUASTUFF.md index 83ec76545..28e77bed8 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -192,6 +192,18 @@ from `0` to `#musicdefs-1`, or string indices (which is equal to calling `S_Find Hook is called whenever `S_ShowMusicCredit` (either from game or mod) is called. Takes musicdef as only argument, returning true will overwrite vanilla behavior (not show music credit), can be used to implement custom music credit pop-ups. +## addHook("SetupVote", function(result, gt, secondgt, prevmap)) + +Hook is called whenever server sets up options for vote screen. `result` is table where lua can store options to, +(for example, `result[1] = 1` will force green hills as first option), gt is current gametype, secondgt is +alternative gametype picked for 3rd entry (for example, gt can be `GT_RACE`, and secondgt can be `GT_MATCH`) +prevmap is the previous map that was played (small note - in game code, it is offset by -1, but for lua its offset back, +so if previous gamemap was 1, prevmap would also be 1. Which means you can safely do mapheaderinfo[prevmap] to get info on previous map) + +Limitations: currently, game can only change gametype for 3rd option in map (meaning for example, if current gametype is race, and you +put battle map in first option, when it gets picked that map will be still run in race gametype). That means, game will only handle maps with +different gametype if it is put in 3rd vote option. + # Other changes ## P_PlayRinglossSound(source, damager) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index c358c3b2c..d60d87ba6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2505,6 +2505,14 @@ void D_SetupVote(void) UINT8 gt = (cv_kartgametypepreference.value == -1) ? gametype : cv_kartgametypepreference.value; UINT8 secondgt = G_SometimesGetDifferentGametype(gt); INT16 votebuffer[4] = {-1,-1,-1,0}; + INT16 luamaps[4] = {0, 0, 0, 0}; + + LUA_HookSetupVote(luamaps, sizeof(luamaps)/sizeof(luamaps[0]), gt, secondgt); + + // Correct secondgt if needed + UINT8 typeoflevel = mapheaderinfo[luamaps[2]-1]->typeoflevel; + if (luamaps[2] && (typeoflevel & G_TOLFlag(secondgt&(~0x80))) == 0) + secondgt = ((typeoflevel & TOL_RACE) ? GT_RACE : GT_MATCH)|(secondgt&0x80); if (cv_kartencore.value && gt == GT_RACE) WRITEUINT8(p, (gt|0x80)); @@ -2513,10 +2521,13 @@ void D_SetupVote(void) WRITEUINT8(p, secondgt); secondgt &= ~0x80; + for (i = 0; i < 4; i++) { UINT16 m; - if (i == 2) // sometimes a different gametype + if (luamaps[i]) + m = luamaps[i]-1; + else if (i == 2) // sometimes a different gametype m = G_RandMap(G_TOLFlag(secondgt), prevmap, false, 0, true, votebuffer); else if (i >= 3) // unknown-random and force-unknown MAP HELL m = G_RandMap(G_TOLFlag(gt), prevmap, false, (i-2), (i < 4), votebuffer); diff --git a/src/lua_hook.h b/src/lua_hook.h index c31a58a67..64c91cc24 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -66,6 +66,7 @@ X (IntermissionThinker),/* Y_Ticker */\ X (VoteThinker),/*SRB2KART*/\ X (ServerJoin),/* SRB2KART - Saturn 32p*/\ + X (SetupVote),/*SRB2KART - Saturn*/ #define STRING_HOOK_LIST(X) \ X (BotAI),/* B_BuildTailsTiccmd by skin name */\ @@ -140,3 +141,8 @@ int LUA_HookShouldSquish(player_t *player, mobj_t *inflictor, mobj_t *source); / boolean LUA_HookPlayerSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SpinPlayer. Allows Lua to execute code and/or overwrite its behavior. boolean LUA_HookPlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_ExplodePlayer. Allows Lua to execute code and/or overwrite its behavior. boolean LUA_HookPlayerSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SquishPlayer. Allows Lua to execute code and/or overwrite its behavior. + +// SRB2KART - Saturn: Allows changing vote level picks +// (note: function format in lua doesn't include maxresults, so its function(result, gametype, secondgametype, prevmap) +// to get maxresults use #result) +void LUA_HookSetupVote(INT16 result[], INT16 maxresults, UINT8 gt, UINT8 secondgt); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 97b86e1bf..98c873a1a 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1138,3 +1138,43 @@ boolean LUA_HookPlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *sourc { return kartdamage_hook(player, inflictor, source, HOOK(PlayerExplode), res_true); } + +void LUA_HookSetupVote(INT16 result[], INT16 maxresults, UINT8 gt, UINT8 secondgt) +{ + Hook_State hook; + if (prepare_hook(&hook, 0, HOOK(SetupVote))) + { + // { 0, 0, 0, 0, } + lua_newtable(gL); + for (int i = 1; i <= maxresults; ++i) + { + lua_pushinteger(gL, 0); + lua_rawseti(gL, -2, i); + } + + // call_hooks does lua_settop(gL, 0) so we need to store our table somewhere + lua_pushvalue(gL, -1); + lua_setfield(gL, LUA_REGISTRYINDEX, "SetupVoteResults"); + + lua_pushinteger(gL, gt); + lua_pushinteger(gL, secondgt); + lua_pushinteger(gL, prevmap+1); // prevmap is gamemap-1 so we offset it back + + call_hooks(&hook, 0, res_none); + + lua_getfield(gL, LUA_REGISTRYINDEX, "SetupVoteResults"); + for (int i = 1; i <= maxresults; ++i) + { + lua_rawgeti(gL, -1, i); + result[i-1] = lua_tointeger(gL, -1); + lua_pop(gL, 1); + + if (result[i-1] && (result[i-1] < 0 || !mapheaderinfo[result[i-1]-1])) + { + CONS_Alert(CONS_WARNING, "Unknown map #%d for vote\n", result[i-1]); + result[i-1] = 0; + } + } + lua_pop(gL, 1); + } +} From b76fc9699aaa40f12ae78a7904a7223f796261ed Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 8 Aug 2025 00:34:33 +0200 Subject: [PATCH 05/15] fixup midi menu stuff i love M_DrawSkyRoom --- src/m_menu.c | 11 ----------- src/m_menudefs.c | 27 +++++++++++---------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index fdbc68e55..02a1bee87 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5274,21 +5274,10 @@ static void M_DrawSkyRoom(void) (music_disabled ? warningflags : highlightflags), (music_disabled ? "OFF" : "ON")); -#ifndef NO_MIDI - V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, - currentMenu->y+currentMenu->menuitems[5].alphaKey, - (music_disabled ? warningflags : highlightflags), - (music_disabled ? "OFF" : "ON")); -#endif - if (itemOn == 0) lengthstring = 8*(sound_disabled ? 3 : 2); else if (itemOn == 2) lengthstring = 8*(music_disabled ? 3 : 2); -#ifndef NO_MIDI - else if (itemOn == 5) - lengthstring = 8*(music_disabled ? 3 : 2); -#endif } for (i = 0; i < currentMenu->numitems; ++i) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 7029a212b..998c457ae 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1070,29 +1070,25 @@ enum static menuitem_t OP_SoundOptionsMenu[] = { {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "SFX", &cv_gamesounds, 10}, - {IT_STRING|IT_CVAR|IT_CV_SLIDER, - NULL, "SFX Volume", &cv_soundvolume, 18}, + {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "SFX Volume", &cv_soundvolume, 18}, {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music", &cv_gamedigimusic, 30}, - {IT_STRING|IT_CVAR|IT_CV_SLIDER, - NULL, "Music Volume", &cv_digmusicvolume, 38}, + {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "Music Volume", &cv_digmusicvolume, 38}, #ifndef NO_MIDI - {IT_STRING|IT_CVAR, NULL, "MIDI", &cv_gamemidimusic, 50}, - {IT_STRING|IT_CVAR|IT_CV_SLIDER, - NULL, "MIDI Volume", &cv_midimusicvolume, 58}, + {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "MIDI Volume", &cv_midimusicvolume, 46}, - {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 50}, + {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, - {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 65}, - {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 75}, - {IT_STRING|IT_CVAR, NULL, "Hit Em Delay", &cv_karthitemdialog, 85}, - {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95}, + {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 75}, + {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 85}, + {IT_STRING|IT_CVAR, NULL, "Hit Em Delay", &cv_karthitemdialog, 95}, + {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 105}, - {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105}, - {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115}, + {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 115}, + {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 125}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 125} + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 135} #else {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, @@ -1115,7 +1111,6 @@ static const char* OP_SoundTooltips[] = "Turn Music on or off.", "Volume of Music.", #ifndef NO_MIDI - "Turn Midi Music on or off.", "Volume of Midi Music.", #endif "Reverse left and right channels of audio.", From 16e1e00c678f7835b9d68659105de00f0aaf6c94 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 8 Aug 2025 00:48:41 +0200 Subject: [PATCH 06/15] "reenable" midi support well it was never really disabled, but like this we can atleast change its volume lel menu entry is still disabled, i dont think theres a single map with midi music, so this would just clutter the menu --- src/doomdef.h | 3 ++- src/m_menudefs.c | 6 ++++-- src/s_sound.c | 11 ++++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index 9797c643e..1f7dcb4d8 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -650,7 +650,8 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #define NOCLIPCAM /// SRB2Kart: MIDI support is shitty and busted and we don't want it, lets throw it behind a define -#define NO_MIDI +// yall didnt properly disable it so it always worked lol (: +//#define NO_MIDI /// Sprite rotation #define ROTSPRITE diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 998c457ae..28b8b94bf 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1075,7 +1075,8 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR|IT_CV_NOPRINT, NULL, "Music", &cv_gamedigimusic, 30}, {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "Music Volume", &cv_digmusicvolume, 38}, -#ifndef NO_MIDI +//#ifndef NO_MIDI +#if 0 {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "MIDI Volume", &cv_midimusicvolume, 46}, {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, @@ -1110,7 +1111,8 @@ static const char* OP_SoundTooltips[] = "Volume of Sound effects.", "Turn Music on or off.", "Volume of Music.", -#ifndef NO_MIDI +//#ifndef NO_MIDI +#if 0 "Volume of Midi Music.", #endif "Reverse left and right channels of audio.", diff --git a/src/s_sound.c b/src/s_sound.c index 7e2a8e40b..aead25f0c 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1629,10 +1629,20 @@ static lumpnum_t S_GetMusicLumpNum(const char *mname) if (S_MusicExists(mname, false, true)) // check non midis first return W_GetNumForName(va("o_%s", mname)); else if (S_MusicExists(mname, true, false)) + { +#ifdef NO_MIDI + CONS_Alert(CONS_ERROR, "A MIDI music lump %.6s was found,\nbut SRB2Kart does not support MIDI output.\nWe apologise for the inconvenience.\n", mname); + return LUMPERROR; +#else return W_GetNumForName(va("d_%s", mname)); +#endif + } + + CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded: lump not found!\n", mname); return LUMPERROR; } + static boolean S_LoadMusic(const char *mname) { lumpnum_t mlumpnum; @@ -1645,7 +1655,6 @@ static boolean S_LoadMusic(const char *mname) if (mlumpnum == LUMPERROR) { - CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded: lump not found!\n", mname); return false; } From a1d16b46133a5737ed8312f7dc48a45773475466 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 8 Aug 2025 17:43:40 +0300 Subject: [PATCH 07/15] Update dedicated/i_sound.c I_StartSound and I_UpdateSoundParams --- src/dedicated/i_sound.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/dedicated/i_sound.c b/src/dedicated/i_sound.c index de43aab85..d2cf53a28 100644 --- a/src/dedicated/i_sound.c +++ b/src/dedicated/i_sound.c @@ -69,13 +69,11 @@ void I_ShutdownSound(void){} \return sfx handle */ -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) +INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, INT32 channel) { (void)id; (void)vol; (void)sep; - (void)pitch; - (void)priority; (void)channel; return 0; } @@ -116,12 +114,11 @@ boolean I_SoundIsPlaying(INT32 handle) \return void */ -void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch) +void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep) { (void)handle; (void)vol; (void)sep; - (void)pitch; } /** \brief The I_SetSfxVolume function From 4c97a4f9e05965222d3852f838eb8172ec019d67 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 8 Aug 2025 17:53:46 +0300 Subject: [PATCH 08/15] Fix potential buffer overflow in DEH_LoadDehackedFile --- src/dehacked.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index ff03e3694..6b774204c 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2855,7 +2855,7 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) dbg_line = -1; // start at -1 so the first line is 0. while (!myfeof(f)) { - char origpos[128]; + char origpos[256]; INT32 size = 0; char *traverse; @@ -2871,6 +2871,12 @@ static void DEH_LoadDehackedFile(MYFILE *f, UINT16 wad) size++; } + if (size > (int)sizeof(origpos)) + { + deh_warning("Line is too long"); + size = sizeof(origpos)-1; + } + strncpy(origpos, s, size); origpos[size] = '\0'; From 932a08b2da146907e1c0e10a41e0ff27e4cb231c Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 8 Aug 2025 18:29:05 +0300 Subject: [PATCH 09/15] Fix makefiles checking for NOLIBGME instead of NOGME --- src/Makefile.d/features.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk index cf6a728db..456b10163 100644 --- a/src/Makefile.d/features.mk +++ b/src/Makefile.d/features.mk @@ -97,7 +97,7 @@ opts+=-DHAVE_VALGRIND endif default_packages:=\ - LIBGME/libgme/LIBGME\ + GME/libgme/LIBGME\ OPENMPT/libopenmpt/LIBOPENMPT\ ZLIB/zlib\ From 3901c7c7da01dc68202ea73983ce3cf083f30ce1 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 8 Aug 2025 18:31:45 +0300 Subject: [PATCH 10/15] Revert "Fix makefiles checking for NOLIBGME instead of NOGME" This reverts commit 932a08b2da146907e1c0e10a41e0ff27e4cb231c. --- src/Makefile.d/features.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk index 456b10163..cf6a728db 100644 --- a/src/Makefile.d/features.mk +++ b/src/Makefile.d/features.mk @@ -97,7 +97,7 @@ opts+=-DHAVE_VALGRIND endif default_packages:=\ - GME/libgme/LIBGME\ + LIBGME/libgme/LIBGME\ OPENMPT/libopenmpt/LIBOPENMPT\ ZLIB/zlib\ From a7c41b458a3247c76f48bfdb0074c1b8cfcad9d8 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 8 Aug 2025 18:33:24 +0300 Subject: [PATCH 11/15] Use NOLIBGME instead of NOGME --- src/Makefile | 2 +- src/Makefile.d/dedicated.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index dcb2eecc6..9b8a92f55 100644 --- a/src/Makefile +++ b/src/Makefile @@ -49,7 +49,7 @@ # Already enabled by default for 32-bit # Windows. # NOCURL=1 - Disable libcurl--HTTP capability. -# NOGME=1 - Disable game music emu, retro VGM support. +# NOLIBGME=1 - Disable game music emu, retro VGM support. # NOOPENMPT=1 - Disable module (tracker) music support. # NOMIXER=1 - Disable SDL Mixer (audio playback). # NOTHREADS=1 - Disable multithreading. diff --git a/src/Makefile.d/dedicated.mk b/src/Makefile.d/dedicated.mk index a421b465d..d50b3b57e 100644 --- a/src/Makefile.d/dedicated.mk +++ b/src/Makefile.d/dedicated.mk @@ -14,6 +14,6 @@ sources+=dedicated/i_threads.c endif NOOPENMPT=1 -NOGME=1 +NOLIBGME=1 NOHW=1 NOUPNP=1 From 222b63d2c38a7b02b2b39a68b287a94957cd2d5a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 8 Aug 2025 17:53:13 +0200 Subject: [PATCH 12/15] move the windoze thing to windoze makefile --- src/Makefile.d/features.mk | 7 ------- src/Makefile.d/win32.mk | 4 ++++ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk index cf6a728db..d79a3816b 100644 --- a/src/Makefile.d/features.mk +++ b/src/Makefile.d/features.mk @@ -73,13 +73,6 @@ libs+=-lbacktrace opts+=-DHAVE_LIBBACKTRACE endif -#windoze hack -ifdef MINGW -ifndef NODISCORDRPC -HAVE_DISCORDRPC=1 -endif -endif - ifdef HAVE_DISCORDRPC $(eval $(call Propogate_flags,DISCORDRPC)) libs+=-ldiscord-rpc diff --git a/src/Makefile.d/win32.mk b/src/Makefile.d/win32.mk index fa411416e..db2b99a84 100644 --- a/src/Makefile.d/win32.mk +++ b/src/Makefile.d/win32.mk @@ -42,6 +42,10 @@ libs+=-Wl,--large-address-aware NOLIBBACKTRACE=1 endif +ifndef NODISCORDRPC +HAVE_DISCORDRPC=1 +endif + ifndef MINGW64 32=32 x86=x86 From 1fe79fe236b895a031eb8f6c008be159ceb1b0f0 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 8 Aug 2025 18:57:58 +0300 Subject: [PATCH 13/15] Add -strict, -strict-soc and -strict-lua cli params Both trigger I_Error if a warning occurs during addon load in a SOC or lua script --- src/dehacked.c | 3 +++ src/lua_script.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index 6b774204c..44f0b5275 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -178,6 +178,9 @@ FUNCPRINTF static void deh_warning(const char *first, ...) else CONS_Alert(CONS_WARNING, "Line %u: %s\n", dbg_line, buf); + if (dbg_line != -1 && (M_CheckParm("-strict") || M_CheckParm("-strict-soc"))) + I_Error("deh_warning: %s", buf); + deh_num_warning++; Z_Free(buf); diff --git a/src/lua_script.c b/src/lua_script.c index 332353bfb..ef095a9b1 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -24,6 +24,7 @@ #include "p_slopes.h" // for P_SlopeById #include "s_sound.h" #include "m_menu.h" +#include "m_argv.h" #ifdef LUA_ALLOW_BYTECODE #include "d_netfil.h" // for LUA_DumpFile #endif @@ -252,7 +253,11 @@ static inline void LUA_LoadFile(MYFILE *f, char *name) lua_pushcfunction(gL, LUA_GetErrorMessage); if (luaL_loadbuffer(gL, f->data, f->size, va("@%s",name)) || lua_pcall(gL, 0, 0, lua_gettop(gL) - 1)) { - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1)); + if (M_CheckParm("-strict") || M_CheckParm("-strict-lua")) + I_Error("Lua error: %s", lua_tostring(gL, -1)); + else + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1)); + lua_pop(gL,1); } lua_gc(gL, LUA_GCCOLLECT, 0); From 43b74923009f97c589fa6c544da67b8201286409 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 8 Aug 2025 21:50:13 +0200 Subject: [PATCH 14/15] disable pointless "Couldn't read mobj_t" warnings in replays mobjs just cannot be unarchived in replays ever so this will always spam those for something that WILL never work in kart maybe if i decide to fix this for 32p or smth those become useful again --- src/lua_script.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index ef095a9b1..d2cddf125 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1028,8 +1028,8 @@ static UINT8 UnArchiveValue(UINT8 **p, int TABLESINDEX, boolean network) case ARCH_MOBJ: if (network == false) // for replays :chaosleep: { - *p += sizeof(UINT32); // Skip this data, we can't read a mobj here, it'd point to garbage and crash the game. - return 3; // Don't set the field + *p += sizeof(UINT32); // Skip this data, we can't read a mobj here, it'd point to garbage and crash the game. + return 3; // Don't set the field } LUA_PushUserdata(gL, P_FindNewPosition(READUINT32(*p)), META_MOBJ); @@ -1104,9 +1104,9 @@ static void UnArchiveExtVars(UINT8 **p, void *pointer, boolean network) CONS_Alert(CONS_ERROR, "Unexpected end marker when reading ExtVars (field '%s')\n", field); break; } - else if (ret == 3) // This will return 3 if we shouldn't set this field. + else if (ret == 3) // This will return 3 if we shouldn't set this field. { - CONS_Alert(CONS_WARNING,"Cannot read mobj_t stored in player variable \'%s\'. Desyncs may occur.\n", field); + //CONS_Alert(CONS_WARNING,"Cannot read mobj_t stored in player variable \'%s\'. Desyncs may occur.\n", field); continue; } @@ -1160,7 +1160,7 @@ static void UnArchiveTables(UINT8 **p, boolean network) ret = UnArchiveValue(p, TABLESINDEX, network); if (ret == 3) { - CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); + //CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); lua_pushnil(gL); } else if (ret == 1) // read key @@ -1175,7 +1175,7 @@ static void UnArchiveTables(UINT8 **p, boolean network) } else if (ret == 3) { - CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); + //CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); lua_pushnil(gL); } else if (ret == 2) // read value From 7b776f01bd9179d4a18e22af5021b82dc1f6e302 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 8 Aug 2025 22:43:23 +0200 Subject: [PATCH 15/15] change flow of K_drawKartStats a bit nothing notable, just the non splitscreen path will return early now --- src/k_hud.c | 91 +++++++++++++++++++++++++++++------------------------ 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index deae2c028..05bce653c 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -1340,40 +1340,76 @@ static void K_drawKartStats(void) spdxoffset = 0; spdoffset = 0; - flags = V_SNAPTOBOTTOM|V_SNAPTOLEFT; - if (!LUA_HudEnabled(hud_statdisplay)) return; + flags = V_SNAPTOBOTTOM|V_SNAPTOLEFT; + //Internal offset for speedometer const UINT8 speedostyle = K_GetSpeedometerStyle(); if (cv_kartspeedometer.value && (!splitscreen)) { - if ((speedostyle == SPEEDO_EXTRA) || (speedostyle == SPEEDO_ACHII) || (speedostyle == SPEEDO_EXTRA3)) - spdoffset = -10; - else if (speedostyle == SPEEDO_DIAL) + switch (speedostyle) { - spdxoffset = 11; - spdoffset = 14; + case SPEEDO_EXTRA: + case SPEEDO_ACHII: + case SPEEDO_EXTRA3: + spdoffset = -10; + break; + case SPEEDO_DIAL: + spdxoffset = 11; + spdoffset = 14; + break; + default: + spdoffset = -14; + break; } - else - spdoffset = -14; } else spdoffset = 0; - if ((speedostyle != SPEEDO_DIAL) || (splitscreen)) - spdoffset += (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0); + if (G_BattleGametype() && ((speedostyle != SPEEDO_DIAL) || splitscreen)) + spdoffset += ((stplyr->kartstuff[k_bumper] ? -5 : -8)); // Customizations c: if (!splitscreen) { + skin_t *fakeskin; + INT32 flags2; + x += 18 + cv_stat_xoffset.value + spdxoffset; y += cv_stat_yoffset.value + spdoffset; + + flags |= V_HUDTRANS; + flags2 = flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor); + + fakeskin = K_GetPlayerSkin(stplyr); + + // Skin name + if (K_IsHighResolution()) // V_DrawSmallString becomes a mess at low resolutions lel + { + V_DrawSmallString(x+20, y+12, flags2, fakeskin->realname); + } + else + { + V_DrawThinString(x+20, y+7, flags2, fakeskin->realname); + } + + // Icon and stats + if (K_UseHighResPortraits()) + V_DrawSmallMappedPatch(x, y, flags, R_GetSkinFaceWant(stplyr), R_GetLocalTranslationColormap(fakeskin, fakeskin, stplyr->skincolor, GTC_CACHE, stplyr->skinlocal)); + else + V_DrawMappedPatch(x, y, flags, R_GetSkinFaceRank(stplyr), R_GetLocalTranslationColormap(fakeskin, fakeskin, stplyr->skincolor, GTC_CACHE, stplyr->skinlocal)); + + V_DrawMappedPatch(x-3, y-2, flags, kp_facenum[min(9, max(1, stplyr->kartspeed))], R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_BLUEBERRY, GTC_CACHE)); + V_DrawMappedPatch(x+10, y+10, flags, kp_facenum[min(9, max(1, stplyr->kartweight))], R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_BURGUNDY, GTC_CACHE)); + + return; } - else if (splitscreen == 1) // I tried my best, but this is still mess :/ < :Blobcatpats: c: + + if (splitscreen == 1) // I tried my best, but this is still mess :/ < :Blobcatpats: c: { x -= 10; y -= 40; @@ -1411,35 +1447,8 @@ static void K_drawKartStats(void) flags |= V_HUDTRANS; - if (!splitscreen) - { - skin_t *fakeskin; - fakeskin = K_GetPlayerSkin(stplyr); - - // Skin name - if (K_IsHighResolution()) // V_DrawSmallString becomes a mess at low resolutions lel - { - V_DrawSmallString(x+20, y+12, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); - } - else - { - V_DrawThinString(x+20, y+7, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); - } - - // Icon and stats - if (K_UseHighResPortraits()) - V_DrawSmallMappedPatch(x, y, flags, R_GetSkinFaceWant(stplyr), R_GetLocalTranslationColormap(fakeskin, fakeskin, stplyr->skincolor, GTC_CACHE, stplyr->skinlocal)); - else - V_DrawMappedPatch(x, y, flags, R_GetSkinFaceRank(stplyr), R_GetLocalTranslationColormap(fakeskin, fakeskin, stplyr->skincolor, GTC_CACHE, stplyr->skinlocal)); - - V_DrawMappedPatch(x-3, y-2, flags, kp_facenum[min(9, max(1, stplyr->kartspeed))], R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_BLUEBERRY, GTC_CACHE)); - V_DrawMappedPatch(x+10, y+10, flags, kp_facenum[min(9, max(1, stplyr->kartweight))], R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_BURGUNDY, GTC_CACHE)); - } - else - { - // In splitscreen, just draw a string with stats - V_DrawString(x, y+10, flags, va("\x84%dS \x87%dW", stplyr->kartspeed, stplyr->kartweight)); - } + // In splitscreen, just draw a string with stats + V_DrawString(x, y+10, flags, va("\x84%dS \x87%dW", stplyr->kartspeed, stplyr->kartweight)); } static void K_drawKartItem(void)