summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2008-08-13 21:11:15 +0000
committerYohann Ferreira <bertram@cegetel.net>2008-08-13 21:11:15 +0000
commit35dcb50b5fefae76c5d9a88ffc27faaa96eaa9eb (patch)
treeb25d119eadc46a1e3b52932d128c41fe9959797e /src
parent052c03225c4f23bb50cd8d8e24a8a355656bcc07 (diff)
downloadmanaserv-35dcb50b5fefae76c5d9a88ffc27faaa96eaa9eb.tar.gz
manaserv-35dcb50b5fefae76c5d9a88ffc27faaa96eaa9eb.tar.bz2
manaserv-35dcb50b5fefae76c5d9a88ffc27faaa96eaa9eb.tar.xz
manaserv-35dcb50b5fefae76c5d9a88ffc27faaa96eaa9eb.zip
Corrected the distance needed to speak to NPC and trade with others
characters.
Diffstat (limited to 'src')
-rw-r--r--src/game-server/gamehandler.cpp18
-rw-r--r--src/game-server/map.hpp2
2 files changed, 14 insertions, 6 deletions
diff --git a/src/game-server/gamehandler.cpp b/src/game-server/gamehandler.cpp
index cfa6ad5f..8b7be98b 100644
--- a/src/game-server/gamehandler.cpp
+++ b/src/game-server/gamehandler.cpp
@@ -42,6 +42,8 @@
#include "utils/logger.h"
#include "utils/tokendispenser.hpp"
+const unsigned int TILES_TO_BE_NEAR = 7;
+
GameHandler::GameHandler():
mTokenCollector(this)
{
@@ -133,12 +135,14 @@ static MovingObject *findBeingNear(Object *p, int id)
{
MapComposite *map = p->getMap();
Point const &ppos = p->getPosition();
- // TODO: use a less arbitrary value.
- for (MovingObjectIterator i(map->getAroundPointIterator(ppos, 48)); i; ++i)
+ // See map.hpp for tiles constants
+ for (MovingObjectIterator i(map->getAroundPointIterator(ppos,
+ DEFAULT_TILE_WIDTH * TILES_TO_BE_NEAR)); i; ++i)
{
MovingObject *o = *i;
if (o->getPublicID() != id) continue;
- return ppos.inRangeOf(o->getPosition(), 48) ? o : NULL;
+ return ppos.inRangeOf(o->getPosition(), DEFAULT_TILE_WIDTH *
+ TILES_TO_BE_NEAR) ? o : NULL;
}
return NULL;
}
@@ -147,12 +151,14 @@ static Character *findCharacterNear(Object *p, int id)
{
MapComposite *map = p->getMap();
Point const &ppos = p->getPosition();
- // TODO: use a less arbitrary value.
- for (CharacterIterator i(map->getAroundPointIterator(ppos, 64)); i; ++i)
+ // See map.hpp for tiles constants
+ for (CharacterIterator i(map->getAroundPointIterator(ppos,
+ DEFAULT_TILE_WIDTH * TILES_TO_BE_NEAR)); i; ++i)
{
Character *o = *i;
if (o->getPublicID() != id) continue;
- return ppos.inRangeOf(o->getPosition(), 64) ? o : NULL;
+ return ppos.inRangeOf(o->getPosition(), DEFAULT_TILE_WIDTH *
+ TILES_TO_BE_NEAR) ? o : NULL;
}
return NULL;
}
diff --git a/src/game-server/map.hpp b/src/game-server/map.hpp
index 54a61283..3d28430a 100644
--- a/src/game-server/map.hpp
+++ b/src/game-server/map.hpp
@@ -28,6 +28,8 @@
#include <map>
#include <string>
+const unsigned int DEFAULT_TILE_WIDTH = 32;
+const unsigned int DEFAULT_TILE_HEIGHT = 32;
struct PATH_NODE {
PATH_NODE(unsigned short u, unsigned short v)