From da1ef9376c28bd03c277b9ece5c148130fb7d057 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 14 Dec 2020 03:13:25 -0800 Subject: [PATCH] Use only one state for LUA_EvalMath and open enum lib once --- src/deh_lua.c | 63 ++++++++++++++++++++++------------------------ src/deh_lua.h | 2 ++ src/lua_script.c | 65 +++++++++++++++++++++++++++++------------------- 3 files changed, 72 insertions(+), 58 deletions(-) diff --git a/src/deh_lua.c b/src/deh_lua.c index e6a436421..043c229fb 100644 --- a/src/deh_lua.c +++ b/src/deh_lua.c @@ -29,6 +29,8 @@ #include "deh_soc.h" // for get_mus #endif +boolean lua_mathlib; + // freeslot takes a name (string only!) // and allocates it to the appropriate free slot. // Returns the slot number allocated for it or nil if failed. @@ -224,7 +226,6 @@ static inline int lib_getenum(lua_State *L) { const char *word, *p; fixed_t i; - boolean mathlib = lua_toboolean(L, lua_upvalueindex(1)); if (lua_type(L,2) != LUA_TSTRING) return 0; word = lua_tostring(L,2); @@ -234,7 +235,7 @@ static inline int lib_getenum(lua_State *L) lua_pushinteger(L, *word-'A'); return 1; } - if (mathlib) return luaL_error(L, "constant '%s' could not be parsed.\n", word); + if (lua_mathlib) return luaL_error(L, "constant '%s' could not be parsed.\n", word); return 0; } else if (fastncmp("MF_", word, 3)) { @@ -244,7 +245,7 @@ static inline int lib_getenum(lua_State *L) lua_pushinteger(L, ((lua_Integer)1<