OpenTTD Source: src/station_cmd.h File Reference

OpenTTD Source 15.3

Functions
station_cmd.h File Reference

Command definitions related to stations. More...

`#include "command_type.h"`
`#include "rail_type.h"`
`#include "road_type.h"`
`#include "station_type.h"`

Go to the source code of this file.

## Functions
Town * | AirportGetNearestTown (const struct AirportSpec *as, Direction rotation, TileIndex tile, TileIterator &&it, uint &mindist)
uint8_t | GetAirportNoiseLevelForDistance (const struct AirportSpec *as, uint distance)
CommandCost | CmdBuildAirport (DoCommandFlags flags, TileIndex tile, uint8_t airport_type, uint8_t layout, StationID station_to_join, bool allow_adjacent)
| Place an Airport.
CommandCost | CmdBuildDock (DoCommandFlags flags, TileIndex tile, StationID station_to_join, bool adjacent)
| Build a dock/haven.
CommandCost | CmdBuildRailStation (DoCommandFlags flags, TileIndex tile_org, RailType rt, Axis axis, uint8_t numtracks, uint8_t plat_len, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
| Build rail station.
CommandCost | CmdRemoveFromRailStation (DoCommandFlags flags, TileIndex start, TileIndex end, bool keep_rail)
| Remove a single tile from a rail station.
CommandCost | CmdBuildRoadStop (DoCommandFlags flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
| Build a bus or truck stop.
CommandCost | CmdRemoveRoadStop (DoCommandFlags flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road)
| Remove bus or truck stops.
CommandCost | CmdRenameStation (DoCommandFlags flags, StationID station_id, const std::string &text)
| Rename a station.
std::tuple< CommandCost, StationID > | CmdMoveStationName (DoCommandFlags flags, StationID station_id, TileIndex tile)
| Move a station name.
CommandCost | CmdOpenCloseAirport (DoCommandFlags flags, StationID station_id)
| Open/close an airport to incoming aircraft.
void | CcMoveStationName (Commands cmd, const CommandCost &result, StationID station_id)
| Callback function that is called after a name is moved.

## Detailed Description

Command definitions related to stations.

Definition in file station_cmd.h.

## Function Documentation

## ◆ CcMoveStationName()

void CcMoveStationName | ( | Commands | cmd,
|  | const CommandCost & | result,
|  | StationID | station_id
| ) |  |

Callback function that is called after a name is moved.

Parameters

  result | of the operation
  station_id | ID of the changed station

Definition at line 4539 of file station_cmd.cpp.

References CommandCost::Failed(), SpecializedStation< Station, false >::Get(), ResetObjectToPlace(), and SetViewportStationRect().

Referenced by QueryStringWindow::OnPlaceObject().

## ◆ CmdBuildAirport()

CommandCost CmdBuildAirport | ( | DoCommandFlags | flags,
|  | TileIndex | tile,
|  | uint8_t | airport_type,
|  | uint8_t | layout,
|  | StationID | station_to_join,
|  | bool | allow_adjacent
| ) |  |

Place an Airport.

Parameters

  flags | operation to perform
  tile | tile where airport will be built
  airport_type | airport type,

See also
  airport.h

Parameters

  layout | airport layout
  station_to_join | station ID to join (NEW_STATION if build new one)
  allow_adjacent | allow airports directly adjacent to other airports.

Returns
  the cost of this operation or an error

Definition at line 2627 of file station_cmd.cpp.

References _settings_game, OrthogonalTileArea::Add(), AddAnimatedTile(), CommandCost::AddCost(), Station::AddFacility(), Station::AfterStationTileSetChange(), AirportFTAClass::Airplanes, Station::airport, Airport, AirportGetNearestTown(), AirportTileSpec::animation, AT_OILRIG, Airport::blocks, BuildStationPart(), Built, CheckFlatLandAirport(), CheckIfAuthorityAllowsNewStation(), ClosestTownFromTile(), CMD_ERROR, CommandCostWithParam(), GameSettings::difficulty, DIR_E, DIR_W, StationSettings::distant_join_stations, GameSettings::economy, Execute, BaseStation::facilities, CommandCost::Failed(), FindJoiningStation(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), AirportTileSpec::Get(), AirportSpec::Get(), GetAirport(), GetAirportNoiseLevelForDistance(), SpecializedStation< Station, false >::GetIfValid(), GetTranslatedAirportTileID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Invalid, INVALID_TILE, InvalidateWindowData(), AirportSpec::IsAvailable(), SpecializedStation< Station, false >::IsValidID(), AirportSpec::IsWithinMapBounds(), SpecializedStation< Station, false >::Iterate(), Airport::layout, RailStationTileLayout::layout, AirportSpec::layouts, MakeAirport(), Town::MaxTownNoise(), NoAnimation, Town::noise_reached, NUM_AIRPORTS, BaseStation::owner, Random, BaseStation::rect, Airport::rotation, SetStationTileRandomBits(), SetWindowDirty(), AirportSpec::size_x, AirportSpec::size_y, GameSettings::station, EconomySettings::station_noise_level, StationSettings::station_spread, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), OrthogonalTileArea::tile, BaseStation::town, DifficultySettings::town_council_tolerance, Airport::type, UpdateAirplanesOnNewStation(), WC_STATION_VIEW, and WC_TOWN_VIEW.

## ◆ CmdBuildDock()

CommandCost CmdBuildDock | ( | DoCommandFlags | flags,
|  | TileIndex | tile,
|  | StationID | station_to_join,
|  | bool | adjacent
| ) |  |

Build a dock/haven.

Parameters

  flags | operation to perform
  tile | tile where dock will be built
  station_to_join | station ID to join (NEW_STATION if build new one)
  adjacent | allow docks directly adjacent to other docks.

Returns
  the cost of this operation or an error

Definition at line 2892 of file station_cmd.cpp.

References _current_company, _settings_game, OrthogonalTileArea::Add(), CommandCost::AddCost(), Station::AddFacility(), Station::AfterStationTileSetChange(), BuildStationPart(), Canal, CheckIfAuthorityAllowsNewStation(), CMD_ERROR, DiagDirToAxis(), StationSettings::distant_join_stations, Dock, Execute, EXPENSES_CONSTRUCTION, CommandCost::Failed(), FindJoiningStation(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), CommandCost::GetCost(), SpecializedStation< Station, false >::GetIfValid(), GetInclinedSlopeDirection(), GetTileSlope(), GetWaterClass(), GFX_DOCK_BASE_WATER_PART, OrthogonalTileArea::h, HasTileWaterClass(), HasTileWaterGround(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, INVALID_DIAGDIR, IsDockBridgeAboveOk(), IsTileFlat(), IsTileOwner(), IsTileType(), SpecializedStation< Station, false >::IsValidID(), IsWaterTile(), MakeDock(), MP_WATER, BaseStation::owner, BaseStation::rect, ReverseDiagDir(), Station::ship_station, GameSettings::station, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), OrthogonalTileArea::tile, TileOffsByDiagDir(), to_underlying(), ToTileIndexDiff(), and OrthogonalTileArea::w.

## ◆ CmdBuildRailStation()

CommandCost CmdBuildRailStation | ( | DoCommandFlags | flags,
|  | TileIndex | tile_org,
|  | RailType | rt,
|  | Axis | axis,
|  | uint8_t | numtracks,
|  | uint8_t | plat_len,
|  | StationClassID | spec_class,
|  | uint16_t | spec_index,
|  | StationID | station_to_join,
|  | bool | adjacent
| ) |  |

Build rail station.

Parameters

  flags | operation to perform
  tile_org | northern most position of station dragging/placement
  rt | railtype
  axis | orientation (Axis)
  numtracks | number of tracks
  plat_len | platform length
  spec_class | custom station class
  spec_index | custom station id
  station_to_join | station ID to join (NEW_STATION if build new one)
  adjacent | allow stations directly adjacent to other stations.

Returns
  the cost of this operation or an error

Definition at line 1438 of file station_cmd.cpp.

References _current_company, _settings_game, Station::AddFacility(), AddTrackToSignalBuffer(), Station::AfterStationTileSetChange(), AllocateSpecToStation(), AssignSpecToStation(), Avail, AXIS_X, AxisToDiagDir(), AxisToTrack(), BuildStationPart(), Built, BaseStation::cached_anim_triggers, CalculateRailStationCost(), CALLBACK_FAILED, StationSpec::callback_mask, CanExpandRailStation(), CBID_STATION_AVAILABILITY, CBID_STATION_BUILD_TILE_LAYOUT, CheckIfAuthorityAllowsNewStation(), CMD_ERROR, Convert8bitBooleanCallback(), DeallocateSpecFromStation(), DeleteAnimatedTile(), DeleteNewGRFInspectWindow(), StationSpec::disallowed_lengths, StationSpec::disallowed_platforms, StationSettings::distant_join_stations, ErrorUnknownCallbackResult(), Execute, CommandCost::Failed(), FindJoiningStation(), FreeTrainReservation(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), NewGRFClass< Tspec, Tindex, Tmax >::Get(), NewGRFClass< Tspec, Tindex, Tmax >::GetClassCount(), GetCustomStationSpecIndex(), GetPlatformInfo(), GetRailStationAxis(), GetRailType(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpec(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpecCount(), GetStationGfx(), GetTrainForReservation(), StationSpec::grf_prop, GRFFilePropsBase::grffile, GRFFilePropsBase::grfid, HasBit(), HasStationReservation(), HasStationTileRail(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, Company::infrastructure, INVALID_TILE, IsBridgeAbove(), IsCompatibleTrainStationTile(), IsRailStationBridgeAboveOk(), IsRailStationTile(), IsStationTileBlocked(), IsValidAxis(), SpecializedStation< Station, false >::IsValidID(), IsValidTile(), IsWaypointClass(), MakeRailStation(), Station::MarkTilesDirty(), OtherAxis(), BaseStation::owner, CompanyInfrastructure::rail, Random, BaseStation::rect, RestoreTrainReservation(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetAnimationFrame(), SetCustomStationSpecIndex(), SetRailStationPlatformReservation(), SetRailStationTileFlags(), SetStationGfx(), SetStationTileRandomBits(), CompanyInfrastructure::station, GameSettings::station, StationSettings::station_spread, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), OrthogonalTileArea::tile, TileAddWrap(), TileOffsByAxis(), TileOffsByDiagDir(), Train, BaseStation::train_station, ValParamRailType(), and YapfNotifyTrackLayoutChange().

## ◆ CmdBuildRoadStop()

CommandCost CmdBuildRoadStop | ( | DoCommandFlags | flags,
|  | TileIndex | tile,
|  | uint8_t | width,
|  | uint8_t | length,
|  | RoadStopType | stop_type,
|  | bool | is_drive_through,
|  | DiagDirection | ddir,
|  | RoadType | rt,
|  | RoadStopClassID | spec_class,
|  | uint16_t | spec_index,
|  | StationID | station_to_join,
|  | bool | adjacent
| ) |  |

Build a bus or truck stop.

Parameters

  flags | Operation to perform.
  tile | Northernmost tile of the stop.
  width | Width of the road stop.
  length | Length of the road stop.
  stop_type | Type of road stop (bus/truck).
  is_drive_through | False for normal stops, true for drive-through.
  ddir | Entrance direction (DiagDirection) for normal stops. Converted to the axis for drive-through stops.
  rt | The roadtype.
  spec_class | Road stop spec class.
  spec_index | Road stop spec index.
  station_to_join | Station ID to join (NEW_STATION if build new one).
  adjacent | Allow stations directly adjacent to other stations.

Returns
  The cost of this operation or an error.

Definition at line 2071 of file station_cmd.cpp.

References _current_company, _settings_game, OrthogonalTileArea::Add(), Station::AddFacility(), Station::AfterStationTileSetChange(), Avail, BuildStationPart(), Built, Bus, Station::bus_station, BusStop, BaseStation::cached_roadstop_anim_triggers, CalculateRoadStopCost(), CALLBACK_FAILED, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_roadstop_pool >::CanAllocateItem(), CBID_STATION_AVAILABILITY, CheckIfAuthorityAllowsNewStation(), CMD_ERROR, Convert8bitBooleanCallback(), CountBits(), DiagDirToAxis(), StationSettings::distant_join_stations, DriveThroughOnly, End, Execute, CommandCost::Failed(), FindJoiningRoadStop(), FindRoadStopSpot(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), NewGRFClass< Tspec, Tindex, Tmax >::Get(), RoadStopSpec::GetBuildCost(), NewGRFClass< Tspec, Tindex, Tmax >::GetClassCount(), GetRoadBits(), GetRoadOwner(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpec(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpecCount(), RoadStopSpec::grf_prop, GRFFilePropsBase::grffile, OrthogonalTileArea::h, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, INVALID_ROADTYPE, INVALID_TILE, IsNormalRoadTile(), IsStationRoadStop(), IsTileType(), IsValidDiagDirection(), SpecializedStation< Station, false >::IsValidID(), IsValidTile(), IsWaypointClass(), RailStationTileLayout::length, RoadStop::MakeDriveThrough(), MakeDriveThroughRoadStop(), MakeRoadStop(), MarkTileDirtyByTile(), MayHaveRoad(), MP_STATION, BaseStation::owner, Random, BaseStation::rect, RemoveRoadStop(), ROAD_STOP_TRACKBIT_FACTOR, ROADSTOPTYPE_ALL, ROADSTOPTYPE_FREIGHT, ROADSTOPTYPE_PASSENGER, RTT_ROAD, RTT_TRAM, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetCustomRoadStopSpecIndex(), GameSettings::station, StationSettings::station_spread, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TileAddWrap(), Truck, Station::truck_station, TruckStop, UpdateCompanyRoadInfrastructure(), ValParamRoadType(), and OrthogonalTileArea::w.

## ◆ CmdMoveStationName()

std::tuple< CommandCost, StationID > CmdMoveStationName | ( | DoCommandFlags | flags,
|  | StationID | station_id,
|  | TileIndex | tile
| ) |  |

Move a station name.

Parameters

  flags | type of operation
  station_id | id of the station
  tile | to move the station name to

Returns
  the cost of this operation or an error and the station ID

Definition at line 4502 of file station_cmd.cpp.

References CheckOwnership(), CMD_ERROR, Execute, CommandCost::Failed(), ForAllStationsRadius(), SpecializedStation< Station, false >::GetIfValid(), Station::MoveSign(), BaseStation::owner, OWNER_NONE, StationRect::PtInExtendedRect(), BaseStation::rect, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TileX(), TileY(), Station::UpdateVirtCoord(), and BaseStation::xy.

## ◆ CmdOpenCloseAirport()

CommandCost CmdOpenCloseAirport | ( | DoCommandFlags | flags,
|  | StationID | station_id
| ) |  |

Open/close an airport to incoming aircraft.

Parameters

  flags | Operation to perform.
  station_id | Station ID of the airport.

Returns
  the cost of this operation or an error

Definition at line 2836 of file station_cmd.cpp.

References Station::airport, Airport, AirportClosed, Airport::blocks, CheckOwnership(), CMD_ERROR, Execute, BaseStation::facilities, CommandCost::Failed(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Flip(), SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, SpecializedStation< Station, false >::IsValidID(), BaseStation::owner, OWNER_NONE, SetWindowWidgetDirty(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), WC_STATION_VIEW, and WID_SV_CLOSE_AIRPORT.

## ◆ CmdRemoveFromRailStation()

CommandCost CmdRemoveFromRailStation | ( | DoCommandFlags | flags,
|  | TileIndex | start,
|  | TileIndex | end,
|  | bool | keep_rail
| ) |  |

Remove a single tile from a rail station.

This allows for custom-built station with holes and weird layouts

Parameters

  flags | operation to perform
  start | tile of station piece to remove
  end | other edge of the rect to remove
  keep_rail | if set keep the rail

Returns
  the cost of this operation or an error

Definition at line 1855 of file station_cmd.cpp.

References CMD_ERROR, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, INVALID_TILE, RemoveFromRailBaseStation(), SetWindowWidgetDirty(), Map::Size(), OrthogonalTileArea::tile, BaseStation::train_station, WC_STATION_VIEW, and WID_SV_TRAINS.

## ◆ CmdRemoveRoadStop()

CommandCost CmdRemoveRoadStop | ( | DoCommandFlags | flags,
|  | TileIndex | tile,
|  | uint8_t | width,
|  | uint8_t | height,
|  | RoadStopType | stop_type,
|  | bool | remove_road
| ) |  |

Remove bus or truck stops.

Parameters

  flags | Operation to perform.
  tile | Northernmost tile of the removal area.
  width | Width of the removal area.
  height | Height of the removal area.
  stop_type | Type of stop (bus/truck).
  remove_road | Remove roads of drive-through stops?

Returns
  The cost of this operation or an error.

Definition at line 2483 of file station_cmd.cpp.

References Bankrupt, CMD_ERROR, End, INVALID_TILE, IsValidTile(), RemoveGenericRoadStop(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and TileAddWrap().

## ◆ CmdRenameStation()

CommandCost CmdRenameStation | ( | DoCommandFlags | flags,
|  | StationID | station_id,
|  | const std::string & | text
| ) |  |

Rename a station.

Parameters

  flags | operation to perform
  station_id | station ID that is to be renamed
  text | the new name or an empty string when resetting to the default

Returns
  the cost of this operation or an error

Definition at line 4465 of file station_cmd.cpp.

References BaseStation::cached_name, CheckOwnership(), CMD_ERROR, Execute, CommandCost::Failed(), SpecializedStation< Station, false >::GetIfValid(), InvalidateWindowData(), MAX_LENGTH_STATION_NAME_CHARS, BaseStation::name, BaseStation::owner, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Station::UpdateVirtCoord(), Utf8StringLength(), and WC_STATION_LIST.