]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/xmlsound.cxx
Introduce "PRESERVE" flag to protect properties on sim reset.
[simgear.git] / simgear / sound / xmlsound.cxx
index 616d9514f59d976da1c4e4a7f32437929a8e8b3c..0c54798f7562612a854a63bd2676bb4b816de321 100644 (file)
@@ -68,7 +68,8 @@ SGXmlSound::SGXmlSound()
     _dt_play(0.0),
     _dt_stop(0.0),
     _delay(0.0),
-    _stopping(0.0)
+    _stopping(0.0),
+    _initialized(false)
 {
 }
 
@@ -84,7 +85,7 @@ SGXmlSound::~SGXmlSound()
 void
 SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node,
                  SGSampleGroup *sgrp, SGSampleGroup *avionics,
-                 const string &path)
+                 const SGPath& currentDir)
 {
 
    //
@@ -272,7 +273,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());
    }
@@ -298,6 +299,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