diff options
author | sfan5 <sfan5@live.de> | 2021-04-02 16:31:44 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2021-04-05 16:02:32 +0200 |
commit | e5f802ab5cb32b242b0261000f8836a7da72a4bc (patch) | |
tree | db3cf0c20750dca8842efeafaac766cc4c299ae2 /src/script/lua_api | |
parent | 847860fc5cf8867deb45646670ce1f11c3f977b0 (diff) | |
download | minetest-e5f802ab5cb32b242b0261000f8836a7da72a4bc.tar.gz minetest-e5f802ab5cb32b242b0261000f8836a7da72a4bc.tar.bz2 minetest-e5f802ab5cb32b242b0261000f8836a7da72a4bc.zip |
Fix server favorites not saving when client/serverlist/ doesn't exist already (#11152)
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_mainmenu.cpp | 19 | ||||
-rw-r--r-- | src/script/lua_api/l_mainmenu.h | 2 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index ba7f708a4..3e9709bde 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -716,21 +716,24 @@ int ModApiMainMenu::l_get_mainmenu_path(lua_State *L) } /******************************************************************************/ -bool ModApiMainMenu::mayModifyPath(const std::string &path) +bool ModApiMainMenu::mayModifyPath(std::string path) { + path = fs::RemoveRelativePathComponents(path); + if (fs::PathStartsWith(path, fs::TempPath())) return true; - if (fs::PathStartsWith(path, fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM "games"))) - return true; + std::string path_user = fs::RemoveRelativePathComponents(porting::path_user); - if (fs::PathStartsWith(path, fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM "mods"))) + if (fs::PathStartsWith(path, path_user + DIR_DELIM "client")) return true; - - if (fs::PathStartsWith(path, fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM "textures"))) + if (fs::PathStartsWith(path, path_user + DIR_DELIM "games")) return true; - - if (fs::PathStartsWith(path, fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM "worlds"))) + if (fs::PathStartsWith(path, path_user + DIR_DELIM "mods")) + return true; + if (fs::PathStartsWith(path, path_user + DIR_DELIM "textures")) + return true; + if (fs::PathStartsWith(path, path_user + DIR_DELIM "worlds")) return true; if (fs::PathStartsWith(path, fs::RemoveRelativePathComponents(porting::path_cache))) diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h index 49ce7c251..33ac9e721 100644 --- a/src/script/lua_api/l_mainmenu.h +++ b/src/script/lua_api/l_mainmenu.h @@ -58,7 +58,7 @@ private: * @param path path to check * @return true if the path may be modified */ - static bool mayModifyPath(const std::string &path); + static bool mayModifyPath(std::string path); //api calls |