1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Refactor how script api reads current mod name

This is to prevent future mistakes and make it clearer whether
the mod name can be trusted depending on how it is retrieved.
This commit is contained in:
sfan5 2024-02-14 13:29:53 +01:00
parent cb5fa56e17
commit ce97210eb1
8 changed files with 88 additions and 78 deletions

View file

@ -82,8 +82,7 @@ EmergeThread *ModApiBase::getEmergeThread(lua_State *L)
std::string ModApiBase::getCurrentModPath(lua_State *L)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_CURRENT_MOD_NAME);
std::string current_mod_name = readParam<std::string>(L, -1, "");
std::string current_mod_name = ScriptApiBase::getCurrentModNameInsecure(L);
if (current_mod_name.empty())
return ".";