diff options
author | sfan5 <sfan5@live.de> | 2019-11-09 15:11:21 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2019-11-09 16:08:38 +0100 |
commit | d961ece144c239a61ff46d830041249867656e9c (patch) | |
tree | 2fba4befafb5ea7ff0643d6626c293606ad91fa1 | |
parent | 485b669840b43af1b10a5e11bf65373c88f63395 (diff) | |
download | minetest-d961ece144c239a61ff46d830041249867656e9c.tar.gz minetest-d961ece144c239a61ff46d830041249867656e9c.tar.bz2 minetest-d961ece144c239a61ff46d830041249867656e9c.zip |
Be lenient with extra slashes for CSM paths
-rw-r--r-- | clientmods/preview/example.lua | 2 | ||||
-rw-r--r-- | src/client/client.cpp | 11 | ||||
-rw-r--r-- | src/client/client.h | 2 |
3 files changed, 12 insertions, 3 deletions
diff --git a/clientmods/preview/example.lua b/clientmods/preview/example.lua index 41dc3b284..2f42eef64 100644 --- a/clientmods/preview/example.lua +++ b/clientmods/preview/example.lua @@ -1,2 +1,2 @@ print("Loaded example file!, loading more examples") -dofile(core.get_modpath(core.get_current_modname()) .. "examples/first.lua") +dofile(core.get_modpath(core.get_current_modname()) .. "/examples/first.lua") diff --git a/src/client/client.cpp b/src/client/client.cpp index fd7673a99..0908e52f9 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1881,8 +1881,17 @@ scene::IAnimatedMesh* Client::getMesh(const std::string &filename, bool cache) return mesh; } -const std::string* Client::getModFile(const std::string &filename) +const std::string* Client::getModFile(std::string filename) { + // strip dir delimiter from beginning of path + auto pos = filename.find_first_of(':'); + if (pos == std::string::npos) + return nullptr; + pos++; + auto pos2 = filename.find_first_not_of("/", pos); + if (pos2 > pos) + filename.erase(pos, pos2 - pos); + StringMap::const_iterator it = m_mod_vfs.find(filename); if (it == m_mod_vfs.end()) return nullptr; diff --git a/src/client/client.h b/src/client/client.h index 40ad4c064..53b47edd0 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -378,7 +378,7 @@ public: bool checkLocalPrivilege(const std::string &priv) { return checkPrivilege(priv); } virtual scene::IAnimatedMesh* getMesh(const std::string &filename, bool cache = false); - const std::string* getModFile(const std::string &filename); + const std::string* getModFile(std::string filename); std::string getModStoragePath() const override; bool registerModStorage(ModMetadata *meta) override; |