MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ClearTile_Station

Function ClearTile_Station

src/station_cmd.cpp:4904–4944  ·  view source on GitHub ↗

* Clear a single tile of a station. * @param tile The tile to clear. * @param flags The DoCommand flags related to the "command". * @return The cost, or error of clearing. */

Source from the content-addressed store, hash-verified

4902 * @return The cost, or error of clearing.
4903 */
4904CommandCost ClearTile_Station(TileIndex tile, DoCommandFlags flags)
4905{
4906 if (flags.Test(DoCommandFlag::Auto)) {
4907 switch (GetStationType(tile)) {
4908 default: break;
4909 case StationType::Rail: return CommandCost(STR_ERROR_MUST_DEMOLISH_RAILROAD);
4910 case StationType::RailWaypoint: return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
4911 case StationType::Airport: return CommandCost(STR_ERROR_MUST_DEMOLISH_AIRPORT_FIRST);
4912 case StationType::Truck: return CommandCost(HasTileRoadType(tile, RTT_TRAM) ? STR_ERROR_MUST_DEMOLISH_CARGO_TRAM_STATION_FIRST : STR_ERROR_MUST_DEMOLISH_TRUCK_STATION_FIRST);
4913 case StationType::Bus: return CommandCost(HasTileRoadType(tile, RTT_TRAM) ? STR_ERROR_MUST_DEMOLISH_PASSENGER_TRAM_STATION_FIRST : STR_ERROR_MUST_DEMOLISH_BUS_STATION_FIRST);
4914 case StationType::RoadWaypoint: return CommandCost(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
4915 case StationType::Buoy: return CommandCost(STR_ERROR_BUOY_IN_THE_WAY);
4916 case StationType::Dock: return CommandCost(STR_ERROR_MUST_DEMOLISH_DOCK_FIRST);
4917 case StationType::Oilrig:
4918 return CommandCostWithParam(STR_ERROR_GENERIC_OBJECT_IN_THE_WAY, STR_INDUSTRY_NAME_OIL_RIG);
4919 }
4920 }
4921
4922 switch (GetStationType(tile)) {
4923 case StationType::Rail: return RemoveRailStation(tile, flags);
4924 case StationType::RailWaypoint: return RemoveRailWaypoint(tile, flags);
4925 case StationType::Airport: return RemoveAirport(tile, flags);
4926 case StationType::Truck: [[fallthrough]];
4927 case StationType::Bus:
4928 if (IsDriveThroughStopTile(tile)) {
4929 CommandCost remove_road = CanRemoveRoadWithStop(tile, flags);
4930 if (remove_road.Failed()) return remove_road;
4931 }
4932 return RemoveRoadStop(tile, flags);
4933 case StationType::RoadWaypoint: {
4934 CommandCost remove_road = CanRemoveRoadWithStop(tile, flags);
4935 if (remove_road.Failed()) return remove_road;
4936 return RemoveRoadWaypointStop(tile, flags);
4937 }
4938 case StationType::Buoy: return RemoveBuoy(tile, flags);
4939 case StationType::Dock: return RemoveDock(tile, flags);
4940 default: break;
4941 }
4942
4943 return CMD_ERROR;
4944}
4945
4946static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
4947{

Callers 3

IsValidTileForWaypointFunction · 0.85
CheckFlatLandRailStationFunction · 0.85
CheckFlatLandRoadStopFunction · 0.85

Calls 15

GetStationTypeFunction · 0.85
CommandCostClass · 0.85
HasTileRoadTypeFunction · 0.85
RemoveRailStationFunction · 0.85
RemoveRailWaypointFunction · 0.85
RemoveAirportFunction · 0.85
IsDriveThroughStopTileFunction · 0.85
CanRemoveRoadWithStopFunction · 0.85
RemoveRoadStopFunction · 0.85
RemoveRoadWaypointStopFunction · 0.85
RemoveBuoyFunction · 0.85
RemoveDockFunction · 0.85

Tested by

no test coverage detected