fix loadSound()

This commit is contained in:
Josh Holtrop 2011-05-20 07:44:53 -04:00
parent f78c42c8c8
commit af88db267f

View File

@ -631,21 +631,24 @@ int Engine::loadModel(const string & name, bool is_static, bool is_reference,
int Engine::loadSound(const string & name) int Engine::loadSound(const string & name)
{ {
string nm = name; if (validatePath(name))
if (validatePath(nm))
{ {
FileLoader::Path path("", nm); string nm = locateResource(name.c_str());
refptr<AV::Sound> avs = m_av.createSound(); refptr<AV::Sound> avs = m_av.createSound();
if (avs->load(*m_fileLoader, path)) unsigned int size;
unsigned char *data = loadFile(nm.c_str(), &size);
if (data != NULL)
{ {
return addSound(avs); if (avs->load(data, size))
} {
else /* TODO: memory leak, fix with buffer */
{ return addSound(avs);
cerr << "error loading sound '" << name << "'" << endl; }
free(data);
} }
cerr << "error loading sound '" << name << "'" << endl;
} }
return 0; return 0;
} }