diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2006-12-29 13:43:24 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2006-12-29 13:43:24 +0000 |
commit | 291ad04d5b5c4ab08d85eadde116f968cd579b77 (patch) | |
tree | e4dced5715a5d9792cfdc0455a6b3ee6d3116079 /src/object.cpp | |
parent | 3d404e743105bb9168c89e3451cf35d7d59120b1 (diff) | |
download | manaserv-291ad04d5b5c4ab08d85eadde116f968cd579b77.tar.gz manaserv-291ad04d5b5c4ab08d85eadde116f968cd579b77.tar.bz2 manaserv-291ad04d5b5c4ab08d85eadde116f968cd579b77.tar.xz manaserv-291ad04d5b5c4ab08d85eadde116f968cd579b77.zip |
Physically split the server into one tmwserv-acount program (account +
chat + database) and multiple tmwserv-game programs (selected with
respect to the maps). Cleaned the repository by moving server-specific
source files into dedicated directories.
Diffstat (limited to 'src/object.cpp')
-rw-r--r-- | src/object.cpp | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/object.cpp b/src/object.cpp index f48d54f4..c2e11a7f 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -20,10 +20,9 @@ * $Id$ */ -#include "object.h" - #include "map.h" -#include "mapmanager.h" +#include "object.h" +#include "game-server/mapmanager.hpp" void MovingObject::move() { @@ -35,22 +34,9 @@ void MovingObject::move() return; } - Map *map = MapManager::instance().getMap(getMapId()); - std::list<PATH_NODE> path; int tileSX = mOld.x / 32, tileSY = mOld.y / 32; int tileDX = mDst.x / 32, tileDY = mDst.y / 32; - if (tileSX != tileDX || tileSY != tileDY) - { - // TODO: cache pathfinding results - path = map->findPath(tileSX, tileSY, tileDX, tileDY); - if (path.empty()) { - // no path was found - mDst = mOld; - mActionTime = 0; - return; - } - } - else + if (tileSX == tileDX && tileSY == tileDY) { // moving while staying on the same tile is free setPosition(mDst); @@ -58,6 +44,17 @@ void MovingObject::move() return; } + Map *map = mapManager->getMap(getMapId()); + // TODO: cache pathfinding results + std::list<PATH_NODE> path = map->findPath(tileSX, tileSY, tileDX, tileDY); + if (path.empty()) + { + // no path was found + mDst = mOld; + mActionTime = 0; + return; + } + PATH_NODE prev(tileSX, tileSY); Point pos; do |