diff --git a/simgear/sound/xmlsound.cxx b/simgear/sound/xmlsound.cxx index f0d6e56e..4d597bec 100644 --- a/simgear/sound/xmlsound.cxx +++ b/simgear/sound/xmlsound.cxx @@ -74,8 +74,7 @@ SGXmlSound::SGXmlSound() _dt_play(0.0), _dt_stop(0.0), _delay(0.0), - _stopping(0.0), - _initialized(false) + _stopping(0.0) { } @@ -337,19 +336,12 @@ 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 // or if the mode is IN_TRANSIT then // test whether the current value matches the previous value. - if ( // Lisp, anyone? + if ( // Lisp, anyone? (_condition && !_condition->test()) || (!_condition && _property && ( diff --git a/simgear/sound/xmlsound.hxx b/simgear/sound/xmlsound.hxx index 53f9adcb..78d6ae7e 100644 --- a/simgear/sound/xmlsound.hxx +++ b/simgear/sound/xmlsound.hxx @@ -116,6 +116,14 @@ public: */ virtual void update (double dt); + /** + * Start taking action on the pre-defined events. + */ + void start() { + if (_property) _prev_value = _property->getDoubleValue(); + _active = false; + } + /** * Stop taking action on the pre-defined events. */ @@ -158,7 +166,6 @@ private: double _delay; // time after which the sound should be started (default: 0) double _stopping; // time after the sound should have stopped. // This is useful for lost packets in in-transit mode. - bool _initialized; // sound system version 1.0 std::vector<_snd_prop> _volume;