From 74edd90aba15db1196b16b5eae918347670d11c8 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 16 Apr 2006 19:23:14 +0000 Subject: Fix for bug #1471383: Instead of overloading ConfigManager::set, we now have new setInt and setBool methods (matching getInt/getBool), which avoids strange quirks & bugs caused by (char *) being implicitly cast to int (ouch) svn-id: r21951 --- common/config-manager.cpp | 4 ++-- common/config-manager.h | 4 ++-- engines/queen/queen.cpp | 12 ++++++------ engines/saga/interface.cpp | 8 ++++---- engines/scumm/dialogs.cpp | 6 +++--- engines/scumm/he/script_v70he.cpp | 2 +- engines/scumm/he/script_v72he.cpp | 2 +- engines/scumm/input.cpp | 14 +++++++------- engines/scumm/script.cpp | 4 ++-- engines/scumm/script_v6.cpp | 2 +- engines/scumm/scumm.cpp | 4 ++-- engines/sky/control.cpp | 6 +++--- engines/sword2/sword2.cpp | 20 ++++++++++---------- gui/options.cpp | 18 +++++++++--------- 14 files changed, 53 insertions(+), 53 deletions(-) diff --git a/common/config-manager.cpp b/common/config-manager.cpp index 3f601a0236..0a15b10f23 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -507,13 +507,13 @@ void ConfigManager::set(const String &key, const String &value, const String &do */ } -void ConfigManager::set(const String &key, int value, const String &domName) { +void ConfigManager::setInt(const String &key, int value, const String &domName) { char tmp[128]; snprintf(tmp, sizeof(tmp), "%i", value); set(key, String(tmp), domName); } -void ConfigManager::set(const String &key, bool value, const String &domName) { +void ConfigManager::setBool(const String &key, bool value, const String &domName) { set(key, String(value ? "true" : "false"), domName); } diff --git a/common/config-manager.h b/common/config-manager.h index 26b1efbf23..f7c1ce121b 100644 --- a/common/config-manager.h +++ b/common/config-manager.h @@ -130,8 +130,8 @@ public: // int getInt(const String &key, const String &domName = String::emptyString) const; bool getBool(const String &key, const String &domName = String::emptyString) const; - void set(const String &key, int value, const String &domName = String::emptyString); - void set(const String &key, bool value, const String &domName = String::emptyString); + void setInt(const String &key, int value, const String &domName = String::emptyString); + void setBool(const String &key, bool value, const String &domName = String::emptyString); void registerDefault(const String &key, const String &value); diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp index c87ccd6695..611832c439 100644 --- a/engines/queen/queen.cpp +++ b/engines/queen/queen.cpp @@ -194,12 +194,12 @@ void QueenEngine::readOptionSettings() { } void QueenEngine::writeOptionSettings() { - ConfMan.set("music_volume", _music->volume()); - ConfMan.set("music_mute", !_sound->musicOn()); - ConfMan.set("sfx_mute", !_sound->sfxOn()); - ConfMan.set("talkspeed", _talkSpeed); - ConfMan.set("speech_mute", !_sound->speechOn()); - ConfMan.set("subtitles", _subtitles); + ConfMan.setInt("music_volume", _music->volume()); + ConfMan.setBool("music_mute", !_sound->musicOn()); + ConfMan.setBool("sfx_mute", !_sound->sfxOn()); + ConfMan.setInt("talkspeed", _talkSpeed); + ConfMan.setBool("speech_mute", !_sound->speechOn()); + ConfMan.setBool("subtitles", _subtitles); ConfMan.flushToDisk(); } diff --git a/engines/saga/interface.cpp b/engines/saga/interface.cpp index 1d3b110068..e1d01507e0 100644 --- a/engines/saga/interface.cpp +++ b/engines/saga/interface.cpp @@ -1364,21 +1364,21 @@ void Interface::setOption(PanelButton *panelButton) { case kTextReadingSpeed: if (_vm->getFeatures() & GF_CD_FX) { _vm->_subtitlesEnabled = !_vm->_subtitlesEnabled; - ConfMan.set("subtitles", _vm->_subtitlesEnabled); + ConfMan.setBool("subtitles", _vm->_subtitlesEnabled); } else { _vm->_readingSpeed = (_vm->_readingSpeed + 1) % 4; - ConfMan.set("talkspeed", _vm->_readingSpeed); + ConfMan.setInt("talkspeed", _vm->_readingSpeed); } break; case kTextMusic: _vm->_musicVolume = (_vm->_musicVolume + 1) % 11; _vm->_music->setVolume(_vm->_musicVolume == 10 ? -1 : _vm->_musicVolume * 25, 1); - ConfMan.set("music_volume", _vm->_musicVolume * 25); + ConfMan.setInt("music_volume", _vm->_musicVolume * 25); break; case kTextSound: _vm->_soundVolume = (_vm->_soundVolume + 1) % 11; _vm->_sound->setVolume(_vm->_soundVolume == 10 ? 255 : _vm->_soundVolume * 25); - ConfMan.set("sfx_volume", _vm->_soundVolume * 25); + ConfMan.setInt("sfx_volume", _vm->_soundVolume * 25); break; } } diff --git a/engines/scumm/dialogs.cpp b/engines/scumm/dialogs.cpp index 333e702944..6cc6224bfa 100644 --- a/engines/scumm/dialogs.cpp +++ b/engines/scumm/dialogs.cpp @@ -719,14 +719,14 @@ void ConfigDialog::open() { void ConfigDialog::close() { if (getResult()) { // Subtitles - ConfMan.set("subtitles", _subtitlesCheckbox->getState(), _domain); + ConfMan.setBool("subtitles", _subtitlesCheckbox->getState(), _domain); // Sync with current setting if (!_speechCheckbox->getState()) { - ConfMan.set("speech_mute", true, _domain); + ConfMan.setBool("speech_mute", true, _domain); _vm->_voiceMode = 2; } else { - ConfMan.set("speech_mute", false, _domain); + ConfMan.setBool("speech_mute", false, _domain); _vm->_voiceMode = _subtitlesCheckbox->getState(); } diff --git a/engines/scumm/he/script_v70he.cpp b/engines/scumm/he/script_v70he.cpp index 3e71073f69..fc8c0874c4 100644 --- a/engines/scumm/he/script_v70he.cpp +++ b/engines/scumm/he/script_v70he.cpp @@ -990,7 +990,7 @@ void ScummEngine_v70he::o70_writeINI() { switch (type) { case 1: // number - ConfMan.set((char *)option, value); + ConfMan.setInt((char *)option, value); debug(1, "o70_writeINI: Option %s Value %d", option, value); break; case 2: // string diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp index 69edc4b51c..58b87419fc 100644 --- a/engines/scumm/he/script_v72he.cpp +++ b/engines/scumm/he/script_v72he.cpp @@ -2134,7 +2134,7 @@ void ScummEngine_v72he::o72_writeINI() { case 6: // number value = pop(); copyScriptString(option, sizeof(option)); - ConfMan.set((char *)option, value); + ConfMan.setInt((char *)option, value); debug(1, "o72_writeINI: Option %s Value %d", option, value); break; case 77: // HE 100 diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index b2e27d15fd..d2ab86b42d 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -334,18 +334,18 @@ void ScummEngine::processKbd(bool smushMode) { switch(_voiceMode) { case 0: sprintf(buf, "Speech Only"); - ConfMan.set("speech_mute", false); - ConfMan.set("subtitles", false); + ConfMan.setBool("speech_mute", false); + ConfMan.setBool("subtitles", false); break; case 1: sprintf(buf, "Speech and Subtitles"); - ConfMan.set("speech_mute", false); - ConfMan.set("subtitles", true); + ConfMan.setBool("speech_mute", false); + ConfMan.setBool("subtitles", true); break; case 2: sprintf(buf, "Subtitles Only"); - ConfMan.set("speech_mute", true); - ConfMan.set("subtitles", true); + ConfMan.setBool("speech_mute", true); + ConfMan.setBool("subtitles", true); break; } @@ -434,7 +434,7 @@ void ScummEngine::processKbd(bool smushMode) { if (vol > Audio::Mixer::kMaxMixerVolume) vol = Audio::Mixer::kMaxMixerVolume; - ConfMan.set("music_volume", vol); + ConfMan.setInt("music_volume", vol); setupVolumes(); } else if (_lastKeyHit == '-' || _lastKeyHit == '+') { // Change text speed if (_lastKeyHit == '+' && _defaultTalkDelay > 0) diff --git a/engines/scumm/script.cpp b/engines/scumm/script.cpp index 02bf17cbbb..686e6262db 100644 --- a/engines/scumm/script.cpp +++ b/engines/scumm/script.cpp @@ -606,14 +606,14 @@ void ScummEngine::writeVar(uint var, int value) { if (_game.heversion <= 73 && vm.slot[_currentScript].number == 1) return; assert(value == 0 || value == 1); - ConfMan.set("subtitles", value); + ConfMan.setBool("subtitles", value); } if (VAR_NOSUBTITLES != 0xFF && var == VAR_NOSUBTITLES) { // Ignore default setting in HE60-71 games if (_game.heversion >= 60 && vm.slot[_currentScript].number == 1) return; assert(value == 0 || value == 1); - ConfMan.set("subtitles", !value); + ConfMan.setBool("subtitles", !value); } if (var == VAR_CHARINC && ConfMan.hasKey("talkspeed")) { diff --git a/engines/scumm/script_v6.cpp b/engines/scumm/script_v6.cpp index 08aa7037a8..cb1bcf4de7 100644 --- a/engines/scumm/script_v6.cpp +++ b/engines/scumm/script_v6.cpp @@ -2592,7 +2592,7 @@ void ScummEngine_v6::o6_kernelSetFunctions() { _saveSound = args[1]; break; case 215: - ConfMan.set("subtitles", args[1] != 0); + ConfMan.setBool("subtitles", args[1] != 0); break; default: error("o6_kernelSetFunctions: default case %d (param count %d)", args[0], num); diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 3eb074fdf4..6466f6e404 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -548,12 +548,12 @@ ScummEngine::ScummEngine(OSystem *syst, const GameSettings &gs, uint8 md5sum[16] if (ConfMan.hasKey("nosubtitles")) { printf("Configuration key 'nosubtitles' is deprecated. Use 'subtitles' instead\n"); if (!ConfMan.hasKey("subtitles")) - ConfMan.set("subtitles", !ConfMan.getBool("nosubtitles")); + ConfMan.setBool("subtitles", !ConfMan.getBool("nosubtitles")); } // Make sure that at least subtitles are enabled if (ConfMan.getBool("speech_mute") && !ConfMan.getBool("subtitles")) - ConfMan.set("subtitles", 1); + ConfMan.setBool("subtitles", true); // TODO Detect subtitle only versions of scumm6 games if (ConfMan.getBool("speech_mute")) diff --git a/engines/sky/control.cpp b/engines/sky/control.cpp index 04eecfe428..8118700eff 100644 --- a/engines/sky/control.cpp +++ b/engines/sky/control.cpp @@ -718,7 +718,7 @@ uint16 Control::toggleFx(ConResource *pButton) { _statusBar->setToText(0x7000 + 86); } - ConfMan.set("sfx_mute", (SkyEngine::_systemVars.systemFlags & SF_FX_OFF) != 0); + ConfMan.setBool("sfx_mute", (SkyEngine::_systemVars.systemFlags & SF_FX_OFF) != 0); pButton->drawToScreen(WITH_MASK); buttonControl(pButton); @@ -742,8 +742,8 @@ uint16 Control::toggleText(void) { _statusBar->setToText(0x7000 + 35); // text only } - ConfMan.set("subtitles", (flags & SF_ALLOW_TEXT) != 0); - ConfMan.set("speech_mute", (flags & SF_ALLOW_SPEECH) == 0); + ConfMan.setBool("subtitles", (flags & SF_ALLOW_TEXT) != 0); + ConfMan.setBool("speech_mute", (flags & SF_ALLOW_SPEECH) == 0); SkyEngine::_systemVars.systemFlags |= flags; diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index 0d354a3f35..5982e62e4d 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -216,16 +216,16 @@ void Sword2Engine::readSettings() { } void Sword2Engine::writeSettings() { - ConfMan.set("music_volume", _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType)); - ConfMan.set("speech_volume", _mixer->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType)); - ConfMan.set("sfx_volume", _mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType)); - ConfMan.set("music_mute", _sound->isMusicMute()); - ConfMan.set("speech_mute", _sound->isSpeechMute()); - ConfMan.set("sfx_mute", _sound->isFxMute()); - ConfMan.set("gfx_details", _screen->getRenderLevel()); - ConfMan.set("subtitles", getSubtitles()); - ConfMan.set("object_labels", _mouse->getObjectLabels()); - ConfMan.set("reverse_stereo", _sound->isReverseStereo()); + ConfMan.setInt("music_volume", _mixer->getVolumeForSoundType(Audio::Mixer::kMusicSoundType)); + ConfMan.setInt("speech_volume", _mixer->getVolumeForSoundType(Audio::Mixer::kSpeechSoundType)); + ConfMan.setInt("sfx_volume", _mixer->getVolumeForSoundType(Audio::Mixer::kSFXSoundType)); + ConfMan.setBool("music_mute", _sound->isMusicMute()); + ConfMan.setBool("speech_mute", _sound->isSpeechMute()); + ConfMan.setBool("sfx_mute", _sound->isFxMute()); + ConfMan.setInt("gfx_details", _screen->getRenderLevel()); + ConfMan.setBool("subtitles", getSubtitles()); + ConfMan.setBool("object_labels", _mouse->getObjectLabels()); + ConfMan.setInt("reverse_stereo", _sound->isReverseStereo()); ConfMan.flushToDisk(); } diff --git a/gui/options.cpp b/gui/options.cpp index 97eb586b33..7d1025d0d0 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -208,8 +208,8 @@ void OptionsDialog::close() { if (getResult()) { if (_fullscreenCheckbox) { if (_enableGraphicSettings) { - ConfMan.set("fullscreen", _fullscreenCheckbox->getState(), _domain); - ConfMan.set("aspect_ratio", _aspectCheckbox->getState(), _domain); + ConfMan.setBool("fullscreen", _fullscreenCheckbox->getState(), _domain); + ConfMan.setBool("aspect_ratio", _aspectCheckbox->getState(), _domain); if ((int32)_gfxPopUp->getSelectedTag() >= 0) ConfMan.set("gfx_mode", _gfxPopUp->getSelectedString(), _domain); @@ -226,9 +226,9 @@ void OptionsDialog::close() { if (_musicVolumeSlider) { if (_enableVolumeSettings) { - ConfMan.set("music_volume", _musicVolumeSlider->getValue(), _domain); - ConfMan.set("sfx_volume", _sfxVolumeSlider->getValue(), _domain); - ConfMan.set("speech_volume", _speechVolumeSlider->getValue(), _domain); + ConfMan.setInt("music_volume", _musicVolumeSlider->getValue(), _domain); + ConfMan.setInt("sfx_volume", _sfxVolumeSlider->getValue(), _domain); + ConfMan.setInt("speech_volume", _speechVolumeSlider->getValue(), _domain); } else { ConfMan.removeKey("music_volume", _domain); ConfMan.removeKey("sfx_volume", _domain); @@ -238,7 +238,7 @@ void OptionsDialog::close() { if (_subCheckbox) { if (_enableAudioSettings) { - ConfMan.set("subtitles", _subCheckbox->getState(), _domain); + ConfMan.setBool("subtitles", _subCheckbox->getState(), _domain); const MidiDriverDescription *md = MidiDriver::getAvailableMidiDrivers(); while (md->name && md->id != (int)_midiPopUp->getSelectedTag()) md++; @@ -255,9 +255,9 @@ void OptionsDialog::close() { // MIDI options if (_multiMidiCheckbox) { if (_enableMIDISettings) { - ConfMan.set("multi_midi", _multiMidiCheckbox->getState(), _domain); - ConfMan.set("native_mt32", _mt32Checkbox->getState(), _domain); - ConfMan.set("enable_gs", _enableGSCheckbox->getState(), _domain); + ConfMan.setBool("multi_midi", _multiMidiCheckbox->getState(), _domain); + ConfMan.setBool("native_mt32", _mt32Checkbox->getState(), _domain); + ConfMan.setBool("enable_gs", _enableGSCheckbox->getState(), _domain); String soundFont = _soundFont->getLabel(); if (!soundFont.empty() && (soundFont != "None")) -- cgit v1.2.3