From a36909f5c3408153c9b5f9477adde9b27d8c7482 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Mon, 25 May 2009 23:04:58 +0200 Subject: Handle map not found gracefully Instead of shutting down, the client will now draw a gray background. This allows the player to still contact a GM in order to be helped out of the situation. It also helps me warp out of the non-existing map I accidentally warped myself onto. ;) --- src/engine.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/engine.cpp') diff --git a/src/engine.cpp b/src/engine.cpp index 1bd6c30f..d33607ec 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -31,6 +31,7 @@ #include "gui/gui.h" #include "gui/minimap.h" +#include "gui/okdialog.h" #include "gui/viewport.h" #include "net/maphandler.h" @@ -40,6 +41,7 @@ #include "resources/monsterdb.h" #include "resources/resourcemanager.h" +#include "utils/gettext.h" #include "utils/stringutils.h" Engine::Engine(): @@ -81,7 +83,11 @@ bool Engine::changeMap(const std::string &mapPath) Map *newMap = MapReader::readMap(map_path); if (!newMap) - logger->error("Could not find map file"); + { + logger->log("Error while loading %s", map_path.c_str()); + new OkDialog(_("Could not load map"), + strprintf(_("Error while loading %s"), map_path.c_str())); + } // Notify the minimap and beingManager about the map change minimap->setMap(newMap); @@ -90,16 +96,12 @@ bool Engine::changeMap(const std::string &mapPath) viewport->setMap(newMap); // Initialize map-based particle effects - newMap->initializeParticleEffects(particleEngine); + if (newMap) + newMap->initializeParticleEffects(particleEngine); // Start playing new music file when necessary - std::string oldMusic = ""; - - if (mCurrentMap) - oldMusic = mCurrentMap->getProperty("music"); - - std::string newMusic = newMap->getProperty("music"); - + std::string oldMusic = mCurrentMap ? mCurrentMap->getMusicFile() : ""; + std::string newMusic = newMap ? newMap->getMusicFile() : ""; if (newMusic != oldMusic) sound.playMusic(newMusic); -- cgit v1.2.3-70-g09d2