From aa1ccafaea8880d174fbadcef07258ba5253dcdf Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Wed, 27 Aug 2025 21:59:37 +0200 Subject: [PATCH] Use G_GamestateUsesLevel everywhere (and actually use levelloaded) --- src/d_main.cpp | 5 ++--- src/hardware/hw_main.c | 2 +- src/lua_baselib.c | 2 +- src/lua_mobjlib.c | 2 +- src/lua_script.h | 6 ++---- src/m_perfstats.c | 7 ++----- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 979796d20..6350d25e9 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -477,8 +477,7 @@ static void D_Display(void) wipetypepre = wipedefs[wipedefindex]; // Fade to black first - if ((wipegamestate == FORCEWIPE || - !(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) // fades to black on its own timing, always + if ((wipegamestate == FORCEWIPE || !G_GamestateUsesLevel()) // fades to black on its own timing, always && wipetypepre != UINT8_MAX) { if (rendermode != render_none) @@ -627,7 +626,7 @@ static void D_Display(void) // change gamma if needed // (GS_LEVEL handles this already due to level-specific palettes) - if (forcerefresh && !(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) + if (forcerefresh && !G_GamestateUsesLevel()) V_SetPalette(0); // draw pause pic diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 945dd724b..25fc10243 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6238,7 +6238,7 @@ void HWR_Switch(void) HWR_LoadMapTextures(numtextures); // Create plane polygons - if (!gl_maploaded && (gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) + if (!gl_maploaded && levelloaded) { HWR_ClearAllTextures(); HWR_LoadLevel(); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index e4ecea783..81d01d62b 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -3279,7 +3279,7 @@ static int lib_gAddGametype(lua_State *L) static int Lcheckmapnumber (lua_State *L, int idx, const char *fun) { - if (ISINLEVEL) + if (G_GamestateUsesLevel()) return luaL_optinteger(L, idx, lua_compatmode ? G_NativeMapToKart(gamemap) : gamemap); else { diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 3adb07a64..2bad993df 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -253,7 +253,7 @@ static int mobj_get(lua_State *L) enum mobj_e field = Lua_optoption(L, 2, NULL, mobj_opt); lua_settop(L, 2); - if (!mo || !ISINLEVEL) { + if (!mo || !G_GamestateUsesLevel()) { if (field == mobj_valid) { lua_pushboolean(L, 0); return 1; diff --git a/src/lua_script.h b/src/lua_script.h index 373d7a4ee..d0d9dc99a 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -18,6 +18,7 @@ #include "d_player.h" #include "g_state.h" #include "taglist.h" +#include "g_game.h" // G_GamestateUsesLevel #include "blua/lua.h" #include "blua/lualib.h" @@ -137,10 +138,7 @@ void COM_Lua_f(void); // uncomment if you want seg_t/node_t in Lua // #define HAVE_LUA_SEGS -#define ISINLEVEL \ - (gamestate == GS_LEVEL || titlemapinaction) - -#define INLEVEL if (! ISINLEVEL)\ +#define INLEVEL if (!G_GamestateUsesLevel())\ return luaL_error(L, "This can only be used in a level!"); #ifdef __cplusplus diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 1afe62019..993b16ab7 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -255,10 +255,7 @@ static void M_DrawRenderStats(void) perfstatcol_t batchcalls_col = {220, 200, V_PURPLEMAP, batchcalls_row}; - boolean rendering = ( - gamestate == GS_LEVEL || - (gamestate == GS_TITLESCREEN && titlemapinaction) - ); + boolean rendering = G_GamestateUsesLevel(); draw_row = 10; M_DrawPerfTiming(&frametime_col); @@ -618,7 +615,7 @@ void M_DrawPerfStats(void) } else if (cv_perfstats.value == PS_THINKFRAME) // lua thinkframe { - if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) + if (!G_GamestateUsesLevel()) return; if (vid.width < 640 || vid.height < 400) // low resolution {