aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_mainmenu.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-04-09 22:36:10 +0200
committerGitHub <noreply@github.com>2021-04-09 22:36:10 +0200
commit0abc1e98edb87b2e23eecccfd6b1393ac7fb4f56 (patch)
treef67a5afc1872850637c3e3c6bb698d36ec4f51b5 /src/script/lua_api/l_mainmenu.cpp
parenta0e7a4a0df8fe49907abad2e28f9709d571386e1 (diff)
downloadminetest-0abc1e98edb87b2e23eecccfd6b1393ac7fb4f56.tar.xz
Fix server favorites not saving when client/serverlist/ doesn't exist already (#11152)
Diffstat (limited to 'src/script/lua_api/l_mainmenu.cpp')
-rw-r--r--src/script/lua_api/l_mainmenu.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index 6826ece05..6488cd0fc 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)))