diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-04-25 23:02:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-04-25 23:02:52 +0300 |
commit | 110134603554e06adab93a132ef8f82e55db68ad (patch) | |
tree | 3a2b5cfef0b04ce1c521a2a890ba1e33ec48e76e | |
parent | 3d447679df26179b7ffa781c34f5277e6a1aec29 (diff) | |
download | ManaVerse-110134603554e06adab93a132ef8f82e55db68ad.tar.gz ManaVerse-110134603554e06adab93a132ef8f82e55db68ad.tar.bz2 ManaVerse-110134603554e06adab93a132ef8f82e55db68ad.tar.xz ManaVerse-110134603554e06adab93a132ef8f82e55db68ad.zip |
Add more checks.
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 50f47e532..ba881858e 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -220,15 +220,23 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) if (player_node) { - /* Scroll if neccessary */ - if (!sameMap - || (abs(x - player_node->getTileX()) - > MAP_TELEPORT_SCROLL_DISTANCE) - || (abs(y - player_node->getTileY()) - > MAP_TELEPORT_SCROLL_DISTANCE)) + Map *map = game->getCurrentMap(); + if (map) { - Map *map = game->getCurrentMap(); - if (map) + if (x >= map->getWidth()) + x = map->getWidth() - 1; + if (y >= map->getHeight()) + y = map->getHeight() - 1; + if (x < 0) + x = 0; + if (y < 0) + y = 0; + /* Scroll if neccessary */ + if (!sameMap + || (abs(x - player_node->getTileX()) + > MAP_TELEPORT_SCROLL_DISTANCE) + || (abs(y - player_node->getTileY()) + > MAP_TELEPORT_SCROLL_DISTANCE)) { scrollOffsetX = static_cast<float>((x - player_node->getTileX()) |