From 1fe79fe236b895a031eb8f6c008be159ceb1b0f0 Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 8 Aug 2025 18:57:58 +0300 Subject: [PATCH] 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);