Skip to content

Commit

Permalink
Do not give up following a path due to the droid being on a blocking …
Browse files Browse the repository at this point in the history
…tile.

If the droid is on a blocking tile, repeatedly redoing pathfinding will not result in a path which does not
originate on said blocking tile.
  • Loading branch information
Cyp committed Jun 13, 2012
1 parent 57a56f2 commit f7c6e38
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/move.cpp
Expand Up @@ -523,13 +523,14 @@ struct BLOCKING_CALLBACK_DATA
{
PROPULSION_TYPE propulsionType;
bool blocking;
Vector2i src;
Vector2i dst;
};

static bool moveBlockingTileCallback(Vector2i pos, int32_t dist, void *data_)
{
BLOCKING_CALLBACK_DATA *data = (BLOCKING_CALLBACK_DATA *)data_;
data->blocking |= pos != data->dst && fpathBlockingTile(map_coord(pos.x), map_coord(pos.y), data->propulsionType);
data->blocking |= pos != data->src && pos != data->dst && fpathBlockingTile(map_coord(pos.x), map_coord(pos.y), data->propulsionType);
return !data->blocking;
}

Expand All @@ -543,6 +544,7 @@ static int32_t moveDirectPathToWaypoint(DROID *psDroid, unsigned positionIndex)
BLOCKING_CALLBACK_DATA data;
data.propulsionType = getPropulsionStats(psDroid)->propulsionType;
data.blocking = false;
data.src = src;
data.dst = dst;
rayCast(src, dst, &moveBlockingTileCallback, &data);
return data.blocking? -1 - dist : dist;
Expand Down

0 comments on commit f7c6e38

Please sign in to comment.