]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Be lenient with extra slashes for CSM paths
authorsfan5 <sfan5@live.de>
Sat, 9 Nov 2019 14:11:21 +0000 (15:11 +0100)
committersfan5 <sfan5@live.de>
Sat, 9 Nov 2019 15:08:38 +0000 (16:08 +0100)
clientmods/preview/example.lua
src/client/client.cpp
src/client/client.h

index 41dc3b2847238059877840213903da451d925054..2f42eef64624cc850d72ea91a9ec23272c058ede 100644 (file)
@@ -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")
index fd7673a994101eae9a24b93845cae00a51ef4650..0908e52f9e674d0c40d6362e8a2b696480d192d8 100644 (file)
@@ -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;
index 40ad4c064ae4bb7bb19b2183cde72f8b771bf5e2..53b47edd009c1dcd7e4e1d8499fc093e6912392c 100644 (file)
@@ -378,7 +378,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
        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;