aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/base/sound/base_sound_manager.cpp
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2013-01-22 15:42:56 +0100
committerEinar Johan Trøan Sømåen2013-01-22 15:42:56 +0100
commit9ec8c509da0db5d1b172ab30e13e93948c70e419 (patch)
tree43328b5ee3db33adf34f718d412852941b8ae234 /engines/wintermute/base/sound/base_sound_manager.cpp
parent7143eaed892e6008a7eb09f058f54d794764f199 (diff)
downloadscummvm-rg350-9ec8c509da0db5d1b172ab30e13e93948c70e419.tar.gz
scummvm-rg350-9ec8c509da0db5d1b172ab30e13e93948c70e419.tar.bz2
scummvm-rg350-9ec8c509da0db5d1b172ab30e13e93948c70e419.zip
WINTERMUTE: Lie to the scripts about the exact master volume-% to avoid round-off-issues.
(Fix Bug #3592875)
Diffstat (limited to 'engines/wintermute/base/sound/base_sound_manager.cpp')
-rw-r--r--engines/wintermute/base/sound/base_sound_manager.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp
index 441793144d..f5f1190331 100644
--- a/engines/wintermute/base/sound/base_sound_manager.cpp
+++ b/engines/wintermute/base/sound/base_sound_manager.cpp
@@ -26,6 +26,7 @@
* Copyright (c) 2011 Jan Nedoma
*/
+#include <math.h>
#include "engines/wintermute/base/sound/base_sound_manager.h"
#include "engines/wintermute/base/base_engine.h"
#include "engines/wintermute/utils/path_util.h"
@@ -50,6 +51,7 @@ namespace Wintermute {
BaseSoundMgr::BaseSoundMgr(BaseGame *inGame) : BaseClass(inGame) {
_soundAvailable = false;
_volumeMaster = 255;
+ _volumeMasterPercent = 100;
}
@@ -217,6 +219,11 @@ byte BaseSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) {
//////////////////////////////////////////////////////////////////////////
bool BaseSoundMgr::setMasterVolume(byte value) {
+ // This function intentionally doesn't touch _volumeMasterPercent,
+ // as that variable keeps track of what the game actually wanted,
+ // and this gives a close approximation, while letting the game
+ // be none the wiser about round-off-errors. This function should thus
+ // ONLY be called by setMasterVolumePercent.
_volumeMaster = value;
for (uint32 i = 0; i < _sounds.size(); i++) {
_sounds[i]->updateVolume();
@@ -226,14 +233,15 @@ bool BaseSoundMgr::setMasterVolume(byte value) {
//////////////////////////////////////////////////////////////////////////
bool BaseSoundMgr::setMasterVolumePercent(byte percent) {
- setMasterVolume(percent * 255 / 100);
+ _volumeMasterPercent = percent;
+ setMasterVolume((int)ceil(percent * 255.0 / 100.0));
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
byte BaseSoundMgr::getMasterVolumePercent() {
- return getMasterVolume() * 100 / 255;
+ return _volumeMasterPercent;
}
//////////////////////////////////////////////////////////////////////////