src/ai/default/default.cpp
changeset 9059 04edde3eb0c6
parent 9052 392f5995d323
child 9069 7b9573ccc411
equal deleted inserted replaced
9058:b9c3fec968b8 9059:04edde3eb0c6
  2637 		TileIndex c = TILE_MASK(tile + ToTileIndexDiff(p->tileoffs));
  2637 		TileIndex c = TILE_MASK(tile + ToTileIndexDiff(p->tileoffs));
  2638 
  2638 
  2639 		_cleared_town = NULL;
  2639 		_cleared_town = NULL;
  2640 
  2640 
  2641 		if (p->mode == 2) {
  2641 		if (p->mode == 2) {
  2642 			if (IsTileType(c, MP_ROAD) &&
  2642 			if (IsNormalRoadTile(c) &&
  2643 					GetRoadTileType(c) == ROAD_TILE_NORMAL &&
       
  2644 					(GetRoadBits(c, ROADTYPE_ROAD) & p->attr) != 0) {
  2643 					(GetRoadBits(c, ROADTYPE_ROAD) & p->attr) != 0) {
  2645 				roadflag |= 2;
  2644 				roadflag |= 2;
  2646 
  2645 
  2647 				// all bits are already built?
  2646 				// all bits are already built?
  2648 				if ((GetRoadBits(c, ROADTYPE_ROAD) & p->attr) == p->attr) continue;
  2647 				if ((GetRoadBits(c, ROADTYPE_ROAD) & p->attr) == p->attr) continue;
  2680 		} else if (p->mode == 3) {
  2679 		} else if (p->mode == 3) {
  2681 			if (flag & DC_EXEC) continue;
  2680 			if (flag & DC_EXEC) continue;
  2682 
  2681 
  2683 			if (GetTileSlope(c, NULL) != SLOPE_FLAT) return CMD_ERROR;
  2682 			if (GetTileSlope(c, NULL) != SLOPE_FLAT) return CMD_ERROR;
  2684 
  2683 
  2685 			if (!IsTileType(c, MP_ROAD) || GetRoadTileType(c) != ROAD_TILE_NORMAL) {
  2684 			if (!IsNormalRoadTile(c)) {
  2686 				ret = DoCommand(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR);
  2685 				ret = DoCommand(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR);
  2687 				if (CmdFailed(ret)) return CMD_ERROR;
  2686 				if (CmdFailed(ret)) return CMD_ERROR;
  2688 			}
  2687 			}
  2689 
  2688 
  2690 		}
  2689 		}
  2855 	uint dist = DistanceManhattan(tile, a->dest);
  2854 	uint dist = DistanceManhattan(tile, a->dest);
  2856 
  2855 
  2857 	if (dist <= a->best_dist) {
  2856 	if (dist <= a->best_dist) {
  2858 		TileIndex tile2 = TILE_MASK(tile + TileOffsByDiagDir(_dir_by_track[track]));
  2857 		TileIndex tile2 = TILE_MASK(tile + TileOffsByDiagDir(_dir_by_track[track]));
  2859 
  2858 
  2860 		if (IsTileType(tile2, MP_ROAD) && GetRoadTileType(tile2) == ROAD_TILE_NORMAL) {
  2859 		if (IsNormalRoadTile(tile2)) {
  2861 			a->best_dist = dist;
  2860 			a->best_dist = dist;
  2862 			a->best_tile = tile;
  2861 			a->best_tile = tile;
  2863 			a->best_track = track;
  2862 			a->best_track = track;
  2864 		}
  2863 		}
  2865 	}
  2864 	}
  3738 	} else if (IsTileType(tile, MP_ROAD)) {
  3737 	} else if (IsTileType(tile, MP_ROAD)) {
  3739 		if (!IsTileOwner(tile, _current_player)) return;
  3738 		if (!IsTileOwner(tile, _current_player)) return;
  3740 
  3739 
  3741 		if (IsLevelCrossing(tile)) goto is_rail_crossing;
  3740 		if (IsLevelCrossing(tile)) goto is_rail_crossing;
  3742 
  3741 
  3743 		if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
  3742 		if (IsRoadDepot(tile)) {
  3744 			DiagDirection dir;
  3743 			DiagDirection dir;
  3745 			TileIndex t;
  3744 			TileIndex t;
  3746 
  3745 
  3747 			// Check if there are any stations around.
  3746 			// Check if there are any stations around.
  3748 			t = tile + TileDiffXY(-1, 0);
  3747 			t = tile + TileDiffXY(-1, 0);