From 631fa62495201245bde935e8d287e266a9373630 Mon Sep 17 00:00:00 2001 From: Erik Hofman Date: Fri, 20 Aug 2021 11:47:03 +0200 Subject: [PATCH] Michael Danilov: Fix issue #2169 Sound with condition=false will play when moving into its max-dist (patch available) --- simgear/sound/sample.hxx | 2 +- simgear/sound/xmlsound.cxx | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/simgear/sound/sample.hxx b/simgear/sound/sample.hxx index bc12b050..804fe549 100644 --- a/simgear/sound/sample.hxx +++ b/simgear/sound/sample.hxx @@ -343,7 +343,7 @@ public: * Schedule this audio sample to stop (or start) playing. */ inline void set_out_of_range(bool oor = true) { - _out_of_range = oor; _playing = (!oor && _loop); _changed = true; + _out_of_range = oor; _changed = true; } /** diff --git a/simgear/sound/xmlsound.cxx b/simgear/sound/xmlsound.cxx index b358b2a6..1aba2f3b 100644 --- a/simgear/sound/xmlsound.cxx +++ b/simgear/sound/xmlsound.cxx @@ -347,7 +347,9 @@ SGXmlSound::update (double dt) // 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. + // test whether the current value matches the previous value, + // else + // check if out of range. if ( // Lisp, anyone? (_condition && !_condition->test()) || (!_condition && _property && @@ -355,7 +357,8 @@ SGXmlSound::update (double dt) !curr_value || ( (_mode == SGXmlSound::IN_TRANSIT) && (curr_value == _prev_value) ) ) - ) + ) || + _sample->test_out_of_range() ) { if ((_mode != SGXmlSound::IN_TRANSIT) || (_stopping > MAX_TRANSIT_TIME))