From 97e0a9eb170499e045c9cec23fcb2d474079c7dd Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Fri, 11 Mar 2011 02:38:25 +0100 Subject: Fixed Actor::setPosition to update the blockmask correctly It was freeing the new tile rather than the previous tile. Reviewed-by: Stefan Dombrowski --- src/game-server/actor.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/game-server/actor.cpp') diff --git a/src/game-server/actor.cpp b/src/game-server/actor.cpp index b9f4504b..68430bca 100644 --- a/src/game-server/actor.cpp +++ b/src/game-server/actor.cpp @@ -27,23 +27,21 @@ void Actor::setPosition(const Point &p) { - mPos = p; - // Update blockmap - if (getMap()) + if (Map *map = getMap()->getMap()) { - Map *map = getMap()->getMap(); int tileWidth = map->getTileWidth(); int tileHeight = map->getTileHeight(); - const Point &oldP = getPosition(); - if ((oldP.x / tileWidth != p.x / tileWidth - || oldP.y / tileHeight != p.y / tileHeight)) + if ((mPos.x / tileWidth != p.x / tileWidth + || mPos.y / tileHeight != p.y / tileHeight)) { - map->freeTile(oldP.x / tileWidth, oldP.y / tileHeight, + map->freeTile(mPos.x / tileWidth, mPos.y / tileHeight, getBlockType()); map->blockTile(p.x / tileWidth, p.y / tileHeight, getBlockType()); } } + + mPos = p; } void Actor::setMap(MapComposite *mapComposite) -- cgit v1.2.3-70-g09d2