OpenTTD Source 20241224-master-gf74b0cf984
station_cmd.h File Reference

Command definitions related to stations. More...

#include "command_type.h"
#include "station_type.h"

Go to the source code of this file.

Functions

TownAirportGetNearestTown (const struct AirportSpec *as, Direction rotation, TileIndex tile, TileIterator &&it, uint &mindist)
 
uint8_t GetAirportNoiseLevelForDistance (const struct AirportSpec *as, uint distance)
 
CommandCost CmdBuildAirport (DoCommandFlag flags, TileIndex tile, uint8_t airport_type, uint8_t layout, StationID station_to_join, bool allow_adjacent)
 Place an Airport.
 
CommandCost CmdBuildDock (DoCommandFlag flags, TileIndex tile, StationID station_to_join, bool adjacent)
 Build a dock/haven.
 
CommandCost CmdBuildRailStation (DoCommandFlag flags, TileIndex tile_org, RailType rt, Axis axis, uint8_t numtracks, uint8_t plat_len, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
 Build rail station.
 
CommandCost CmdRemoveFromRailStation (DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail)
 Remove a single tile from a rail station.
 
CommandCost CmdBuildRoadStop (DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent)
 Build a bus or truck stop.
 
CommandCost CmdRemoveRoadStop (DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road)
 Remove bus or truck stops.
 
CommandCost CmdRenameStation (DoCommandFlag flags, StationID station_id, const std::string &text)
 Rename a station.
 
CommandCost CmdOpenCloseAirport (DoCommandFlag flags, StationID station_id)
 Open/close an airport to incoming aircraft.
 

Detailed Description

Command definitions related to stations.

Definition in file station_cmd.h.

Function Documentation

◆ CmdBuildAirport()

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

References _settings_game, AAT_BUILT, OrthogonalTileArea::Add(), AddAnimatedTile(), CommandCost::AddCost(), Station::AddFacility(), Station::AfterStationTileSetChange(), AirportFTAClass::AIRPLANES, Station::airport, AirportGetNearestTown(), ANIM_STATUS_NO_ANIMATION, AirportTileSpec::animation, AT_OILRIG, BuildStationPart(), CheckFlatLandAirport(), CheckIfAuthorityAllowsNewStation(), ClosestTownFromTile(), CMD_ERROR, DC_EXEC, GameSettings::difficulty, DIR_E, DIR_W, StationSettings::distant_join_stations, GameSettings::economy, FACIL_AIRPORT, BaseStation::facilities, CommandCost::Failed(), FindJoiningStation(), Airport::flags, GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), AirportTileSpec::Get(), AirportSpec::Get(), GetAirport(), GetAirportNoiseLevelForDistance(), SpecializedStation< Station, false >::GetIfValid(), GetTranslatedAirportTileID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_TILE, InvalidateWindowData(), AirportSpec::IsAvailable(), SpecializedStation< Station, false >::IsValidID(), AirportSpec::IsWithinMapBounds(), SpecializedStation< Station, false >::Iterate(), Airport::layout, AirportSpec::layouts, MakeAirport(), Town::MaxTownNoise(), Town::noise_reached, NUM_AIRPORTS, BaseStation::owner, BaseStation::rect, Airport::rotation, SetDParam(), SetStationTileRandomBits(), SetWindowDirty(), AirportSpec::size_x, AirportSpec::size_y, GameSettings::station, EconomySettings::station_noise_level, StationSettings::station_spread, AnimationInfo::status, Swap(), OrthogonalTileArea::tile, BaseStation::town, DifficultySettings::town_council_tolerance, Airport::type, UpdateAirplanesOnNewStation(), WATER_CLASS_INVALID, WC_STATION_VIEW, and WC_TOWN_VIEW.

◆ CmdBuildDock()

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

◆ CmdBuildRailStation()

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

References _current_company, _settings_game, Station::AddFacility(), AddTrackToSignalBuffer(), Station::AfterStationTileSetChange(), AllocateSpecToStation(), AXIS_X, AxisToDiagDir(), AxisToTrack(), BuildStationPart(), BaseStation::cached_anim_triggers, CalculateRailStationCost(), CALLBACK_FAILED, StationSpec::callback_mask, CanExpandRailStation(), CBID_STATION_AVAILABILITY, CBID_STATION_BUILD_TILE_LAYOUT, CBM_STATION_AVAIL, CheckIfAuthorityAllowsNewStation(), CMD_ERROR, Convert8bitBooleanCallback(), DC_EXEC, DeallocateSpecFromStation(), DeleteAnimatedTile(), StationSpec::disallowed_lengths, StationSpec::disallowed_platforms, StationSettings::distant_join_stations, ErrorUnknownCallbackResult(), FACIL_TRAIN, CommandCost::Failed(), FindJoiningStation(), FreeTrainReservation(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), NewGRFClass< Tspec, Tindex, Tmax >::Get(), NewGRFClass< Tspec, Tindex, Tmax >::GetClassCount(), GetCustomStationSpecIndex(), GetPlatformInfo(), GetRailStationAxis(), GetRailType(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpec(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpecCount(), GetStationGfx(), GetStationLayout(), GetTrainForReservation(), StationSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, GRFFilePropsBase< Tcnt >::grfid, HasBit(), HasStationReservation(), HasStationTileRail(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Company::infrastructure, INVALID_TILE, IsCompatibleTrainStationTile(), IsRailStationTile(), IsStationTileBlocked(), IsValidAxis(), SpecializedStation< Station, false >::IsValidID(), IsWaypointClass(), MakeRailStation(), Station::MarkTilesDirty(), OtherAxis(), BaseStation::owner, CompanyInfrastructure::rail, BaseStation::rect, RestoreTrainReservation(), SAT_BUILT, SetAnimationFrame(), SetCustomStationSpecIndex(), SetRailStationPlatformReservation(), SetRailStationTileFlags(), SetStationGfx(), SetStationTileRandomBits(), CompanyInfrastructure::station, GameSettings::station, StationSettings::station_spread, OrthogonalTileArea::tile, TileOffsByAxis(), TileOffsByDiagDir(), BaseStation::train_station, AnimationInfo::triggers, ValParamRailType(), and YapfNotifyTrackLayoutChange().

◆ CmdBuildRoadStop()

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

References _current_company, _settings_game, OrthogonalTileArea::Add(), Station::AddFacility(), Station::AfterStationTileSetChange(), BuildStationPart(), Station::bus_station, BaseStation::cached_roadstop_anim_triggers, CalculateRoadStopCost(), CALLBACK_FAILED, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_roadstop_pool >::CanAllocateItem(), CBID_STATION_AVAILABILITY, CBM_ROAD_STOP_AVAIL, CheckIfAuthorityAllowsNewStation(), CMD_ERROR, Convert8bitBooleanCallback(), CountBits(), DC_EXEC, DiagDirToAxis(), StationSettings::distant_join_stations, FACIL_BUS_STOP, FACIL_TRUCK_STOP, CommandCost::Failed(), FindJoiningRoadStop(), FindRoadStopSpot(), GB(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), NewGRFClass< Tspec, Tindex, Tmax >::Get(), RoadStopSpec::GetBuildCost(), NewGRFClass< Tspec, Tindex, Tmax >::GetClassCount(), GetRoadBits(), GetRoadOwner(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpec(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpecCount(), RoadStopSpec::grf_prop, GRFFilePropsBase< Tcnt >::grffile, OrthogonalTileArea::h, HasBit(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_ROADTYPE, INVALID_TILE, IsNormalRoadTile(), IsStationRoadStop(), IsTileType(), IsValidDiagDirection(), SpecializedStation< Station, false >::IsValidID(), IsValidTile(), IsWaypointClass(), RoadStop::MakeDriveThrough(), MakeDriveThroughRoadStop(), MakeRoadStop(), MarkTileDirtyByTile(), MayHaveRoad(), MP_STATION, BaseStation::owner, BaseStation::rect, RemoveRoadStop(), ROAD_STOP_TRACKBIT_FACTOR, ROADSTOP_BUS, ROADSTOP_END, ROADSTOP_TRUCK, ROADSTOPTYPE_ALL, ROADSTOPTYPE_FREIGHT, ROADSTOPTYPE_PASSENGER, RSF_DRIVE_THROUGH_ONLY, SAT_BUILT, SetCustomRoadStopSpecIndex(), GameSettings::station, StationSettings::station_spread, TileAddWrap(), AnimationInfo::triggers, Station::truck_station, UpdateCompanyRoadInfrastructure(), ValParamRoadType(), and OrthogonalTileArea::w.

◆ CmdOpenCloseAirport()

◆ CmdRemoveFromRailStation()

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

Remove a single tile from a rail station.

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

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

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

◆ CmdRemoveRoadStop()

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

References CMD_ERROR, DC_BANKRUPT, INVALID_TILE, IsValidTile(), RemoveGenericRoadStop(), ROADSTOP_BUS, ROADSTOP_END, and TileAddWrap().

◆ CmdRenameStation()

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

References BaseStation::cached_name, CheckOwnership(), CMD_ERROR, DC_EXEC, CommandCost::Failed(), SpecializedStation< Station, false >::GetIfValid(), InvalidateWindowData(), MAX_LENGTH_STATION_NAME_CHARS, BaseStation::name, BaseStation::owner, Station::UpdateVirtCoord(), Utf8StringLength(), and WC_STATION_LIST.