summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-04-27 23:03:43 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-27 23:39:57 +0300
commitcaf62e4d1c039f8d4d33bfd05f476890fdc79fcf (patch)
tree0d3e455994185ffdf04212f3284797a899931744 /src/net
parent7f0fa9b82fc4deb28d61fc0d2fc503f0e48747c1 (diff)
downloadmanaverse-caf62e4d1c039f8d4d33bfd05f476890fdc79fcf.tar.gz
manaverse-caf62e4d1c039f8d4d33bfd05f476890fdc79fcf.tar.bz2
manaverse-caf62e4d1c039f8d4d33bfd05f476890fdc79fcf.tar.xz
manaverse-caf62e4d1c039f8d4d33bfd05f476890fdc79fcf.zip
Improve screen position calculation.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/playerhandler.cpp18
-rw-r--r--src/net/manaserv/playerhandler.cpp7
2 files changed, 10 insertions, 15 deletions
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index bfbef0798..8f4cfd411 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -216,8 +216,8 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg)
mapPath = mapPath.substr(0, mapPath.rfind("."));
game->changeMap(mapPath);
- float scrollOffsetX = 0.0f;
- float scrollOffsetY = 0.0f;
+ int scrollOffsetX = 0;
+ int scrollOffsetY = 0;
if (player_node)
{
@@ -239,12 +239,10 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg)
|| (abs(y - player_node->getTileY())
> MAP_TELEPORT_SCROLL_DISTANCE))
{
- scrollOffsetX = static_cast<float>((x
- - player_node->getTileX())
- * map->getTileWidth());
- scrollOffsetY = static_cast<float>((y
- - player_node->getTileY())
- * map->getTileHeight());
+ scrollOffsetX = (x - player_node->getTileX())
+ * map->getTileWidth();
+ scrollOffsetY = (y - player_node->getTileY())
+ * map->getTileHeight();
}
}
@@ -253,9 +251,7 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg)
player_node->navigateClean();
}
- logger->log("Adjust scrolling by %d:%d",
- static_cast<int>(scrollOffsetX),
- static_cast<int>(scrollOffsetY));
+ logger->log("Adjust scrolling by %d:%d", scrollOffsetX, scrollOffsetY);
if (viewport)
{
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index b2609cf02..eeb597908 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -306,8 +306,8 @@ void PlayerHandler::handleMapChangeMessage(Net::MessageIn &msg)
game->changeMap(mapName);
const Vector &playerPos = player_node->getPosition();
- float scrollOffsetX = 0.0f;
- float scrollOffsetY = 0.0f;
+ int scrollOffsetX = 0;
+ int scrollOffsetY = 0;
/* Scroll if neccessary */
if (!sameMap
@@ -322,8 +322,7 @@ void PlayerHandler::handleMapChangeMessage(Net::MessageIn &msg)
player_node->setPosition(x, y);
player_node->setDestination(x, y);
- logger->log("Adjust scrolling by %d,%d", (int) scrollOffsetX,
- (int) scrollOffsetY);
+ logger->log("Adjust scrolling by %d,%d", scrollOffsetX, scrollOffsetY);
viewport->scrollBy(scrollOffsetX, scrollOffsetY);
}