subdirectories work for real this time

This commit is contained in:
Josh Holtrop 2010-12-19 00:11:34 -05:00
parent 2edea049bd
commit df953ef20f

View File

@ -68,9 +68,10 @@ static void normalize(dVector3 vec)
static vector<string> split(const string & str, char delim)
{
vector<string> 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<AV::Sound> 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 != "")