diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2008-03-15 00:01:09 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2008-03-15 00:01:09 +0000 |
commit | 68c0625ee9a3a01090f0bc93612bf84dd71eaa67 (patch) | |
tree | d1cd93e73bb2e5a2746f8cbd2c1cfac2c5dcce39 /src/game-server/movingobject.cpp | |
parent | 4736ec595c1ed46f8b076f89bc31660ae21e9231 (diff) | |
download | manaserv-68c0625ee9a3a01090f0bc93612bf84dd71eaa67.tar.gz manaserv-68c0625ee9a3a01090f0bc93612bf84dd71eaa67.tar.bz2 manaserv-68c0625ee9a3a01090f0bc93612bf84dd71eaa67.tar.xz manaserv-68c0625ee9a3a01090f0bc93612bf84dd71eaa67.zip |
Implemented script binding for controllig movement of beings and fixed a crash caused by the new blocking system (thanks to peavey for reporting).
Diffstat (limited to 'src/game-server/movingobject.cpp')
-rw-r--r-- | src/game-server/movingobject.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/game-server/movingobject.cpp b/src/game-server/movingobject.cpp index f7db2d93..70334341 100644 --- a/src/game-server/movingobject.cpp +++ b/src/game-server/movingobject.cpp @@ -20,6 +20,8 @@ * $Id$ */ +#include <cassert> + #include "game-server/map.hpp" #include "game-server/mapcomposite.hpp" #include "game-server/movingobject.hpp" @@ -43,14 +45,22 @@ void MovingObject::setPosition(const Point &p) void MovingObject::setMap(MapComposite *map) { - Point p = getPosition(); + assert (map); MapComposite *oldMap = getMap(); + Point p = getPosition(); + if (oldMap) { oldMap->getMap()->freeTile(p.x / 32, p.y / 32, getBlockType()); } - map->getMap()->blockTile(p.x / 32, p.y / 32, getBlockType()); Object::setMap(map); + map->getMap()->blockTile(p.x / 32, p.y / 32, getBlockType()); + /* the last line might look illogical because the current position is + * invalid on the new map, but it is necessary to block the old position + * because the next call of setPosition() will automatically free the old + * position. When we don't block the position now the occupation counting + * will be off. + */ } void MovingObject::setDestination(Point const &dst) @@ -63,6 +73,7 @@ void MovingObject::setDestination(Point const &dst) void MovingObject::move() { mOld = getPosition(); + if (mActionTime > 100) { // Current move has not yet ended |