diff options
author | rubenwardy <rw@rubenwardy.com> | 2020-10-31 18:19:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-31 18:19:23 +0000 |
commit | 89dd05fdf35ce465fcc2b3588337f79f818a78aa (patch) | |
tree | 8cd34c9435fd0feca4d35184649bc002cc53d260 /src/script/lua_api/l_base.h | |
parent | 2dff3dd03f7ba25f3fab7c360759ddbf93615668 (diff) | |
download | dragonfireclient-89dd05fdf35ce465fcc2b3588337f79f818a78aa.tar.xz |
Fix segfault in deprecation logging due to tail call, log by default (#10174)
Diffstat (limited to 'src/script/lua_api/l_base.h')
-rw-r--r-- | src/script/lua_api/l_base.h | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/script/lua_api/l_base.h b/src/script/lua_api/l_base.h index 65fce8481..aa5905d26 100644 --- a/src/script/lua_api/l_base.h +++ b/src/script/lua_api/l_base.h @@ -41,7 +41,6 @@ class Environment; class ServerInventoryManager; class ModApiBase : protected LuaHelper { - public: static ScriptApiBase* getScriptApiBase(lua_State *L); static Server* getServer(lua_State *L); @@ -75,10 +74,18 @@ public: lua_CFunction func, int top); - static int l_deprecated_function(lua_State *L); - static void markAliasDeprecated(luaL_Reg *reg); -private: - // <old_name> = { <new_name>, <new_function> } - static std::unordered_map<std::string, luaL_Reg> m_deprecated_wrappers; - static bool m_error_deprecated_calls; + /** + * A wrapper for deprecated functions. + * + * When called, handles the deprecation according to user settings and then calls `func`. + * + * @throws Lua Error if required by the user settings. + * + * @param L Lua state + * @param good Name of good function/method + * @param bad Name of deprecated function/method + * @param func Actual implementation of function + * @return value from `func` + */ + static int l_deprecated_function(lua_State *L, const char *good, const char *bad, lua_CFunction func); }; |