summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--src/being.cpp6
-rw-r--r--src/gui/viewport.cpp2
-rw-r--r--src/localplayer.cpp4
-rw-r--r--src/map.cpp13
-rw-r--r--src/map.h5
6 files changed, 17 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index d94aabd4..f928fd85 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-02-12 Dennis Friis <peavey@placid.dk>
+ * src/localplayer.cpp, src/map.cpp, src/gui/viewport.cpp, src/being.cpp
+ src/map.h: Made pathfinding not halt on collision destination tile,
+ made moving around with mouse smoother. Added possibility to pass
+ through players with key controls.
+
2008-02-11 Philipp Sehmisch <tmw@crushnet.org>
* data/maps/new_22-1.tmx: Added music and overlay to snake dungeon.
diff --git a/src/being.cpp b/src/being.cpp
index ad60dc2f..e76370fd 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -339,6 +339,12 @@ Being::nextStep()
setDirection(dir);
+ if (mMap->tileCollides(node.x, node.y))
+ {
+ setAction(STAND);
+ return;
+ }
+
mX = node.x;
mY = node.y;
setAction(WALK);
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index d99b48ba..3a297f66 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -423,7 +423,7 @@ Viewport::mousePressed(gcn::MouseEvent &event)
player_node->pickUp(item);
}
// Just walk around
- else if (mMap->getWalk(tilex, tiley))
+ else
{
// XXX XXX XXX REALLY UGLY!
Uint8 *keys = SDL_GetKeyState(NULL);
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 1b65d9bb..3b8dda9e 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -223,11 +223,11 @@ void LocalPlayer::walk(unsigned char dir)
dy = 0;
// Choose a straight direction when diagonal target is blocked
- if (dx && dy && !mMap->getWalk(mX + dx, mY + dy))
+ if (dx && dy && mMap->tileCollides(mX + dx, mY + dy))
dx = 0;
// Walk to where the player can actually go
- if ((dx || dy) && mMap->getWalk(mX + dx, mY + dy))
+ if ((dx || dy) && !mMap->tileCollides(mX + dx, mY + dy))
{
setDestination(mX + dx, mY + dy);
}
diff --git a/src/map.cpp b/src/map.cpp
index 2dbf9cb6..c8bdc574 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -276,11 +276,6 @@ void Map::setWalk(int x, int y, bool walkable)
mMetaTiles[x + y * mWidth].walkable = walkable;
}
-bool Map::getWalk(int x, int y) const
-{
- return !tileCollides(x, y) && !occupied(x, y);
-}
-
bool Map::occupied(int x, int y) const
{
Beings &beings = beingManager->getAll();
@@ -340,10 +335,6 @@ Path Map::findPath(int startX, int startY, int destX, int destY)
// Declare open list, a list with open tiles sorted on F cost
std::priority_queue<Location> openList;
- // Return empty path when destination collides
- if (tileCollides(destX, destY))
- return path;
-
// Reset starting tile's G cost to 0
MetaTile *startTile = getMetaTile(startX, startY);
startTile->Gcost = 0;
@@ -388,8 +379,8 @@ Path Map::findPath(int startX, int startY, int destX, int destY)
MetaTile *newTile = getMetaTile(x, y);
- // Skip if the tile is on the closed list or collides
- if (newTile->whichList == mOnClosedList || tileCollides(x, y))
+ // Skip if the tile is on the closed list or collides unless its the destination tile
+ if (newTile->whichList == mOnClosedList || tileCollides(x, y) && !(x == destX && y == destY))
{
continue;
}
diff --git a/src/map.h b/src/map.h
index 5c7fe1e9..fab7bfb7 100644
--- a/src/map.h
+++ b/src/map.h
@@ -134,11 +134,6 @@ class Map : public Properties
void setWalk(int x, int y, bool walkable);
/**
- * Tell if a tile is walkable or not, includes checking beings.
- */
- bool getWalk(int x, int y) const;
-
- /**
* Tell if a tile collides, not including a check on beings.
*/
bool tileCollides(int x, int y) const;