summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-01-18 23:17:31 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-01-19 23:22:44 +0100
commitdb8df518c05d38c3d7452fe8f18fdc7c48c3eb4e (patch)
tree33e9a2b1bc899dbcd47ea26804daaebde0a9fe48 /src
parent7272d727271b226948ff56f486a3f322fe1762bd (diff)
downloadmana-client-db8df518c05d38c3d7452fe8f18fdc7c48c3eb4e.tar.gz
mana-client-db8df518c05d38c3d7452fe8f18fdc7c48c3eb4e.tar.bz2
mana-client-db8df518c05d38c3d7452fe8f18fdc7c48c3eb4e.tar.xz
mana-client-db8df518c05d38c3d7452fe8f18fdc7c48c3eb4e.zip
Fixed handling of problems with loading the initial map
This can always happen, either due to mismatching local data or a server-side error. The client displays a pop-up in this case, but it's not possible to read that when it crashes as well. Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src')
-rw-r--r--src/net/tmwa/gamehandler.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index 9e2c6fa4..5719f700 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -108,14 +108,15 @@ void GameHandler::event(Event::Channel channel, const Event &event)
{
Game *game = Game::instance();
game->changeMap(mMap);
- Map *map = game->getCurrentMap();
- const int tileWidth = map->getTileWidth();
- const int tileHeight = map->getTileHeight();
- if (mTileX && mTileY)
+
+ // It could be that loading the map failed
+ if (Map *map = game->getCurrentMap())
{
- local_player->setPosition(Vector(mTileX * tileWidth + tileWidth / 2,
- mTileY * tileHeight + tileHeight / 2));
- mTileX = mTileY = 0;
+ if (mTileX && mTileY)
+ {
+ local_player->setPosition(map->getTileCenter(mTileX, mTileY));
+ mTileX = mTileY = 0;
+ }
}
}
else if (event.getType() == Event::MapLoaded)