Old revision #phhnp7qo0 | New revision #pixetasle | ||
---|---|---|---|
1 | /** | 1 | /** |
2 | * Is this tile a target for ships to get to a nearby dock? | 2 | * Ensure this tile is not a target for ships to get to a nearby dock. |
3 | * @note Also takes into account Oil Rigs under construction. | ||
3 | * @param tile Tile to query | 4 | * @param tile Tile to query |
4 | * @param diagdir Optional diagonal direction to look for axis compatibility. | 5 | * @param diagdir Optional diagonal direction to look for axis compatibility. |
5 | * @return True if the tile is a target for ships to get to a nearby dock. | 6 | * @return Succeeded if the tile is not a ship docking area of a nearby dock, |
6 | * @note If the axis of the provided diagdir is paralel to the axis of a nearby | 7 | * or an error message if the tile is a ship docking area of a nearby |
7 | * dock station, this function returns True. If diagdir is not provided, | 8 | dock. |
8 | * only tile locations are compared. | 9 | * @note If the axis of a provided diagdir is equal to the axis of a nearby |
10 | * docking area, it returns Succeeded. If diagdir is not provided, only | ||
11 | * the docking area location is ensured. | ||
9 | */ | 12 | */ |
10 | 10 | CommandCost EnsureNoDockingTile(TileIndex tile, DiagDirection diagdir = INVALID_DIAGDIR) | |
11 | { | 14 | { |
12 | Axis axis = diagdir == INVALID_DIAGDIR ? INVALID_AXIS : DiagDirToAxis(diagdir); | 15 | Axis axis = diagdir == INVALID_DIAGDIR ? INVALID_AXIS : DiagDirToAxis(diagdir); |
13 | 16 | … | … |
17 | Station *dock = Station::GetByTile(tc); | 20 | Station *dock = Station::GetByTile(tc); |
18 | TileIndex docking_location = TILE_ADD(dock->dock_tile, ToTileIndexDiff(GetDockOffset(dock->dock_tile))); | 21 | TileIndex docking_location = TILE_ADD(dock->dock_tile, ToTileIndexDiff(GetDockOffset(dock->dock_tile))); |
19 | if (axis == INVALID_AXIS) { | 22 | if (axis == INVALID_AXIS) { |
20 | return tile == docking_location; | 20 | return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_DOCK); |
21 | } | 21 | } else { |
22 | else { | ||
23 | if (tile == docking_location) { | 25 | if (tile == docking_location) { |
24 | Axis axis_tc = DiagDirToAxis(rot); | 26 | Axis axis_tc = DiagDirToAxis(rot); |
25 | return axis != axis_tc; | 27 | if (axis != axis_tc) { |
28 | return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_DOCK); | ||
29 | } | ||
26 | } | 30 | } |
27 | } | 31 | } |
28 | } | 32 | } |
29 | if (rot == DIAGDIR_NE && IsTileType(tc + TileDiffXY(-1, 0), MP_INDUSTRY) && GetIndustryGfx(tc + TileDiffXY(-1, 0)) == GFX_OILRIG_1) return true; | 33 | if (axis != AXIS_X && DiagDirToAxis(rot) == AXIS_X) { |
34 | if (IsTileType(tc + TileDiffXY(-1, 0), MP_INDUSTRY) && GetIndustryGfx(tc + TileDiffXY(-1, 0)) == GFX_OILRIG_1) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); | ||
35 | } | ||
30 | } | 36 | } |
31 | 37 | ||
32 | return | 32 | return CommandCost(); |
33 | } | 39 | } |