# station_cmd.cpp File Reference

Handling of station tiles. More...

`#include "stdafx.h"`
`#include "aircraft.h"`
`#include "bridge_map.h"`
`#include "cmd_helper.h"`
`#include "landscape.h"`
`#include "viewport_func.h"`
`#include "command_func.h"`
`#include "town.h"`
`#include "news_func.h"`
`#include "train.h"`
`#include "roadveh.h"`
`#include "industry.h"`
`#include "newgrf_cargo.h"`
`#include "newgrf_station.h"`
`#include "pathfinder/yapf/yapf_cache.h"`
`#include "road_internal.h"`
`#include "variables.h"`
`#include "autoslope.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 "animated_tile_func.h"`
`#include "elrail_func.h"`
`#include "station_base.h"`
`#include "roadstop_base.h"`
`#include "newgrf_railtype.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 "newgrf.h"`
`#include "table/airporttile_ids.h"`
`#include "table/strings.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...

## Defines

#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, STATIONNAMING_ROAD, STATIONNAMING_AIRPORT, STATIONNAMING_OILRIG, STATIONNAMING_DOCK, STATIONNAMING_HELIPORT }

## Functions

bool | IsHangar (TileIndex t)
| Check whether the given tile is a hangar.
template<class T >
bool | GetStationAround (TileArea ta, StationID closest_station, T **st)
| Look for a station around the given tile area.
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 bool | FindNearIndustryName (TileIndex tile, void *user_data)
| Find a station action 0 property 24 station name, or reduce the free_names if needed.
static StringID | GenerateStationName (Station *st, TileIndex tile, StationNaming name_class)
static Station * | GetClosestDeletedStation (TileIndex tile)
| Find the closest deleted station of the current company.
void | UpdateAllStationVirtCoords ()
| Update the virtual coords needed to draw the station sign for all stations.
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.
CargoArray | GetProductionAroundTiles (TileIndex tile, int w, int h, int rad)
| Get the cargo types being produced around the tile (in a rectangle).
CargoArray | GetAcceptanceAroundTiles (TileIndex tile, int w, int h, int rad, uint32 *always_accepted)
| Get the acceptance of cargos around the tile in 1/8.
void | UpdateStationAcceptance (Station *st, bool show_msg)
| Update the acceptance for a station.
static void | UpdateStationSignCoord (BaseStation *st)
static void | DeleteStationIfEmpty (BaseStation *st)
| This is called right after a station was deleted.
CommandCost | ClearTile_Station (TileIndex tile, DoCommandFlag flags)
CommandCost | CheckFlatLandBelow (TileIndex tile, uint w, uint h, DoCommandFlag flags, uint invalid_dirs, StationID *station, bool check_clear=true, RailType rt=INVALID_RAILTYPE)
| Tries to clear the given area.
bool | CanExpandRailStation (const BaseStation *st, TileArea &new_ta, Axis axis)
| Check whether we can expand the rail part of the given station.
static byte * | CreateSingle (byte *layout, int n)
static byte * | CreateMulti (byte *layout, int n, byte b)
void | GetStationLayout (byte *layout, int numtracks, int plat_len, const StationSpec *statspec)
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.
static CommandCost | FindJoiningStation (StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, Station **st)
| Find a nearby station that joins this station.
CommandCost | FindJoiningWaypoint (StationID existing_waypoint, StationID waypoint_to_join, bool adjacent, TileArea ta, Waypoint **wp)
| Find a nearby waypoint that joins this waypoint.
CommandCost | CmdBuildRailStation (TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build rail station.
static void | MakeRailStationAreaSmaller (BaseStation *st)
template<class T >
CommandCost | RemoveFromRailBaseStation (TileArea ta, SmallVector< T *, 4 > &affected_stations, DoCommandFlag flags, Money removal_cost, bool keep_rail)
| Remove a number of tiles from any rail station within the area.
CommandCost | CmdRemoveFromRailStation (TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Remove a single tile from a rail station.
CommandCost | CmdRemoveFromRailWaypoint (TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Remove a single tile from a waypoint.
template<class T >
CommandCost | RemoveRailStation (T *st, DoCommandFlag flags)
| Remove a rail road station/waypoint.
static CommandCost | RemoveRailStation (TileIndex tile, DoCommandFlag flags)
| Remove a rail road station.
static CommandCost | RemoveRailWaypoint (TileIndex tile, DoCommandFlag flags)
| Remove a rail waypoint.
static RoadStop ** | FindRoadStopSpot (bool truck_station, Station *st)
CommandCost | CmdBuildRoadStop (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a bus or truck stop.
static Vehicle * | ClearRoadStopStatusEnum (Vehicle *v, void *)
static CommandCost | RemoveRoadStop (TileIndex tile, DoCommandFlag flags)
| Remove a bus station/truck stop.
CommandCost | CmdRemoveRoadStop (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Remove a bus or truck stop.
static uint | GetMinimalAirportDistanceToTile (const AirportSpec *as, TileIndex town_tile, TileIndex airport_tile)
| Computes the minimal distance from town's xy to any airport's tile.
uint8 | GetAirportNoiseLevelForTown (const AirportSpec *as, TileIndex town_tile, TileIndex tile)
| Get a possible noise reduction factor based on distance from town center.
Town * | AirportGetNearestTown (const AirportSpec *as, TileIndex airport_tile)
| Finds the town nearest to given airport.
void | UpdateAirportsNoise ()
| Recalculate the noise generated by the airports of each town.
CommandCost | CmdBuildAirport (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Place an Airport.
static CommandCost | RemoveAirport (TileIndex tile, DoCommandFlag flags)
| Remove an airport.
bool | HasStationInUse (StationID station, CompanyID company)
| Tests whether the company's vehicles have this station in orders When company == INVALID_COMPANY, then check all vehicles.
CommandCost | CmdBuildDock (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Build a dock/haven.
static CommandCost | RemoveDock (TileIndex tile, DoCommandFlag flags)
| Remove a dock.
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 | 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)
static bool | StationHandleBigTick (BaseStation *st)
| This function is called for each station once every 250 ticks.
static void | byte_inc_sat (byte *p)
static void | UpdateStationRating (Station *st)
static void | StationHandleSmallTick (BaseStation *st)
void | OnTick_Station ()
void | StationMonthlyLoop ()
void | ModifyStationRatingAround (TileIndex tile, Owner owner, int amount, uint radius)
static void | UpdateStationWaiting (Station *st, CargoID type, uint amount, SourceType source_type, SourceID source_id)
static bool | IsUniqueStationName (const char *name)
CommandCost | CmdRenameStation (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Rename a station.
void | FindStationsAroundTiles (const TileArea &location, StationList *stations)
| Find all stations around a rectangular producer (industry, house, headquarter, .
uint | MoveGoodsToStation (CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations)
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.
static CommandCost | TerraformTile_Station (TileIndex tile, DoCommandFlag flags, uint 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

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

## Function Documentation

Town* AirportGetNearestTown | ( | const AirportSpec * | as,
|  | TileIndex | airport_tile |
| ) |  |  |

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
  | airport_tile | st->airport_tile

Returns:
  nearest town to airport

Definition at line 1857 of file station_cmd.cpp.

References DistanceManhattan(), GetMinimalAirportDistanceToTile(), AirportSpec::size_x, and AirportSpec::size_y.

Referenced by CmdBuildAirport(), AIAirport::GetNearestTown(), AIAirport::GetNoiseLevelIncrease(), RemoveAirport(), and UpdateAirportsNoise().

bool 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:
  true if we are allowed to extend

Definition at line 775 of file station_cmd.cpp.

References _settings_game, GetRailStationAxis(), TileArea::h, max(), min(), StationSettings::nonuniform_stations, GameSettings::station, StationSettings::station_spread, TileArea::tile, TILE_LOOP, BaseStation::TileBelongsToRailStation(), TileDiffXY(), TileX(), TileXY(), TileY(), BaseStation::train_station, and TileArea::w.

Referenced by CmdBuildRailStation(), and CmdBuildRailWaypoint().

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

References CheckAllowRemoveRoad(), CheckOwnership(), GetAnyRoadBits(), HasBit(), OWNER_TOWN, OWNER_WATER, ROADTYPE_ROAD, and ROADTYPE_TRAM.

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

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)
  | rt | The rail type to check for (overbuilding rail stations over rail)

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

Definition at line 675 of file station_cmd.cpp.

References _settings_game, CommandCost::AddCost(), ConstructionSettings::build_on_slopes, CMD_ERROR, CMD_LANDSCAPE_CLEAR, CMD_REMOVE_SINGLE_RAIL, GameSettings::construction, DC_AUTO, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, DoCommand(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), GetRailType(), GetStationIndex(), GetTileSlope(), GetTrackBits(), HasBit(), HasPowerOnRail(), HasSignals(), INVALID_RAILTYPE, IsBridgeAbove(), IsPlainRailTile(), IsRailStation(), IsSteepSlope(), IsTileType(), MayHaveBridgeAbove(), MP_STATION, RemoveFirstTrack(), return_cmd_error, SLOPE_FLAT, SLOPE_NE, SLOPE_NW, SLOPE_SE, SLOPE_SW, TILE_HEIGHT, TILE_LOOP, TRACK_BIT_NONE, TRACK_X, and TRACK_Y.

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

CommandCost CmdBuildAirport | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Place an Airport.

Parameters:

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

See also:
  airport.h

Parameters:

  p2

  various bitstuffed elements
  - p2 = (bit 0) - allow airports directly adjacent to other airports.
  - p2 = (bit 16-31) - station ID to join (NEW_STATION if build new one)

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1903 of file station_cmd.cpp.

References _settings_game, CommandCost::AddCost(), Station::AddFacility(), Station::airport_flags, Station::airport_tile, AirportGetNearestTown(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_station_pool >::CanAllocateItem(), CheckFlatLandBelow(), CheckIfAuthorityAllowsNewStation(), CMD_ERROR, DC_EXEC, StationSettings::distant_join_stations, GameSettings::economy, FACIL_AIRPORT, BaseStation::facilities, CommandCost::Failed(), FindJoiningStation(), GB(), AirportSpec::Get(), GetAirportNoiseLevelForTown(), GetClosestDeletedStation(), SpecializedStation< Station, false >::GetIfValid(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), SpecializedStation< Station, false >::IsValidID(), MakeAirport(), Town::MaxTownNoise(), BaseStation::owner, Station::RecomputeIndustriesNear(), BaseStation::rect, return_cmd_error, SetBit(), SetDParam(), SetWindowDirty(), SetWindowWidgetDirty(), AirportSpec::size_x, AirportSpec::size_y, GameSettings::station, EconomySettings::station_noise_level, StationSettings::station_spread, BaseStation::string_id, SVW_PLANES, AirportSpec::table, ToTileIndexDiff(), BaseStation::town, UpdateAirplanesOnNewStation(), UpdateStationAcceptance(), and Station::UpdateVirtCoord().

CommandCost CmdBuildDock | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

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 | bit 16-31: station ID to join (NEW_STATION if build new one)
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 2156 of file station_cmd.cpp.

References _settings_game, Station::AddFacility(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_station_pool >::CanAllocateItem(), CheckIfAuthorityAllowsNewStation(), CMD_ERROR, CMD_LANDSCAPE_CLEAR, DC_EXEC, StationSettings::distant_join_stations, Station::dock_tile, DoCommand(), EXPENSES_CONSTRUCTION, FACIL_DOCK, CommandCost::Failed(), FindJoiningStation(), GB(), GetClosestDeletedStation(), SpecializedStation< Station, false >::GetIfValid(), GetInclinedSlopeDirection(), GetTileSlope(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_DIAGDIR, INVALID_TILE, InvalidateWindowData(), IsBridgeAbove(), IsTileType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), SpecializedStation< Station, false >::IsValidID(), MakeDock(), MayHaveBridgeAbove(), MP_WATER, BaseStation::owner, Station::RecomputeIndustriesNear(), BaseStation::rect, return_cmd_error, ReverseDiagDir(), SetBit(), SetWindowWidgetDirty(), SLOPE_FLAT, GameSettings::station, BaseStation::string_id, SVW_SHIPS, TileOffsByDiagDir(), ToTileIndexDiff(), BaseStation::town, UpdateStationAcceptance(), and Station::UpdateVirtCoord().

CommandCost CmdBuildRailStation | ( | TileIndex | tile_org,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Build rail station.

Parameters:

  | tile_org | northern most position of station dragging/placement
  | flags | operation to perform

  p1

  various bitstuffed elements
  - p1 = (bit 0- 3) - railtype
  - p1 = (bit 4) - 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- 7) - custom station class
  - p2 = (bit 8-15) - custom station id
  - p2 = (bit 16-31) - station ID to join (NEW_STATION if build new one)

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 966 of file station_cmd.cpp.

References _settings_game, CommandCost::AddCost(), Station::AddFacility(), AddTrackToSignalBuffer(), AllocaM, AllocateSpecToStation(), SmallVector< T, S >::Append(), AXIS_X, AxisToTrack(), BaseStation::cached_anim_triggers, CALLBACK_FAILED, StationSpec::callback_mask, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_station_pool >::CanAllocateItem(), CanExpandRailStation(), CBID_STATION_AVAILABILITY, CBID_STATION_TILE_LAYOUT, CBM_STATION_AVAIL, CheckFlatLandBelow(), CheckIfAuthorityAllowsNewStation(), CMD_ERROR, DC_EXEC, DeallocateSpecFromStation(), DeleteAnimatedTile(), StationSpec::disallowed_lengths, StationSpec::disallowed_platforms, StationSettings::distant_join_stations, FACIL_TRAIN, CommandCost::Failed(), FindJoiningStation(), FreeTrainTrackReservation(), GB(), GetClosestDeletedStation(), GetCustomStationSpec(), GetCustomStationSpecIndex(), GetNumCustomStations(), GetNumStationClasses(), GetRailStationAxis(), GetTrainForReservation(), Train::GetVehicleTrackdir(), HasBit(), HasStationReservation(), HasStationTileRail(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, InvalidateWindowData(), IsRailStationTile(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), SpecializedStation< Station, false >::IsValidID(), StationSettings::join_stations, SmallVector< T, S >::Length(), MakeRailStation(), Station::MarkTilesDirty(), SpecializedVehicle< T, Type >::Next(), StationSettings::nonuniform_stations, BaseStation::owner, Station::RecomputeIndustriesNear(), BaseStation::rect, return_cmd_error, ReverseTrackdir(), SetBit(), SetCustomStationSpecIndex(), SetRailStationPlatformReservation(), SetStationAnimationFrame(), SetStationGfx(), SetStationTileRandomBits(), SetWindowWidgetDirty(), GameSettings::station, StationSettings::station_spread, BaseStation::string_id, SVW_TRAINS, Vehicle::tile, TileArea::tile, TileDiffXY(), BaseStation::town, TrackdirToExitdir(), BaseStation::train_station, TryPathReserve(), UpdateStationAcceptance(), Station::UpdateVirtCoord(), ValParamRailtype(), and YapfNotifyTrackLayoutChange().

CommandCost CmdBuildRoadStop | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

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..3: the roadtypes bit 5: allow stations directly adjacent to other stations. bit 16..31: station ID to join (NEW_STATION if build new one)
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1515 of file station_cmd.cpp.

References _settings_game, TileArea::Add(), CommandCost::AddCost(), Station::AddFacility(), AreValidRoadTypes(), AXIS_X, Station::bus_station, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_station_pool >::CanAllocateItem(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_roadstop_pool >::CanAllocateItem(), CheckFlatLandBelow(), CheckIfAuthorityAllowsNewStation(), CheckOwnership(), CMD_ERROR, GameSettings::construction, CountBits(), DC_EXEC, StationSettings::distant_join_stations, FACIL_BUS_STOP, FACIL_TRUCK_STOP, CommandCost::Failed(), FindJoiningStation(), FindRoadStopSpot(), GB(), GetAllRoadBits(), GetClosestDeletedStation(), HasBit(), HasRoadTypesAvail(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowData(), IsValidAxis(), IsValidDiagDirection(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), SpecializedStation< Station, false >::IsValidID(), RoadStop::MakeDriveThrough(), MakeDriveThroughRoadStop(), MakeRoadStop(), BaseStation::owner, OWNER_NONE, OWNER_TOWN, Station::RecomputeIndustriesNear(), BaseStation::rect, return_cmd_error, ConstructionSettings::road_stop_on_competitor_road, ConstructionSettings::road_stop_on_town_road, ROAD_X, ROAD_Y, ROADSTOP_BUS, ROADSTOP_TRUCK, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_NONE, SetBit(), SetWindowWidgetDirty(), GameSettings::station, BaseStation::string_id, SVW_ROADVEHS, BaseStation::town, Station::truck_station, UpdateStationAcceptance(), and Station::UpdateVirtCoord().

CommandCost CmdRemoveFromRailStation | ( | TileIndex | start,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Remove a single tile from a rail station.

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

Parameters:

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

  p2

  various bitstuffed elements
  - p2 = bit 0 - if set keep the rail

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1336 of file station_cmd.cpp.

References SmallVector< T, S >::Begin(), CMD_ERROR, SmallVector< T, S >::End(), CommandCost::Failed(), HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, MapSize(), Station::MarkTilesDirty(), Station::RecomputeIndustriesNear(), RemoveFromRailBaseStation(), SetWindowWidgetDirty(), SVW_TRAINS, TileArea::tile, and BaseStation::train_station.

CommandCost CmdRemoveFromRailWaypoint | ( | TileIndex | start,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Remove a single tile from a waypoint.

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

Parameters:

  | start | tile of waypoint piece to remove
  | flags | operation to perform
  | p1 | start_tile

  p2

  various bitstuffed elements
  - p2 = bit 0 - if set keep the rail

  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1370 of file station_cmd.cpp.

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

CommandCost CmdRemoveRoadStop | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

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
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 1764 of file station_cmd.cpp.

References CMD_ERROR, DC_EXEC, DIAGDIR_NE, DiagDirToRoadBits(), GB(), GetRoadStopDir(), GetRoadStopType(), IsDriveThroughStopTile(), IsRoadStop(), IsTileType(), MP_STATION, RemoveRoadStop(), ROAD_X, ROAD_Y, ROADTYPE_ROAD, ROADTYPE_TRAM, and CommandCost::Succeeded().

CommandCost CmdRenameStation | ( | TileIndex | tile,
|  | DoCommandFlag | flags,
|  | uint32 | p1,
|  | uint32 | p2,
|  | const char * | text |
| ) |  |  |

Rename a station.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | station ID that is to be renamed
  | p2 | unused
  | 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 2977 of file station_cmd.cpp.

References CheckOwnership(), CMD_ERROR, DC_EXEC, SpecializedStation< Station, false >::GetIfValid(), InvalidateWindowData(), MAX_LENGTH_STATION_NAME_BYTES, BaseStation::name, BaseStation::owner, return_cmd_error, StrEmpty(), and Station::UpdateVirtCoord().

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

References CT_INVALID, CargoSpec::Get(), Industry::GetByTile(), GetIndustrySpec(), INDUSTRYLIFE_ORGANIC, IsTileType(), CargoSpec::label, lengthof, 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 136 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.

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 173 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 163 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'
  | cmp | the comparator/matcher (

See also:
  CMSAMatcher)

Returns:
  the number of matching tiles around

Definition at line 117 of file station_cmd.cpp.

References INVALID_TILE, and TileAddWrap().

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

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

Referenced by RemoveAirport(), RemoveDock(), RemoveFromRailBaseStation(), RemoveRailStation(), and RemoveRoadStop().

template<class T , StringID error_message>

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

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

References _settings_game, StationSettings::adjacent_stations, CMD_ERROR, GetStationAround(), return_cmd_error, and GameSettings::station.

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

Referenced by CmdBuildAirport(), CmdBuildDock(), CmdBuildRailStation(), and CmdBuildRoadStop().

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

Referenced by CmdBuildRailWaypoint().

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 it's name to one of the other stations in town.

Definition at line 226 of file station_cmd.cpp.

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

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

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

Referenced by CmdBuildRoadStop().

void FindStationsAroundTiles | ( | const TileArea & | location,
|  | StationList * | stations |
| ) |  |  |

Find all stations around a rectangular producer (industry, house, headquarter, .

..)

Parameters:

  | location | The location/area of the producer
  | stations | The list to store the stations in

Definition at line 3006 of file station_cmd.cpp.

References _settings_game, CA_UNMODIFIED, SpecializedStation< Station, false >::GetByTile(), Station::GetCatchmentRadius(), TileArea::h, SmallVector< T, S >::Include(), INVALID_TILE, IsTileType(), MAX_CATCHMENT, StationSettings::modified_catchment, MP_STATION, GameSettings::station, TileArea::tile, TileAddWrap(), and TileArea::w.

Referenced by AIIndustry::GetAmountOfStationsAround(), StationFinder::GetStations(), and WhoCanServiceIndustry().

CargoArray GetAcceptanceAroundTiles | ( | TileIndex | tile,
|  | int | w,
|  | int | h,
|  | int | rad,
|  | uint32 * | always_accepted |
| ) |  |  |

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

Parameters:

  | 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 NULL

Definition at line 524 of file station_cmd.cpp.

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

Referenced by AITileList_IndustryAccepting::AITileList_IndustryAccepting(), DrawStationCoverageAreaText(), AITile::GetCargoAcceptance(), and 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 441 of file station_cmd.cpp.

References Station::goods, HasBit(), and NUM_CARGO.

Referenced by UpdateStationAcceptance().

uint8 GetAirportNoiseLevelForTown | ( | const AirportSpec * | as,
|  | TileIndex | town_tile,
|  | TileIndex | tile |
| ) |  |  |

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
  | town_tile | TileIndex of town's center, the one who will receive the airport's candidature
  | tile | TileIndex of northern tile of an airport (present or to-be-built), NOT the station tile

Returns:
  the noise that will be generated, according to distance

Definition at line 1827 of file station_cmd.cpp.

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

Referenced by CmdBuildAirport(), AIAirport::GetNoiseLevelIncrease(), RemoveAirport(), and UpdateAirportsNoise().

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 NULL if too far.

Definition at line 356 of file station_cmd.cpp.

References DistanceManhattan(), BaseStation::IsInUse(), BaseStation::owner, and BaseStation::xy.

Referenced by CmdBuildAirport(), CmdBuildDock(), CmdBuildRailStation(), and CmdBuildRoadStop().

static uint GetMinimalAirportDistanceToTile | ( | const AirportSpec * | as,
|  | TileIndex | town_tile,
|  | TileIndex | airport_tile |
| ) |  |  | `[static]`

Computes the minimal distance from town's xy to any airport's tile.

Parameters:

  | as | airport's description
  | town_tile | town's tile (t->xy)
  | airport_tile | st->airport_tile

Returns:
  minimal manhattan distance from town_tile to any airport's tile

Definition at line 1799 of file station_cmd.cpp.

References AirportSpec::size_x, AirportSpec::size_y, TileX(), and TileY().

Referenced by AirportGetNearestTown(), and GetAirportNoiseLevelForTown().

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

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

Parameters:

  | tile | Northtile 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 471 of file station_cmd.cpp.

References CT_INVALID, TileArea::Intersects(), lengthof, Industry::location, MapSizeX(), MapSizeY(), max(), min(), Industry::produced_cargo, TILE_AREA_LOOP, TileX(), TileXY(), and TileY().

Referenced by DrawStationCoverageAreaText(), and AITile::GetCargoProduction().

template<class T >

bool GetStationAround | ( | TileArea | ta,
|  | StationID | closest_station,
|  | T ** | st |
| ) |  |  | `[inline]`

Look for a station around the given tile area.

Parameters:

  | ta | the area to search over
  | closest_station | the closest station found so far
  | st | to 'return' the found station

Returns:
  false if more than one stations are found. True when zero or one are found.

Definition at line 85 of file station_cmd.cpp.

References GetStationIndex(), TileArea::h, IsTileType(), MP_STATION, TileArea::tile, TILE_LOOP, TileDiffXY(), and TileArea::w.

Referenced by FindJoiningBaseStation().

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

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

Parameters:

  | station | station ID
  | company | company ID, INVALID_COMPANY to disable the check

Definition at line 2123 of file station_cmd.cpp.

References Order::GetDestination(), INVALID_COMPANY, and Order::IsType().

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

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

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

Referenced by AIOrder::GetOrderDestination(), GetOrderTypeByTile(), IsHangarTile(), and AIAirport::IsHangarTile().

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

References _settings_game, CommandCost::AddCost(), Station::airport_tile, AirportGetNearestTown(), CheckOwnership(), CMD_ERROR, DC_EXEC, DeleteAnimatedTile(), DeleteStationIfEmpty(), DeleteWindowById(), GameSettings::economy, EXPENSES_CONSTRUCTION, FACIL_AIRPORT, BaseStation::facilities, GetAirportNoiseLevelForTown(), SpecializedStation< Station, false >::GetByTile(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, Aircraft::IsNormalAircraft(), AirportSpec::nof_depots, BaseStation::owner, OWNER_WATER, Station::RecomputeIndustriesNear(), BaseStation::rect, SetWindowDirty(), SetWindowWidgetDirty(), AirportSpec::size_x, AirportSpec::size_y, EconomySettings::station_noise_level, SVW_PLANES, TILE_LOOP, BaseStation::town, and Station::UpdateVirtCoord().

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

References CheckOwnership(), CMD_ERROR, DC_EXEC, DeleteStationIfEmpty(), Station::dock_tile, EXPENSES_CONSTRUCTION, FACIL_DOCK, BaseStation::facilities, SpecializedStation< Station, false >::GetByTile(), GetDockDirection(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, MarkTileDirtyByTile(), BaseStation::owner, Station::RecomputeIndustriesNear(), BaseStation::rect, SetWindowWidgetDirty(), SVW_SHIPS, TileOffsByDiagDir(), and Station::UpdateVirtCoord().

template<class T >

CommandCost RemoveFromRailBaseStation | ( | TileArea | ta,
|  | SmallVector< T *, 4 > & | affected_stations,
|  | DoCommandFlag | flags,
|  | Money | removal_cost,
|  | bool | keep_rail |
| ) |  |  | `[inline]`

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

References _settings_game, CommandCost::AddCost(), AddTrackToSignalBuffer(), SmallVector< T, S >::Begin(), CheckOwnership(), CMD_ERROR, DC_EXEC, DeallocateSpecFromStation(), DeleteStationIfEmpty(), SmallVector< T, S >::End(), EXPENSES_CONSTRUCTION, FACIL_TRAIN, FreeTrainTrackReservation(), GetCustomStationSpecIndex(), GetRailStationTrack(), GetRailType(), GetTileOwner(), GetTrainForReservation(), Vehicle::GetVehicleTrackdir(), Train::GetVehicleTrackdir(), HasStationReservation(), HasStationTileRail(), SmallVector< T, S >::Include(), INVALID_TILE, IsRailStationTile(), SpecializedVehicle< T, Type >::Next(), Vehicle::Next(), StationSettings::nonuniform_stations, OWNER_WATER, return_cmd_error, ReverseTrackdir(), SetRailStationPlatformReservation(), SetWindowWidgetDirty(), GameSettings::station, SVW_TRAINS, Vehicle::tile, TILE_AREA_LOOP, TrackdirToExitdir(), TrackToTrackBits(), TryPathReserve(), and YapfNotifyTrackLayoutChange().

Referenced by CmdRemoveFromRailStation(), and CmdRemoveFromRailWaypoint().

static CommandCost RemoveRailStation | ( | TileIndex | tile,
|  | DoCommandFlag | flags |
| ) |  |  | `[static]`

Remove a rail road station.

Parameters:

  | tile | TileIndex been queried
  | flags | operation to perform

Returns:
  cost or failure of operation

Definition at line 1451 of file station_cmd.cpp.

References _settings_game, CMD_REMOVE_FROM_RAIL_STATION, DC_EXEC, DoCommand(), SpecializedStation< Station, false >::GetByTile(), StationSettings::nonuniform_stations, OWNER_WATER, Station::RecomputeIndustriesNear(), RemoveRailStation(), and GameSettings::station.

template<class T >

CommandCost RemoveRailStation | ( | T * | st,
|  | DoCommandFlag | flags |
| ) |  |  | `[inline]`

Remove a rail road station/waypoint.

Parameters:

  | st | The station/waypoint to remove the rail part from
  | flags | operation to perform

Template Parameters:

  | T | the type of station to remove

Returns:
  cost or failure of operation

Definition at line 1390 of file station_cmd.cpp.

References CommandCost::AddCost(), AddTrackToSignalBuffer(), CheckOwnership(), CMD_ERROR, DC_EXEC, DeleteStationIfEmpty(), EXPENSES_CONSTRUCTION, FACIL_TRAIN, FreeTrainTrackReservation(), GetRailStationTrack(), GetTileOwner(), GetTrainForReservation(), TileArea::h, HasStationReservation(), OWNER_WATER, SetWindowWidgetDirty(), SVW_TRAINS, TILE_AREA_LOOP, TryPathReserve(), TileArea::w, and YapfNotifyTrackLayoutChange().

Referenced by RemoveRailStation(), and RemoveRailWaypoint().

static CommandCost RemoveRailWaypoint | ( | TileIndex | tile,
|  | DoCommandFlag | flags |
| ) |  |  | `[static]`

Remove a rail waypoint.

Parameters:

  | tile | TileIndex been queried
  | flags | operation to perform

Returns:
  cost or failure of operation

Definition at line 1472 of file station_cmd.cpp.

References _settings_game, CMD_REMOVE_FROM_RAIL_WAYPOINT, DC_EXEC, DoCommand(), SpecializedStation< Waypoint, true >::GetByTile(), StationSettings::nonuniform_stations, OWNER_WATER, RemoveRailStation(), and GameSettings::station.

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

References TileArea::Add(), Station::bus_station, Station::bus_stops, CheckOwnership(), TileArea::Clear(), RoadStop::ClearDriveThrough(), CMD_ERROR, Vehicle::current_order, DC_BANKRUPT, DC_EXEC, DeleteStationIfEmpty(), Vehicle::dest_tile, EXPENSES_CONSTRUCTION, FACIL_BUS_STOP, FACIL_TRUCK_STOP, BaseStation::facilities, FindVehicleOnPos(), SpecializedVehicle< T, Type >::First(), RoadStop::GetByTile(), SpecializedStation< Station, false >::GetByTile(), RoadVehicle::GetOrderStationLocation(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, IsDriveThroughStopTile(), IsTruckStop(), Order::IsType(), RoadStop::next, BaseStation::owner, OWNER_WATER, Station::RecomputeIndustriesNear(), BaseStation::rect, ROADSTOP_BUS, ROADSTOP_TRUCK, SetWindowWidgetDirty(), SVW_ROADVEHS, Station::truck_station, Station::truck_stops, and Station::UpdateVirtCoord().

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

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

Referenced by UpdateStationAcceptance().

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

References BaseStation::delete_ctr, FACIL_WAYPOINT, BaseStation::facilities, SpecializedStation< Station, false >::From(), BaseStation::IsInUse(), and UpdateStationAcceptance().

void UpdateAllStationVirtCoords | ( |  | ) |

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

Definition at line 428 of file station_cmd.cpp.

References BaseStation::UpdateVirtCoord().

Referenced by CmdRenameTown(), and UpdateAllVirtCoords().

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

References Station::always_accepted, CC_PASSENGERS, CT_INVALID, FACIL_BUS_STOP, FACIL_TRUCK_STOP, BaseStation::facilities, GetAcceptanceAroundTiles(), GetAcceptanceMask(), Station::GetCatchmentRadius(), Station::goods, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem< Tpool >::index, IsCargoInClass(), BaseStation::IsInUse(), lengthof, min(), NUM_CARGO, BaseStation::owner, BaseStation::rect, SB(), SetWindowWidgetDirty(), ShowRejectOrAcceptNews(), SVW_ACCEPTLIST, and TileXY().

Referenced by CmdBuildAirport(), CmdBuildDock(), CmdBuildRailStation(), CmdBuildRoadStop(), and StationHandleBigTick().

## Variable Documentation

const TileIndexDiffC _dock_tileoffs_chkaround[]`[static]`

Initial value:

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

Definition at line 2139 of file station_cmd.cpp.

const TileTypeProcs _tile_type_station_procs

Initial value:

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