summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-04-25 23:02:52 +0300
committerAndrei Karas <akaras@inbox.ru>2011-04-25 23:02:52 +0300
commit110134603554e06adab93a132ef8f82e55db68ad (patch)
tree3a2b5cfef0b04ce1c521a2a890ba1e33ec48e76e /src
parent3d447679df26179b7ffa781c34f5277e6a1aec29 (diff)
downloadplus-110134603554e06adab93a132ef8f82e55db68ad.tar.gz
plus-110134603554e06adab93a132ef8f82e55db68ad.tar.bz2
plus-110134603554e06adab93a132ef8f82e55db68ad.tar.xz
plus-110134603554e06adab93a132ef8f82e55db68ad.zip
Add more checks.
Diffstat (limited to 'src')
-rw-r--r--src/net/tmwa/playerhandler.cpp24
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())