From a83d9294768fd4a29ad00a6191bc9803c76cdbf4 Mon Sep 17 00:00:00 2001 From: Sky Dusk <47698279+Ace-Lite@users.noreply.github.com> Date: Tue, 4 Feb 2025 11:24:58 +0100 Subject: [PATCH 1/5] Add G_GetCustomExitVars --- src/doomstat.h | 1 + src/g_game.c | 3 ++- src/lua_baselib.c | 29 ++++++++++++++++++++++++----- src/p_setup.c | 1 + 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index b5b2984407..936d622610 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -249,6 +249,7 @@ extern textprompt_t *textprompts[MAX_PROMPTS]; // For the Custom Exit linedef. extern INT16 nextmapoverride; extern UINT8 skipstats; +extern UINT8 luakeepcutscenes; extern INT16 nextgametype; extern UINT32 ssspheres; // Total # of spheres in a level diff --git a/src/g_game.c b/src/g_game.c index 1c186ae031..b73be39b21 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3159,6 +3159,7 @@ void G_DoReborn(INT32 playernum) nextmapoverride = gamemap; countdown2 = TICRATE; skipstats = 2; + luakeepcutscenes = 0; for (i = 0; i < MAXPLAYERS; i++) { @@ -4209,7 +4210,7 @@ void G_AfterIntermission(void) if ((gametyperules & GTR_CUTSCENES) && mapheaderinfo[gamemap-1]->cutscenenum && !modeattacking - && skipstats <= 1 + && (skipstats <= 1 || luakeepcutscenes > 0) && (gamecomplete || !(marathonmode & MA_NOCUTSCENES)) && stagefailed == false) { diff --git a/src/lua_baselib.c b/src/lua_baselib.c index ecd1ee55e6..ab12a301f9 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4171,26 +4171,44 @@ static int lib_gSetCustomExitVars(lua_State *L) // LUA EXTENSION: Custom exit like support // Supported: - // G_SetCustomExitVars(); [reset to defaults] - // G_SetCustomExitVars(int) [nextmap override only] - // G_SetCustomExitVars(nil, int) [skipstats only] - // G_SetCustomExitVars(int, int) [both of the above] - // G_SetCustomExitVars(int, int, int) [nextmapoverride, skipstats and nextgametype] + // G_SetCustomExitVars(); [reset to defaults] + // G_SetCustomExitVars(int) [nextmap override only] + // G_SetCustomExitVars(nil, int) [skipstats only] + // G_SetCustomExitVars(int, int) [both of the above] + // G_SetCustomExitVars(int, int, int) [nextmapoverride, skipstats and nextgametype] + // G_SetCustomExitVars(int, int, int, int) [nextmapoverride, skipstats, nextgametype and keepcutscenes] nextmapoverride = 0; skipstats = 0; nextgametype = -1; + luakeepcutscenes = 0; if (n >= 1) { nextmapoverride = (INT16)luaL_optinteger(L, 1, 0); skipstats = (INT16)luaL_optinteger(L, 2, 0); nextgametype = (INT16)luaL_optinteger(L, 3, -1); + luakeepcutscenes = (INT16)luaL_optinteger(L, 4, 0); } return 0; } +// Another Lua function that doesn't actually exist, but since lib_gSetCustomExitVars exists... +// The get counterpart would have been useful as well. +// Gets nextmapoverride, skipstats and nextgametype for any other use +static int lib_gGetCustomExitVars(lua_State* L) +{ + NOHUD + INLEVEL + + lua_pushinteger(L, nextmapoverride); + lua_pushinteger(L, skipstats); + lua_pushinteger(L, nextgametype); + lua_pushinteger(L, luakeepcutscenes); + return 4; +} + static int lib_gEnoughPlayersFinished(lua_State *L) { INLEVEL @@ -4632,6 +4650,7 @@ static luaL_Reg lib[] = { {"G_FindMapByNameOrCode",lib_gFindMapByNameOrCode}, {"G_DoReborn",lib_gDoReborn}, {"G_SetCustomExitVars",lib_gSetCustomExitVars}, + {"G_GetCustomExitVars", lib_gGetCustomExitVars}, {"G_EnoughPlayersFinished",lib_gEnoughPlayersFinished}, {"G_ExitLevel",lib_gExitLevel}, {"G_IsSpecialStage",lib_gIsSpecialStage}, diff --git a/src/p_setup.c b/src/p_setup.c index c2b8f2db2e..9d6fcca007 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8120,6 +8120,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) R_PrecacheLevel(); nextmapoverride = 0; + luakeepcutscenes = 0; skipstats = 0; levelloading = false; -- GitLab From d3ec5be5426e78f683f9839943a47dcf3e3f229d Mon Sep 17 00:00:00 2001 From: Sky Dusk <47698279+Ace-Lite@users.noreply.github.com> Date: Tue, 4 Feb 2025 11:44:27 +0100 Subject: [PATCH 2/5] Oops, accidently deleted while copying. --- src/g_game.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/g_game.c b/src/g_game.c index b73be39b21..e3f1c41b09 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -160,6 +160,7 @@ textprompt_t *textprompts[MAX_PROMPTS]; INT16 nextmapoverride; UINT8 skipstats; +UINT8 luakeepcutscenes; INT16 nextgametype = -1; // Pointers to each CTF flag -- GitLab From abbdd18db7aca9ce5bbdfcfee11cec91a4217c7c Mon Sep 17 00:00:00 2001 From: Sky Dusk <47698279+Ace-Lite@users.noreply.github.com> Date: Tue, 4 Feb 2025 12:10:31 +0100 Subject: [PATCH 3/5] Removal of NOHUD and INLEVEL macros, function should be harmless in both cases --- src/lua_baselib.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index ab12a301f9..6adf5b1599 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4199,9 +4199,6 @@ static int lib_gSetCustomExitVars(lua_State *L) // Gets nextmapoverride, skipstats and nextgametype for any other use static int lib_gGetCustomExitVars(lua_State* L) { - NOHUD - INLEVEL - lua_pushinteger(L, nextmapoverride); lua_pushinteger(L, skipstats); lua_pushinteger(L, nextgametype); -- GitLab From d2a8654563ee57e4837ec603d3dcdc358b33a9e5 Mon Sep 17 00:00:00 2001 From: Sky Dusk <47698279+Ace-Lite@users.noreply.github.com> Date: Tue, 4 Feb 2025 12:54:52 +0100 Subject: [PATCH 4/5] Make keepcutscene, nextgametype, skipstats and nextmapoverdrive Lua globals instead. Also add custom exit option for keepcutscene. --- extras/conf/udb/Includes/SRB222_linedefs.cfg | 1 + src/doomstat.h | 2 +- src/g_game.c | 7 ++++--- src/lua_baselib.c | 19 ++++--------------- src/lua_script.c | 12 ++++++++++++ src/p_setup.c | 2 +- src/p_spec.c | 4 ++++ src/p_spec.h | 1 + 8 files changed, 28 insertions(+), 20 deletions(-) diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg index ce1979581f..1b3343c9c5 100644 --- a/extras/conf/udb/Includes/SRB222_linedefs.cfg +++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg @@ -125,6 +125,7 @@ udmf { 1 = "Skip score tally"; 2 = "Check emeralds"; + 4 = "Keep post level cutscene if score tally is skipped"; } } arg2 diff --git a/src/doomstat.h b/src/doomstat.h index 936d622610..a996941862 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -249,7 +249,7 @@ extern textprompt_t *textprompts[MAX_PROMPTS]; // For the Custom Exit linedef. extern INT16 nextmapoverride; extern UINT8 skipstats; -extern UINT8 luakeepcutscenes; +extern boolean keepcutscene; extern INT16 nextgametype; extern UINT32 ssspheres; // Total # of spheres in a level diff --git a/src/g_game.c b/src/g_game.c index e3f1c41b09..95f96ccf21 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -160,9 +160,10 @@ textprompt_t *textprompts[MAX_PROMPTS]; INT16 nextmapoverride; UINT8 skipstats; -UINT8 luakeepcutscenes; INT16 nextgametype = -1; +boolean keepcutscene; + // Pointers to each CTF flag mobj_t *redflag; mobj_t *blueflag; @@ -3160,7 +3161,7 @@ void G_DoReborn(INT32 playernum) nextmapoverride = gamemap; countdown2 = TICRATE; skipstats = 2; - luakeepcutscenes = 0; + forcekeepcutscenes = 0; for (i = 0; i < MAXPLAYERS; i++) { @@ -4211,7 +4212,7 @@ void G_AfterIntermission(void) if ((gametyperules & GTR_CUTSCENES) && mapheaderinfo[gamemap-1]->cutscenenum && !modeattacking - && (skipstats <= 1 || luakeepcutscenes > 0) + && (skipstats <= 1 || keepcutscene == true) && (gamecomplete || !(marathonmode & MA_NOCUTSCENES)) && stagefailed == false) { diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 6adf5b1599..211336c8cb 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -4181,31 +4181,21 @@ static int lib_gSetCustomExitVars(lua_State *L) nextmapoverride = 0; skipstats = 0; nextgametype = -1; - luakeepcutscenes = 0; + keepcutscene = false; if (n >= 1) { nextmapoverride = (INT16)luaL_optinteger(L, 1, 0); skipstats = (INT16)luaL_optinteger(L, 2, 0); nextgametype = (INT16)luaL_optinteger(L, 3, -1); - luakeepcutscenes = (INT16)luaL_optinteger(L, 4, 0); + + if (!lua_isnil(L, 4)) + keepcutscene = luaL_checkboolean(L, 4); } return 0; } -// Another Lua function that doesn't actually exist, but since lib_gSetCustomExitVars exists... -// The get counterpart would have been useful as well. -// Gets nextmapoverride, skipstats and nextgametype for any other use -static int lib_gGetCustomExitVars(lua_State* L) -{ - lua_pushinteger(L, nextmapoverride); - lua_pushinteger(L, skipstats); - lua_pushinteger(L, nextgametype); - lua_pushinteger(L, luakeepcutscenes); - return 4; -} - static int lib_gEnoughPlayersFinished(lua_State *L) { INLEVEL @@ -4647,7 +4637,6 @@ static luaL_Reg lib[] = { {"G_FindMapByNameOrCode",lib_gFindMapByNameOrCode}, {"G_DoReborn",lib_gDoReborn}, {"G_SetCustomExitVars",lib_gSetCustomExitVars}, - {"G_GetCustomExitVars", lib_gGetCustomExitVars}, {"G_EnoughPlayersFinished",lib_gEnoughPlayersFinished}, {"G_ExitLevel",lib_gExitLevel}, {"G_IsSpecialStage",lib_gIsSpecialStage}, diff --git a/src/lua_script.c b/src/lua_script.c index 686555a16d..ff2ced1ecf 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -274,6 +274,18 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word,"tutorialmode")) { lua_pushboolean(L, tutorialmode); return 1; + } else if (fastcmp(word, "keepcutscene")) { + lua_pushboolean(L, keepcutscene); + return 1; + } else if (fastcmp(word, "nextgametype")) { + lua_pushinteger(L, nextgametype); + return 1; + } else if (fastcmp(word, "skipstats")) { + lua_pushinteger(L, skipstats); + return 1; + } else if (fastcmp(word, "nextmapoverride")) { + lua_pushinteger(L, nextmapoverride); + return 1; // end map vars // begin CTF colors } else if (fastcmp(word,"skincolor_redteam")) { diff --git a/src/p_setup.c b/src/p_setup.c index 9d6fcca007..296ebbf0ac 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8120,7 +8120,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) R_PrecacheLevel(); nextmapoverride = 0; - luakeepcutscenes = 0; + keepcutscene = false; skipstats = 0; levelloading = false; diff --git a/src/p_spec.c b/src/p_spec.c index 93809cbb4b..ddc97831e3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4573,6 +4573,10 @@ static void P_ProcessExitSector(player_t *player, mtag_t sectag) if (lines[lineindex].args[1] & TMEF_SKIPTALLY) skipstats = 1; + + //skip stats actually skips post-level cutscenes. + if (lines[lineindex].args[1] & TMEF_KEEPCUTSCENE) + keepcutscene = true; } static void P_ProcessTeamBase(player_t *player, boolean redteam) diff --git a/src/p_spec.h b/src/p_spec.h index ba08781b63..7fd99ac65c 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -130,6 +130,7 @@ typedef enum { TMEF_SKIPTALLY = 1, TMEF_EMERALDCHECK = 1<<1, + TMEF_KEEPCUTSCENE = 1<<2, } textmapexitflags_t; typedef enum -- GitLab From 43ca8fe6d0a1c12e267ec30bc412cb6551add9d7 Mon Sep 17 00:00:00 2001 From: Sky Dusk <47698279+Ace-Lite@users.noreply.github.com> Date: Tue, 4 Feb 2025 13:09:26 +0100 Subject: [PATCH 5/5] housekeeping VS auto nonsense to keep style --- src/g_game.c | 2 +- src/lua_script.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 95f96ccf21..ea4cdaf539 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3161,7 +3161,7 @@ void G_DoReborn(INT32 playernum) nextmapoverride = gamemap; countdown2 = TICRATE; skipstats = 2; - forcekeepcutscenes = 0; + keepcutscene = 0; for (i = 0; i < MAXPLAYERS; i++) { diff --git a/src/lua_script.c b/src/lua_script.c index ff2ced1ecf..adf095d593 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -274,16 +274,16 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word,"tutorialmode")) { lua_pushboolean(L, tutorialmode); return 1; - } else if (fastcmp(word, "keepcutscene")) { + } else if (fastcmp(word,"keepcutscene")) { lua_pushboolean(L, keepcutscene); return 1; - } else if (fastcmp(word, "nextgametype")) { + } else if (fastcmp(word,"nextgametype")) { lua_pushinteger(L, nextgametype); return 1; - } else if (fastcmp(word, "skipstats")) { + } else if (fastcmp(word,"skipstats")) { lua_pushinteger(L, skipstats); return 1; - } else if (fastcmp(word, "nextmapoverride")) { + } else if (fastcmp(word,"nextmapoverride")) { lua_pushinteger(L, nextmapoverride); return 1; // end map vars -- GitLab