Permalink
Browse files

WINTERMUTE: Flush ConfMan to disk on every change

All ConfMan.set***() calls are coupled with ConfMan.flushToDisk().
  • Loading branch information...
lolbot-iichan committed Aug 25, 2018
1 parent 82e8bc4 commit 3e34cec7ced19e3a0f91588653b8cf4868db18d6
@@ -237,6 +237,7 @@ BaseGame::~BaseGame() {
LOG(0, "Shutting down...");

ConfMan.setBool("last_run", true);
ConfMan.flushToDisk();

cleanup();

@@ -1255,6 +1256,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
int val = stack->pop()->getInt();
Common::String privKey = "priv_" + StringUtil::encodeSetting(key);
ConfMan.setInt(privKey, val);
ConfMan.flushToDisk();
stack->pushNULL();
return STATUS_OK;
}
@@ -1285,6 +1287,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack
Common::String privKey = "wme_" + StringUtil::encodeSetting(key);
Common::String privVal = StringUtil::encodeSetting(val);
ConfMan.set(privKey, privVal);
ConfMan.flushToDisk();
stack->pushNULL();
return STATUS_OK;
}
@@ -3884,7 +3887,6 @@ bool BaseGame::isDoubleClick(int32 buttonIndex) {
//////////////////////////////////////////////////////////////////////////
void BaseGame::autoSaveOnExit() {
_soundMgr->saveSettings();
ConfMan.flushToDisk();

if (!_autoSaveOnExit) {
return;
@@ -101,6 +101,7 @@ bool SaveLoad::saveGame(int slot, const char *desc, bool quickSave, BaseGame *ga
pm->putDWORD(BaseEngine::instance().getRandomSource()->getSeed());
if (DID_SUCCEED(ret = pm->saveFile(filename))) {
ConfMan.setInt("most_recent_saveslot", slot);
ConfMan.flushToDisk();
}
}
}
@@ -73,6 +73,7 @@ bool BaseSoundMgr::cleanup() {
void BaseSoundMgr::saveSettings() {
if (_soundAvailable) {
ConfMan.setInt("master_volume_percent", _volumeMasterPercent);
ConfMan.flushToDisk();
}
}

@@ -181,12 +182,15 @@ bool BaseSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) {
switch (type) {
case Audio::Mixer::kSFXSoundType:
ConfMan.setInt("sfx_volume", volume);
ConfMan.flushToDisk();
break;
case Audio::Mixer::kSpeechSoundType:
ConfMan.setInt("speech_volume", volume);
ConfMan.flushToDisk();
break;
case Audio::Mixer::kMusicSoundType:
ConfMan.setInt("music_volume", volume);
ConfMan.flushToDisk();
break;
case Audio::Mixer::kPlainSoundType:
error("Plain sound type shouldn't be used in WME");

0 comments on commit 3e34cec

Please sign in to comment.