Lua_optoption shouldn't change stack state at the end of call now

This commit is contained in:
indev authored and Alug committed 2024-06-03 17:02:14 +02:00
1 parent c8fb25066b
commit 9552e09471
1 file changed
+8 -3
+8 -3
View File
@@ -1690,6 +1690,8 @@ void LUA_UnArchiveDemo(void)
// For mobj_t, player_t, etc. to take custom variables.
int Lua_optoption(lua_State *L, int narg, int def, int list_ref)
{
int result = -1;
if (lua_isnoneornil(L, narg))
return def;
@@ -1702,8 +1704,11 @@ int Lua_optoption(lua_State *L, int narg, int def, int list_ref)
lua_rawget(L, -2);
if (lua_isnumber(L, -1))
return lua_tointeger(L, -1);
return -1;
result = lua_tointeger(L, -1);
lua_pop(L, 2); // Pop result and fields table
return result;
}
@@ -1720,4 +1725,4 @@ int Lua_CreateFieldTable(lua_State *L, const char *const lst[])
}
return luaL_ref(L, LUA_REGISTRYINDEX);
}
}