local adjacentStationId = checkAdjacentStation(tile, a);
local nearest_town;
if (adjacentStationId == AIStation.STATION_NEW) {
nearest_town = AITile.GetClosestTown(tile);
if (nearest_town != town) continue;
} else {
nearest_town = AIStation.GetNearestTown(adjacentStationId);
if (nearest_town != town) {
adjacentStationId = AIStation.STATION_NEW;
nearest_town = AITile.GetClosestTown(tile);
if (nearest_town != town) continue;
}
}