Skip to content

Commit d961ece

Browse files
committedNov 9, 2019
Be lenient with extra slashes for CSM paths
1 parent 485b669 commit d961ece

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed
 

‎clientmods/preview/example.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
print("Loaded example file!, loading more examples")
2-
dofile(core.get_modpath(core.get_current_modname()) .. "examples/first.lua")
2+
dofile(core.get_modpath(core.get_current_modname()) .. "/examples/first.lua")

‎src/client/client.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -1881,8 +1881,17 @@ scene::IAnimatedMesh* Client::getMesh(const std::string &filename, bool cache)
18811881
return mesh;
18821882
}
18831883

1884-
const std::string* Client::getModFile(const std::string &filename)
1884+
const std::string* Client::getModFile(std::string filename)
18851885
{
1886+
// strip dir delimiter from beginning of path
1887+
auto pos = filename.find_first_of(':');
1888+
if (pos == std::string::npos)
1889+
return nullptr;
1890+
pos++;
1891+
auto pos2 = filename.find_first_not_of("/", pos);
1892+
if (pos2 > pos)
1893+
filename.erase(pos, pos2 - pos);
1894+
18861895
StringMap::const_iterator it = m_mod_vfs.find(filename);
18871896
if (it == m_mod_vfs.end())
18881897
return nullptr;

‎src/client/client.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
378378
bool checkLocalPrivilege(const std::string &priv)
379379
{ return checkPrivilege(priv); }
380380
virtual scene::IAnimatedMesh* getMesh(const std::string &filename, bool cache = false);
381-
const std::string* getModFile(const std::string &filename);
381+
const std::string* getModFile(std::string filename);
382382

383383
std::string getModStoragePath() const override;
384384
bool registerModStorage(ModMetadata *meta) override;

0 commit comments

Comments
 (0)
Please sign in to comment.