From 914d3de7c324cb1ec456892702689718352a7842 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Fri, 17 Jun 2011 16:46:06 +0200 Subject: First pass on removing tile hard coded values. Every files has been checked against the hard coded 32 values except the map.cpp file. I also added convenience functions in the Game class, centralized the default item icon size, and removed two unused defines in being.cpp. --- src/actorspritemanager.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/actorspritemanager.cpp') diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 0134dd63..fedf880c 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -21,6 +21,7 @@ #include "actorspritemanager.h" +#include "game.h" #include "localplayer.h" #include "utils/dtor.h" @@ -37,12 +38,17 @@ class FindBeingFunctor { if (actor->getType() == ActorSprite::FLOOR_ITEM) return false; + Game *game = Game::instance(); + if (!game) + return false; + Being* b = static_cast(actor); uint16_t other_y = y + ((b->getType() == ActorSprite::NPC) ? 1 : 0); const Vector &pos = b->getPosition(); - return ((int) pos.x / 32 == x && - ((int) pos.y / 32 == y || (int) pos.y / 32 == other_y) && + return ((int) pos.x / game->getCurrentTileWidth() == x && + ((int) pos.y / game->getCurrentTileHeight() == y + || (int) pos.y / game->getCurrentTileHeight() == other_y) && b->isAlive() && (type == ActorSprite::UNKNOWN || b->getType() == type)); } @@ -272,10 +278,14 @@ Being *ActorSpriteManager::findNearestLivingBeing(int x, int y, ActorSprite::Type type, Being *excluded) const { + Game *game = Game::instance(); + if (!game) + return 0; + Being *closestBeing = 0; int dist = 0; - const int maxDist = maxTileDist * 32; + const int maxDist = maxTileDist * game->getCurrentTileWidth(); for_actors { -- cgit v1.2.3-70-g09d2