|
@@ -118,13 +118,13 @@ AyStar *new_AyStar_AiPathFinder(int max_
|
|
|
|
|
|
// Set the user_data to the PathFinderInfo
|
|
|
result->user_target = PathFinderInfo;
|
|
|
|
|
|
// Set the start node
|
|
|
start_node.parent = NULL;
|
|
|
start_node.node.direction = 0;
|
|
|
start_node.node.direction = INVALID_TRACKDIR;
|
|
|
start_node.node.user_data[0] = 0;
|
|
|
|
|
|
// Now we add all the starting tiles
|
|
|
for (x = TileX(PathFinderInfo->start_tile_tl); x <= TileX(PathFinderInfo->start_tile_br); x++) {
|
|
|
for (y = TileY(PathFinderInfo->start_tile_tl); y <= TileY(PathFinderInfo->start_tile_br); y++) {
|
|
|
start_node.node.tile = TileXY(x, y);
|
|
@@ -147,13 +147,13 @@ void clean_AyStar_AiPathFinder(AyStar *a
|
|
|
|
|
|
// Set the user_data to the PathFinderInfo
|
|
|
aystar->user_target = PathFinderInfo;
|
|
|
|
|
|
// Set the start node
|
|
|
start_node.parent = NULL;
|
|
|
start_node.node.direction = 0;
|
|
|
start_node.node.direction = INVALID_TRACKDIR;
|
|
|
start_node.node.user_data[0] = 0;
|
|
|
start_node.node.tile = PathFinderInfo->start_tile_tl;
|
|
|
|
|
|
// Now we add all the starting tiles
|
|
|
for (x = TileX(PathFinderInfo->start_tile_tl); x <= TileX(PathFinderInfo->start_tile_br); x++) {
|
|
|
for (y = TileY(PathFinderInfo->start_tile_tl); y <= TileY(PathFinderInfo->start_tile_br); y++) {
|
|
@@ -297,13 +297,13 @@ static void AyStar_AiPathFinder_GetNeigh
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// The tile can be connected
|
|
|
aystar->neighbours[aystar->num_neighbours].tile = atile;
|
|
|
aystar->neighbours[aystar->num_neighbours].user_data[0] = 0;
|
|
|
aystar->neighbours[aystar->num_neighbours++].direction = 0;
|
|
|
aystar->neighbours[aystar->num_neighbours++].direction = INVALID_TRACKDIR;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Next step, check for bridges and tunnels
|
|
|
if (current->path.parent != NULL && current->path.node.user_data[0] == 0) {
|
|
|
// First we get the dir from this tile and his parent
|
|
@@ -330,13 +330,13 @@ static void AyStar_AiPathFinder_GetNeigh
|
|
|
// Try building the bridge..
|
|
|
ret = AI_DoCommand(tile, new_tile, (0 << 8) + (MAX_BRIDGES / 2), DC_AUTO, CMD_BUILD_BRIDGE);
|
|
|
if (CmdFailed(ret)) continue;
|
|
|
// We can build a bridge here.. add him to the neighbours
|
|
|
aystar->neighbours[aystar->num_neighbours].tile = new_tile;
|
|
|
aystar->neighbours[aystar->num_neighbours].user_data[0] = AI_PATHFINDER_FLAG_BRIDGE + (dir << 8);
|
|
|
aystar->neighbours[aystar->num_neighbours++].direction = 0;
|
|
|
aystar->neighbours[aystar->num_neighbours++].direction = INVALID_TRACKDIR;
|
|
|
// We can only have 12 neighbours, and we need 1 left for tunnels
|
|
|
if (aystar->num_neighbours == 11) break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Next, check for tunnels!
|
|
@@ -346,13 +346,13 @@ static void AyStar_AiPathFinder_GetNeigh
|
|
|
// Now simply check if a tunnel can be build
|
|
|
ret = AI_DoCommand(tile, (PathFinderInfo->rail_or_road ? 0 : 0x200), 0, DC_AUTO, CMD_BUILD_TUNNEL);
|
|
|
tileh = GetTileSlope(_build_tunnel_endtile, NULL);
|
|
|
if (CmdSucceeded(ret) && IsInclinedSlope(tileh)) {
|
|
|
aystar->neighbours[aystar->num_neighbours].tile = _build_tunnel_endtile;
|
|
|
aystar->neighbours[aystar->num_neighbours].user_data[0] = AI_PATHFINDER_FLAG_TUNNEL + (dir << 8);
|
|
|
aystar->neighbours[aystar->num_neighbours++].direction = 0;
|
|
|
aystar->neighbours[aystar->num_neighbours++].direction = INVALID_TRACKDIR;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|