diff options
author | Bertram <bertram@cegetel.net> | 2010-02-09 02:54:09 +0100 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2010-02-09 03:20:48 +0100 |
commit | 6a6b36fa2d19a6ea9d39b975354709e7ad82281d (patch) | |
tree | 09451c98d6a711ffd45a7f5da5796549dbcdd173 /src/net | |
parent | f3ee70f4aa0b4df7388a4539440355bb066dc0d3 (diff) | |
download | mana-6a6b36fa2d19a6ea9d39b975354709e7ad82281d.tar.gz mana-6a6b36fa2d19a6ea9d39b975354709e7ad82281d.tar.bz2 mana-6a6b36fa2d19a6ea9d39b975354709e7ad82281d.tar.xz mana-6a6b36fa2d19a6ea9d39b975354709e7ad82281d.zip |
Pushed away some 32 hardcoded values.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/playerhandler.cpp | 11 | ||||
-rw-r--r-- | src/net/manaserv/itemhandler.cpp | 22 |
2 files changed, 28 insertions, 5 deletions
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index f6f54d59..33a6b146 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -192,8 +192,8 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) Game *game = Game::instance(); - const std::string ¤tMap = game->getCurrentMapName(); - bool sameMap = (currentMap == mapPath); + const std::string ¤tMapName = game->getCurrentMapName(); + bool sameMap = (currentMapName == mapPath); // Switch the actual map, deleting the previous one if necessary mapPath = mapPath.substr(0, mapPath.rfind(".")); @@ -207,8 +207,11 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) || (abs(x - player_node->getTileX()) > MAP_TELEPORT_SCROLL_DISTANCE) || (abs(y - player_node->getTileY()) > MAP_TELEPORT_SCROLL_DISTANCE)) { - scrollOffsetX = (x - player_node->getTileX()) * 32; - scrollOffsetY = (y - player_node->getTileY()) * 32; + Map *map = game->getCurrentMap(); + scrollOffsetX = (x - player_node->getTileX()) + * map->getTileWidth(); + scrollOffsetY = (y - player_node->getTileY()) + * map->getTileHeight(); } player_node->setAction(Being::STAND); diff --git a/src/net/manaserv/itemhandler.cpp b/src/net/manaserv/itemhandler.cpp index 6a9dec74..802f9303 100644 --- a/src/net/manaserv/itemhandler.cpp +++ b/src/net/manaserv/itemhandler.cpp @@ -26,6 +26,10 @@ #include "net/manaserv/protocol.h" #include "net/manaserv/messagein.h" +#include "game.h" +#include "map.h" +#include "log.h" + namespace ManaServ { ItemHandler::ItemHandler() @@ -54,7 +58,23 @@ void ItemHandler::handleMessage(Net::MessageIn &msg) if (itemId) { - floorItemManager->create(id, itemId, x / 32, y / 32); + Game *game = Game::instance(); + Map *map = 0; + if (game) + { + map = game->getCurrentMap(); + if (map) + { + floorItemManager->create(id, + itemId, + x / map->getTileWidth(), + y / map->getTileHeight()); + } + else + logger->log( + "ItemHandler: An item wasn't created because of" + "Game/Map not initialized..."); + } } else if (FloorItem *item = floorItemManager->findById(id)) { |