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

(edit: don't) Fix unpack, and some other things

This commit is contained in:
Desour 2025-02-22 12:37:39 +01:00
parent a70fee4d35
commit 439ac1d192
4 changed files with 8 additions and 15 deletions

View file

@ -162,11 +162,11 @@ Client::Client(
} }
{ {
//TODO: network packets //FIXME: network packets
//TODO: check that *client_builtin* is not overridden //FIXME: check that *client_builtin* is not overridden
std::string enable_sscsm = g_settings->get("enable_sscsm"); std::string enable_sscsm = g_settings->get("enable_sscsm");
if (enable_sscsm == "singleplayer") { if (enable_sscsm == "singleplayer") { //FIXME: enum
auto event1 = std::make_unique<SSCSMEventUpdateVFSFiles>(); auto event1 = std::make_unique<SSCSMEventUpdateVFSFiles>();
event1->files.emplace_back("sscsm_test0:init.lua", event1->files.emplace_back("sscsm_test0:init.lua",
R"=+=( R"=+=(

View file

@ -76,7 +76,7 @@ ScriptApiBase::ScriptApiBase(ScriptingType type):
lua_atpanic(m_luastack, &luaPanic); lua_atpanic(m_luastack, &luaPanic);
if (m_type == ScriptingType::Client) if (m_type == ScriptingType::Client || m_type == ScriptingType::SSCSM)
clientOpenLibs(m_luastack); clientOpenLibs(m_luastack);
else else
luaL_openlibs(m_luastack); luaL_openlibs(m_luastack);
@ -213,7 +213,8 @@ void ScriptApiBase::checkSetByBuiltin()
if (getType() == ScriptingType::Server || if (getType() == ScriptingType::Server ||
(getType() == ScriptingType::Async && m_gamedef) || (getType() == ScriptingType::Async && m_gamedef) ||
getType() == ScriptingType::Emerge || getType() == ScriptingType::Emerge ||
getType() == ScriptingType::Client) { getType() == ScriptingType::Client ||
getType() == ScriptingType::SSCSM) {
CHECK(CUSTOM_RIDX_READ_NODE, "read_node"); CHECK(CUSTOM_RIDX_READ_NODE, "read_node");
CHECK(CUSTOM_RIDX_PUSH_NODE, "push_node"); CHECK(CUSTOM_RIDX_PUSH_NODE, "push_node");
} }

View file

@ -392,7 +392,6 @@ void ScriptApiSecurity::initializeSecuritySSCSM()
"next", "next",
"pairs", "pairs",
"pcall", "pcall",
"print", //TODO
"rawequal", "rawequal",
"rawget", "rawget",
"rawset", "rawset",
@ -403,7 +402,7 @@ void ScriptApiSecurity::initializeSecuritySSCSM()
"tonumber", "tonumber",
"tostring", "tostring",
"type", "type",
"unpack", //TODO: replace, because of UB in some lua versions "unpack",
"_VERSION", "_VERSION",
"xpcall", "xpcall",
// Completely safe libraries // Completely safe libraries
@ -423,7 +422,6 @@ void ScriptApiSecurity::initializeSecuritySSCSM()
"getinfo", // used by builtin and unset before mods load //TODO "getinfo", // used by builtin and unset before mods load //TODO
"traceback" //TODO: is this fine, or does it print paths of C functions? "traceback" //TODO: is this fine, or does it print paths of C functions?
}; };
#if USE_LUAJIT #if USE_LUAJIT
static const char *jit_whitelist[] = { static const char *jit_whitelist[] = {
"arch", "arch",
@ -469,7 +467,7 @@ void ScriptApiSecurity::initializeSecuritySSCSM()
lua_pop(L, 1); // Pop old OS lua_pop(L, 1); // Pop old OS
// Copy safe debug functions //TODO // Copy safe debug functions
lua_getglobal(L, "debug"); lua_getglobal(L, "debug");
lua_newtable(L); lua_newtable(L);
copy_safe(L, debug_whitelist, sizeof(debug_whitelist)); copy_safe(L, debug_whitelist, sizeof(debug_whitelist));

View file

@ -9,12 +9,6 @@
class ModApiSSCSM : public ModApiBase class ModApiSSCSM : public ModApiBase
{ {
private: private:
// print(text)
static int l_print(lua_State *L);
// log([level], text)
static int l_log(lua_State *L);
// get_node_or_nil(pos) // get_node_or_nil(pos)
static int l_get_node_or_nil(lua_State *L); static int l_get_node_or_nil(lua_State *L);