OpenTTD Source: src/station_cmd.cpp File Reference

OpenTTD Source 13.2.1

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
station_cmd.cpp File Reference
`#include "stdafx.h"`
`#include "aircraft.h"`
`#include "bridge_map.h"`
`#include "viewport_func.h"`
`#include "viewport_kdtree.h"`
`#include "command_func.h"`
`#include "town.h"`
`#include "news_func.h"`
`#include "train.h"`
`#include "ship.h"`
`#include "roadveh.h"`
`#include "industry.h"`
`#include "newgrf_cargo.h"`
`#include "newgrf_debug.h"`
`#include "newgrf_station.h"`
`#include "newgrf_canal.h"`
`#include "pathfinder/yapf/yapf_cache.h"`
`#include "road_internal.h"`
`#include "autoslope.h"`
`#include "water.h"`
`#include "strings_func.h"`
`#include "clear_func.h"`
`#include "date_func.h"`
`#include "vehicle_func.h"`
`#include "string_func.h"`
`#include "animated_tile_func.h"`
`#include "elrail_func.h"`
`#include "station_base.h"`
`#include "station_func.h"`
`#include "station_kdtree.h"`
`#include "roadstop_base.h"`
`#include "newgrf_railtype.h"`
`#include "newgrf_roadtype.h"`
`#include "waypoint_base.h"`
`#include "waypoint_func.h"`
`#include "pbs.h"`
`#include "debug.h"`
`#include "core/random_func.hpp"`
`#include "company_base.h"`
`#include "table/airporttile_ids.h"`
`#include "newgrf_airporttiles.h"`
`#include "order_backup.h"`
`#include "newgrf_house.h"`
`#include "company_gui.h"`
`#include "linkgraph/linkgraph_base.h"`
`#include "linkgraph/refresh.h"`
`#include "widgets/station_widget.h"`
`#include "tunnelbridge_map.h"`
`#include "station_cmd.h"`
`#include "waypoint_cmd.h"`
`#include "landscape_cmd.h"`
`#include "rail_cmd.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`
`#include "table/station_land.h"`

Go to the source code of this file.

## Data Structures
struct | StationNameInformation
| Information to handle station action 0 property 24 correctly. More...

## Macros
#define | M(x) ((x) - STR_SV_STNAME)

## Typedefs
typedef bool(* | CMSAMatcher) (TileIndex tile)
| Function to check whether the given tile matches some criterion. More...

## Enumerations
enum | StationNaming { STATIONNAMING_RAIL, STATIONNAMING_ROAD, STATIONNAMING_AIRPORT, STATIONNAMING_OILRIG, STATIONNAMING_DOCK, STATIONNAMING_HELIPORT }

## Functions
bool | IsHangar (TileIndex t)
| Check whether the given tile is a hangar. More...
template<class T >
CommandCost | GetStationAround (TileArea ta, StationID closest_station, CompanyID company, T **st)
| Look for a station owned by the given company around the given tile area. More...
static int | CountMapSquareAround (TileIndex tile, CMSAMatcher cmp)
| Counts the numbers of tiles matching a specific type in the area around. More...
static bool | CMSAMine (TileIndex tile)
| Check whether the tile is a mine. More...
static bool | CMSAWater (TileIndex tile)
| Check whether the tile is water. More...
static bool | CMSATree (TileIndex tile)
| Check whether the tile is a tree. More...
static bool | FindNearIndustryName (TileIndex tile, void *user_data)
| Find a station action 0 property 24 station name, or reduce the free_names if needed. More...
static StringID | GenerateStationName (Station *st, TileIndex tile, StationNaming name_class)
static Station * | GetClosestDeletedStation (TileIndex tile)
| Find the closest deleted station of the current company. More...
void | UpdateAllStationVirtCoords ()
| Update the virtual coords needed to draw the station sign for all stations.
void | ClearAllStationCachedNames ()
static CargoTypes | GetAcceptanceMask (const Station *st)
| Get a mask of the cargo types that the station accepts. More...
static void | ShowRejectOrAcceptNews (const Station *st, uint num_items, CargoID *cargo, StringID msg)
| Items contains the two cargo names that are to be accepted or rejected. More...
CargoArray | GetProductionAroundTiles (TileIndex north_tile, int w, int h, int rad)
| Get the cargo types being produced around the tile (in a rectangle). More...
CargoArray | GetAcceptanceAroundTiles (TileIndex center_tile, int w, int h, int rad, CargoTypes *always_accepted)
| Get the acceptance of cargoes around the tile in 1/8. More...
static CargoArray | GetAcceptanceAroundStation (const Station *st, CargoTypes *always_accepted)
| Get the acceptance of cargoes around the station in. More...
void | UpdateStationAcceptance (Station *st, bool show_msg)
| Update the acceptance for a station. More...
static void | UpdateStationSignCoord (BaseStation *st)
static CommandCost | BuildStationPart (Station **st, DoCommandFlag flags, bool reuse, TileArea area, StationNaming name_class)
| Common part of building various station parts and possibly attaching them to an existing one. More...
static void | DeleteStationIfEmpty (BaseStation *st)
| This is called right after a station was deleted. More...
CommandCost | ClearTile_Station (TileIndex tile, DoCommandFlag flags)
| Clear a single tile of a station. More...
CommandCost | CheckBuildableTile (TileIndex tile, uint invalid_dirs, int &allowed_z, bool allow_steep, bool check_bridge=true)
| Checks if the given tile is buildable, flat and has a certain height. More...
static CommandCost | CheckFlatLandAirport (AirportTileTableIterator tile_iter, DoCommandFlag flags)
| Checks if an airport can be built at the given location and clear the area. More...
static CommandCost | CheckFlatLandRailStation (TileArea tile_area, DoCommandFlag flags, Axis axis, StationID *station, RailType rt, std::vector< Train * > &affected_vehicles, StationClassID spec_class, byte spec_index, byte plat_len, byte numtracks)
| Checks if a rail station can be built at the given area. More...
static CommandCost | CheckFlatLandRoadStop (TileArea tile_area, DoCommandFlag flags, uint invalid_dirs, bool is_drive_through, bool is_truck_stop, Axis axis, StationID *station, RoadType rt)
| Checks if a road stop can be built at the given tile. More...
CommandCost | CanExpandRailStation (const BaseStation *st, TileArea &new_ta, Axis axis)
| Check whether we can expand the rail part of the given station. More...
static byte * | CreateSingle (byte *layout, int n)
static byte * | CreateMulti (byte *layout, int n, byte b)
void | GetStationLayout (byte *layout, uint numtracks, uint plat_len, const StationSpec *statspec)
| Create the station layout for the given number of tracks and platform length. More...
template<class T , StringID error_message>
CommandCost | FindJoiningBaseStation (StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, T **st)
| Find a nearby station that joins this station. More...
static CommandCost | FindJoiningStation (StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, Station **st)
| Find a nearby station that joins this station. More...
CommandCost | FindJoiningWaypoint (StationID existing_waypoint, StationID waypoint_to_join, bool adjacent, TileArea ta, Waypoint **wp)
| Find a nearby waypoint that joins this waypoint. More...
static void | FreeTrainReservation (Train *v)
| Clear platform reservation during station building/removing. More...
static void | RestoreTrainReservation (Train *v)
| Restore platform reservation during station building/removing. More...
CommandCost | CmdBuildRailStation (DoCommandFlag flags, TileIndex tile_org, RailType rt, Axis axis, byte numtracks, byte plat_len, StationClassID spec_class, byte spec_index, StationID station_to_join, bool adjacent)
| Build rail station. More...
static TileArea | MakeStationAreaSmaller (BaseStation *st, TileArea ta, bool(*func)(BaseStation *, TileIndex))
static bool | TileBelongsToRailStation (BaseStation *st, TileIndex tile)
static void | MakeRailStationAreaSmaller (BaseStation *st)
static bool | TileBelongsToShipStation (BaseStation *st, TileIndex tile)
static void | MakeShipStationAreaSmaller (Station *st)
template<class T >
CommandCost | RemoveFromRailBaseStation (TileArea ta, std::vector< T * > &affected_stations, DoCommandFlag flags, Money removal_cost, bool keep_rail)
| Remove a number of tiles from any rail station within the area. More...
CommandCost | CmdRemoveFromRailStation (DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail)
| Remove a single tile from a rail station. More...
CommandCost | CmdRemoveFromRailWaypoint (DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail)
| Remove a single tile from a waypoint. More...
template<class T >
CommandCost | RemoveRailStation (T *st, DoCommandFlag flags, Money removal_cost)
| Remove a rail station/waypoint. More...
static CommandCost | RemoveRailStation (TileIndex tile, DoCommandFlag flags)
| Remove a rail station. More...
static CommandCost | RemoveRailWaypoint (TileIndex tile, DoCommandFlag flags)
| Remove a rail waypoint. More...
static RoadStop ** | FindRoadStopSpot (bool truck_station, Station *st)
static CommandCost | RemoveRoadStop (TileIndex tile, DoCommandFlag flags)
| Remove a bus station/truck stop. More...
static CommandCost | FindJoiningRoadStop (StationID existing_stop, StationID station_to_join, bool adjacent, TileArea ta, Station **st)
| Find a nearby station that joins this road stop. More...
CommandCost | CmdBuildRoadStop (DoCommandFlag flags, TileIndex tile, uint8 width, uint8 length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, StationID station_to_join, bool adjacent)
| Build a bus or truck stop. More...
static Vehicle * | ClearRoadStopStatusEnum (Vehicle *v, void *)
CommandCost | CmdRemoveRoadStop (DoCommandFlag flags, TileIndex tile, uint8 width, uint8 height, RoadStopType stop_type, bool remove_road)
| Remove bus or truck stops. More...
uint8 | GetAirportNoiseLevelForDistance (const AirportSpec *as, uint distance)
| Get a possible noise reduction factor based on distance from town center. More...
Town * | AirportGetNearestTown (const AirportSpec *as, const TileIterator &it, uint &mindist)
| Finds the town nearest to given airport. More...
void | UpdateAirportsNoise ()
| Recalculate the noise generated by the airports of each town.
CommandCost | CmdBuildAirport (DoCommandFlag flags, TileIndex tile, byte airport_type, byte layout, StationID station_to_join, bool allow_adjacent)
| Place an Airport. More...
static CommandCost | RemoveAirport (TileIndex tile, DoCommandFlag flags)
| Remove an airport. More...
CommandCost | CmdOpenCloseAirport (DoCommandFlag flags, StationID station_id)
| Open/close an airport to incoming aircraft. More...
bool | HasStationInUse (StationID station, bool include_company, CompanyID company)
| Tests whether the company's vehicles have this station in orders. More...
CommandCost | CmdBuildDock (DoCommandFlag flags, TileIndex tile, StationID station_to_join, bool adjacent)
| Build a dock/haven. More...
void | RemoveDockingTile (TileIndex t)
void | ClearDockingTilesCheckingNeighbours (TileIndex tile)
| Clear docking tile status from tiles around a removed dock, if the tile has no neighbours which would keep it as a docking tile. More...
bool | IsValidDockingDirectionForDock (TileIndex t, DiagDirection d)
| Check if a dock tile can be docked from the given direction. More...
static TileIndex | FindDockLandPart (TileIndex t)
| Find the part of a dock that is land-based. More...
static CommandCost | RemoveDock (TileIndex tile, DoCommandFlag flags)
| Remove a dock. More...
const DrawTileSprites * | GetStationTileLayout (StationType st, byte gfx)
bool | SplitGroundSpriteForOverlay (const TileInfo *ti, SpriteID *ground, RailTrackOffset *overlay_offset)
| Check whether a sprite is a track sprite, which can be replaced by a non-track ground sprite and a rail overlay. More...
static void | DrawTile_Station (TileInfo *ti)
void | StationPickerDrawSprite (int x, int y, StationType st, RailType railtype, RoadType roadtype, int image)
static int | GetSlopePixelZ_Station (TileIndex tile, uint x, uint y)
static Foundation | GetFoundation_Station (TileIndex tile, Slope tileh)
static void | GetTileDesc_Station (TileIndex tile, TileDesc *td)
static TrackStatus | GetTileTrackStatus_Station (TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
static void | TileLoop_Station (TileIndex tile)
static void | AnimateTile_Station (TileIndex tile)
static bool | ClickTile_Station (TileIndex tile)
static VehicleEnterTileStatus | VehicleEnter_Station (Vehicle *v, TileIndex tile, int x, int y)
void | TriggerWatchedCargoCallbacks (Station *st)
| Run the watched cargo callback for all houses in the catchment area. More...
static bool | StationHandleBigTick (BaseStation *st)
| This function is called for each station once every 250 ticks. More...
static void | byte_inc_sat (byte *p)
static void | TruncateCargo (const CargoSpec *cs, GoodsEntry *ge, uint amount=UINT_MAX)
| Truncate the cargo by a specific amount. More...
static void | UpdateStationRating (Station *st)
void | RerouteCargo (Station *st, CargoID c, StationID avoid, StationID avoid2)
| Reroute cargo of type c at station st or in any vehicles unloading there. More...
void | DeleteStaleLinks (Station *from)
| Check all next hops of cargo packets in this station for existence of a a valid link they may use to travel on. More...
void | IncreaseStats (Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, uint32 time, EdgeUpdateMode mode)
| Increase capacity for a link stat given by station cargo and next hop. More...
void | IncreaseStats (Station *st, const Vehicle *front, StationID next_station_id, uint32 time)
| Increase capacity for all link stats associated with vehicles in the given consist. More...
static void | StationHandleSmallTick (BaseStation *st)
void | OnTick_Station ()
void | StationMonthlyLoop ()
| Monthly loop for stations.
void | ModifyStationRatingAround (TileIndex tile, Owner owner, int amount, uint radius)
static uint | UpdateStationWaiting (Station *st, CargoID type, uint amount, SourceType source_type, SourceID source_id)
static bool | IsUniqueStationName (const std::string &name)
CommandCost | CmdRenameStation (DoCommandFlag flags, StationID station_id, const std::string &text)
| Rename a station. More...
static void | AddNearbyStationsByCatchment (TileIndex tile, StationList *stations, StationList &nearby)
static bool | CanMoveGoodsToStation (const Station *st, CargoID type)
uint | MoveGoodsToStation (CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations, Owner exclusivity)
void | UpdateStationDockingTiles (Station *st)
void | BuildOilRig (TileIndex tile)
void | DeleteOilRig (TileIndex tile)
static void | ChangeTileOwner_Station (TileIndex tile, Owner old_owner, Owner new_owner)
static bool | CanRemoveRoadWithStop (TileIndex tile, DoCommandFlag flags)
| Check if a drive-through road stop tile can be cleared. More...
static CommandCost | TerraformTile_Station (TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)

## Variables
static const TileIndexDiffC | _dock_tileoffs_chkaround []
static const byte | _dock_w_chk [4] = { 2, 1, 2, 1 }
static const byte | _dock_h_chk [4] = { 1, 2, 1, 2 }
const TileTypeProcs | _tile_type_station_procs

## Detailed Description

Handling of station tiles.

Definition in file station_cmd.cpp.

## Typedef Documentation

## ◆ CMSAMatcher

typedef bool(* CMSAMatcher) (TileIndex tile)

Function to check whether the given tile matches some criterion.

Parameters

  tile | the tile to check

Returns
  true if it matches, false otherwise

Definition at line 131 of file station_cmd.cpp.

## Function Documentation

## ◆ AirportGetNearestTown()

Town* AirportGetNearestTown | ( | const AirportSpec * | as,
|  | const TileIterator & | it,
|  | uint & | mindist
| ) |  |

Finds the town nearest to given airport.

Based on minimal manhattan distance to any airport's tile. If two towns have the same distance, town with lower index is returned.

Parameters

  | as | airport's description
  | it | An iterator over all airport tiles
  [out] | mindist | Minimum distance to town

Returns
  nearest town to airport

Definition at line 2153 of file station_cmd.cpp.

References CalcClosestTownFromTile(), TileIterator::Clone(), DistanceManhattan(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, AirportSpec::size_x, AirportSpec::size_y, TileX(), TileY(), and Town::xy.

Referenced by RemoveAirport(), and UpdateAirportsNoise().

## ◆ BuildStationPart()

static CommandCost BuildStationPart | ( | Station ** | st,
|  | DoCommandFlag | flags,
|  | bool | reuse,
|  | TileArea | area,
|  | StationNaming | name_class
| ) |  |
| static

Common part of building various station parts and possibly attaching them to an existing one.

Parameters

  [in,out] | st | Station to attach to
  | flags | Command flags
  | reuse | Whether to try to reuse a deleted station (gray sign) if possible
  | area | Area occupied by the new part
  | name_class | Station naming class to use to generate the new station's name

Returns
  Command error that occurred, if any

Definition at line 692 of file station_cmd.cpp.

References _current_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_station_pool >::CanAllocateItem(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), GetClosestDeletedStation(), OrthogonalTileArea::h, return_cmd_error, OrthogonalTileArea::tile, and OrthogonalTileArea::w.

## ◆ CanExpandRailStation()

CommandCost CanExpandRailStation | ( | const BaseStation * | st,
|  | TileArea & | new_ta,
|  | Axis | axis
| ) |  |

Check whether we can expand the rail part of the given station.

Parameters

  st | the station to expand
  new_ta | the current (and if all is fine new) tile area of the rail part of the station
  axis | the axis of the newly build rail

Returns
  Succeeded or failed command.

Definition at line 1077 of file station_cmd.cpp.

References BaseStation::train_station.

## ◆ CanRemoveRoadWithStop()

static bool CanRemoveRoadWithStop | ( | TileIndex | tile,
|  | DoCommandFlag | flags
| ) |  |
| static

Check if a drive-through road stop tile can be cleared.

Road stops built on town-owned roads check the conditions that would allow clearing of the original road.

Parameters

  tile | road stop tile to check
  flags | command flags

Returns
  true if the road can be cleared

Definition at line 4227 of file station_cmd.cpp.

References _current_company, and OWNER_WATER.

## ◆ CheckBuildableTile()

CommandCost CheckBuildableTile | ( | TileIndex | tile,
|  | uint | invalid_dirs,
|  | int & | allowed_z,
|  | bool | allow_steep,
|  | bool | check_bridge = `true`
| ) |  |

Checks if the given tile is buildable, flat and has a certain height.

Parameters

  tile | TileIndex to check.
  invalid_dirs | Prohibited directions for slopes (set of DiagDirection).
  allowed_z | Height allowed for the tile. If allowed_z is negative, it will be set to the height of this tile.
  allow_steep | Whether steep slopes are allowed.
  check_bridge | Check for the existence of a bridge.

Returns
  The cost in case of success, or an error code if it failed.

Definition at line 794 of file station_cmd.cpp.

References _settings_game, CommandCost::AddCost(), ConstructionSettings::build_on_slopes, CanBuildDepotByTileh(), GameSettings::construction, DIAGDIR_BEGIN, DIAGDIR_END, EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), GetSlopeMaxZ(), GetTileSlope(), HasBit(), IsBridgeAbove(), IsSteepSlope(), return_cmd_error, and SLOPE_FLAT.

Referenced by CheckFlatLandAirport(), CheckFlatLandRailStation(), and CheckFlatLandRoadStop().

## ◆ CheckFlatLandAirport()

static CommandCost CheckFlatLandAirport | ( | AirportTileTableIterator | tile_iter,
|  | DoCommandFlag | flags
| ) |  |
| static

Checks if an airport can be built at the given location and clear the area.

Parameters

  tile_iter | Airport tile iterator.
  flags | Operation to perform.

Returns
  The cost in case of success, or an error code if it failed.

Definition at line 844 of file station_cmd.cpp.

References CommandCost::AddCost(), CheckBuildableTile(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), and INVALID_TILE.

## ◆ CheckFlatLandRailStation()

static CommandCost CheckFlatLandRailStation | ( | TileArea | tile_area,
|  | DoCommandFlag | flags,
|  | Axis | axis,
|  | StationID * | station,
|  | RailType | rt,
|  | std::vector< Train * > & | affected_vehicles,
|  | StationClassID | spec_class,
|  | byte | spec_index,
|  | byte | plat_len,
|  | byte | numtracks
| ) |  |
| static

Checks if a rail station can be built at the given area.

Parameters

  tile_area | Area to check.
  flags | Operation to perform.
  axis | Rail station axis.
  station | StationID to be queried and returned if available.
  rt | The rail type to check for (overbuilding rail stations over rail).
  affected_vehicles | List of trains with PBS reservations on the tiles
  spec_class | Station class.
  spec_index | Index into the station class.
  plat_len | Platform length.
  numtracks | Number of platforms.

Returns
  The cost in case of success, or an error code if it failed.

Definition at line 876 of file station_cmd.cpp.

References CommandCost::AddCost(), StationSpec::callback_mask, CBM_STATION_SLOPE_CHECK, CheckBuildableTile(), ClearTile_Station(), DC_AUTO, EXPENSES_CONSTRUCTION, CommandCost::Failed(), NewGRFClass< Tspec, Tid, Tmax >::Get(), GetStationIndex(), HasBit(), IsRailStation(), IsTileType(), MP_STATION, and PerformStationTileSlopeCheck().

## ◆ CheckFlatLandRoadStop()

static CommandCost CheckFlatLandRoadStop | ( | TileArea | tile_area,
|  | DoCommandFlag | flags,
|  | uint | invalid_dirs,
|  | bool | is_drive_through,
|  | bool | is_truck_stop,
|  | Axis | axis,
|  | StationID * | station,
|  | RoadType | rt
| ) |  |
| static

Checks if a road stop can be built at the given tile.

Parameters

  tile_area | Area to check.
  flags | Operation to perform.
  invalid_dirs | Prohibited directions (set of DiagDirections).
  is_drive_through | True if trying to build a drive-through station.
  is_truck_stop | True when building a truck stop, false otherwise.
  axis | Axis of a drive-through road stop.
  station | StationID to be queried and returned if available.
  rt | Road type to build.

Returns
  The cost in case of success, or an error code if it failed.

Definition at line 962 of file station_cmd.cpp.

References CommandCost::AddCost(), CheckBuildableTile(), ClearTile_Station(), DC_AUTO, DiagDirToAxis(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), GetRoadStopDir(), GetStationIndex(), IsDriveThroughStopTile(), IsRoadStop(), IsTileType(), IsTruckStop(), MP_STATION, and return_cmd_error.

## ◆ ClearDockingTilesCheckingNeighbours()

void ClearDockingTilesCheckingNeighbours | ( | TileIndex | tile | ) |

Clear docking tile status from tiles around a removed dock, if the tile has no neighbours which would keep it as a docking tile.

Parameters

  tile | Ex-dock tile to check.

Definition at line 2583 of file station_cmd.cpp.

References DIAGDIR_BEGIN, DIAGDIR_END, IsValidTile(), and TileOffsByDiagDir().

## ◆ ClearTile_Station()

CommandCost ClearTile_Station | ( | TileIndex | tile,
|  | DoCommandFlag | flags
| ) |  |

Clear a single tile of a station.

Parameters

  tile | The tile to clear.
  flags | The DoCommand flags related to the "command".

Returns
  The cost, or error of clearing.

Definition at line 4254 of file station_cmd.cpp.

References DC_AUTO, and GetStationType().

Referenced by CheckFlatLandRailStation(), CheckFlatLandRoadStop(), and IsValidTileForWaypoint().

## ◆ CmdBuildAirport()

CommandCost CmdBuildAirport | ( | DoCommandFlag | flags,
|  | TileIndex | tile,
|  | byte | airport_type,
|  | byte | 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 2211 of file station_cmd.cpp.

## ◆ CmdBuildDock()

CommandCost CmdBuildDock | ( | DoCommandFlag | 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 2476 of file station_cmd.cpp.

## ◆ CmdBuildRailStation()

CommandCost CmdBuildRailStation | ( | DoCommandFlag | flags,
|  | TileIndex | tile_org,
|  | RailType | rt,
|  | Axis | axis,
|  | byte | numtracks,
|  | byte | plat_len,
|  | StationClassID | spec_class,
|  | byte | 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 1260 of file station_cmd.cpp.

References AXIS_X, CheckIfAuthorityAllowsNewStation(), CMD_ERROR, CommandCost::Failed(), NewGRFClass< Tspec, Tid, Tmax >::Get(), IsValidAxis(), STAT_CLASS_WAYP, and ValParamRailtype().

## ◆ CmdBuildRoadStop()

CommandCost CmdBuildRoadStop | ( | DoCommandFlag | flags,
|  | TileIndex | tile,
|  | uint8 | width,
|  | uint8 | length,
|  | RoadStopType | stop_type,
|  | bool | is_drive_through,
|  | DiagDirection | ddir,
|  | RoadType | rt,
|  | 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.
  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 1827 of file station_cmd.cpp.

References CMD_ERROR, IsValidDiagDirection(), ROADSTOP_END, and ValParamRoadType().

## ◆ CmdOpenCloseAirport()

CommandCost CmdOpenCloseAirport | ( | DoCommandFlag | 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 2422 of file station_cmd.cpp.

References Station::airport, AIRPORT_CLOSED_block, CheckOwnership(), CMD_ERROR, DC_EXEC, FACIL_AIRPORT, BaseStation::facilities, CommandCost::Failed(), Airport::flags, SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, SpecializedStation< Station, false >::IsValidID(), BaseStation::owner, OWNER_NONE, SetWindowWidgetDirty(), WC_STATION_VIEW, and WID_SV_CLOSE_AIRPORT.

## ◆ CmdRemoveFromRailStation()

CommandCost CmdRemoveFromRailStation | ( | DoCommandFlag | 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 1657 of file station_cmd.cpp.

References CMD_ERROR, MapSize(), and RemoveFromRailBaseStation().

## ◆ CmdRemoveFromRailWaypoint()

CommandCost CmdRemoveFromRailWaypoint | ( | DoCommandFlag | flags,
|  | TileIndex | start,
|  | TileIndex | end,
|  | bool | keep_rail
| ) |  |

Remove a single tile from a waypoint.

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

Parameters

  flags | operation to perform
  start | tile of waypoint 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 1690 of file station_cmd.cpp.

References CMD_ERROR, MapSize(), and RemoveFromRailBaseStation().

## ◆ CmdRemoveRoadStop()

CommandCost CmdRemoveRoadStop | ( | DoCommandFlag | flags,
|  | TileIndex | tile,
|  | uint8 | width,
|  | uint8 | 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 2058 of file station_cmd.cpp.

References CMD_ERROR, DC_BANKRUPT, EXPENSES_CONSTRUCTION, GetRoadStopType(), INVALID_ROADTYPE, INVALID_TILE, IsDriveThroughStopTile(), IsRoadStop(), IsTileType(), IsValidTile(), MP_STATION, OWNER_NONE, ROAD_NONE, ROADSTOP_END, and TileAddWrap().

## ◆ CmdRenameStation()

CommandCost CmdRenameStation | ( | DoCommandFlag | 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 3897 of file station_cmd.cpp.

References CheckOwnership(), CMD_ERROR, CommandCost::Failed(), SpecializedStation< Station, false >::GetIfValid(), MAX_LENGTH_STATION_NAME_CHARS, BaseStation::owner, and Utf8StringLength().

## ◆ CMSAMine()

static bool CMSAMine | ( | TileIndex | tile | ) |
| static

Check whether the tile is a mine.

Parameters

  tile | the tile to investigate.

Returns
  true if and only if the tile is a mine

Definition at line 158 of file station_cmd.cpp.

References CC_LIQUID, CC_MAIL, CC_PASSENGERS, CargoSpec::classes, CT_INVALID, CargoSpec::Get(), Industry::GetByTile(), GetIndustrySpec(), INDUSTRYLIFE_EXTRACTIVE, IsTileType(), lengthof, IndustrySpec::life_type, MP_INDUSTRY, Industry::produced_cargo, and Industry::type.

## ◆ CMSATree()

static bool CMSATree | ( | TileIndex | tile | ) |
| static

Check whether the tile is a tree.

Parameters

  tile | the tile to investigate.

Returns
  true if and only if the tile is a tree tile

Definition at line 195 of file station_cmd.cpp.

References IsTileType(), and MP_TREES.

## ◆ CMSAWater()

static bool CMSAWater | ( | TileIndex | tile | ) |
| static

Check whether the tile is water.

Parameters

  tile | the tile to investigate.

Returns
  true if and only if the tile is a water tile

Definition at line 185 of file station_cmd.cpp.

References IsTileType(), IsWater(), and MP_WATER.

## ◆ CountMapSquareAround()

static int CountMapSquareAround | ( | TileIndex | tile,
|  | CMSAMatcher | cmp
| ) |  |
| static

Counts the numbers of tiles matching a specific type in the area around.

Parameters

  tile | the center tile of the 'count area'
  cmp | the comparator/matcher (

See also
  CMSAMatcher)

Returns
  the number of matching tiles around

Definition at line 139 of file station_cmd.cpp.

References INVALID_TILE, and TileAddWrap().

## ◆ DeleteStaleLinks()

void DeleteStaleLinks | ( | Station * | from | ) |

Check all next hops of cargo packets in this station for existence of a a valid link they may use to travel on.

Reroute any cargo not having a valid link and remove timed out links found like this from the linkgraph. We're not all links here as that is expensive and useless. A link no one is using doesn't hurt either.

Parameters

  from | Station to check.

Definition at line 3610 of file station_cmd.cpp.

References _date, _settings_game, LinkGraph::Node::Begin(), DistanceManhattan(), DT_MANUAL, LinkGraph::Node::End(), SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::GetIfValid(), Station::goods, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_orderlist_pool >::Iterate(), LinkGraph::EdgeWrapper< Tedge >::LastUpdate(), GoodsEntry::link_graph, GameSettings::linkgraph, LinkGraph::MIN_TIMEOUT_DISTANCE, Order::next, GoodsEntry::node, NUM_CARGO, and BaseStation::xy.

## ◆ DeleteStationIfEmpty()

static void DeleteStationIfEmpty | ( | BaseStation * | st | ) |
| static

This is called right after a station was deleted.

It checks if the whole station is free of substations, and if so, the station will be deleted after a little while.

Parameters

  st | Station

Definition at line 729 of file station_cmd.cpp.

References BaseStation::delete_ctr, InvalidateWindowData(), BaseStation::IsInUse(), BaseStation::owner, and WC_STATION_LIST.

## ◆ FindDockLandPart()

static TileIndex FindDockLandPart | ( | TileIndex | t | ) |
| static

Find the part of a dock that is land-based.

Parameters

  t | Dock tile to find land part of

Returns
  tile of land part of dock

Definition at line 2618 of file station_cmd.cpp.

References DIAGDIR_BEGIN, DIAGDIR_END, GetDockDirection(), GetStationGfx(), GFX_DOCK_BASE_WATER_PART, INVALID_TILE, IsDockTile(), IsValidTile(), and TileOffsByDiagDir().

Referenced by RemoveDock().

## ◆ FindJoiningBaseStation()

template<class T , StringID error_message>

CommandCost FindJoiningBaseStation | ( | StationID | existing_station,
|  | StationID | station_to_join,
|  | bool | adjacent,
|  | TileArea | ta,
|  | T ** | st
| ) |  |

Find a nearby station that joins this station.

Template Parameters

  T | the class to find a station for
  error_message | the error message when building a station on top of others

Parameters

  existing_station | an existing station we build over
  station_to_join | the station to join to
  adjacent | whether adjacent stations are allowed
  ta | the area of the newly build station
  st | 'return' pointer for the found station

Returns
  command cost with the error or 'okay'

Definition at line 1158 of file station_cmd.cpp.

## ◆ FindJoiningRoadStop()

static CommandCost FindJoiningRoadStop | ( | StationID | existing_stop,
|  | StationID | station_to_join,
|  | bool | adjacent,
|  | TileArea | ta,
|  | Station ** | st
| ) |  |
| static

Find a nearby station that joins this road stop.

Parameters

  existing_stop | an existing road stop we build over
  station_to_join | the station to join to
  adjacent | whether adjacent stations are allowed
  ta | the area of the newly build station
  st | 'return' pointer for the found station

Returns
  command cost with the error or 'okay'

Definition at line 1808 of file station_cmd.cpp.

## ◆ FindJoiningStation()

static CommandCost FindJoiningStation | ( | StationID | existing_station,
|  | StationID | station_to_join,
|  | bool | adjacent,
|  | TileArea | ta,
|  | Station ** | st
| ) |  |
| static

Find a nearby station that joins this station.

Parameters

  existing_station | an existing station we build over
  station_to_join | the station to join to
  adjacent | whether adjacent stations are allowed
  ta | the area of the newly build station
  st | 'return' pointer for the found station

Returns
  command cost with the error or 'okay'

Definition at line 1203 of file station_cmd.cpp.

## ◆ FindJoiningWaypoint()

CommandCost FindJoiningWaypoint | ( | StationID | existing_waypoint,
|  | StationID | waypoint_to_join,
|  | bool | adjacent,
|  | TileArea | ta,
|  | Waypoint ** | wp
| ) |  |

Find a nearby waypoint that joins this waypoint.

Parameters

  existing_waypoint | an existing waypoint we build over
  waypoint_to_join | the waypoint to join to
  adjacent | whether adjacent waypoints are allowed
  ta | the area of the newly build waypoint
  wp | 'return' pointer for the found waypoint

Returns
  command cost with the error or 'okay'

Definition at line 1217 of file station_cmd.cpp.

## ◆ FindNearIndustryName()

static bool FindNearIndustryName | ( | TileIndex | tile,
|  | void * | user_data
| ) |  |
| static

Find a station action 0 property 24 station name, or reduce the free_names if needed.

Parameters

  tile | the tile to search
  user_data | the StationNameInformation to base the search on

Returns
  true if the tile contains an industry that has not given its name to one of the other stations in town.

Definition at line 225 of file station_cmd.cpp.

References StationNameInformation::free_names, GetIndustrySpec(), GetIndustryType(), IsTileType(), and MP_INDUSTRY.

## ◆ FindRoadStopSpot()

static RoadStop** FindRoadStopSpot | ( | bool | truck_station,
|  | Station * | st
| ) |  |
| static

Parameters

  truck_station | Determines whether a stop is ROADSTOP_BUS or ROADSTOP_TRUCK
  st | The Station to do the whole procedure for

Returns
  a pointer to where to link a new RoadStop*

Definition at line 1782 of file station_cmd.cpp.

References Station::bus_stops, RoadStop::next, and Station::truck_stops.

## ◆ FreeTrainReservation()

static void FreeTrainReservation | ( | Train * | v | ) |
| static

Clear platform reservation during station building/removing.

Parameters

  v | vehicle which holds reservation

Definition at line 1226 of file station_cmd.cpp.

References FreeTrainTrackReservation(), Train::GetVehicleTrackdir(), IsRailStationTile(), SpecializedVehicle< T, Type >::Last(), ReverseTrackdir(), SetRailStationPlatformReservation(), Vehicle::tile, and TrackdirToExitdir().

## ◆ GetAcceptanceAroundStation()

static CargoArray GetAcceptanceAroundStation | ( | const Station * | st,
|  | CargoTypes * | always_accepted
| ) |  |
| static

Get the acceptance of cargoes around the station in.

Parameters

  st | Station to get acceptance of.
  always_accepted | bitmask of cargo accepted by houses and headquarters; can be nullptr

Definition at line 570 of file station_cmd.cpp.

References Station::catchment_tiles, and INVALID_TILE.

Referenced by UpdateStationAcceptance().

## ◆ GetAcceptanceAroundTiles()

CargoArray GetAcceptanceAroundTiles | ( | TileIndex | center_tile,
|  | int | w,
|  | int | h,
|  | int | rad,
|  | CargoTypes * | always_accepted
| ) |  |

Get the acceptance of cargoes around the tile in 1/8.

Parameters

  center_tile | Center of the search area
  w | X extent of area
  h | Y extent of area
  rad | Search radius in addition to given area
  always_accepted | bitmask of cargo accepted by houses and headquarters; can be nullptr
  ind | Industry associated with neutral station (e.g. oil rig) or nullptr

Definition at line 548 of file station_cmd.cpp.

References _settings_game, OrthogonalTileArea::Expand(), Industry::GetByTile(), IsTileType(), MP_INDUSTRY, StationSettings::serve_neutral_industries, and GameSettings::station.

## ◆ GetAcceptanceMask()

static CargoTypes GetAcceptanceMask | ( | const Station * | st | ) |
| static

Get a mask of the cargo types that the station accepts.

Parameters

  st | Station to query

Returns
  the expected mask

Definition at line 478 of file station_cmd.cpp.

References GoodsEntry::GES_ACCEPTANCE, Station::goods, HasBit(), NUM_CARGO, SetBit(), and GoodsEntry::status.

Referenced by UpdateStationAcceptance().

## ◆ GetAirportNoiseLevelForDistance()

uint8 GetAirportNoiseLevelForDistance | ( | const AirportSpec * | as,
|  | uint | distance
| ) |  |

Get a possible noise reduction factor based on distance from town center.

The further you get, the less noise you generate. So all those folks at city council can now happily slee... work in their offices

Parameters

  as | airport information
  distance | minimum distance between town and airport

Returns
  the noise that will be generated, according to distance

Definition at line 2124 of file station_cmd.cpp.

References _settings_game, GameSettings::difficulty, AirportSpec::noise_level, and DifficultySettings::town_council_tolerance.

Referenced by RemoveAirport(), and UpdateAirportsNoise().

## ◆ GetClosestDeletedStation()

static Station* GetClosestDeletedStation | ( | TileIndex | tile | ) |
| static

Find the closest deleted station of the current company.

Parameters

  tile | the tile to search from.

Returns
  the closest station or nullptr if too far.

Definition at line 362 of file station_cmd.cpp.

References _current_company, ForAllStationsRadius(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, BaseStation::IsInUse(), and BaseStation::owner.

Referenced by BuildStationPart().

## ◆ GetProductionAroundTiles()

CargoArray GetProductionAroundTiles | ( | TileIndex | north_tile,
|  | int | w,
|  | int | h,
|  | int | rad
| ) |  |

Get the cargo types being produced around the tile (in a rectangle).

Parameters

  north_tile | Northern most tile of area
  w | X extent of the area
  h | Y extent of the area
  rad | Search radius in addition to the given area

Definition at line 509 of file station_cmd.cpp.

References OrthogonalTileArea::Expand(), GetIndustryIndex(), IsTileType(), and MP_INDUSTRY.

## ◆ GetStationAround()

template<class T >

CommandCost GetStationAround | ( | TileArea | ta,
|  | StationID | closest_station,
|  | CompanyID | company,
|  | T ** | st
| ) |  |

Look for a station owned by the given company around the given tile area.

Parameters

  ta | the area to search over
  closest_station | the closest owned station found so far
  company | the company whose stations to look for
  st | to 'return' the found station

Returns
  Succeeded command (if zero or one station found) or failed command (for two or more stations found).

Definition at line 106 of file station_cmd.cpp.

## ◆ GetStationLayout()

void GetStationLayout | ( | byte * | layout,
|  | uint | numtracks,
|  | uint | plat_len,
|  | const StationSpec * | statspec
| ) |  |

Create the station layout for the given number of tracks and platform length.

Parameters

  layout | The layout to write to.
  numtracks | The number of tracks to write.
  plat_len | The length of the platforms.
  statspec | The specification of the station to (possibly) get the layout from.

Definition at line 1122 of file station_cmd.cpp.

References StationSpec::layouts.

## ◆ HasStationInUse()

bool HasStationInUse | ( | StationID | station,
|  | bool | include_company,
|  | CompanyID | company
| ) |  |

Tests whether the company's vehicles have this station in orders.

Parameters

  station | station ID
  include_company | If true only check vehicles of company, if false only check vehicles of other companies
  company | company ID

Definition at line 2445 of file station_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Iterate(), Vehicle::Orders(), and Vehicle::owner.

Referenced by CompanyStationsWindow::BuildStationsList(), and RemoveBuoy().

## ◆ IncreaseStats() [1/2]

void IncreaseStats | ( | Station * | st,
|  | CargoID | cargo,
|  | StationID | next_station_id,
|  | uint | capacity,
|  | uint | usage,
|  | uint32 | time,
|  | EdgeUpdateMode | mode
| ) |  |

Increase capacity for a link stat given by station cargo and next hop.

Parameters

  st | Station to get the link stats from.
  cargo | Cargo to increase stat for.
  next_station_id | Station the consist will be travelling to next.
  capacity | Capacity to add to link stat.
  usage | Usage to add to link stat.
  mode | Update mode to be applied.

Definition at line 3704 of file station_cmd.cpp.

References SpecializedStation< Station, false >::Get(), Station::goods, and GoodsEntry::link_graph.

Referenced by IncreaseStats().

## ◆ IncreaseStats() [2/2]

void IncreaseStats | ( | Station * | st,
|  | const Vehicle * | front,
|  | StationID | next_station_id,
|  | uint32 | time
| ) |  |

Increase capacity for all link stats associated with vehicles in the given consist.

Parameters

  st | Station to get the link stats from.
  front | First vehicle in the consist.
  next_station_id | Station the consist will be travelling to next.

Definition at line 3756 of file station_cmd.cpp.

References Vehicle::cargo, Vehicle::cargo_type, EUM_INCREASE, IncreaseStats(), Vehicle::Next(), Vehicle::refit_cap, and VehicleCargoList::StoredCount().

## ◆ IsHangar()

bool IsHangar | ( | TileIndex | t | ) |

Check whether the given tile is a hangar.

Parameters

  t | the tile to of whether it is a hangar.

Precondition
  IsTileType(t, MP_STATION)

Returns
  true if and only if the tile is a hangar.

Definition at line 80 of file station_cmd.cpp.

References Station::airport, SpecializedStation< Station, false >::GetByTile(), Airport::GetHangarTile(), Airport::GetSpec(), IsAirport(), IsTileType(), MP_STATION, and AirportSpec::nof_depots.

Referenced by IsHangarTile().

## ◆ IsValidDockingDirectionForDock()

bool IsValidDockingDirectionForDock | ( | TileIndex | t,
|  | DiagDirection | d
| ) |  |

Check if a dock tile can be docked from the given direction.

Parameters

  t | Tile index of dock.
  d | DiagDirection adjacent to dock being tested. (unused)

Returns
  True iff the dock can be docked from the given direction.

Definition at line 2605 of file station_cmd.cpp.

References GetStationGfx(), GFX_DOCK_BASE_WATER_PART, and IsDockTile().

Referenced by CheckForDockingTile(), and IsShipDestinationTile().

## ◆ RemoveAirport()

static CommandCost RemoveAirport | ( | TileIndex | tile,
|  | DoCommandFlag | flags
| ) |  |
| static

Remove an airport.

Parameters

  tile | TileIndex been queried
  flags | operation to perform

Returns
  cost or failure of operation

Definition at line 2339 of file station_cmd.cpp.

References _current_company, _settings_game, CommandCost::AddCost(), Station::airport, AirportGetNearestTown(), CheckOwnership(), CloseWindowById(), DC_EXEC, GameSettings::economy, EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), FLYING, GetAirportNoiseLevelForDistance(), SpecializedStation< Station, false >::GetByTile(), Airport::GetHangarTile(), Airport::GetNumHangars(), Airport::GetSpec(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::Iterate(), Town::noise_reached, BaseStation::owner, OWNER_WATER, OrderBackup::Reset(), return_cmd_error, SetWindowDirty(), EconomySettings::station_noise_level, OrthogonalTileArea::tile, WC_TOWN_VIEW, and WC_VEHICLE_DEPOT.

## ◆ RemoveDock()

static CommandCost RemoveDock | ( | TileIndex | tile,
|  | DoCommandFlag | flags
| ) |  |
| static

Remove a dock.

Parameters

  tile | TileIndex been queried
  flags | operation to perform

Returns
  cost or failure of operation

Definition at line 2641 of file station_cmd.cpp.

References CheckOwnership(), CMD_ERROR, DC_EXEC, EnsureNoVehicleOnGround(), CommandCost::Failed(), FindDockLandPart(), SpecializedStation< Station, false >::GetByTile(), GetDockDirection(), INVALID_TILE, IsDockTile(), BaseStation::owner, CommandCost::Succeeded(), and TileOffsByDiagDir().

## ◆ RemoveFromRailBaseStation()

template<class T >

CommandCost RemoveFromRailBaseStation | ( | TileArea | ta,
|  | std::vector< T * > & | affected_stations,
|  | DoCommandFlag | flags,
|  | Money | removal_cost,
|  | bool | keep_rail
| ) |  |

Remove a number of tiles from any rail station within the area.

Parameters

  ta | the area to clear station tile from.
  affected_stations | the stations affected.
  flags | the command flags.
  removal_cost | the cost for removing the tile, including the rail.
  keep_rail | whether to keep the rail of the station.

Template Parameters

  T | the type of station to remove.

Returns
  the number of cleared tiles or an error.

Definition at line 1551 of file station_cmd.cpp.

References EnsureNoVehicleOnGround(), error(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), and HasStationTileRail().

Referenced by CmdRemoveFromRailStation(), and CmdRemoveFromRailWaypoint().

## ◆ RemoveRailStation() [1/2]

template<class T >

CommandCost RemoveRailStation | ( | T * | st,
|  | DoCommandFlag | flags,
|  | Money | removal_cost
| ) |  |

Remove a rail station/waypoint.

Parameters

  st | The station/waypoint to remove the rail part from
  flags | operation to perform
  removal_cost | the cost for removing a tile

Template Parameters

  T | the type of station to remove

Returns
  cost or failure of operation

Definition at line 1711 of file station_cmd.cpp.

Referenced by RemoveRailStation(), and RemoveRailWaypoint().

## ◆ RemoveRailStation() [2/2]

static CommandCost RemoveRailStation | ( | TileIndex | tile,
|  | DoCommandFlag | flags
| ) |  |
| static

Remove a rail station.

Parameters

  tile | Tile of the station.
  flags | operation to perform

Returns
  cost or failure of operation

Definition at line 1745 of file station_cmd.cpp.

References _current_company, DC_EXEC, SpecializedStation< Station, false >::GetByTile(), OWNER_WATER, and RemoveRailStation().

## ◆ RemoveRailWaypoint()

static CommandCost RemoveRailWaypoint | ( | TileIndex | tile,
|  | DoCommandFlag | flags
| ) |  |
| static

Remove a rail waypoint.

Parameters

  tile | Tile of the waypoint.
  flags | operation to perform

Returns
  cost or failure of operation

Definition at line 1766 of file station_cmd.cpp.

References _current_company, DC_EXEC, SpecializedStation< Waypoint, true >::GetByTile(), OWNER_WATER, and RemoveRailStation().

## ◆ RemoveRoadStop()

static CommandCost RemoveRoadStop | ( | TileIndex | tile,
|  | DoCommandFlag | flags
| ) |  |
| static

Remove a bus station/truck stop.

Parameters

  tile | TileIndex been queried
  flags | operation to perform

Returns
  cost or failure of operation

Definition at line 1958 of file station_cmd.cpp.

References _current_company, Station::bus_stops, CheckOwnership(), DC_BANKRUPT, DC_EXEC, CommandCost::Failed(), FindVehicleOnPos(), RoadStop::GetByTile(), SpecializedStation< Station, false >::GetByTile(), IsDriveThroughStopTile(), IsTruckStop(), BaseStation::owner, OWNER_WATER, ROADSTOP_BUS, ROADSTOP_TRUCK, and Station::truck_stops.

## ◆ RerouteCargo()

void RerouteCargo | ( | Station * | st,
|  | CargoID | c,
|  | StationID | avoid,
|  | StationID | avoid2
| ) |  |

Reroute cargo of type c at station st or in any vehicles unloading there.

Make sure the cargo's new next hop is neither "avoid" nor "avoid2".

Parameters

  st | Station to be rerouted at.
  c | Type of cargo.
  avoid | Original next hop of cargo, avoid this.
  avoid2 | Another station to be avoided when rerouting.

Definition at line 3586 of file station_cmd.cpp.

References GoodsEntry::cargo, Vehicle::cargo, Vehicle::cargo_type, Station::goods, Vehicle::Next(), VehicleCargoList::Reroute(), and StationCargoList::Reroute().

## ◆ RestoreTrainReservation()

static void RestoreTrainReservation | ( | Train * | v | ) |
| static

Restore platform reservation during station building/removing.

Parameters

  v | vehicle which held reservation

Definition at line 1238 of file station_cmd.cpp.

References Train::GetVehicleTrackdir(), IsRailStationTile(), SpecializedVehicle< T, Type >::Last(), ReverseTrackdir(), SetRailStationPlatformReservation(), Vehicle::tile, TrackdirToExitdir(), and TryPathReserve().

## ◆ ShowRejectOrAcceptNews()

static void ShowRejectOrAcceptNews | ( | const Station * | st,
|  | uint | num_items,
|  | CargoID * | cargo,
|  | StringID | msg
| ) |  |
| static

Items contains the two cargo names that are to be accepted or rejected.

msg is the string id of the message to display.

Definition at line 492 of file station_cmd.cpp.

References AddNewsItem(), CargoSpec::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, NF_INCOLOUR, NF_SMALL, NR_STATION, NT_ACCEPTANCE, and SetDParam().

Referenced by UpdateStationAcceptance().

## ◆ SplitGroundSpriteForOverlay()

bool SplitGroundSpriteForOverlay | ( | const TileInfo * | ti,
|  | SpriteID * | ground,
|  | RailTrackOffset * | overlay_offset
| ) |  |

Check whether a sprite is a track sprite, which can be replaced by a non-track ground sprite and a rail overlay.

If the ground sprite is suitable, ground is replaced with the new non-track ground sprite, and overlay_offset is set to the overlay to draw.

Parameters

  | ti | Positional info for the tile to decide snowyness etc. May be nullptr.
  [in,out] | ground | Groundsprite to draw.
  [out] | overlay_offset | Overlay to draw.

Returns
  true if overlay can be drawn.

Definition at line 2720 of file station_cmd.cpp.

## ◆ StationHandleBigTick()

static bool StationHandleBigTick | ( | BaseStation * | st | ) |
| static

This function is called for each station once every 250 ticks.

Not all stations will get the tick at the same time.

Parameters

  st | the station receiving the tick.

Returns
  true if the station is still valid (wasn't deleted)

Definition at line 3373 of file station_cmd.cpp.

References ClrBit(), BaseStation::delete_ctr, FACIL_WAYPOINT, BaseStation::facilities, SpecializedStation< Station, false >::From(), GoodsEntry::GES_ACCEPTED_BIGTICK, SpecializedStation< Station, false >::IsExpected(), BaseStation::IsInUse(), NUM_CARGO, TriggerWatchedCargoCallbacks(), and UpdateStationAcceptance().

## ◆ TriggerWatchedCargoCallbacks()

void TriggerWatchedCargoCallbacks | ( | Station * | st | ) |

Run the watched cargo callback for all houses in the catchment area.

Parameters

  st | Station.

Definition at line 3347 of file station_cmd.cpp.

References Station::catchment_tiles, GoodsEntry::GES_ACCEPTED_BIGTICK, Station::goods, HasBit(), INVALID_TILE, IsTileType(), MP_HOUSE, NUM_CARGO, SetBit(), GoodsEntry::status, and WatchedCargoCallback().

Referenced by StationHandleBigTick().

## ◆ TruncateCargo()

static void TruncateCargo | ( | const CargoSpec * | cs,
|  | GoodsEntry * | ge,
|  | uint | amount = `UINT_MAX`
| ) |  |
| static

Truncate the cargo by a specific amount.

Parameters

  cs | The type of cargo to perform the truncation for.
  ge | The goods entry, of the station, to truncate.
  amount | The amount to truncate the cargo by.

Definition at line 3406 of file station_cmd.cpp.

References GoodsEntry::cargo, SpecializedStation< Station, false >::GetIfValid(), Station::goods, CargoSpec::Index(), GoodsEntry::max_waiting_cargo, and StationCargoList::Truncate().

## ◆ UpdateStationAcceptance()

void UpdateStationAcceptance | ( | Station * | st,
|  | bool | show_msg
| ) |  |

Update the acceptance for a station.

Parameters

  st | Station to update
  show_msg | controls whether to display a message that acceptance was changed.

Definition at line 588 of file station_cmd.cpp.

References _local_company, Station::always_accepted, CC_PASSENGERS, CT_INVALID, FACIL_BUS_STOP, FACIL_TRUCK_STOP, BaseStation::facilities, GoodsEntry::GES_ACCEPTANCE, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::Get(), GetAcceptanceAroundStation(), GetAcceptanceMask(), Station::goods, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsCargoInClass(), BaseStation::IsInUse(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::IsValidID(), lengthof, GoodsEntry::link_graph, GoodsEntry::node, NUM_CARGO, BaseStation::owner, BaseStation::rect, SB(), SetWindowWidgetDirty(), ShowRejectOrAcceptNews(), GoodsEntry::status, WC_STATION_VIEW, and WID_SV_ACCEPT_RATING_LIST.

Referenced by StationHandleBigTick().

## Variable Documentation

## ◆ _dock_tileoffs_chkaround

const TileIndexDiffC _dock_tileoffs_chkaround[]
| static

Initial value:
= {
{-1, 0},
{ 0, 0},
{ 0, 0},
{ 0, -1}
}

Definition at line 2459 of file station_cmd.cpp.

## ◆ _tile_type_station_procs

const TileTypeProcs _tile_type_station_procs

Initial value:
= {
DrawTile_Station,
GetSlopePixelZ_Station,
ClearTile_Station,
nullptr,
GetTileDesc_Station,
GetTileTrackStatus_Station,
ClickTile_Station,
AnimateTile_Station,
TileLoop_Station,
ChangeTileOwner_Station,
nullptr,
VehicleEnter_Station,
GetFoundation_Station,
TerraformTile_Station,
}

Definition at line 52 of file landscape.cpp.

ClearTile_Station
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlag flags)
Clear a single tile of a station.
Definition: station_cmd.cpp:4254