summaryrefslogtreecommitdiff
path: root/src/engine.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-25 23:04:58 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-25 23:04:58 +0200
commita36909f5c3408153c9b5f9477adde9b27d8c7482 (patch)
tree0acd7721cd2bb2b27878d20027d0510458581515 /src/engine.cpp
parent4e18e7619e9a8c909dea3374a2a7aa39befe0c16 (diff)
downloadmana-client-a36909f5c3408153c9b5f9477adde9b27d8c7482.tar.gz
mana-client-a36909f5c3408153c9b5f9477adde9b27d8c7482.tar.bz2
mana-client-a36909f5c3408153c9b5f9477adde9b27d8c7482.tar.xz
mana-client-a36909f5c3408153c9b5f9477adde9b27d8c7482.zip
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. ;)
Diffstat (limited to 'src/engine.cpp')
-rw-r--r--src/engine.cpp20
1 files changed, 11 insertions, 9 deletions
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);