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

Function CmdRemoveFromRailStation

src/station_cmd.cpp:1855–1877  ·  view source on GitHub ↗

* Remove a single tile from a rail station. * This allows for custom-built station with holes and weird layouts * @param flags operation to perform * @param start tile of station piece to remove * @param end other edge of the rect to remove * @param keep_rail if set keep the rail * @return the cost of this operation or an error */

Source from the content-addressed store, hash-verified

1853 * @return the cost of this operation or an error
1854 */
1855CommandCost CmdRemoveFromRailStation(DoCommandFlags flags, TileIndex start, TileIndex end, bool keep_rail)
1856{
1857 if (end == 0) end = start;
1858 if (start >= Map::Size() || end >= Map::Size()) return CMD_ERROR;
1859
1860 TileArea ta(start, end);
1861 std::vector<Station *> affected_stations;
1862
1863 CommandCost ret = RemoveFromRailBaseStation(ta, affected_stations, flags, _price[PR_CLEAR_STATION_RAIL], keep_rail);
1864 if (ret.Failed()) return ret;
1865
1866 /* Do all station specific functions here. */
1867 for (Station *st : affected_stations) {
1868
1869 if (st->train_station.tile == INVALID_TILE) SetWindowWidgetDirty(WC_STATION_VIEW, st->index, WID_SV_TRAINS);
1870 st->MarkTilesDirty(false);
1871 MarkCatchmentTilesDirty();
1872 st->RecomputeCatchment();
1873 }
1874
1875 /* Now apply the rail cost to the number that we deleted */
1876 return ret;
1877}
1878
1879/**
1880 * Remove a single tile from a waypoint.

Callers

nothing calls this directly

Calls 6

SetWindowWidgetDirtyFunction · 0.85
MarkCatchmentTilesDirtyFunction · 0.85
FailedMethod · 0.80
MarkTilesDirtyMethod · 0.80
RecomputeCatchmentMethod · 0.80

Tested by

no test coverage detected