From c8d5b5596acc1f6e93e8cc6df3e6c92bf6cc4bd8 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 9 Apr 2009 22:45:16 +0200 Subject: Fixed crash on applying setup before entering the game Engine hasn't been created yet at that point. --- src/gui/setup_audio.cpp | 19 +++++++++++-------- 1 file 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()); } } -- cgit v1.2.3-70-g09d2