summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-09 22:45:16 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-09 22:52:14 +0200
commitc8d5b5596acc1f6e93e8cc6df3e6c92bf6cc4bd8 (patch)
treefd2a5bdb8b2bcd2d6ac36d01a622687f32ef5dcd
parent6ada0095e10a592ca78206edf851cc9e235619ab (diff)
downloadmana-client-c8d5b5596acc1f6e93e8cc6df3e6c92bf6cc4bd8.tar.gz
mana-client-c8d5b5596acc1f6e93e8cc6df3e6c92bf6cc4bd8.tar.bz2
mana-client-c8d5b5596acc1f6e93e8cc6df3e6c92bf6cc4bd8.tar.xz
mana-client-c8d5b5596acc1f6e93e8cc6df3e6c92bf6cc4bd8.zip
Fixed crash on applying setup before entering the game
Engine hasn't been created yet at that point.
-rw-r--r--src/gui/setup_audio.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index c0c2b9e4..5e13574e 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -91,8 +91,11 @@ void Setup_Audio::apply()
new OkDialog("Sound Engine", err);
logger->log("Warning: %s", err);
}
- Map *currentMap = engine->getCurrentMap();
- sound.playMusic(currentMap->getProperty("music"), -1);
+
+ if (engine) {
+ Map *currentMap = engine->getCurrentMap();
+ sound.playMusic(currentMap->getProperty("music"), -1);
+ }
}
else
{
@@ -101,8 +104,8 @@ void Setup_Audio::apply()
}
mSoundEnabled = config.getValue("sound", 0);
- mSfxVolume = (int)config.getValue("sfxVolume", 100);
- mMusicVolume = (int)config.getValue("musicVolume", 60);
+ mSfxVolume = (int) config.getValue("sfxVolume", 100);
+ mMusicVolume = (int) config.getValue("musicVolume", 60);
}
void Setup_Audio::cancel()
@@ -115,7 +118,7 @@ void Setup_Audio::cancel()
sound.setMusicVolume(mMusicVolume);
mMusicSlider->setValue(mMusicVolume);
- config.setValue("sound", mSoundEnabled ? true : false);
+ config.setValue("sound", mSoundEnabled ? 1 : 0);
config.setValue("sfxVolume", mSfxVolume);
config.setValue("musicVolume", mMusicVolume);
}
@@ -124,12 +127,12 @@ void Setup_Audio::action(const gcn::ActionEvent &event)
{
if (event.getId() == "sfx")
{
- config.setValue("sfxVolume", (int)mSfxSlider->getValue());
- sound.setSfxVolume((int)mSfxSlider->getValue());
+ config.setValue("sfxVolume", (int) mSfxSlider->getValue());
+ sound.setSfxVolume((int) mSfxSlider->getValue());
}
else if (event.getId() == "music")
{
- config.setValue("musicVolume", (int)mMusicSlider->getValue());
+ config.setValue("musicVolume", (int) mMusicSlider->getValue());
sound.setMusicVolume((int)mMusicSlider->getValue());
}
}