diff --git a/src/script/lua_api/l_settings.cpp b/src/script/lua_api/l_settings.cpp index f3f1a57bf..c4395e390 100644 --- a/src/script/lua_api/l_settings.cpp +++ b/src/script/lua_api/l_settings.cpp @@ -12,11 +12,12 @@ #include "log.h" -/* This protects the following from being set: - * 'secure.*' settings - * some security-relevant settings +/* + * This protects the following from being set: + * - 'secure.*' settings + * - some security-relevant settings * (better solution pending) - * some mapgen settings + * - some mapgen settings * (not security-criticial, just to avoid messing up user configs) */ #define CHECK_SETTING_SECURITY(L, name) \ @@ -27,14 +28,16 @@ static inline int checkSettingSecurity(lua_State* L, const std::string &name) { +#if CHECK_CLIENT_BUILD() + // Main menu is allowed everything + if (ModApiBase::getGuiEngine(L) != nullptr) + return 0; +#endif + if (ScriptApiSecurity::isSecure(L) && name.compare(0, 7, "secure.") == 0) throw LuaError("Attempted to set secure setting."); - bool is_mainmenu = false; -#if CHECK_CLIENT_BUILD() - is_mainmenu = ModApiBase::getGuiEngine(L) != nullptr; -#endif - if (!is_mainmenu && (name == "mg_name" || name == "mg_flags")) { + if (name == "mg_name" || name == "mg_flags") { errorstream << "Tried to set global setting " << name << ", ignoring. " "minetest.set_mapgen_setting() should be used instead." << std::endl; infostream << script_get_backtrace(L) << std::endl; @@ -45,11 +48,9 @@ static inline int checkSettingSecurity(lua_State* L, const std::string &name) "main_menu_script", "shader_path", "texture_path", "screenshot_path", "serverlist_file", "serverlist_url", "map-dir", "contentdb_url", }; - if (!is_mainmenu) { - for (const char *name2 : disallowed) { - if (name == name2) - throw LuaError("Attempted to set disallowed setting."); - } + for (const char *name2 : disallowed) { + if (name == name2) + throw LuaError("Attempted to set disallowed setting."); } return 0;