From: James Turner Date: Mon, 6 Sep 2010 08:26:46 +0000 (+0100) Subject: Pass current-dir down through XMLSound X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d75ce1e12ee4fba106bc6595a2fb1b3b50ccbbc1;p=simgear.git Pass current-dir down through XMLSound (should allow relative paths in sound XML files) --- diff --git a/simgear/sound/sample_openal.cxx b/simgear/sound/sample_openal.cxx index 022cb40d..3c9cb864 100644 --- a/simgear/sound/sample_openal.cxx +++ b/simgear/sound/sample_openal.cxx @@ -79,7 +79,7 @@ SGSoundSample::SGSoundSample() : } // constructor -SGSoundSample::SGSoundSample( const char *path, const char *file ) : +SGSoundSample::SGSoundSample(const char *file, const SGPath& currentDir) : _absolute_pos(SGVec3d::zeros()), _relative_pos(SGVec3d::zeros()), _direction(SGVec3d::zeros()), @@ -111,7 +111,7 @@ SGSoundSample::SGSoundSample( const char *path, const char *file ) : _static_changed(true), _is_file(true) { - SGPath p = simgear::ResourceManager::instance()->findPath(file); + SGPath p = simgear::ResourceManager::instance()->findPath(file, currentDir); _refname = p.str(); } diff --git a/simgear/sound/sample_openal.hxx b/simgear/sound/sample_openal.hxx index 491ba572..b2afba4f 100644 --- a/simgear/sound/sample_openal.hxx +++ b/simgear/sound/sample_openal.hxx @@ -60,11 +60,10 @@ public: /** * Constructor - * @param path Path name to sound * @param file File name of sound Buffer data is freed by the sample group */ - SGSoundSample( const char *path, const char *file ); + SGSoundSample(const char *file, const SGPath& currentDir); /** * Constructor. diff --git a/simgear/sound/xmlsound.cxx b/simgear/sound/xmlsound.cxx index 616d9514..2ca9cdfa 100644 --- a/simgear/sound/xmlsound.cxx +++ b/simgear/sound/xmlsound.cxx @@ -84,7 +84,7 @@ SGXmlSound::~SGXmlSound() void SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node, SGSampleGroup *sgrp, SGSampleGroup *avionics, - const string &path) + const SGPath& currentDir) { // @@ -272,7 +272,7 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node, } else { _sgrp = sgrp; } - _sample = new SGSoundSample( path.c_str(), node->getStringValue("path", "")); + _sample = new SGSoundSample(node->getStringValue("path", ""), currentDir); if (!_sample->file_path().exists()) { throw sg_io_exception("XML sound: couldn't find file: " + _sample->file_path().str()); } diff --git a/simgear/sound/xmlsound.hxx b/simgear/sound/xmlsound.hxx index 141f5eef..f3635b08 100644 --- a/simgear/sound/xmlsound.hxx +++ b/simgear/sound/xmlsound.hxx @@ -104,7 +104,7 @@ public: * @param path The path where the audio files remain. */ virtual void init (SGPropertyNode *, SGPropertyNode *, SGSampleGroup *, - SGSampleGroup *, const string &); + SGSampleGroup *, const SGPath& currentDir); /** * Check whether an event has happened and if action has to be taken.