From df953ef20fa97825d1dfd6775615e8d13507a42c Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 19 Dec 2010 00:11:34 -0500 Subject: [PATCH] subdirectories work for real this time --- Engine.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Engine.cc b/Engine.cc index 0844443..bc2c965 100644 --- a/Engine.cc +++ b/Engine.cc @@ -68,9 +68,10 @@ static void normalize(dVector3 vec) static vector split(const string & str, char delim) { vector ret; - ssize_t begin = 0, pos; - int len = str.length(); - while ((pos = str.find(delim)) != string::npos && begin < len) + ssize_t begin = 0, len = str.length(); + size_t pos; + while ((pos = str.find(delim)) != string::npos + && begin < len) { ret.push_back(string(str, begin, pos - begin)); begin = pos + 1; @@ -578,11 +579,11 @@ int Engine::clearEventHandler(lua_State * L) int Engine::loadModel(const string & name, bool is_static, bool is_reference, bool enable_blending, float scale) { - size_t pos = name.find_first_not_of(FILENAME_SAFE_CHARS); - if (pos == string::npos) + string path = name; + if (validatePath(path)) { - FileLoader::Path model_path("", name + ".obj"); - FileLoader::Path phys_path("", name + ".phy"); + FileLoader::Path model_path("", path + ".obj"); + FileLoader::Path phys_path("", path + ".phy"); WFObj * obj = new WFObj(*m_fileLoader, m_textureCache); @@ -608,10 +609,10 @@ int Engine::loadModel(const string & name, bool is_static, bool is_reference, int Engine::loadSound(const string & name) { - size_t pos = name.find_first_not_of(FILENAME_SAFE_CHARS); - if (pos == string::npos) + string nm = name; + if (validatePath(nm)) { - FileLoader::Path path("", name); + FileLoader::Path path("", nm); refptr avs = m_av.createSound(); @@ -640,8 +641,7 @@ void Engine::exit() bool Engine::import(const char * name) { string nm(name); - size_t pos = nm.find_first_not_of(FILENAME_SAFE_CHARS); - if (pos == string::npos) + if (validatePath(nm)) { string file_path = locateResource(nm + ".lua"); if (file_path != "")