Skip to content

Commit

Permalink
Be lenient with extra slashes for CSM paths
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Nov 9, 2019
1 parent 485b669 commit d961ece
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 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")
11 changes: 10 additions & 1 deletion src/client/client.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/client/client.h
Expand Up @@ -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;
Expand Down

0 comments on commit d961ece

Please sign in to comment.