Michael Danilov: Fix issue #2169 Sound with condition=false will play when moving into its max-dist (patch available)

This commit is contained in:
Erik Hofman 2021-08-20 11:47:03 +02:00 committed by Michael Danilov
parent a157e50302
commit 631fa62495
2 changed files with 6 additions and 3 deletions

View File

@ -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;
}
/**

View File

@ -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))