OpenTTD Source 20261112-master-gbcbec5e63f
station_cmd.h File Reference

Command definitions related to stations. More...

#include "command_type.h"
#include "rail_type.h"
#include "road_type.h"
#include "station_type.h"
#include "newgrf_roadstop.h"
#include "newgrf_station.h"
#include "tilearea_airport.h"
#include "tilearea_airportlayout.h"
#include "tilearea_wrapper.h"

Go to the source code of this file.

Functions

Town * AirportGetNearestTown (const AirportSpec *as, Direction rotation, TileIndex tile, TileIteratorWrapper< AirportTileIterator, AirportTileTableIterator > &&iter, uint &mindist)
 Finds the town nearest to given airport.
uint8_t GetAirportNoiseLevelForDistance (const AirportSpec *as, uint distance)
 Get a possible noise reduction factor based on distance from town center.
CommandCost CmdBuildAirport (DoCommandFlags flags, TileIndex tile, uint8_t airport_type, uint8_t layout, StationID station_to_join, bool allow_adjacent)
 Place an Airport.
CommandCost CmdBuildDock (DoCommandFlags flags, TileIndex tile, StationID station_to_join, bool adjacent)
 Build a dock/haven.
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.
CommandCost CmdRemoveFromRailStation (DoCommandFlags flags, TileIndex start, TileIndex end, bool keep_rail)
 Remove a single tile from a rail station.
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.
CommandCost CmdRemoveRoadStop (DoCommandFlags flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road)
 Remove bus or truck stops.
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.
CommandCost CmdOpenCloseAirport (DoCommandFlags flags, StationID station_id)
 Open/close an airport to incoming aircraft.
void CcMoveStationName (Commands, const CommandCost &result, StationID station_id)
 Callback function that is called after a name is moved.

Detailed Description

Command definitions related to stations.

Definition in file station_cmd.h.

Function Documentation

◆ AirportGetNearestTown()

Town * AirportGetNearestTown ( const AirportSpec * as,
Direction rotation,
TileIndex tile,
TileIteratorWrapper< AirportTileIterator, AirportTileTableIterator > && iter,
uint & mindist )
extern

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)
iterAn iterator over all airport tiles (consumed)
[out]mindistMinimum distance to town
Returns
nearest town to airport

Definition at line 2552 of file station_cmd.cpp.

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

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

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

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

Referenced by QueryStringWindow::OnPlaceObject().

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

References _price, _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(), CheckStationSpread(), ClosestTownFromTile(), CMD_ERROR, CommandCostWithParam(), E, Execute, BaseStation::facilities, CommandCost::Failed(), FindJoiningStation(), GB(), AirportSpec::Get(), AirportTileSpec::Get(), GetAirport(), GetAirportNoiseLevelForDistance(), SpecializedStation< Station, false >::GetIfValid(), GetTranslatedAirportTileID(), Heliport, Invalid, INVALID_TILE, InvalidateWindowData(), AirportSpec::IsAvailable(), OrthogonalTileArea::IsEmpty(), SpecializedStation< Station, false >::IsValidID(), AirportSpec::IsWithinMapBounds(), SpecializedStation< Station, false >::Iterate(), Airport::layout, RailStationTileLayout< T >::layout, AirportSpec::layouts, MakeAirport(), Town::MaxTownNoise(), NoAnimation, Town::noise_reached, NUM_AIRPORTS, BaseStation::owner, Airport::rotation, SetStationTileRandomBits(), SetWindowDirty(), AirportSpec::size_x, AirportSpec::size_y, BaseStation::spread, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), BaseStation::town, Airport::type, UpdateAirplanesOnNewStation(), and W.

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

References _current_company, _settings_game, OrthogonalTileArea::Add(), Station::AddFacility(), AddTrackToSignalBuffer(), Station::AfterStationTileSetChange(), AllocateSpecToStation(), AssignSpecToStation(), Avail, AxisToDiagDir(), AxisToTrack(), BuildStationPart(), Built, BaseStation::cached_anim_triggers, CalculateRailStationCost(), CALLBACK_FAILED, StationSpec::callback_mask, CBID_STATION_AVAILABILITY, CBID_STATION_BUILD_TILE_LAYOUT, CheckIfAuthorityAllowsNewStation(), CheckStationSpread(), CMD_ERROR, Convert8bitBooleanCallback(), DeallocateSpecFromStation(), DeleteAnimatedTile(), DeleteNewGRFInspectWindow(), StationSpec::disallowed_lengths, StationSpec::disallowed_platforms, ErrorUnknownCallbackResult(), Execute, CommandCost::Failed(), FindJoiningStation(), FreeTrainReservation(), GB(), NewGRFClass< StationSpec, StationClassID >::Get(), NewGRFClass< StationSpec, StationClassID >::GetClassCount(), GetCustomStationSpecIndex(), GetPlatformInfo(), GetRailStationAxis(), GetRailType(), NewGRFClass< Tspec, Tindex >::GetSpec(), NewGRFClass< Tspec, Tindex >::GetSpecCount(), 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, RestoreTrainReservation(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetAnimationFrame(), SetCustomStationSpecIndex(), SetRailStationPlatformReservation(), SetRailStationTileFlags(), SetStationGfx(), SetStationTileRandomBits(), BaseStation::spread, CompanyInfrastructure::station, Stations, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), OrthogonalTileArea::tile, TileAddWrap(), TileOffsByAxis(), TileOffsByDiagDir(), to_underlying(), Train, BaseStation::train_station, ValParamRailType(), X, 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 2066 of file station_cmd.cpp.

References _current_company, _price, _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(), CheckStationSpread(), CMD_ERROR, Convert8bitBooleanCallback(), Count, DiagDirToAxis(), DriveThroughOnly, End, Execute, CommandCost::Failed(), FindJoiningRoadStop(), FindRoadStopSpot(), GB(), NewGRFClass< RoadStopSpec, RoadStopClassID >::Get(), RoadStopSpec::GetBuildCost(), NewGRFClass< RoadStopSpec, RoadStopClassID >::GetClassCount(), GetRoadBits(), GetRoadOwner(), GetRoadType(), NewGRFClass< Tspec, Tindex >::GetSpec(), NewGRFClass< Tspec, Tindex >::GetSpecCount(), RoadStopSpec::grf_prop, GRFFilePropsBase::grffile, OrthogonalTileArea::h, INVALID_ROADTYPE, INVALID_TILE, IsNormalRoadTile(), IsStationRoadStop(), IsTileType(), IsValidDiagDirection(), SpecializedStation< Station, false >::IsValidID(), IsValidTile(), IsWaypointClass(), RailStationTileLayout< T >::length, RoadStop::MakeDriveThrough(), MakeDriveThroughRoadStop(), MakeRoadStop(), MarkTileDirtyByTile(), MayHaveRoad(), BaseStation::owner, RemoveRoadStop(), Road, ROAD_STOP_TRACKBIT_FACTOR, ROADSTOPTYPE_ALL, ROADSTOPTYPE_FREIGHT, ROADSTOPTYPE_PASSENGER, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetCustomRoadStopSpecIndex(), BaseStation::spread, Station, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TileAddWrap(), Tram, 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 4498 of file station_cmd.cpp.

References CheckOwnership(), CMD_ERROR, OrthogonalTileArea::Contains(), Execute, CommandCost::Failed(), ForAllStationsRadius(), SpecializedStation< Station, false >::GetIfValid(), Station::MoveSign(), BaseStation::owner, OWNER_NONE, Station::RecomputeCatchment(), BaseStation::spread, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Station::UpdateVirtCoord(), and BaseStation::xy.

◆ CmdOpenCloseAirport()

◆ 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 _price, ClearStationRail, CMD_ERROR, CommandCost::Failed(), OrthogonalTileArea::IsEmpty(), RemoveFromRailBaseStation(), SetWindowWidgetDirty(), Map::Size(), BaseStation::train_station, and WID_SV_TRAINS.

◆ 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 2481 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 4461 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(), and Utf8StringLength().

◆ GetAirportNoiseLevelForDistance()

uint8_t GetAirportNoiseLevelForDistance ( const AirportSpec * as,
uint distance )
extern

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

References _settings_game, and AirportSpec::noise_level.

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