# station_cmd.cpp File Reference

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "aircraft.h"`
`#include "bridge_map.h"`
`#include "cmd_helper.h"`
`#include "debug.h"`
`#include "tile_cmd.h"`
`#include "landscape.h"`
`#include "station_map.h"`
`#include "station.h"`
`#include "viewport_func.h"`
`#include "command_func.h"`
`#include "town.h"`
`#include "news.h"`
`#include "saveload.h"`
`#include "airport.h"`
`#include "sprite.h"`
`#include "depot.h"`
`#include "train.h"`
`#include "roadveh.h"`
`#include "water_map.h"`
`#include "industry_map.h"`
`#include "newgrf_callbacks.h"`
`#include "newgrf_station.h"`
`#include "yapf/yapf.h"`
`#include "road_type.h"`
`#include "road_internal.h"`
`#include "cargotype.h"`
`#include "variables.h"`
`#include "autoslope.h"`
`#include "transparency.h"`
`#include "water.h"`
`#include "station_gui.h"`
`#include "strings_func.h"`
`#include "functions.h"`
`#include "window_func.h"`
`#include "date_func.h"`
`#include "vehicle_func.h"`
`#include "string_func.h"`
`#include "signal_func.h"`
`#include "table/sprites.h"`
`#include "table/strings.h"`
`#include "table/station_land.h"`

Go to the source code of this file.

## Data Structures
struct | ottd_Rectangle
## Defines
#define | CHECK_STATIONS_ERR ((Station*)-1)
#define | M(x) ((x) - STR_SV_STNAME)
## Typedefs
typedef bool(* | CMSAMatcher )(TileIndex tile)
| Function to check whether the given tile matches some criterion.
## Enumerations
enum | StationNaming { STATIONNAMING_RAIL = 0, STATIONNAMING_ROAD = 0, STATIONNAMING_AIRPORT, STATIONNAMING_OILRIG, STATIONNAMING_DOCK, STATIONNAMING_BUOY, STATIONNAMING_HELIPORT }
## Functions
bool | IsHangar (TileIndex t)
| Check whether the given tile is a hangar.
RoadStop * | GetRoadStopByTile (TileIndex tile, RoadStop::Type type)
static uint | GetNumRoadStopsInStation (const Station *st, RoadStop::Type type)
static uint | FindCatchmentRadius (const Station *st)
| Calculate the radius of the station.
static Station * | GetStationAround (TileIndex tile, int w, int h, StationID closest_station)
static int | CountMapSquareAround (TileIndex tile, CMSAMatcher cmp)
| Counts the numbers of tiles matching a specific type in the area around.
static bool | CMSAMine (TileIndex tile)
| Check whether the tile is a mine.
static bool | CMSAWater (TileIndex tile)
| Check whether the tile is water.
static bool | CMSATree (TileIndex tile)
| Check whether the tile is a tree.
static bool | CMSAForest (TileIndex tile)
| Check whether the tile is a forest.
static void | GenerateStationName (Station *st, TileIndex tile, int flag)
static Station * | GetClosestStationFromTile (TileIndex tile)
static void | UpdateStationVirtCoord (Station *st)
| Update the virtual coords needed to draw the station sign.
void | UpdateAllStationVirtCoord ()
| Update the virtual coords needed to draw the station sign for all stations.
static void | UpdateStationVirtCoordDirty (Station *st)
| Update the station virt coords while making the modified parts dirty.
static uint | GetAcceptanceMask (const Station *st)
| Get a mask of the cargo types that the station accepts.
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.
void | GetProductionAroundTiles (AcceptedCargo produced, TileIndex tile, int w, int h, int rad)
| Get a list of the cargo types being produced around the tile (in a rectangle).
void | GetAcceptanceAroundTiles (AcceptedCargo accepts, TileIndex tile, int w, int h, int rad)
| Get a list of the cargo types that are accepted around the tile.
static void | MergePoint (ottd_Rectangle *rect, TileIndex tile)
static void | UpdateStationAcceptance (Station *st, bool show_msg)
| Update the acceptance for a station.
static void | UpdateStationSignCoord (Station *st)
static void | DeleteStationIfEmpty (Station *st)
| This is called right after a station was deleted.
static CommandCost | ClearTile_Station (TileIndex tile, byte flags)
CommandCost | CheckFlatLandBelow (TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID *station, bool check_clear=true)
| Tries to clear the given area.
static bool | CanExpandRailroadStation (const Station *st, uint *fin, Axis axis)
static byte * | CreateSingle (byte *layout, int n)
static byte * | CreateMulti (byte *layout, int n, byte b)
static void | GetStationLayout (byte *layout, int numtracks, int plat_len, const StationSpec *statspec)
CommandCost | CmdBuildRailroadStation (TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2)
| Build railroad station.
static void | MakeRailwayStationAreaSmaller (Station *st)
CommandCost | CmdRemoveFromRailroadStation (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Remove a single tile from a railroad station.
static CommandCost | RemoveRailroadStation (Station *st, TileIndex tile, uint32 flags)
static RoadStop ** | FindRoadStopSpot (bool truck_station, Station *st)
CommandCost | CmdBuildRoadStop (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a bus or truck stop.
static void * | ClearRoadStopStatusEnum (Vehicle *v, void *)
static CommandCost | RemoveRoadStop (Station *st, uint32 flags, TileIndex tile)
| Remove a bus station.
CommandCost | CmdRemoveRoadStop (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Remove a bus or truck stop.
CommandCost | CmdBuildAirport (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Place an Airport.
static CommandCost | RemoveAirport (Station *st, uint32 flags)
CommandCost | CmdBuildBuoy (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a buoy.
bool | HasStationInUse (StationID station, PlayerID player)
| Tests whether the player's vehicles have this station in orders When player == INVALID_PLAYER, then check all vehicles.
static CommandCost | RemoveBuoy (Station *st, uint32 flags)
CommandCost | CmdBuildDock (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Build a dock/haven.
static CommandCost | RemoveDock (Station *st, uint32 flags)
const DrawTileSprites * | GetStationTileLayout (StationType st, byte gfx)
static void | DrawTile_Station (TileInfo *ti)
void | StationPickerDrawSprite (int x, int y, StationType st, RailType railtype, RoadType roadtype, int image)
static uint | GetSlopeZ_Station (TileIndex tile, uint x, uint y)
static Foundation | GetFoundation_Station (TileIndex tile, Slope tileh)
static void | GetAcceptedCargo_Station (TileIndex tile, AcceptedCargo ac)
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 void | ClickTile_Station (TileIndex tile)
static VehicleEnterTileStatus | VehicleEnter_Station (Vehicle *v, TileIndex tile, int x, int y)
static void | StationHandleBigTick (Station *st)
static void | byte_inc_sat (byte *p)
static void | UpdateStationRating (Station *st)
static void | StationHandleSmallTick (Station *st)
void | OnTick_Station ()
void | StationMonthlyLoop ()
void | ModifyStationRatingAround (TileIndex tile, PlayerID owner, int amount, uint radius)
static void | UpdateStationWaiting (Station *st, CargoID type, uint amount)
static bool | IsUniqueStationName (const char *name)
CommandCost | CmdRenameStation (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
| Rename a station.
StationSet | FindStationsAroundIndustryTile (TileIndex tile, int w, int h)
| Find all (non-buoy) stations around an industry tile.
uint | MoveGoodsToStation (TileIndex tile, int w, int h, CargoID type, uint amount)
void | BuildOilRig (TileIndex tile)
void | DeleteOilRig (TileIndex tile)
static void | ChangeTileOwner_Station (TileIndex tile, PlayerID old_player, PlayerID new_player)
static bool | CanRemoveRoadWithStop (TileIndex tile)
| Check if a drive-through road stop tile can be cleared.
void | InitializeStations ()
void | AfterLoadStations ()
static CommandCost | TerraformTile_Station (TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
void | SaveLoad_STNS (Station *st)
static void | Save_STNS ()
static void | Load_STNS ()
static void | Save_ROADSTOP ()
static void | Load_ROADSTOP ()
## Variables
static const byte | _airport_sections_country []
static const byte | _airport_sections_town []
static const byte | _airport_sections_metropolitan []
static const byte | _airport_sections_international []
static const byte | _airport_sections_intercontinental []
static const byte | _airport_sections_commuter []
static const byte | _airport_sections_heliport []
static const byte | _airport_sections_helidepot []
static const byte | _airport_sections_helistation []
static const byte *const | _airport_sections []
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 }
static const byte | _enter_station_speedtable [12]
const TileTypeProcs | _tile_type_station_procs
static const SaveLoad | _roadstop_desc []
static const SaveLoad | _station_desc []
static uint16 | _waiting_acceptance
static uint16 | _cargo_source
static uint32 | _cargo_source_xy
static uint16 | _cargo_days
static Money | _cargo_feeder_share
static const SaveLoad | _station_speclist_desc []
const ChunkHandler | _station_chunk_handlers []

## Detailed Description

Definition in file station_cmd.cpp.

## Typedef Documentation

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 140 of file station_cmd.cpp.

## Function Documentation

static bool CanRemoveRoadWithStop | ( | TileIndex | tile | ) | `[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

Returns:
  true if the road can be cleared

Definition at line 2900 of file station_cmd.cpp.

References CheckAllowRemoveRoad(), GetAnyRoadBits(), OWNER_TOWN, ROADTYPE_ROAD, and ROADTYPE_TRAM.

CommandCost CheckFlatLandBelow | ( | TileIndex | tile,
|  | uint | w,
|  | uint | h,
|  | uint | flags,
|  | uint | invalid_dirs,
|  | StationID * | station,
|  | bool | check_clear = `true` |
| ) |  |  |

Tries to clear the given area.

Parameters:

  | tile | TileIndex to start check
  | w | width of search area
  | h | height of search area
  | flags | operation to perform
  | invalid_dirs | prohibited directions (set of DiagDirections)
  | station | StationID to be queried and returned if available
  | check_clear | if clearing tile should be performed (in wich case, cost will be added)

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

Definition at line 703 of file station_cmd.cpp.

References CommandCost::AddCost(), BEGIN_TILE_LOOP, CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_AUTO, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, DoCommand(), END_TILE_LOOP, HasBit(), IsBridgeAbove(), IsSteepSlope(), IsTileType(), MayHaveBridgeAbove(), return_cmd_error, SLOPE_FLAT, SLOPE_NE, SLOPE_NW, SLOPE_SE, SLOPE_SW, and TILE_HEIGHT.

Referenced by CmdBuildAirport(), CmdBuildCompanyHQ(), CmdBuildRailroadStation(), and CmdBuildRoadStop().

CommandCost CmdBuildAirport | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Place an Airport.

Parameters:

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

See also:
  airport.h

Parameters:

  | p2 | (bit 0) - allow airports directly adjacent to other airports.

Definition at line 1651 of file station_cmd.cpp.

References CommandCost::AddCost(), BEGIN_TILE_LOOP, CheckFlatLandBelow(), CMD_ERROR, CmdFailed(), DC_NO_TOWN_RATING, END_TILE_LOOP, GetValidAirports(), HasBit(), RebuildStationLists(), return_cmd_error, SetBit(), SVW_PLANES, UpdateAirplanesOnNewStation(), UpdateStationAcceptance(), and UpdateStationVirtCoordDirty().

CommandCost CmdBuildBuoy | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Build a buoy.

Parameters:

  | tile | tile where to place the bouy
  | flags | operation to perform
  | p1 | unused
  | p2 | unused

Definition at line 1819 of file station_cmd.cpp.

References IsBridgeAbove(), MayHaveBridgeAbove(), OWNER_NONE, RebuildStationLists(), return_cmd_error, SetBit(), SLOPE_FLAT, SVW_SHIPS, UpdateStationAcceptance(), and UpdateStationVirtCoordDirty().

CommandCost CmdBuildDock | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Build a dock/haven.

Parameters:

  | tile | tile where dock will be built
  | flags | operation to perform
  | p1 | (bit 0) - allow docks directly adjacent to other docks.
  | p2 | unused

Definition at line 1930 of file station_cmd.cpp.

References CMD_ERROR, CMD_LANDSCAPE_CLEAR, CmdFailed(), DC_NO_TOWN_RATING, DoCommand(), GetInclinedSlopeDirection(), HasBit(), INVALID_DIAGDIR, IsBridgeAbove(), IsTileType(), MayHaveBridgeAbove(), MP_WATER, RebuildStationLists(), return_cmd_error, ReverseDiagDir(), SetBit(), SLOPE_FLAT, SVW_SHIPS, TileOffsByDiagDir(), ToTileIndexDiff(), UpdateStationAcceptance(), and UpdateStationVirtCoordDirty().

CommandCost CmdBuildRailroadStation | ( | TileIndex | tile_org,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Build railroad station.

Parameters:

  | tile_org | starting position of station dragging/placement
  | flags | operation to perform
  | p1 | various bitstuffed elements p1 = (bit 0) - orientation (Axis) p1 = (bit 8-15) - number of tracks p1 = (bit 16-23) - platform length p1 = (bit 24) - allow stations directly adjacent to other stations.
  | p2 | various bitstuffed elements p2 = (bit 0- 3) - railtype (p2 & 0xF) p2 = (bit 8-15) - custom station class p2 = (bit 16-23) - custom station id

Definition at line 898 of file station_cmd.cpp.

References AddTrackToSignalBuffer(), AllocateSpecToStation(), AXIS_X, AxisToTrack(), CALLBACK_FAILED, CBID_STATION_AVAILABILITY, CBID_STATION_TILE_LAYOUT, CBM_STATION_AVAIL, CheckFlatLandBelow(), CMD_ERROR, CmdFailed(), DC_EXEC, DC_NO_TOWN_RATING, GB(), CommandCost::GetCost(), GetCustomStationSpec(), GetNumStationClasses(), HasBit(), INVALID_TILE, RebuildStationLists(), return_cmd_error, SetBit(), SVW_TRAINS, TileDiffXY(), UpdateStationAcceptance(), UpdateStationVirtCoordDirty(), ValParamRailtype(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildRoadStop | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Build a bus or truck stop.

Parameters:

  | tile | tile to build the stop at
  | flags | operation to perform
  | p1 | entrance direction (DiagDirection)
  | p2 | bit 0: 0 for Bus stops, 1 for truck stops bit 1: 0 for normal, 1 for drive-through bit 2..4: the roadtypes bit 5: allow stations directly adjacent to other stations.

Definition at line 1321 of file station_cmd.cpp.

References CommandCost::AddCost(), AreValidRoadTypes(), AXIS_X, RoadStop::BUS, PoolItem< T, Tid, Tpool >::CanAllocateItem(), CheckFlatLandBelow(), CMD_ERROR, CmdFailed(), CountBits(), DC_NO_TOWN_RATING, FindRoadStopSpot(), GB(), HasBit(), IsValidAxis(), IsValidDiagDirection(), RoadStop::LIMIT, OWNER_NONE, OWNER_TOWN, RebuildStationLists(), return_cmd_error, ROAD_X, ROAD_Y, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_NONE, SetBit(), SVW_ROADVEHS, RoadStop::TRUCK, UpdateStationAcceptance(), and UpdateStationVirtCoordDirty().

CommandCost CmdRemoveFromRailroadStation | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Remove a single tile from a railroad station.

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

Parameters:

  | tile | tile of station piece to remove
  | flags | operation to perform
  | p1 | start_tile
  | p2 | unused

Definition at line 1147 of file station_cmd.cpp.

References AddTrackToSignalBuffer(), BEGIN_TILE_LOOP, CMD_ERROR, DC_EXEC, DeallocateSpecFromStation(), DeleteStationIfEmpty(), END_TILE_LOOP, GetTileOwner(), IsTileType(), MapSize(), OWNER_WATER, return_cmd_error, SVW_TRAINS, Swap(), TileX(), TileXY(), TileY(), UpdateStationVirtCoordDirty(), and YapfNotifyTrackLayoutChange().

CommandCost CmdRemoveRoadStop | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Remove a bus or truck stop.

Parameters:

  | tile | tile to remove the stop from
  | flags | operation to perform
  | p1 | not used
  | p2 | bit 0: 0 for Bus stops, 1 for truck stops

Definition at line 1525 of file station_cmd.cpp.

References CMD_ERROR, CmdSucceeded(), DIAGDIR_NE, DiagDirToRoadBits(), GetRoadStopDir(), IsTileType(), OWNER_TOWN, RemoveRoadStop(), ROAD_X, and ROAD_Y.

CommandCost CmdRenameStation | ( | TileIndex | tile,
|  | uint32 | flags,
|  | uint32 | p1,
|  | uint32 | p2 |
| ) |  |  |

Rename a station.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | station ID that is to be renamed
  | p2 | unused

Definition at line 2639 of file station_cmd.cpp.

References _cmd_text, CMD_ERROR, MarkWholeScreenDirty(), ResortStationLists(), return_cmd_error, and UpdateStationVirtCoord().

static bool CMSAForest | ( | TileIndex | tile | ) | `[static]`

Check whether the tile is a forest.

Parameters:

  | tile | the tile to investigate.

Returns:
  true if and only if the tile is a mine

Definition at line 211 of file station_cmd.cpp.

References GetIndustryByTile(), GetIndustrySpec(), INDUSTRYLIFE_ORGANIC, IsTileType(), IndustrySpec::life_type, MP_INDUSTRY, Industry::produced_cargo, and Industry::type.

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 168 of file station_cmd.cpp.

References CC_LIQUID, GetIndustryByTile(), GetIndustrySpec(), INDUSTRYLIFE_EXTRACTIVE, IsTileType(), IndustrySpec::life_type, MP_INDUSTRY, Industry::produced_cargo, and Industry::type.

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 mine

Definition at line 201 of file station_cmd.cpp.

References IsTileType(), and MP_TREES.

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 mine

Definition at line 191 of file station_cmd.cpp.

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

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'
  | type | the type of tile searched for
  | industry | when type == MP_INDUSTRY, the type of the industry, in all other cases this parameter is ignored

Returns:
  the result the noumber of matching tiles around

Definition at line 150 of file station_cmd.cpp.

References TILE_MASK, and TileDiffXY().

static void DeleteStationIfEmpty | ( | Station * | 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 680 of file station_cmd.cpp.

References RebuildStationLists().

Referenced by CmdRemoveFromRailroadStation(), and RemoveRoadStop().

static uint FindCatchmentRadius | ( | const Station * | st | ) | `[static]`

Calculate the radius of the station.

Basicly it is the biggest radius that is available within the station

Parameters:

  | st | Station to query

Returns:
  the so calculated radius

Definition at line 102 of file station_cmd.cpp.

Referenced by FindStationsAroundIndustryTile(), and UpdateStationAcceptance().

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 1297 of file station_cmd.cpp.

References RoadStop::next.

Referenced by CmdBuildRoadStop().

StationSet FindStationsAroundIndustryTile | ( | TileIndex | tile,
|  | int | w,
|  | int | h |
| ) |  |  |

Find all (non-buoy) stations around an industry tile.

Parameters:

  | tile,: | Center tile to search from
  | w,: | Width of the center
  | h,: | Height of the center

Returns:
  : Set of found stations

Definition at line 2669 of file station_cmd.cpp.

References BEGIN_TILE_LOOP, CA_UNMODIFIED, END_TILE_LOOP, FindCatchmentRadius(), IsTileType(), MAX_CATCHMENT, min(), TILE_MASK, and TileDiffXY().

Referenced by WhoCanServiceIndustry().

void GetAcceptanceAroundTiles | ( | AcceptedCargo | accepts,
|  | TileIndex | tile,
|  | int | w,
|  | int | h,
|  | int | rad |
| ) |  |  |

Get a list of the cargo types that are accepted around the tile.

Parameters:

  | accepts,: | Destination array of accepted cargo
  | tile,: | Center of the search area
  | w,: | Width of the center
  | h,: | Height of the center
  | rad,: | Radius of the rectangular search area

Definition at line 492 of file station_cmd.cpp.

References IsTileType(), MapSizeX(), MapSizeY(), max(), min(), TileX(), TileXY(), and TileY().

Referenced by UpdateStationAcceptance().

static uint 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 413 of file station_cmd.cpp.

References HasBit().

Referenced by UpdateStationAcceptance().

void GetProductionAroundTiles | ( | AcceptedCargo | produced,
|  | TileIndex | tile,
|  | int | w,
|  | int | h,
|  | int | rad |
| ) |  |  |

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

Parameters:

  | produced,: | Destination array of produced cargo
  | tile,: | Center of the search area
  | w,: | Width of the center
  | h,: | Height of the center
  | rad,: | Radius of the search area

Definition at line 444 of file station_cmd.cpp.

References GetTileType(), IsInsideBS(), MapSizeX(), MapSizeY(), max(), min(), TileX(), TileXY(), and TileY().

bool HasStationInUse | ( | StationID | station,
|  | PlayerID | player |
| ) |  |  |

Tests whether the player's vehicles have this station in orders When player == INVALID_PLAYER, then check all vehicles.

Parameters:

  | station | station ID
  | player | player ID, INVALID_PLAYER to disable the check

Definition at line 1866 of file station_cmd.cpp.

References INVALID_PLAYER.

Referenced by BuildStationsList().

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 59 of file station_cmd.cpp.

References IsTileType(), MP_STATION, and ToTileIndexDiff().

Referenced by IsDepotTile().

static CommandCost RemoveRoadStop | ( | Station * | st,
|  | uint32 | flags,
|  | TileIndex | tile |
| ) |  |  | `[static]`

Remove a bus station.

Parameters:

  | st | Station to remove
  | flags | operation to perform
  | tile | TileIndex been queried

Returns:
  cost or failure of operation

Definition at line 1464 of file station_cmd.cpp.

References RoadStop::BUS, CMD_ERROR, DC_BANKRUPT, DeleteStationIfEmpty(), FindVehicleOnPos(), RoadStop::next, OWNER_WATER, SVW_ROADVEHS, RoadStop::TRUCK, and UpdateStationVirtCoordDirty().

Referenced by CmdRemoveRoadStop().

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 426 of file station_cmd.cpp.

References AddNewsItem(), NEWS_FLAGS, NF_TILE, NF_VIEWPORT, NM_SMALL, and NT_ACCEPTANCE.

Referenced by UpdateStationAcceptance().

void UpdateAllStationVirtCoord | ( |  | ) |

Update the virtual coords needed to draw the station sign for all stations.

Definition at line 385 of file station_cmd.cpp.

References UpdateStationVirtCoord().

Referenced by CmdRenameTown(), and InitializeWindowsAndCaches().

static void UpdateStationAcceptance | ( | Station * | st,
|  | bool | show_msg |
| ) |  |  | `[static]`

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 548 of file station_cmd.cpp.

References CA_UNMODIFIED, CC_PASSENGERS, FindCatchmentRadius(), GetAcceptanceAroundTiles(), GetAcceptanceMask(), HasBit(), MapSizeX(), MapSizeY(), min(), SB(), ShowRejectOrAcceptNews(), SVW_ACCEPTLIST, TileDiffXY(), and TileXY().

Referenced by CmdBuildAirport(), CmdBuildBuoy(), CmdBuildDock(), CmdBuildRailroadStation(), and CmdBuildRoadStop().

static void UpdateStationVirtCoord | ( | Station * | st | ) | `[static]`

Update the virtual coords needed to draw the station sign.

Parameters:

  | st | Station to update for.

Definition at line 372 of file station_cmd.cpp.

References TILE_SIZE, TileX(), and TileY().

Referenced by CmdRenameStation(), UpdateAllStationVirtCoord(), and UpdateStationVirtCoordDirty().

## Variable Documentation

const byte* const _airport_sections[]`[static]`

Initial value:

     {
      _airport_sections_country,
      _airport_sections_town,
      _airport_sections_heliport,
      _airport_sections_metropolitan,
      _airport_sections_international,
      _airport_sections_commuter,
      _airport_sections_helidepot,
      _airport_sections_intercontinental,
      _airport_sections_helistation
    }

Definition at line 1633 of file station_cmd.cpp.

const byte _airport_sections_commuter[]`[static]`

Initial value:

     {
      85, 30, 115, 115, 32,
      87, 8,    8,   8, 10,
      87, 11,  11,  11, 10,
      26, 23,  23,  23, 26
    }

Definition at line 1609 of file station_cmd.cpp.

const byte _airport_sections_country[]`[static]`

Initial value:

     {
      54, 53, 52, 65,
      58, 57, 56, 55,
      64, 63, 63, 62
    }

Definition at line 1555 of file station_cmd.cpp.

const byte _airport_sections_helidepot[]`[static]`

Initial value:

     {
      124, 32,
      122, 123
    }

Definition at line 1622 of file station_cmd.cpp.

const byte _airport_sections_heliport[]`[static]`

Initial value:

     {
      66,
    }

Definition at line 1617 of file station_cmd.cpp.

const byte _airport_sections_helistation[]`[static]`

Initial value:

     {
       32, 134, 159, 158,
      161, 142, 142, 157
    }

Definition at line 1628 of file station_cmd.cpp.

const byte _airport_sections_intercontinental[]`[static]`

Initial value:

     {
      102, 120,  89,  89,  89,  89,  89,  89, 118,
      120,  23,  23,  23,  23,  23,  23, 119, 117,
       87,  54,  87,   8,   8,   8,   8,  51, 117,
       87, 162,  87,  85, 116, 116,   8,   9,  10,
       87,   8,   8,  11,  31,  11,   8, 160,  32,
       32, 160,   8,  11,  27,  11,   8,   8,  10,
       87,   8,   8,  11,  30,  11,   8,   8,  10,
       87, 142,   8,  11,  29,  11,  10, 163,  10,
       87, 164,  87,   8,   8,   8,  10,  37, 117,
       87, 120,  89,  89,  89,  89,  89,  89, 119,
      121,  23,  23,  23,  23,  23,  23, 119,  37
    }

Definition at line 1593 of file station_cmd.cpp.

const byte _airport_sections_international[]`[static]`

Initial value:

     {
      88, 89, 89, 89, 89, 89,  88,
      51,  8,  8,  8,  8,  8,  32,
      30,  8, 11, 27, 11,  8,  10,
      32,  8, 11, 27, 11,  8, 114,
      87,  8, 11, 85, 11,  8, 114,
      87,  8,  8,  8,  8,  8,  90,
      26, 23, 23, 23, 23, 23,  26
    }

Definition at line 1582 of file station_cmd.cpp.

const byte _airport_sections_metropolitan[]`[static]`

Initial value:

     {
       31,  9, 33,  9,  9, 32,
       27, 36, 29, 34,  8, 10,
       30, 11, 35, 13, 20, 21,
      102,  8,  8,  8,  8, 28,
       83, 84, 84, 84, 84, 83,
       26, 23, 23, 23, 23, 26
    }

Definition at line 1572 of file station_cmd.cpp.

const byte _airport_sections_town[]`[static]`

Initial value:

     {
      31,  9, 33,  9,  9, 32,
      27, 36, 29, 34,  8, 10,
      30, 11, 35, 13, 20, 21,
      51, 12, 14, 17, 19, 28,
      38, 13, 15, 16, 18, 39,
      26, 22, 23, 24, 25, 26
    }

Definition at line 1562 of file station_cmd.cpp.

const TileIndexDiffC _dock_tileoffs_chkaround[]`[static]`

Initial value:

     {
      {-1,  0},
      { 0,  0},
      { 0,  0},
      { 0, -1}
    }

Definition at line 1915 of file station_cmd.cpp.

const byte _enter_station_speedtable[12]`[static]`

Initial value:

     {
      215, 195, 175, 155, 135, 115, 95, 75, 55, 35, 15, 0
    }

Definition at line 2361 of file station_cmd.cpp.

const SaveLoad _roadstop_desc[]`[static]`

Initial value:

     {
      SLE_VAR(RoadStop,xy,           SLE_UINT32),
      SLE_CONDNULL(1, 0, 44),
      SLE_VAR(RoadStop,status,       SLE_UINT8),

      SLE_CONDNULL(4, 0, 8),
      SLE_CONDNULL(2, 0, 44),
      SLE_CONDNULL(1, 0, 25),

      SLE_REF(RoadStop,next,         REF_ROADSTOPS),
      SLE_CONDNULL(2, 0, 44),

      SLE_CONDNULL(4, 0, 24),
      SLE_CONDNULL(1, 25, 25),

    }

Definition at line 3030 of file station_cmd.cpp.

const ChunkHandler _station_chunk_handlers[]

Initial value:

     {
      { 'STNS', Save_STNS,      Load_STNS,      CH_ARRAY },
      { 'ROAD', Save_ROADSTOP,  Load_ROADSTOP,  CH_ARRAY | CH_LAST},
    }

const SaveLoad _station_speclist_desc[]`[static]`

Initial value:

     {
      SLE_CONDVAR(StationSpecList, grfid,    SLE_UINT32, 27, SL_MAX_VERSION),
      SLE_CONDVAR(StationSpecList, localidx, SLE_UINT8,  27, SL_MAX_VERSION),

    }

Definition at line 3113 of file station_cmd.cpp.

const TileTypeProcs _tile_type_station_procs

Initial value:

     {
      DrawTile_Station,
      GetSlopeZ_Station,
      ClearTile_Station,
      GetAcceptedCargo_Station,
      GetTileDesc_Station,
      GetTileTrackStatus_Station,
      ClickTile_Station,
      AnimateTile_Station,
      TileLoop_Station,
      ChangeTileOwner_Station,
      NULL,
      VehicleEnter_Station,
      GetFoundation_Station,
      TerraformTile_Station,
    }