diff options
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/map.cpp b/src/map.cpp index 716e9aee..b5e815f3 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -68,10 +68,6 @@ TileAnimation::TileAnimation(Animation *ani): { } -TileAnimation::~TileAnimation() -{ - delete mLastImage; -} void TileAnimation::update() { @@ -330,7 +326,7 @@ Tileset* Map::getTilesetWithGid(int gid) const containsGid.gid = gid; Tilesets::const_iterator i = find_if(mTilesets.begin(), mTilesets.end(), - containsGid); + containsGid); return (i == mTilesets.end()) ? NULL : *i; } @@ -339,7 +335,7 @@ void Map::setWalk(int x, int y, bool walkable) { mMetaTiles[x + y * mWidth].walkable = walkable; } - + bool Map::occupied(int x, int y) const { Beings &beings = beingManager->getAll(); @@ -357,7 +353,7 @@ bool Map::occupied(int x, int y) const bool Map::tileCollides(int x, int y) const { - return !(contains(x, y) && mMetaTiles[x + y * mWidth].walkable); + return !(contains(x, y) && mMetaTiles[x + y * mWidth].walkable); } bool Map::contains(int x, int y) const @@ -459,6 +455,13 @@ Path Map::findPath(int startX, int startY, int destX, int destY) // 14 for moving diagonal (sqrt(200) = 14.1421...) int Gcost = curr.tile->Gcost + ((dx == 0 || dy == 0) ? 10 : 14); + // It costs extra to walk through a being (needs to be enough + // to make it more attractive to walk around). + if (occupied(x, y)) + { + Gcost += 30; + } + // Skip if Gcost becomes too much // Warning: probably not entirely accurate if (Gcost > 200) |