Skip to content

Commit

Permalink
Pathfind to oil wells which are only accessible from a diagonal tile.
Browse files Browse the repository at this point in the history
Let * = Cliff, D = Derrick, O = Oil well

*****
*OD
*Dx
*

In the above, trucks trying to build on the oil well will now pathfind to the tile
marked "x".

Fixes ticket:3215.
  • Loading branch information
Cyp committed Mar 13, 2012
1 parent b4ad988 commit c831b5b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/astar.cpp
Expand Up @@ -364,6 +364,10 @@ static PathCoord fpathAStarExplore(PathfindContext &context, PathCoord tileF)
// loop through possible moves in 8 directions to find a valid move
for (unsigned dir = 0; dir < ARRAY_SIZE(aDirOffset); ++dir)
{
// Try a new location
int x = node.p.x + aDirOffset[dir].x;
int y = node.p.y + aDirOffset[dir].y;

/*
5 6 7
\|/
Expand All @@ -372,7 +376,7 @@ static PathCoord fpathAStarExplore(PathfindContext &context, PathCoord tileF)
3 2 1
odd:orthogonal-adjacent tiles even:non-orthogonal-adjacent tiles
*/
if (dir % 2 != 0)
if (dir % 2 != 0 && !context.dstIgnore.isNonblocking(node.p.x, node.p.y) && !context.dstIgnore.isNonblocking(x, y))
{
int x, y;

Expand All @@ -391,10 +395,6 @@ static PathCoord fpathAStarExplore(PathfindContext &context, PathCoord tileF)
}
}

// Try a new location
int x = node.p.x + aDirOffset[dir].x;
int y = node.p.y + aDirOffset[dir].y;

// See if the node is a blocking tile
if (context.isBlocked(x, y))
{
Expand Down

0 comments on commit c831b5b

Please sign in to comment.