diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-05-13 12:03:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-13 12:03:11 +0200 |
commit | 6673aff685047d4a0e6254f3b62313425e8f5b3c (patch) | |
tree | 9edf8177760eec9fcde5accb9a91cecd2307bf6d /src/game.cpp | |
parent | 9b8ca3a746cdb9478a46939d36c30484a97255e1 (diff) | |
download | minetest-6673aff685047d4a0e6254f3b62313425e8f5b3c.tar.gz minetest-6673aff685047d4a0e6254f3b62313425e8f5b3c.tar.bz2 minetest-6673aff685047d4a0e6254f3b62313425e8f5b3c.zip |
Limit properly the sound setting at updateSound runtime step (#5753)
* Limit properly the sound setting at updateSound runtime step
Fix #5026
* Add a comment
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/game.cpp b/src/game.cpp index ab8eb5c70..f237a87aa 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3444,7 +3444,15 @@ void Game::updateSound(f32 dtime) v3f(0, 0, 0), // velocity camera->getDirection(), camera->getCameraNode()->getUpVector()); - sound->setListenerGain(g_settings->getFloat("sound_volume")); + + // Check if volume is in the proper range, else fix it. + float old_volume = g_settings->getFloat("sound_volume"); + float new_volume = rangelim(old_volume, 0.0f, 1.0f); + sound->setListenerGain(new_volume); + + if (old_volume != new_volume) { + g_settings->setFloat("sound_volume", new_volume); + } LocalPlayer *player = client->getEnv().getLocalPlayer(); |