X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fsound%2Fxmlsound.cxx;h=f3471d4ef0c2c9cfdf2d1b2203f34b8eb071c9e2;hb=be7065674586ffbb5940ab21a028bc8c461217e2;hp=616d9514f59d976da1c4e4a7f32437929a8e8b3c;hpb=44c587400d67cb5ba2a3aeff3fe61d033553cf5b;p=simgear.git diff --git a/simgear/sound/xmlsound.cxx b/simgear/sound/xmlsound.cxx index 616d9514..f3471d4e 100644 --- a/simgear/sound/xmlsound.cxx +++ b/simgear/sound/xmlsound.cxx @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -68,7 +69,8 @@ SGXmlSound::SGXmlSound() _dt_play(0.0), _dt_stop(0.0), _delay(0.0), - _stopping(0.0) + _stopping(0.0), + _initialized(false) { } @@ -84,7 +86,7 @@ SGXmlSound::~SGXmlSound() void SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node, SGSampleGroup *sgrp, SGSampleGroup *avionics, - const string &path) + const SGPath& currentDir) { // @@ -272,9 +274,10 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node, } else { _sgrp = sgrp; } - _sample = new SGSoundSample( path.c_str(), node->getStringValue("path", "")); + string soundFileStr = node->getStringValue("path", ""); + _sample = new SGSoundSample(soundFileStr.c_str(), currentDir); if (!_sample->file_path().exists()) { - throw sg_io_exception("XML sound: couldn't find file: " + _sample->file_path().str()); + throw sg_io_exception("XML sound: couldn't find file: '" + soundFileStr + "'"); } _sample->set_relative_position( offset_pos ); @@ -298,6 +301,13 @@ SGXmlSound::update (double dt) if (_property) curr_value = _property->getDoubleValue(); + if (!_initialized) + { + // update initial value before detecting changes + _prev_value = curr_value; + _initialized = true; + } + // If a condition is defined, test whether it is FALSE, // else // if a property is defined then test if it's value is FALSE