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
This commit is contained in:
Max Horn 2006-04-16 19:23:14 +00:00
parent 08b9cd7922
commit 74edd90aba
14 changed files with 53 additions and 53 deletions

View File

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

View File

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

View File

@ -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();
}

View File

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

View File

@ -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();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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();
}

View File

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