OpenTTD Source 20260206-master-g4d4e37dbf1
station_cmd.cpp File Reference

Handling of station tiles. More...

#include "stdafx.h"
#include "core/flatset_type.hpp"
#include "aircraft.h"
#include "bridge_map.h"
#include "vehiclelist_func.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 "tilehighlight_func.h"
#include "strings_func.h"
#include "clear_func.h"
#include "timer/timer_game_calendar.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 "core/container_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 "tunnelbridge_map.h"
#include "station_cmd.h"
#include "waypoint_cmd.h"
#include "landscape_cmd.h"
#include "rail_cmd.h"
#include "newgrf_roadstop.h"
#include "timer/timer.h"
#include "timer/timer_game_economy.h"
#include "timer/timer_game_tick.h"
#include "cheat_type.h"
#include "road_func.h"
#include "station_layout_type.h"
#include "widgets/station_widget.h"
#include "widgets/misc_widget.h"
#include "table/strings.h"
#include "table/station_land.h"
#include <bitset>
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  StationNameInformation
 Information to handle station action 0 property 24 correctly. More...

Typedefs

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

Enumerations

enum  StationNaming : uint8_t {
  STATIONNAMING_RAIL , STATIONNAMING_ROAD , STATIONNAMING_AIRPORT , STATIONNAMING_OILRIG ,
  STATIONNAMING_DOCK , STATIONNAMING_HELIPORT
}

Functions

bool IsHangar (Tile t)
 Check whether the given tile is a hangar.
template<class T, class F>
CommandCost GetStationAround (TileArea ta, StationID closest_station, CompanyID company, T **st, F filter)
 Look for a station owned by the given company 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 StringID GenerateStationName (Station *st, TileIndex tile, StationNaming name_class)
static StationGetClosestDeletedStation (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.
void ClearAllStationCachedNames ()
CargoTypes GetAcceptanceMask (const Station *st)
 Get a mask of the cargo types that the station accepts.
CargoTypes GetEmptyMask (const Station *st)
 Get a mask of the cargo types that are empty at the station.
static void ShowRejectOrAcceptNews (const Station *st, CargoTypes cargoes, bool reject)
 Add news item for when a station changes which cargoes it accepts.
CargoArray GetProductionAroundTiles (TileIndex north_tile, int w, int h, int rad)
 Get the cargo types being produced around the tile (in a rectangle).
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.
static CargoArray GetAcceptanceAroundStation (const Station *st, CargoTypes *always_accepted)
 Get the acceptance of cargoes around the station in.
void UpdateStationAcceptance (Station *st, bool show_msg)
 Update the acceptance for a station.
static void UpdateStationSignCoord (BaseStation *st)
static CommandCost BuildStationPart (Station **st, DoCommandFlags flags, bool reuse, TileArea area, StationNaming name_class)
 Common part of building various station parts and possibly attaching them to an existing one.
static void DeleteStationIfEmpty (BaseStation *st)
 This is called right after a station was deleted.
CommandCost ClearTile_Station (TileIndex tile, DoCommandFlags flags)
 Clear a single tile of a station.
CommandCost CheckBuildableTile (TileIndex tile, DiagDirections 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.
static CommandCost CheckFlatLandAirport (AirportTileTableIterator tile_iter, DoCommandFlags flags)
 Checks if an airport can be built at the given location and clear the area.
static StringID GetBridgeTooLowMessageForStationType (StationType type)
 Get station-type-specific string for a bridge that is too low.
static CommandCost IsStationBridgeAboveOk (TileIndex tile, std::span< const BridgeableTileInfo > bridgeable_info, StationType type, StationGfx layout, int bridge_height, StringID disallowed_msg=INVALID_STRING_ID)
 Test if a bridge can be built above a station.
static std::span< const BridgeableTileInfoGetStationBridgeableTileInfo (StationType type)
 Get bridgeable tile information for a station type.
CommandCost IsRailStationBridgeAboveOk (TileIndex tile, const StationSpec *spec, StationType type, StationGfx layout)
 Test if a rail station can be built below a bridge.
CommandCost IsRoadStationBridgeAboveOk (TileIndex tile, const RoadStopSpec *spec, StationType type, StationGfx layout)
 Test if a road station can be built below a bridge.
static CommandCost IsDockBridgeAboveOk (TileIndex tile, StationGfx layout)
 Test if a dock can be built below a bridge.
CommandCost IsBuoyBridgeAboveOk (TileIndex tile)
 Test if a buoy can be built below a bridge.
static CommandCost CheckFlatLandRailStation (TileIndex tile_cur, TileIndex north_tile, int &allowed_z, DoCommandFlags flags, Axis axis, StationID *station, RailType rt, std::vector< Train * > &affected_vehicles, StationClassID spec_class, uint16_t spec_index, uint8_t plat_len, uint8_t numtracks)
 Checks if a rail station can be built at the given tile.
static CommandCost CheckFlatLandRoadStop (TileIndex cur_tile, int &allowed_z, const RoadStopSpec *spec, DoCommandFlags flags, DiagDirections invalid_dirs, bool is_drive_through, StationType station_type, Axis axis, StationID *station, RoadType rt)
 Checks if a road stop can be built at the given tile.
CommandCost CanExpandRailStation (const BaseStation *st, TileArea &new_ta)
 Check whether we can expand the rail part of the given station.
template<class T, StringID error_message, class F>
CommandCost FindJoiningBaseStation (StationID existing_station, StationID station_to_join, bool adjacent, TileArea ta, T **st, F filter)
 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, bool is_road)
 Find a nearby waypoint that joins this waypoint.
static void FreeTrainReservation (Train *v)
 Clear platform reservation during station building/removing.
static void RestoreTrainReservation (Train *v)
 Restore platform reservation during station building/removing.
static CommandCost CalculateRailStationCost (TileArea tile_area, DoCommandFlags flags, Axis axis, StationID *station, RailType rt, std::vector< Train * > &affected_vehicles, StationClassID spec_class, uint16_t spec_index, uint8_t plat_len, uint8_t numtracks)
 Calculates cost of new rail stations within the area.
static StationSpec::TileFlags GetStationTileFlags (StationGfx gfx, const StationSpec *statspec)
 Get station tile flags for the given StationGfx.
void SetRailStationTileFlags (TileIndex tile, const StationSpec *statspec)
 Set rail station tile flags for the given tile.
CommandCost CmdBuildRailStation (DoCommandFlags flags, TileIndex tile_org, RailType rt, Axis axis, uint8_t numtracks, uint8_t plat_len, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
 Build rail station.
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)
static bool TileBelongsToRoadWaypointStation (BaseStation *st, TileIndex tile)
void MakeRoadWaypointStationAreaSmaller (BaseStation *st, TileArea &road_waypoint_area)
template<class T>
CommandCost RemoveFromRailBaseStation (TileArea ta, std::vector< T * > &affected_stations, DoCommandFlags flags, Money removal_cost, bool keep_rail)
 Remove a number of tiles from any rail station within the area.
CommandCost CmdRemoveFromRailStation (DoCommandFlags flags, TileIndex start, TileIndex end, bool keep_rail)
 Remove a single tile from a rail station.
CommandCost CmdRemoveFromRailWaypoint (DoCommandFlags flags, TileIndex start, TileIndex end, bool keep_rail)
 Remove a single tile from a waypoint.
template<class T>
CommandCost RemoveRailStation (T *st, DoCommandFlags flags, Money removal_cost)
 Remove a rail station/waypoint.
static CommandCost RemoveRailStation (TileIndex tile, DoCommandFlags flags)
 Remove a rail station.
static CommandCost RemoveRailWaypoint (TileIndex tile, DoCommandFlags flags)
 Remove a rail waypoint.
static RoadStop ** FindRoadStopSpot (bool truck_station, Station *st)
static CommandCost RemoveRoadStop (TileIndex tile, DoCommandFlags flags, int replacement_spec_index)
 Remove a bus station/truck stop.
CommandCost RemoveRoadWaypointStop (TileIndex tile, DoCommandFlags flags, int replacement_spec_index)
 Remove a road waypoint.
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.
CommandCost CalculateRoadStopCost (TileArea tile_area, DoCommandFlags flags, bool is_drive_through, StationType station_type, const RoadStopSpec *roadstopspec, Axis axis, DiagDirection ddir, StationID *station, RoadType rt, Money unit_cost)
 Calculates cost of new road stops within the area.
CommandCost CmdBuildRoadStop (DoCommandFlags flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
 Build a bus or truck stop.
static CommandCost RemoveGenericRoadStop (DoCommandFlags flags, const TileArea &roadstop_area, bool road_waypoint, bool remove_road)
 Remove a tile area of road stop or road waypoints.
CommandCost CmdRemoveRoadStop (DoCommandFlags flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road)
 Remove bus or truck stops.
CommandCost CmdRemoveFromRoadWaypoint (DoCommandFlags flags, TileIndex start, TileIndex end)
 Remove road waypoints.
uint8_t GetAirportNoiseLevelForDistance (const AirportSpec *as, uint distance)
 Get a possible noise reduction factor based on distance from town center.
TownAirportGetNearestTown (const AirportSpec *as, Direction rotation, TileIndex tile, TileIterator &&it, uint &mindist)
 Finds the town nearest to given airport.
static TownAirportGetNearestTown (const Station *st, uint &mindist)
 Finds the town nearest to given existing airport.
void UpdateAirportsNoise ()
 Recalculate the noise generated by the airports of each town.
CommandCost CmdBuildAirport (DoCommandFlags flags, TileIndex tile, uint8_t airport_type, uint8_t layout, StationID station_to_join, bool allow_adjacent)
 Place an Airport.
static CommandCost RemoveAirport (TileIndex tile, DoCommandFlags flags)
 Remove an airport.
CommandCost CmdOpenCloseAirport (DoCommandFlags flags, StationID station_id)
 Open/close an airport to incoming aircraft.
bool HasStationInUse (StationID station, bool include_company, CompanyID company)
 Tests whether the company's vehicles have this station in orders.
CommandCost CmdBuildDock (DoCommandFlags flags, TileIndex tile, StationID station_to_join, bool adjacent)
 Build a dock/haven.
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.
static TileIndex FindDockLandPart (TileIndex t)
 Find the part of a dock that is land-based.
static CommandCost RemoveDock (TileIndex tile, DoCommandFlags flags)
 Remove a dock.
const DrawTileSpritesGetStationTileLayout (StationType st, uint8_t gfx)
 Get station tile layout for a station type and its station 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.
static BridgePillarFlags GetStationBlockedPillars (std::span< const BridgeableTileInfo > bridgeable_info, uint8_t layout)
 Get blocked pillar information for a station tile.
static bool DrawCustomStationFoundations (const StationSpec *statspec, BaseStation *st, TileInfo *ti, StationGfx gfx)
 Draw custom station foundations for a NewGRF station if provided.
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, uint, bool)
static Foundation GetFoundation_Station (TileIndex, Slope tileh)
static void FillTileDescRoadStop (TileIndex tile, TileDesc &td)
void FillTileDescRailStation (TileIndex tile, TileDesc &td)
void FillTileDescAirport (TileIndex tile, TileDesc &td)
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 VehicleEnterTileStates 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.
static bool StationHandleBigTick (BaseStation *st)
 This function is called for each station once every 250 ticks.
static void byte_inc_sat (uint8_t *p)
static void TruncateCargo (const CargoSpec *cs, GoodsEntry *ge, uint amount=UINT_MAX)
 Truncate the cargo by a specific amount.
static void UpdateStationRating (Station *st)
 Periodic update of a station's rating.
void RerouteCargo (Station *st, CargoType cargo, StationID avoid, StationID avoid2)
 Reroute cargo of type c at station st or in any vehicles unloading there.
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.
void IncreaseStats (Station *st, CargoType cargo, StationID next_station_id, uint capacity, uint usage, uint32_t time, EdgeUpdateModes modes)
 Increase capacity for a link stat given by station cargo and next hop.
void IncreaseStats (Station *st, const Vehicle *front, StationID next_station_id, uint32_t time)
 Increase capacity for all link stats associated with vehicles in the given consist.
static void StationHandleSmallTick (BaseStation *st)
void OnTick_Station ()
void ModifyStationRatingAround (TileIndex tile, Owner owner, int amount, uint radius)
 Forcibly modify station ratings near a given tile.
static uint UpdateStationWaiting (Station *st, CargoType cargo, uint amount, Source source)
static bool IsUniqueStationName (const std::string &name)
CommandCost CmdRenameStation (DoCommandFlags flags, StationID station_id, const std::string &text)
 Rename a station.
std::tuple< CommandCost, StationID > CmdMoveStationName (DoCommandFlags flags, StationID station_id, TileIndex tile)
 Move a station name.
void CcMoveStationName (Commands, const CommandCost &result, StationID station_id)
 Callback function that is called after a name is moved.
static void AddNearbyStationsByCatchment (TileIndex tile, StationList &stations, StationList &nearby)
static bool CanMoveGoodsToStation (const Station *st, CargoType cargo)
uint MoveGoodsToStation (CargoType cargo, uint amount, Source source, 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 CommandCost CanRemoveRoadWithStop (TileIndex tile, DoCommandFlags flags)
 Check if a drive-through road stop tile can be cleared.
static CommandCost TerraformTile_Station (TileIndex tile, DoCommandFlags flags, int z_new, Slope tileh_new)
static CommandCost CheckBuildAbove_Station (TileIndex tile, DoCommandFlags, Axis, int height)

Variables

static const TileIndexDiffC _dock_tileoffs_chkaround []
static const uint8_t _dock_w_chk [4] = { 2, 1, 2, 1 }
static const uint8_t _dock_h_chk [4] = { 1, 2, 1, 2 }
static const IntervalTimer< TimerGameEconomy_economy_stations_monthly ({TimerGameEconomy::Trigger::Month, TimerGameEconomy::Priority::Station}, [](auto) { for(Station *st :Station::Iterate()) { for(GoodsEntry &ge :st->goods) { ge.status.Set(GoodsEntry::State::LastMonth, ge.status.Test(GoodsEntry::State::CurrentMonth));ge.status.Reset(GoodsEntry::State::CurrentMonth);} } })
 Economy monthly loop for stations.
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
tilethe tile to check
Returns
true if it matches, false otherwise

Definition at line 149 of file station_cmd.cpp.

Enumeration Type Documentation

◆ StationNaming

enum StationNaming : uint8_t

Definition at line 218 of file station_cmd.cpp.

Function Documentation

◆ AddNearbyStationsByCatchment()

void AddNearbyStationsByCatchment ( TileIndex tile,
StationList & stations,
StationList & nearby )
static

Definition at line 4553 of file station_cmd.cpp.

◆ AirportGetNearestTown() [1/2]

Town * AirportGetNearestTown ( const AirportSpec * as,
Direction rotation,
TileIndex tile,
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
asairport's description
rotationairport's rotation
tileorigin tile (top corner of the airport)
itAn iterator over all airport tiles (consumed)
[out]mindistMinimum distance to town
Returns
nearest town to airport

Definition at line 2557 of file station_cmd.cpp.

References CalcClosestTownFromTile(), DIR_E, DIR_W, DistanceManhattan(), INVALID_TILE, IsInsideBS(), AirportSpec::size_x, AirportSpec::size_y, TileX(), TileY(), and Town::xy.

Referenced by AirportGetNearestTown(), CmdBuildAirport(), RemoveAirport(), and UpdateAirportsNoise().

◆ AirportGetNearestTown() [2/2]

Town * AirportGetNearestTown ( const Station * st,
uint & mindist )
static

Finds the town nearest to given existing 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
stExisting station with airport.
[out]mindistMinimum distance to town
Returns
nearest town to airport

Definition at line 2600 of file station_cmd.cpp.

References Station::airport, AirportGetNearestTown(), Airport::GetSpec(), Airport::rotation, and OrthogonalTileArea::tile.

◆ AnimateTile_Station()

void AnimateTile_Station ( TileIndex tile)
static

Definition at line 3808 of file station_cmd.cpp.

◆ BuildOilRig()

void BuildOilRig ( TileIndex tile)

Definition at line 4715 of file station_cmd.cpp.

◆ BuildStationPart()

CommandCost BuildStationPart ( Station ** st,
DoCommandFlags 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]stStation to attach to
flagsCommand flags
reuseWhether to try to reuse a deleted station (gray sign) if possible
areaArea occupied by the new part
name_classStation naming class to use to generate the new station's name
Returns
Command error that occurred, if any

Definition at line 686 of file station_cmd.cpp.

References _current_company, ClosestTownFromTile(), CMD_ERROR, SpecializedStation< Station, false >::Create(), Execute, CommandCost::Failed(), GenerateStationName(), GetClosestDeletedStation(), OrthogonalTileArea::h, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), OrthogonalTileArea::tile, and OrthogonalTileArea::w.

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

◆ byte_inc_sat()

void byte_inc_sat ( uint8_t * p)
inlinestatic

Definition at line 3942 of file station_cmd.cpp.

◆ CalculateRailStationCost()

CommandCost CalculateRailStationCost ( TileArea tile_area,
DoCommandFlags flags,
Axis axis,
StationID * station,
RailType rt,
std::vector< Train * > & affected_vehicles,
StationClassID spec_class,
uint16_t spec_index,
uint8_t plat_len,
uint8_t numtracks )
static

Calculates cost of new rail stations within the area.

Parameters
tile_areaArea to check.
flagsOperation to perform.
axisRail station axis.
stationStationID to be queried and returned if available.
rtThe rail type to check for (overbuilding rail stations over rail).
affected_vehiclesList of trains with PBS reservations on the tiles
spec_classStation class.
spec_indexIndex into the station class.
plat_lenPlatform length.
numtracksNumber of platforms.
Returns
The cost in case of success, or an error code if it failed.

Definition at line 1363 of file station_cmd.cpp.

References CommandCost::AddCost(), BuildStationRail, BuildStationRailLength, CheckFlatLandRailStation(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), CommandCost::GetCost(), GetRailStationAxis(), IsRailStationTile(), RailBuildCost(), and OrthogonalTileArea::tile.

Referenced by CmdBuildRailStation().

◆ CalculateRoadStopCost()

CommandCost CalculateRoadStopCost ( TileArea tile_area,
DoCommandFlags flags,
bool is_drive_through,
StationType station_type,
const RoadStopSpec * roadstopspec,
Axis axis,
DiagDirection ddir,
StationID * station,
RoadType rt,
Money unit_cost )

Calculates cost of new road stops within the area.

Parameters
tile_areaArea to check.
flagsOperation to perform.
is_drive_throughTrue if trying to build a drive-through station.
station_typeStation type (bus, truck or road waypoint).
roadstopspecSpec of road stop being built.
axisAxis of a drive-through road stop.
ddirEntrance direction (DiagDirection) for normal stops. Converted to the axis for drive-through stops.
stationStationID to be queried and returned if available.
rtRoad type to build, may be INVALID_ROADTYPE if an existing road is required.
unit_costThe cost to build one road stop of the current type.
Returns
The cost in case of success, or an error code if it failed.

Definition at line 2027 of file station_cmd.cpp.

References CommandCost::AddCost(), AxisToDiagDir(), CheckFlatLandRoadStop(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), CommandCost::GetCost(), IsAnyRoadStop(), IsTileType(), ReverseDiagDir(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), and Station.

Referenced by CmdBuildRoadStop(), and CmdBuildRoadWaypoint().

◆ CanExpandRailStation()

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

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

Parameters
stthe station to expand
new_tathe current (and if all is fine new) tile area of the rail part of the station
Returns
Succeeded or failed command.

Definition at line 1191 of file station_cmd.cpp.

References _settings_game, OrthogonalTileArea::h, OrthogonalTileArea::tile, TileX(), TileXY(), TileY(), BaseStation::train_station, and OrthogonalTileArea::w.

Referenced by CmdBuildRailStation(), and CmdBuildRailWaypoint().

◆ CanMoveGoodsToStation()

bool CanMoveGoodsToStation ( const Station * st,
CargoType cargo )
static

Definition at line 4583 of file station_cmd.cpp.

◆ CanRemoveRoadWithStop()

CommandCost CanRemoveRoadWithStop ( TileIndex tile,
DoCommandFlags 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
tileThe road stop tile to check.
flagsCommand flags.
Returns
A succeeded command if the road can be removed, a failed command with the relevant error message otherwise.

Definition at line 4874 of file station_cmd.cpp.

References _current_company, CheckAllowRemoveRoad(), CheckOwnership(), CommandCost::Failed(), GetAnyRoadBits(), GetRoadOwner(), INVALID_ROADTYPE, OWNER_NONE, OWNER_TOWN, OWNER_WATER, RTT_ROAD, and RTT_TRAM.

Referenced by ClearTile_Station().

◆ CcMoveStationName()

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

Callback function that is called after a name is moved.

Parameters
resultof the operation
station_idID of the changed station

Definition at line 4544 of file station_cmd.cpp.

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

Referenced by QueryStringWindow::OnPlaceObject().

◆ ChangeTileOwner_Station()

void ChangeTileOwner_Station ( TileIndex tile,
Owner old_owner,
Owner new_owner )
static

Definition at line 4780 of file station_cmd.cpp.

◆ CheckBuildableTile()

CommandCost CheckBuildableTile ( TileIndex tile,
DiagDirections 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
tileTileIndex to check.
invalid_dirsProhibited directions for slopes (set of DiagDirection).
allowed_zHeight allowed for the tile. If allowed_z is negative, it will be set to the height of this tile.
allow_steepWhether steep slopes are allowed.
check_bridgeCheck for the existence of a bridge.
Returns
The cost in case of success, or an error code if it failed.

Definition at line 788 of file station_cmd.cpp.

References _settings_game, CommandCost::AddCost(), BuildFoundation, CanBuildDepotByTileh(), DIAGDIR_BEGIN, DIAGDIR_END, EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), GetSlopeMaxZ(), GetTileSlopeZ(), IsBridgeAbove(), IsSteepSlope(), SLOPE_FLAT, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

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

◆ CheckBuildAbove_Station()

CommandCost CheckBuildAbove_Station ( TileIndex tile,
DoCommandFlags ,
Axis ,
int height )
static

Definition at line 5371 of file station_cmd.cpp.

◆ CheckFlatLandAirport()

CommandCost CheckFlatLandAirport ( AirportTileTableIterator tile_iter,
DoCommandFlags flags )
static

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

Parameters
tile_iterAirport tile iterator.
flagsOperation to perform.
Returns
The cost in case of success, or an error code if it failed.

Definition at line 837 of file station_cmd.cpp.

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

Referenced by CmdBuildAirport().

◆ CheckFlatLandRailStation()

CommandCost CheckFlatLandRailStation ( TileIndex tile_cur,
TileIndex north_tile,
int & allowed_z,
DoCommandFlags flags,
Axis axis,
StationID * station,
RailType rt,
std::vector< Train * > & affected_vehicles,
StationClassID spec_class,
uint16_t spec_index,
uint8_t plat_len,
uint8_t numtracks )
static

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

Parameters
tile_curTile to check.
north_tileNorth tile of the area being checked.
allowed_zHeight allowed for the tile. If allowed_z is negative, it will be set to the height of this tile.
flagsOperation to perform.
axisRail station axis.
stationStationID to be queried and returned if available.
rtThe rail type to check for (overbuilding rail stations over rail).
affected_vehiclesList of trains with PBS reservations on the tiles
spec_classStation class.
spec_indexIndex into the station class.
plat_lenPlatform length.
numtracksNumber of platforms.
Returns
The cost in case of success, or an error code if it failed.

Definition at line 992 of file station_cmd.cpp.

References CommandCost::AddCost(), Auto, AxisToDiagDirs(), StationSpec::callback_mask, CheckBuildableTile(), ClearTile_Station(), DIAGDIR_NE, EXPENSES_CONSTRUCTION, CommandCost::Failed(), NewGRFClass< StationSpec, StationClassID, STAT_CLASS_MAX >::Get(), CommandCost::GetCost(), GetRailReservationTrackBits(), GetRailType(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpec(), GetStationIndex(), GetTrackBits(), GetTrainForReservation(), HasBit(), HasPowerOnRail(), HasSignals(), INVALID_RAILTYPE, IsPlainRailTile(), IsRailStation(), IsTileType(), PerformStationTileSlopeCheck(), RemoveFirstTrack(), SlopeCheck, Station, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TRACK_BIT_NONE, TRACK_X, and TRACK_Y.

Referenced by CalculateRailStationCost().

◆ CheckFlatLandRoadStop()

CommandCost CheckFlatLandRoadStop ( TileIndex cur_tile,
int & allowed_z,
const RoadStopSpec * spec,
DoCommandFlags flags,
DiagDirections invalid_dirs,
bool is_drive_through,
StationType station_type,
Axis axis,
StationID * station,
RoadType rt )
static

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

Parameters
cur_tileTile to check.
allowed_zHeight allowed for the tile. If allowed_z is negative, it will be set to the height of this tile.
specSpec of road stop to be built.
flagsOperation to perform.
invalid_dirsProhibited directions (set of DiagDirections).
is_drive_throughTrue if trying to build a drive-through station.
station_typeStation type (bus, truck or road waypoint).
axisAxis of a drive-through road stop.
stationStationID to be queried and returned if available.
rtRoad type to build, may be INVALID_ROADTYPE if an existing road is required.
Returns
The cost in case of success, or an error code if it failed.

Definition at line 1075 of file station_cmd.cpp.

References _settings_game, CommandCost::AddCost(), Auto, AXIS_X, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::base(), CheckBuildableTile(), CheckOwnership(), ClearTile_Station(), CountBits(), DRD_NONE, EXPENSES_CONSTRUCTION, CommandCost::Failed(), FindFirstBit(), GetAllRoadBits(), CommandCost::GetCost(), GetDisallowedRoadDirections(), GetDriveThroughStopAxis(), GetRoadBits(), GetRoadOwner(), GetStationIndex(), GetStationType(), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET, HasExactlyOneBit(), HasPowerOnRoad(), INVALID_ROADTYPE, IsAnyRoadStop(), IsDriveThroughStopTile(), IsNormalRoadTile(), IsRoadStationBridgeAboveOk(), IsTileType(), OWNER_NONE, OWNER_TOWN, ROAD_NONE, ROAD_X, ROAD_Y, RoadBuildCost(), RTT_ROAD, RTT_TRAM, and Station.

Referenced by CalculateRoadStopCost().

◆ ClearAllStationCachedNames()

void ClearAllStationCachedNames ( )

Definition at line 477 of file station_cmd.cpp.

◆ 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
tileEx-dock tile to check.

Definition at line 3004 of file station_cmd.cpp.

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

Referenced by RemoveDock().

◆ ClearTile_Station()

CommandCost ClearTile_Station ( TileIndex tile,
DoCommandFlags flags )

◆ ClickTile_Station()

bool ClickTile_Station ( TileIndex tile)
static

Definition at line 3827 of file station_cmd.cpp.

◆ CmdBuildAirport()

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

Place an Airport.

Parameters
flagsoperation to perform
tiletile where airport will be built
airport_typeairport type,
See also
airport.h
Parameters
layoutairport layout
station_to_joinstation ID to join (NEW_STATION if build new one)
allow_adjacentallow airports directly adjacent to other airports.
Returns
the cost of this operation or an error

Definition at line 2630 of file station_cmd.cpp.

References _settings_game, OrthogonalTileArea::Add(), AddAnimatedTile(), CommandCost::AddCost(), Station::AddFacility(), Station::AfterStationTileSetChange(), AirportFTAClass::Airplanes, Airport, Station::airport, AirportGetNearestTown(), AT_OILRIG, Airport::blocks, BuildStationAirport, BuildStationPart(), Built, CheckFlatLandAirport(), CheckIfAuthorityAllowsNewStation(), ClosestTownFromTile(), CMD_ERROR, CommandCostWithParam(), DIR_E, DIR_W, Execute, BaseStation::facilities, CommandCost::Failed(), FindJoiningStation(), GB(), AirportSpec::Get(), AirportTileSpec::Get(), GetAirport(), GetAirportNoiseLevelForDistance(), SpecializedStation< Station, false >::GetIfValid(), GetTranslatedAirportTileID(), Invalid, INVALID_TILE, InvalidateWindowData(), AirportSpec::IsAvailable(), SpecializedStation< Station, false >::IsValidID(), AirportSpec::IsWithinMapBounds(), SpecializedStation< Station, false >::Iterate(), Airport::layout, RailStationTileLayout::layout, AirportSpec::layouts, MakeAirport(), Town::MaxTownNoise(), NoAnimation, Town::noise_reached, NUM_AIRPORTS, BaseStation::owner, BaseStation::rect, Airport::rotation, SetStationTileRandomBits(), SetWindowDirty(), AirportSpec::size_x, AirportSpec::size_y, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), OrthogonalTileArea::tile, BaseStation::town, Airport::type, UpdateAirplanesOnNewStation(), WC_STATION_VIEW, and WC_TOWN_VIEW.

◆ CmdBuildDock()

◆ CmdBuildRailStation()

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

Build rail station.

Parameters
flagsoperation to perform
tile_orgnorthern most position of station dragging/placement
rtrailtype
axisorientation (Axis)
numtracksnumber of tracks
plat_lenplatform length
spec_classcustom station class
spec_indexcustom station id
station_to_joinstation ID to join (NEW_STATION if build new one)
adjacentallow stations directly adjacent to other stations.
Returns
the cost of this operation or an error

Definition at line 1438 of file station_cmd.cpp.

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

◆ CmdBuildRoadStop()

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

Build a bus or truck stop.

Parameters
flagsOperation to perform.
tileNorthernmost tile of the stop.
widthWidth of the road stop.
lengthLength of the road stop.
stop_typeType of road stop (bus/truck).
is_drive_throughFalse for normal stops, true for drive-through.
ddirEntrance direction (DiagDirection) for normal stops. Converted to the axis for drive-through stops.
rtThe roadtype.
spec_classRoad stop spec class.
spec_indexRoad stop spec index.
station_to_joinStation ID to join (NEW_STATION if build new one).
adjacentAllow stations directly adjacent to other stations.
Returns
The cost of this operation or an error.

Definition at line 2072 of file station_cmd.cpp.

References _current_company, _settings_game, OrthogonalTileArea::Add(), Station::AddFacility(), Station::AfterStationTileSetChange(), AllocateSpecToRoadStop(), AssignSpecToRoadStop(), Avail, BuildStationBus, BuildStationPart(), BuildStationTruck, Built, Bus, Station::bus_station, BusStop, BaseStation::cached_roadstop_anim_triggers, CalculateRoadStopCost(), CALLBACK_FAILED, CBID_STATION_AVAILABILITY, CheckIfAuthorityAllowsNewStation(), CMD_ERROR, Convert8bitBooleanCallback(), CountBits(), DiagDirToAxis(), DriveThroughOnly, End, Execute, CommandCost::Failed(), FindJoiningRoadStop(), FindRoadStopSpot(), GB(), NewGRFClass< RoadStopSpec, RoadStopClassID, ROADSTOP_CLASS_MAX >::Get(), RoadStopSpec::GetBuildCost(), NewGRFClass< RoadStopSpec, RoadStopClassID, ROADSTOP_CLASS_MAX >::GetClassCount(), GetRoadBits(), GetRoadOwner(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpec(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpecCount(), RoadStopSpec::grf_prop, GRFFilePropsBase::grffile, OrthogonalTileArea::h, INVALID_ROADTYPE, INVALID_TILE, IsNormalRoadTile(), IsStationRoadStop(), IsTileType(), IsValidDiagDirection(), SpecializedStation< Station, false >::IsValidID(), IsValidTile(), IsWaypointClass(), RailStationTileLayout::length, RoadStop::MakeDriveThrough(), MakeDriveThroughRoadStop(), MakeRoadStop(), MarkTileDirtyByTile(), MayHaveRoad(), BaseStation::owner, BaseStation::rect, RemoveRoadStop(), ROAD_STOP_TRACKBIT_FACTOR, ROADSTOPTYPE_ALL, ROADSTOPTYPE_FREIGHT, ROADSTOPTYPE_PASSENGER, RTT_ROAD, RTT_TRAM, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetCustomRoadStopSpecIndex(), Station, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TileAddWrap(), Truck, Station::truck_station, TruckStop, UpdateCompanyRoadInfrastructure(), ValParamRoadType(), and OrthogonalTileArea::w.

◆ CmdMoveStationName()

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

Move a station name.

Parameters
flagstype of operation
station_idid of the station
tileto move the station name to
Returns
the cost of this operation or an error and the station ID

Definition at line 4507 of file station_cmd.cpp.

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

◆ CmdOpenCloseAirport()

CommandCost CmdOpenCloseAirport ( DoCommandFlags flags,
StationID station_id )

◆ CmdRemoveFromRailStation()

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

Remove a single tile from a rail station.

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

Parameters
flagsoperation to perform
starttile of station piece to remove
endother edge of the rect to remove
keep_railif set keep the rail
Returns
the cost of this operation or an error

Definition at line 1856 of file station_cmd.cpp.

References ClearStationRail, CMD_ERROR, CommandCost::Failed(), INVALID_TILE, RemoveFromRailBaseStation(), SetWindowWidgetDirty(), Map::Size(), OrthogonalTileArea::tile, BaseStation::train_station, WC_STATION_VIEW, and WID_SV_TRAINS.

◆ CmdRemoveFromRailWaypoint()

CommandCost CmdRemoveFromRailWaypoint ( DoCommandFlags 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
flagsoperation to perform
starttile of waypoint piece to remove
endother edge of the rect to remove
keep_railif set keep the rail
Returns
the cost of this operation or an error

Definition at line 1889 of file station_cmd.cpp.

References ClearWaypointRail, CMD_ERROR, RemoveFromRailBaseStation(), and Map::Size().

◆ CmdRemoveFromRoadWaypoint()

CommandCost CmdRemoveFromRoadWaypoint ( DoCommandFlags flags,
TileIndex start,
TileIndex end )

Remove road waypoints.

Parameters
flagsoperation to perform
starttile of road waypoint piece to remove
endother edge of the rect to remove
Returns
the cost of this operation or an error

Definition at line 2508 of file station_cmd.cpp.

References CMD_ERROR, RemoveGenericRoadStop(), and Map::Size().

◆ CmdRemoveRoadStop()

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

Remove bus or truck stops.

Parameters
flagsOperation to perform.
tileNorthernmost tile of the removal area.
widthWidth of the removal area.
heightHeight of the removal area.
stop_typeType of stop (bus/truck).
remove_roadRemove roads of drive-through stops?
Returns
The cost of this operation or an error.

Definition at line 2486 of file station_cmd.cpp.

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

◆ CmdRenameStation()

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

Rename a station.

Parameters
flagsoperation to perform
station_idstation ID that is to be renamed
textthe new name or an empty string when resetting to the default
Returns
the cost of this operation or an error

Definition at line 4470 of file station_cmd.cpp.

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

◆ CMSAMine()

bool CMSAMine ( TileIndex tile)
static

Check whether the tile is a mine.

Parameters
tilethe tile to investigate.
Returns
true if and only if the tile is a mine

Definition at line 176 of file station_cmd.cpp.

References Extractive, CargoSpec::Get(), Industry::GetByTile(), GetIndustrySpec(), Industry, IsTileType(), IsValidCargoType(), IndustrySpec::life_type, Industry::produced, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and Industry::type.

Referenced by GenerateStationName().

◆ CMSATree()

bool CMSATree ( TileIndex tile)
static

Check whether the tile is a tree.

Parameters
tilethe tile to investigate.
Returns
true if and only if the tile is a tree tile

Definition at line 213 of file station_cmd.cpp.

References IsTileType(), and Trees.

Referenced by GenerateStationName().

◆ CMSAWater()

bool CMSAWater ( TileIndex tile)
static

Check whether the tile is water.

Parameters
tilethe tile to investigate.
Returns
true if and only if the tile is a water tile

Definition at line 203 of file station_cmd.cpp.

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

Referenced by GenerateStationName().

◆ CountMapSquareAround()

int CountMapSquareAround ( TileIndex tile,
CMSAMatcher cmp )
static

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

Parameters
tilethe center tile of the 'count area'
cmpthe comparator/matcher (
See also
CMSAMatcher)
Returns
the number of matching tiles around

Definition at line 157 of file station_cmd.cpp.

References INVALID_TILE, and TileAddWrap().

Referenced by GenerateStationName().

◆ DeleteOilRig()

void DeleteOilRig ( TileIndex tile)

Definition at line 4764 of file station_cmd.cpp.

◆ 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
fromStation to check.

Definition at line 4171 of file station_cmd.cpp.

References _settings_game, LinkGraph::COMPRESSION_INTERVAL, TimerGameEconomy::date, Vehicle::date_of_last_service, FlowStatMap::DeleteFlows(), DistanceManhattan(), DT_MANUAL, GoodsEntry::GoodsEntryData::flows, SpecializedStation< Station, false >::Get(), GoodsEntry::GetData(), Station::goods, GoodsEntry::HasData(), TimerGameConst< struct Economy >::INVALID_DATE, Vehicle::IsStoppedInDepot(), LinkGraph::LastCompression(), GoodsEntry::link_graph, LinkGraph::MIN_TIMEOUT_DISTANCE, Vehicle::NextShared(), GoodsEntry::node, NUM_CARGO, RerouteCargo(), FlowStatMap::RestrictFlows(), LinkRefresher::Run(), LinkGraph::STALE_LINK_DEPOT_TIMEOUT, and BaseStation::xy.

◆ DeleteStationIfEmpty()

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
stStation

Definition at line 723 of file station_cmd.cpp.

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

Referenced by Station::AfterStationTileSetChange(), RemoveFromRailBaseStation(), and RemoveRoadWaypointStop().

◆ DrawCustomStationFoundations()

bool DrawCustomStationFoundations ( const StationSpec * statspec,
BaseStation * st,
TileInfo * ti,
StationGfx gfx )
static

Draw custom station foundations for a NewGRF station if provided.

Parameters
statspecCustom NewGRF station.
stStation being drawn.
tiTile being drawn.
gfxGraphics layout for tile.
Returns
true iff a custom foundation was drawn.

Definition at line 3210 of file station_cmd.cpp.

References AddSortableSpriteToDraw(), CustomFoundations, ExtendedFoundations, StationSpec::flags, GetCustomStationFoundationRelocation(), GetFoundationPixelSlope(), SetBit(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TileInfo::tile, and TileInfo::tileh.

◆ DrawTile_Station()

void DrawTile_Station ( TileInfo * ti)
static

Definition at line 3270 of file station_cmd.cpp.

◆ FillTileDescAirport()

void FillTileDescAirport ( TileIndex tile,
TileDesc & td )

Definition at line 3638 of file station_cmd.cpp.

◆ FillTileDescRailStation()

void FillTileDescRailStation ( TileIndex tile,
TileDesc & td )

Definition at line 3619 of file station_cmd.cpp.

◆ FillTileDescRoadStop()

void FillTileDescRoadStop ( TileIndex tile,
TileDesc & td )
static

Definition at line 3581 of file station_cmd.cpp.

◆ FindDockLandPart()

TileIndex FindDockLandPart ( TileIndex t)
static

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

Parameters
tDock tile to find land part of
Returns
tile of land part of dock

Definition at line 3025 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, class F>
CommandCost FindJoiningBaseStation ( StationID existing_station,
StationID station_to_join,
bool adjacent,
TileArea ta,
T ** st,
F filter )

Find a nearby station that joins this station.

Template Parameters
Tthe class to find a station for
error_messagethe error message when building a station on top of others
Fthe filter functor type
Parameters
existing_stationan existing station we build over
station_to_jointhe station to join to
adjacentwhether adjacent stations are allowed
tathe area of the newly build station
st'return' pointer for the found station
filterThe filter to remove unwanted stations.
Returns
command cost with the error or 'okay'

Definition at line 1257 of file station_cmd.cpp.

References _current_company, CommandCost::Failed(), and GetStationAround().

Referenced by FindJoiningRoadStop(), FindJoiningStation(), and FindJoiningWaypoint().

◆ FindJoiningRoadStop()

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_stopan existing road stop we build over
station_to_jointhe station to join to
adjacentwhether adjacent stations are allowed
tathe area of the newly build station
st'return' pointer for the found station
Returns
command cost with the error or 'okay'

Definition at line 2008 of file station_cmd.cpp.

References FindJoiningBaseStation().

Referenced by CmdBuildRoadStop().

◆ FindJoiningStation()

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_stationan existing station we build over
station_to_jointhe station to join to
adjacentwhether adjacent stations are allowed
tathe area of the newly build station
st'return' pointer for the found station
Returns
command cost with the error or 'okay'

Definition at line 1301 of file station_cmd.cpp.

References FindJoiningBaseStation().

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

◆ FindJoiningWaypoint()

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

Find a nearby waypoint that joins this waypoint.

Parameters
existing_waypointan existing waypoint we build over
waypoint_to_jointhe waypoint to join to
adjacentwhether adjacent waypoints are allowed
tathe area of the newly build waypoint
wp'return' pointer for the found waypoint
is_roadwhether to find a road waypoint
Returns
command cost with the error or 'okay'

Definition at line 1316 of file station_cmd.cpp.

References FindJoiningBaseStation(), HasBit(), Waypoint::waypoint_flags, and WPF_ROAD.

Referenced by CmdBuildRailWaypoint(), and CmdBuildRoadWaypoint().

◆ FindRoadStopSpot()

RoadStop ** FindRoadStopSpot ( bool truck_station,
Station * st )
static
Parameters
truck_stationDetermines whether a stop is RoadStopType::Bus or RoadStopType::Truck
stThe Station to do the whole procedure for
Returns
a pointer to where to link a new RoadStop*

Definition at line 1981 of file station_cmd.cpp.

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

Referenced by CmdBuildRoadStop().

◆ FreeTrainReservation()

void FreeTrainReservation ( Train * v)
static

Clear platform reservation during station building/removing.

Parameters
vvehicle which holds reservation

Definition at line 1329 of file station_cmd.cpp.

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

Referenced by CmdBuildRailStation(), and RemoveFromRailBaseStation().

◆ GenerateStationName()

◆ GetAcceptanceAroundStation()

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

Get the acceptance of cargoes around the station in.

Parameters
stStation to get acceptance of.
always_acceptedbitmask of cargo accepted by houses and headquarters; can be nullptr

Definition at line 592 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_tileCenter of the search area
wX extent of area
hY extent of area
radSearch radius in addition to given area
always_acceptedbitmask of cargo accepted by houses and headquarters; can be nullptr

Definition at line 570 of file station_cmd.cpp.

References _settings_game, OrthogonalTileArea::Expand(), Industry::GetByTile(), Industry, and IsTileType().

Referenced by DrawStationCoverageAreaText().

◆ GetAcceptanceMask()

CargoTypes GetAcceptanceMask ( const Station * st)

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

Parameters
stStation to query
Returns
the expected mask

Definition at line 489 of file station_cmd.cpp.

References GoodsEntry::Acceptance, Station::goods, and SetBit().

Referenced by StationViewWindow::DrawAcceptedCargo(), and UpdateStationAcceptance().

◆ GetAirportNoiseLevelForDistance()

uint8_t 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
asairport information
distanceminimum distance between town and airport
Returns
the noise that will be generated, according to distance

Definition at line 2526 of file station_cmd.cpp.

References _settings_game, and AirportSpec::noise_level.

Referenced by CmdBuildAirport(), RemoveAirport(), and UpdateAirportsNoise().

◆ GetBridgeTooLowMessageForStationType()

StringID GetBridgeTooLowMessageForStationType ( StationType type)
static

Get station-type-specific string for a bridge that is too low.

Parameters
typeStation type.
Returns
bridge too low string.

Definition at line 860 of file station_cmd.cpp.

References End, INVALID_STRING_ID, and to_underlying().

Referenced by IsStationBridgeAboveOk().

◆ GetClosestDeletedStation()

Station * GetClosestDeletedStation ( TileIndex tile)
static

Find the closest deleted station of the current company.

Parameters
tilethe tile to search from.
Returns
the closest station or nullptr if too far.

Definition at line 393 of file station_cmd.cpp.

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

Referenced by BuildStationPart().

◆ GetEmptyMask()

CargoTypes GetEmptyMask ( const Station * st)

Get a mask of the cargo types that are empty at the station.

Parameters
stStation to query
Returns
the empty mask

Definition at line 504 of file station_cmd.cpp.

References Station::goods, and SetBit().

Referenced by TriggerRoadStopRandomisation(), and TriggerStationRandomisation().

◆ GetFoundation_Station()

Foundation GetFoundation_Station ( TileIndex ,
Slope tileh )
static

Definition at line 3576 of file station_cmd.cpp.

◆ 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_tileNorthern most tile of area
wX extent of the area
hY extent of the area
radSearch radius in addition to the given area

Definition at line 533 of file station_cmd.cpp.

References _settings_game, OrthogonalTileArea::Expand(), GetIndustryIndex(), Industry, FlatSet< Tkey, Tcompare >::insert(), IsTileType(), IsValidCargoType(), Industry::neutral_station, and Industry::produced.

Referenced by DrawStationCoverageAreaText().

◆ GetSlopePixelZ_Station()

int GetSlopePixelZ_Station ( TileIndex tile,
uint ,
uint ,
bool  )
static

Definition at line 3571 of file station_cmd.cpp.

◆ GetStationAround()

template<class T, class F>
CommandCost GetStationAround ( TileArea ta,
StationID closest_station,
CompanyID company,
T ** st,
F filter )

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

Parameters
tathe area to search over
closest_stationthe closest owned station found so far
companythe company whose stations to look for
stto 'return' the found station
filterFilter function
Returns
Succeeded command (if zero or one station found) or failed command (for two or more stations found).

Definition at line 124 of file station_cmd.cpp.

References OrthogonalTileArea::Expand(), GetStationIndex(), IsTileType(), and Station.

Referenced by FindJoiningBaseStation().

◆ GetStationBlockedPillars()

BridgePillarFlags GetStationBlockedPillars ( std::span< const BridgeableTileInfo > bridgeable_info,
uint8_t layout )
static

Get blocked pillar information for a station tile.

Parameters
bridgeable_info
layoutTile layout of rail station.
Returns
blocked pillar information.

Definition at line 3196 of file station_cmd.cpp.

References RailStationTileLayout::layout.

◆ GetStationBridgeableTileInfo()

std::span< const BridgeableTileInfo > GetStationBridgeableTileInfo ( StationType type)
static

Get bridgeable tile information for a station type.

Parameters
typeStation type.
Returns
bridgeable tile information.

Definition at line 908 of file station_cmd.cpp.

References to_underlying().

Referenced by IsBuoyBridgeAboveOk(), IsDockBridgeAboveOk(), IsRailStationBridgeAboveOk(), and IsRoadStationBridgeAboveOk().

◆ GetStationTileFlags()

StationSpec::TileFlags GetStationTileFlags ( StationGfx gfx,
const StationSpec * statspec )
static

Get station tile flags for the given StationGfx.

Parameters
gfxStationGfx of station tile.
statspecStation spec of station tile.
Returns
Tile flags to apply.

Definition at line 1404 of file station_cmd.cpp.

References StationSpec::Pylons, and StationSpec::tileflags.

Referenced by SetRailStationTileFlags().

◆ GetStationTileLayout()

const DrawTileSprites * GetStationTileLayout ( StationType st,
uint8_t gfx )

Get station tile layout for a station type and its station gfx.

Parameters
stStation type to draw.
gfxStationGfx of tile to draw.
Returns
Tile layout to draw.

Definition at line 3118 of file station_cmd.cpp.

References to_underlying().

Referenced by DrawStationTile().

◆ GetTileDesc_Station()

void GetTileDesc_Station ( TileIndex tile,
TileDesc & td )
static

Definition at line 3656 of file station_cmd.cpp.

◆ GetTileTrackStatus_Station()

TrackStatus GetTileTrackStatus_Station ( TileIndex tile,
TransportType mode,
uint sub_mode,
DiagDirection side )
static

Definition at line 3691 of file station_cmd.cpp.

◆ HasStationInUse()

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

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

Parameters
stationstation ID
include_companyIf true only check vehicles of company, if false only check vehicles of other companies
companycompany ID

Definition at line 2862 of file station_cmd.cpp.

References Vehicle::owner.

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

◆ IncreaseStats() [1/2]

void IncreaseStats ( Station * st,
CargoType cargo,
StationID next_station_id,
uint capacity,
uint usage,
uint32_t time,
EdgeUpdateModes modes )

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

Parameters
stStation to get the link stats from.
cargoCargo to increase stat for.
next_station_idStation the consist will be travelling to next.
capacityCapacity to add to link stat.
usageUsage to add to link stat.
timeThe travel time for the link.
modesUpdate modes to be applied.

Definition at line 4266 of file station_cmd.cpp.

References LinkGraph::AddNode(), Debug, SpecializedStation< Station, false >::Get(), Station::goods, LinkGraphSchedule::instance, GoodsEntry::link_graph, LinkGraph::Merge(), GoodsEntry::node, and LinkGraph::Size().

Referenced by Vehicle::BeginLoading(), IncreaseStats(), and LinkRefresher::RefreshStats().

◆ IncreaseStats() [2/2]

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

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

Parameters
stStation to get the link stats from.
frontFirst vehicle in the consist.
next_station_idStation the consist will be travelling to next.
timeThe travel time for the links.

Definition at line 4319 of file station_cmd.cpp.

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

◆ IsBuoyBridgeAboveOk()

CommandCost IsBuoyBridgeAboveOk ( TileIndex tile)

Test if a buoy can be built below a bridge.

Parameters
tileTile to test.
Returns
Command result.

Definition at line 967 of file station_cmd.cpp.

References Buoy, GetBridgeHeight(), GetSouthernBridgeEnd(), GetStationBridgeableTileInfo(), IsBridgeAbove(), and IsStationBridgeAboveOk().

Referenced by CmdBuildBuoy().

◆ IsDockBridgeAboveOk()

CommandCost IsDockBridgeAboveOk ( TileIndex tile,
StationGfx layout )
static

Test if a dock can be built below a bridge.

Parameters
tileTile to test.
layoutLayout piece of station to test.
Returns
Command result.

Definition at line 953 of file station_cmd.cpp.

References Dock, GetBridgeHeight(), GetSouthernBridgeEnd(), GetStationBridgeableTileInfo(), IsBridgeAbove(), and IsStationBridgeAboveOk().

Referenced by CmdBuildDock().

◆ IsHangar()

bool IsHangar ( Tile t)

Check whether the given tile is a hangar.

Parameters
tthe tile to of whether it is a hangar.
Precondition
IsTileType(t, TileType::Station)
Returns
true if and only if the tile is a hangar.

Definition at line 97 of file station_cmd.cpp.

References Station::airport, AirportSpec::depots, BaseStation::GetByTile(), Airport::GetRotatedTileFromOffset(), Airport::GetSpec(), IsAirport(), IsTileType(), and Station.

Referenced by IsHangarTile().

◆ IsRailStationBridgeAboveOk()

CommandCost IsRailStationBridgeAboveOk ( TileIndex tile,
const StationSpec * spec,
StationType type,
StationGfx layout )

Test if a rail station can be built below a bridge.

Parameters
tileTile to test.
specCustom station spec to test.
typeType of rail station.
layoutLayout piece of station to test.
Returns
Command result.

Definition at line 921 of file station_cmd.cpp.

References StationSpec::bridgeable_info, GetBridgeHeight(), GetSouthernBridgeEnd(), GetStationBridgeableTileInfo(), IsBridgeAbove(), and IsStationBridgeAboveOk().

Referenced by CmdBuildRailStation(), and CmdBuildRailWaypoint().

◆ IsRoadStationBridgeAboveOk()

CommandCost IsRoadStationBridgeAboveOk ( TileIndex tile,
const RoadStopSpec * spec,
StationType type,
StationGfx layout )

Test if a road station can be built below a bridge.

Parameters
tileTile to test.
specCustom roadstop spec to test.
typeType of road station.
layoutLayout piece of station to test.
Returns
Command result.

Definition at line 938 of file station_cmd.cpp.

References RoadStopSpec::bridgeable_info, GetBridgeHeight(), GetSouthernBridgeEnd(), GetStationBridgeableTileInfo(), IsBridgeAbove(), and IsStationBridgeAboveOk().

Referenced by CheckFlatLandRoadStop().

◆ IsStationBridgeAboveOk()

CommandCost IsStationBridgeAboveOk ( TileIndex tile,
std::span< const BridgeableTileInfo > bridgeable_info,
StationType type,
StationGfx layout,
int bridge_height,
StringID disallowed_msg = INVALID_STRING_ID )
static

Test if a bridge can be built above a station.

Parameters
tileTile to test.
bridgeable_infoMinimum height before bridge is okay for each of the layouts.
typeType of station.
layoutLayout piece of road station to test.
bridge_heightHeight of bridge to test.
disallowed_msgError message if bridge is disallowed.
Returns
Command result.

Definition at line 886 of file station_cmd.cpp.

References Auto, CommandCostWithParam(), GetBridgeTooLowMessageForStationType(), GetTileMaxZ(), INVALID_STRING_ID, and TILE_HEIGHT_STEP.

Referenced by IsBuoyBridgeAboveOk(), IsDockBridgeAboveOk(), IsRailStationBridgeAboveOk(), and IsRoadStationBridgeAboveOk().

◆ IsUniqueStationName()

bool IsUniqueStationName ( const std::string & name)
static

Definition at line 4454 of file station_cmd.cpp.

◆ MakeRailStationAreaSmaller()

void MakeRailStationAreaSmaller ( BaseStation * st)
static

Definition at line 1711 of file station_cmd.cpp.

◆ MakeRoadWaypointStationAreaSmaller()

void MakeRoadWaypointStationAreaSmaller ( BaseStation * st,
TileArea & road_waypoint_area )

Definition at line 1732 of file station_cmd.cpp.

◆ MakeShipStationAreaSmaller()

void MakeShipStationAreaSmaller ( Station * st)
static

Definition at line 1721 of file station_cmd.cpp.

◆ MakeStationAreaSmaller()

TileArea MakeStationAreaSmaller ( BaseStation * st,
TileArea ta,
bool(* func )(BaseStation *, TileIndex) )
static

Definition at line 1656 of file station_cmd.cpp.

◆ ModifyStationRatingAround()

void ModifyStationRatingAround ( TileIndex tile,
Owner owner,
int amount,
uint radius )

Forcibly modify station ratings near a given tile.

Used when a crash hurts a company's station ratings nearby, or when local authority actions affect nearby ratings.

Parameters
tileThe center of the ratings change area.
ownerThe station owner whose stations are affected.
amountThe amount to change the rating.
radiusThe radius to search for stations, from the origin tile.

Definition at line 4393 of file station_cmd.cpp.

References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), ClampTo(), DistanceManhattan(), ForAllStationsRadius(), Station::goods, BaseStation::owner, GoodsEntry::rating, GoodsEntry::status, and BaseStation::xy.

Referenced by CheckTrainCollision(), CrashAirplane(), TownActionAdvertiseLarge(), TownActionAdvertiseMedium(), TownActionAdvertiseSmall(), and TownActionBuyRights().

◆ MoveGoodsToStation()

uint MoveGoodsToStation ( CargoType cargo,
uint amount,
Source source,
const StationList & all_stations,
Owner exclusivity )

Definition at line 4604 of file station_cmd.cpp.

◆ OnTick_Station()

void OnTick_Station ( )

Definition at line 4347 of file station_cmd.cpp.

◆ RemoveAirport()

◆ RemoveDock()

◆ RemoveDockingTile()

void RemoveDockingTile ( TileIndex t)

Definition at line 2983 of file station_cmd.cpp.

◆ RemoveFromRailBaseStation()

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

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

Parameters
tathe area to clear station tile from.
affected_stationsthe stations affected.
flagsthe command flags.
removal_costthe cost for removing the tile, including the rail.
keep_railwhether to keep the rail of the station.
Template Parameters
Tthe type of station to remove.
Returns
the number of cleared tiles or an error.

Definition at line 1748 of file station_cmd.cpp.

References _current_company, CommandCost::AddCost(), AddTrackToSignalBuffer(), CheckOwnership(), ClearRail, DeallocateSpecFromStation(), DeleteNewGRFInspectWindow(), DeleteStationIfEmpty(), DirtyCompanyInfrastructureWindows(), EnsureNoVehicleOnGround(), Execute, EXPENSES_CONSTRUCTION, BaseStation::facilities, CommandCost::Failed(), FreeTrainReservation(), GetCustomStationSpecIndex(), GetRailStationTrack(), GetRailType(), GetTileOwner(), GetTrainForReservation(), HasStationReservation(), HasStationTileRail(), include(), INVALID_TILE, IsStationTileBlocked(), OWNER_WATER, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), RestoreTrainReservation(), SetWindowClassesDirty(), SetWindowWidgetDirty(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), OrthogonalTileArea::tile, TrackToTrackBits(), Train, BaseStation::train_station, BaseStation::UpdateVirtCoord(), WC_STATION_VIEW, WC_VEHICLE_ORDERS, WID_SV_TRAINS, and YapfNotifyTrackLayoutChange().

Referenced by CmdRemoveFromRailStation(), CmdRemoveFromRailWaypoint(), and RemoveRailStation().

◆ RemoveGenericRoadStop()

CommandCost RemoveGenericRoadStop ( DoCommandFlags flags,
const TileArea & roadstop_area,
bool road_waypoint,
bool remove_road )
static

Remove a tile area of road stop or road waypoints.

Parameters
flagsoperation to perform
roadstop_areatile area of road stop or road waypoint tiles to remove
road_waypointWhether to remove road waypoints or road stops
remove_roadRemove roads of drive-through stops?
Returns
the cost of this operation or an error

Definition at line 2423 of file station_cmd.cpp.

References _current_company, CommandCost::AddCost(), AxisToRoadBits(), ClosestTownFromTile(), CountBits(), Execute, EXPENSES_CONSTRUCTION, CommandCost::Failed(), CommandCost::GetCost(), GetDriveThroughStopAxis(), GetRoadOwner(), INVALID_ROADTYPE, IsAnyRoadStop(), IsDriveThroughStopTile(), IsRoadWaypoint(), IsTileType(), MakeRoadNormal(), OWNER_NONE, RemoveRoadStop(), RemoveRoadWaypointStop(), ROAD_NONE, RTT_ROAD, RTT_TRAM, Station, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and UpdateCompanyRoadInfrastructure().

Referenced by CmdRemoveFromRoadWaypoint(), and CmdRemoveRoadStop().

◆ RemoveRailStation() [1/2]

template<class T>
CommandCost RemoveRailStation ( T * st,
DoCommandFlags flags,
Money removal_cost )

Remove a rail station/waypoint.

Parameters
stThe station/waypoint to remove the rail part from
flagsoperation to perform
removal_costthe cost for removing a tile
Template Parameters
Tthe type of station to remove
Returns
cost or failure of operation

Definition at line 1910 of file station_cmd.cpp.

References _current_company, CommandCost::AddCost(), CheckOwnership(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), CommandCost::GetCost(), OrthogonalTileArea::h, OWNER_WATER, RemoveFromRailBaseStation(), and OrthogonalTileArea::w.

Referenced by ClearTile_Station(), RemoveRailStation(), and RemoveRailWaypoint().

◆ RemoveRailStation() [2/2]

CommandCost RemoveRailStation ( TileIndex tile,
DoCommandFlags flags )
static

Remove a rail station.

Parameters
tileTile of the station.
flagsoperation to perform
Returns
cost or failure of operation

Definition at line 1944 of file station_cmd.cpp.

References _current_company, ClearStationRail, Execute, BaseStation::GetByTile(), OWNER_WATER, Station::RecomputeCatchment(), RemoveRailStation(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

◆ RemoveRailWaypoint()

CommandCost RemoveRailWaypoint ( TileIndex tile,
DoCommandFlags flags )
static

Remove a rail waypoint.

Parameters
tileTile of the waypoint.
flagsoperation to perform
Returns
cost or failure of operation

Definition at line 1965 of file station_cmd.cpp.

References _current_company, ClearWaypointRail, Execute, BaseStation::GetByTile(), OWNER_WATER, and RemoveRailStation().

Referenced by ClearTile_Station().

◆ RemoveRoadStop()

CommandCost RemoveRoadStop ( TileIndex tile,
DoCommandFlags flags,
int replacement_spec_index )
static

Remove a bus station/truck stop.

Parameters
tileTileIndex been queried
flagsoperation to perform
replacement_spec_indexreplacement spec index to avoid deallocating, if < 0, tile is not being replaced
Returns
cost or failure of operation

Definition at line 2231 of file station_cmd.cpp.

References _current_company, OrthogonalTileArea::Add(), Station::AfterStationTileSetChange(), Bankrupt, Bus, Station::bus_station, Station::bus_stops, BusStop, CheckOwnership(), OrthogonalTileArea::Clear(), RoadStop::ClearDriveThrough(), ClearStationBus, ClearStationTruck, Vehicle::current_order, DeallocateSpecFromRoadStop(), DeleteAnimatedTile(), DeleteNewGRFInspectWindow(), Vehicle::dest_tile, DirtyCompanyInfrastructureWindows(), EnsureNoVehicleOnGround(), Execute, EXPENSES_CONSTRUCTION, BaseStation::facilities, CommandCost::Failed(), FindVehiclesWithOrder(), SpecializedVehicle< RoadVehicle, Type >::From(), BaseStation::GetByTile(), RoadStop::GetByTile(), RoadStopSpec::GetClearCost(), GetCustomRoadStopSpecIndex(), Vehicle::GetOrderStationLocation(), GetRoadOwner(), HasBit(), IsDriveThroughStopTile(), IsTruckStop(), Order::IsType(), RoadStop::next, BaseStation::owner, OWNER_WATER, BaseStation::rect, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), ROAD_STOP_TRACKBIT_FACTOR, RVS_IN_DT_ROAD_STOP, RVSB_ROAD_STOP_TRACKDIR_MASK, SetWindowClassesDirty(), RoadVehicle::state, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Truck, Station::truck_station, Station::truck_stops, TruckStop, BaseVehicle::type, UpdateCompanyRoadInfrastructure(), VEH_ROAD, and WC_VEHICLE_ORDERS.

Referenced by ClearTile_Station(), CmdBuildRoadStop(), and RemoveGenericRoadStop().

◆ RemoveRoadWaypointStop()

◆ RerouteCargo()

void RerouteCargo ( Station * st,
CargoType cargo,
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
stStation to be rerouted at.
cargoType of cargo.
avoidOriginal next hop of cargo, avoid this.
avoid2Another station to be avoided when rerouting.

Definition at line 4147 of file station_cmd.cpp.

References GoodsEntry::GoodsEntryData::cargo, GoodsEntry::GetData(), Station::goods, GoodsEntry::HasData(), Vehicle::Next(), and StationCargoList::Reroute().

Referenced by DeleteStaleLinks(), LinkGraphJob::~LinkGraphJob(), and Station::~Station().

◆ RestoreTrainReservation()

void RestoreTrainReservation ( Train * v)
static

Restore platform reservation during station building/removing.

Parameters
vvehicle which held reservation

Definition at line 1341 of file station_cmd.cpp.

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

Referenced by CmdBuildRailStation(), and RemoveFromRailBaseStation().

◆ SetRailStationTileFlags()

void SetRailStationTileFlags ( TileIndex tile,
const StationSpec * statspec )

Set rail station tile flags for the given tile.

Parameters
tileTile to set flags on.
statspecStatspec of the tile.

Definition at line 1416 of file station_cmd.cpp.

References StationSpec::Blocked, GetStationGfx(), GetStationTileFlags(), StationSpec::NoWires, StationSpec::Pylons, SetStationTileBlocked(), SetStationTileHavePylons(), and SetStationTileHaveWires().

Referenced by CmdBuildRailStation(), and CmdBuildRailWaypoint().

◆ ShowRejectOrAcceptNews()

void ShowRejectOrAcceptNews ( const Station * st,
CargoTypes cargoes,
bool reject )
static

Add news item for when a station changes which cargoes it accepts.

Parameters
stStation of cargo change.
cargoesBit mask of cargo types to list.
rejectTrue iff the station rejects the cargo types.

Definition at line 520 of file station_cmd.cpp.

References Acceptance, AddNewsItem(), GetEncodedString(), InColour, and Small.

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
tiPositional info for the tile to decide snowyness etc. May be nullptr.
[in,out]groundGroundsprite to draw.
[out]overlay_offsetOverlay to draw.
Returns
true if overlay can be drawn.

Definition at line 3134 of file station_cmd.cpp.

References _settings_game, Arctic, GetSnowLine(), GetTropicZone(), RTO_X, RTO_Y, TileInfo::tile, TILE_HEIGHT, Tropic, TROPICZONE_DESERT, and Coord3D< T >::z.

Referenced by DrawStationTile().

◆ StationHandleBigTick()

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
stthe station receiving the tick.
Returns
true if the station is still valid (wasn't deleted)

Definition at line 3921 of file station_cmd.cpp.

References GoodsEntry::AcceptedBigtick, BaseStation::delete_ctr, BaseStation::facilities, SpecializedStation< Station, false >::From(), SpecializedStation< Station, false >::IsExpected(), BaseStation::IsInUse(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), GoodsEntry::status, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TriggerWatchedCargoCallbacks(), UpdateStationAcceptance(), and Waypoint.

◆ StationHandleSmallTick()

void StationHandleSmallTick ( BaseStation * st)
static

Definition at line 4336 of file station_cmd.cpp.

◆ StationPickerDrawSprite()

void StationPickerDrawSprite ( int x,
int y,
StationType st,
RailType railtype,
RoadType roadtype,
int image )

Definition at line 3520 of file station_cmd.cpp.

◆ TerraformTile_Station()

CommandCost TerraformTile_Station ( TileIndex tile,
DoCommandFlags flags,
int z_new,
Slope tileh_new )
static

Definition at line 4951 of file station_cmd.cpp.

◆ TileBelongsToRailStation()

bool TileBelongsToRailStation ( BaseStation * st,
TileIndex tile )
static

Definition at line 1706 of file station_cmd.cpp.

◆ TileBelongsToRoadWaypointStation()

bool TileBelongsToRoadWaypointStation ( BaseStation * st,
TileIndex tile )
static

Definition at line 1727 of file station_cmd.cpp.

◆ TileBelongsToShipStation()

bool TileBelongsToShipStation ( BaseStation * st,
TileIndex tile )
static

Definition at line 1716 of file station_cmd.cpp.

◆ TileLoop_Station()

void TileLoop_Station ( TileIndex tile)
static

Definition at line 3738 of file station_cmd.cpp.

◆ TriggerWatchedCargoCallbacks()

void TriggerWatchedCargoCallbacks ( Station * st)

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

Parameters
stStation.

Definition at line 3895 of file station_cmd.cpp.

References GoodsEntry::AcceptedBigtick, Station::catchment_tiles, Station::goods, House, INVALID_TILE, IsTileType(), NUM_CARGO, SetBit(), and TriggerHouseAnimation_WatchedCargoAccepted().

Referenced by StationHandleBigTick().

◆ TruncateCargo()

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

Truncate the cargo by a specific amount.

Parameters
csThe type of cargo to perform the truncation for.
geThe goods entry, of the station, to truncate.
amountThe amount to truncate the cargo by.

Definition at line 3954 of file station_cmd.cpp.

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

Referenced by UpdateStationRating().

◆ UpdateAirportsNoise()

void UpdateAirportsNoise ( )

Recalculate the noise generated by the airports of each town.

Definition at line 2607 of file station_cmd.cpp.

References AirportGetNearestTown(), AT_OILRIG, GetAirportNoiseLevelForDistance(), INVALID_TILE, SpecializedStation< Station, false >::Iterate(), and Town::noise_reached.

Referenced by DoCreateTown(), and InitializeWindowsAndCaches().

◆ UpdateAllStationVirtCoords()

void UpdateAllStationVirtCoords ( )

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

Definition at line 464 of file station_cmd.cpp.

Referenced by CmdRenameTown(), and UpdateAllVirtCoords().

◆ UpdateStationAcceptance()

◆ UpdateStationDockingTiles()

void UpdateStationDockingTiles ( Station * st)

Definition at line 4689 of file station_cmd.cpp.

◆ UpdateStationRating()

◆ UpdateStationSignCoord()

void UpdateStationSignCoord ( BaseStation * st)
static

Definition at line 658 of file station_cmd.cpp.

◆ UpdateStationWaiting()

uint UpdateStationWaiting ( Station * st,
CargoType cargo,
uint amount,
Source source )
static

Definition at line 4406 of file station_cmd.cpp.

◆ VehicleEnter_Station()

VehicleEnterTileStates VehicleEnter_Station ( Vehicle * v,
TileIndex tile,
int x,
int y )
static

Definition at line 3842 of file station_cmd.cpp.

Variable Documentation

◆ _dock_h_chk

const uint8_t _dock_h_chk[4] = { 1, 2, 1, 2 }
static

Definition at line 2885 of file station_cmd.cpp.

◆ _dock_tileoffs_chkaround

const TileIndexDiffC _dock_tileoffs_chkaround[]
static
Initial value:
= {
{-1, 0},
{ 0, 0},
{ 0, 0},
{ 0, -1}
}

Definition at line 2878 of file station_cmd.cpp.

◆ _dock_w_chk

const uint8_t _dock_w_chk[4] = { 2, 1, 2, 1 }
static

Definition at line 2884 of file station_cmd.cpp.

◆ _tile_type_station_procs

const TileTypeProcs _tile_type_station_procs
extern
Initial value:
= {
DrawTile_Station,
GetSlopePixelZ_Station,
nullptr,
GetTileDesc_Station,
GetTileTrackStatus_Station,
ClickTile_Station,
AnimateTile_Station,
TileLoop_Station,
ChangeTileOwner_Station,
nullptr,
VehicleEnter_Station,
GetFoundation_Station,
TerraformTile_Station,
CheckBuildAbove_Station,
}
CommandCost ClearTile_Station(TileIndex tile, DoCommandFlags flags)
Clear a single tile of a station.

Definition at line 57 of file landscape.cpp.