From 6eb96a499276d0a01416f6eec8f7f054a2dfce19 Mon Sep 17 00:00:00 2001 From: hayaunderscore Date: Wed, 18 Oct 2023 15:30:46 +0800 Subject: [PATCH] clean up `extra.kart` and `extra2.kart` lump checking --- src/d_main.c | 33 ++++++++++++++++++--------------- src/w_wad.c | 20 ++++++++++++++++++++ src/w_wad.h | 3 +++ 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index 33ae8e0f1..69243f2de 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1271,27 +1271,30 @@ void D_SRB2Main(void) #endif //ifndef DEVELOP - if (found_extra_kart){ // found the funny, add it in! - mainwads++; + if (found_extra_kart || found_extra2_kart) // found the funny, add it in! + { + // HAYA: These are seperated for a reason lmao + if (found_extra_kart) + mainwads++; + if (found_extra2_kart) + mainwads++; // now check for speedometer stuff - if ((W_LumpExists("SP_SMSTC")) && (W_LumpExists("K_TRNULL")) && (W_LumpExists("SP_MKMH")) && (W_LumpExists("SP_MMPH")) && (W_LumpExists("SP_MFRAC")) && (W_LumpExists("SP_MPERC"))) - snw_speedo = true; + if (W_CheckMultipleLumps("SP_SMSTC", "K_TRNULL", "SP_MKMH", "SP_MMPH", "SP_MFRAC", "SP_MPERC", NULL)) + snw_speedo = true; - if ((W_LumpExists("K_STLAPB")) && (W_LumpExists("K_STLA2B"))) // check for bigger lap count - big_lap = true; - } - - if (found_extra2_kart){ // found the funny, add it in! - mainwads++; + // check for bigger lap count + if (W_CheckMultipleLumps("K_STLAPB", "K_STLA2B", NULL)) + big_lap = true; // now check for colour hud stuff - if ((W_LumpExists("K_SCTIME")) && (W_LumpExists("K_SCTIMW")) && (W_LumpExists("K_SCLAPS")) && (W_LumpExists("K_SCLAPW")) && (W_LumpExists("K_SCBALN")) - && (W_LumpExists("K_SCBALW")) && (W_LumpExists("K_SCKARM")) && (W_LumpExists("K_SCTOUT")) && (W_LumpExists("K_ISMULC")) && (W_LumpExists("K_ITMULC"))) - clr_hud = true; + if (W_CheckMultipleLumps("K_SCTIME", "K_SCTIMW", "K_SCLAPS", "K_SCLAPW", \ + "K_SCBALN", "K_SCBALW", "K_SCKARM", "K_SCTOUT", "K_ISMULC", "K_ITMULC", NULL)) + clr_hud = true; - if ((W_LumpExists("K_SCLAPB")) && (W_LumpExists("K_SCLA2B"))) // check for bigger lap count but colour - big_lap_color = true; + // check for bigger lap count but color** its color bitch + if (W_CheckMultipleLumps("K_SCLAPB", "K_SCLA2B", NULL)) + big_lap_color = true; } // diff --git a/src/w_wad.c b/src/w_wad.c index 2aba94321..f9e449268 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1319,6 +1319,26 @@ UINT8 W_LumpExists(const char *name) return false; } +UINT8 W_CheckMultipleLumps(const char* lump, ...) +{ + va_list lumps; + va_start(lumps, lump); + const char* lumpname = lump; + + while (lumpname != NULL) + { + if (!W_LumpExists(lumpname)) + { + va_end(lumps); + return FALSE; + } + lumpname = va_arg(lumps, const char*); + } + + va_end(lumps); + return TRUE; +} + size_t W_LumpLengthPwad(UINT16 wad, UINT16 lump) { if (!TestValidLump(wad, lump)) diff --git a/src/w_wad.h b/src/w_wad.h index b2b518793..52e726d80 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -22,6 +22,8 @@ #pragma interface #endif +#include // hopefully this shouldn't cause any problems... + // a raw entry of the wad directory // NOTE: This sits here and not in w_wad.c because p_setup.c makes use of it to load map WADs inside PK3s. #if defined(_MSC_VER) @@ -165,6 +167,7 @@ lumpnum_t W_GetNumForName(const char *name); // like W_CheckNumForName but I_Err lumpnum_t W_GetNumForLongName(const char *name); lumpnum_t W_CheckNumForNameInBlock(const char *name, const char *blockstart, const char *blockend); UINT8 W_LumpExists(const char *name); // Lua uses this. +UINT8 W_CheckMultipleLumps(const char* lump, ...); // variadic version of above lmao size_t W_LumpLengthPwad(UINT16 wad, UINT16 lump); size_t W_LumpLength(lumpnum_t lumpnum);