FadeInOutSound not working correctly at high frame rates
In the FadeInOutSound::play function in soundlib.cpp:
dt = oapiGetSimStep(); currentVolume -= int(round(double(fadeSlope) * dt));
If the frame rate is large enough, which makes dt a very small number, then the
round(double(fadeSlope) * dt)
part of the line rounds down to 0 and so currentVolume doesn't get decremented at all. Also depends on the magnitude of fadeSlope.
Potential fix is making currentVolume a double instead of an int and implementing some code that converts back to an integer safely before the Sound::play function is called. "ceil" instead of "round" just makes the fade in/out very fast at high framerates and would also make it a bit too fast at "normal" framerates, so that solution is not desirable.
Potentially fixed in PR #1170 with the latest 3 commits starting here: , which transition our volume to use a double precision floating point ranging from 0.0 to 1.0 instead of an integer from 0 to 255.
Closed via #1170.