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

Async environment for mods to do concurrent tasks (#11131)

This commit is contained in:
sfan5 2022-05-02 20:55:04 +02:00
parent 663c936428
commit e7659883cc
38 changed files with 1646 additions and 48 deletions

View file

@ -166,3 +166,17 @@ void log_deprecated(lua_State *L, std::string message, int stack_depth)
infostream << script_get_backtrace(L) << std::endl;
}
void call_string_dump(lua_State *L, int idx)
{
// Retrieve string.dump from insecure env to avoid it being tampered with
lua_rawgeti(L, LUA_REGISTRYINDEX, CUSTOM_RIDX_GLOBALS_BACKUP);
if (!lua_isnil(L, -1))
lua_getfield(L, -1, "string");
else
lua_getglobal(L, "string");
lua_getfield(L, -1, "dump");
lua_remove(L, -2); // remove _G
lua_remove(L, -2); // remove 'string' table
lua_pushvalue(L, idx);
lua_call(L, 1, 1);
}