OpenTTD Source 20260911-master-gee2b2ac12a
road_cmd.h File Reference

Road related functions. More...

#include "direction_type.h"
#include "road_type.h"
#include "command_type.h"
#include "station_type.h"
#include "town_type.h"
#include "newgrf_roadstop.h"

Go to the source code of this file.

Functions

CommandCost CmdBuildLongRoad (DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, DisallowedRoadDirections drd, bool start_half, bool end_half, bool is_ai)
 Build a long piece of road.
std::tuple< CommandCost, Money > CmdRemoveLongRoad (DoCommandFlags flags, TileIndex end_tile, TileIndex start_tile, RoadType rt, Axis axis, bool start_half, bool end_half)
 Remove a long piece of road.
CommandCost CmdBuildRoad (DoCommandFlags flags, TileIndex tile, RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id)
 Build a piece of road.
CommandCost CmdBuildRoadDepot (DoCommandFlags flags, TileIndex tile, RoadType rt, DiagDirection dir)
 Build a road depot.
CommandCost CmdConvertRoad (DoCommandFlags flags, TileIndex tile, TileIndex area_start, RoadType to_type, bool diagonal)
 Convert one road subtype to another.
void CcRoadDepot (Commands cmd, const CommandCost &result, TileIndex tile, RoadType rt, DiagDirection dir)
void CcRoadStop (Commands, const CommandCost &result, TileIndex tile, uint8_t width, uint8_t length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool)
 Command callback for building road stops.

Variables

CommandCallback CcPlaySound_CONSTRUCTION_OTHER
CommandCallback CcBuildRoadTunnel

Detailed Description

Road related functions.

Definition in file road_cmd.h.

Function Documentation

◆ CcRoadDepot()

void CcRoadDepot ( Commands cmd,
const CommandCost & result,
TileIndex tile,
RoadType rt,
DiagDirection dir )

Definition at line 178 of file road_gui.cpp.

◆ CcRoadStop()

void CcRoadStop ( Commands ,
const CommandCost & result,
TileIndex tile,
uint8_t width,
uint8_t length,
RoadStopType ,
bool is_drive_through,
DiagDirection dir,
RoadType ,
RoadStopClassID spec_class,
uint16_t spec_index,
StationID ,
bool  )

Command callback for building road stops.

Parameters
resultResult of the build road stop command.
tileStart tile.
widthWidth of the road stop.
lengthLength of the road stop.
is_drive_throughFalse for normal stops, true for drive-through.
dirEntrance direction (DiagDirection) for normal stops. Converted to the axis for drive-through stops.
spec_classRoad stop spec class.
spec_indexRoad stop spec index.
See also
CmdBuildRoadStop

Definition at line 199 of file road_gui.cpp.

References _settings_client, ConnectRoadToStructure(), CommandCost::Failed(), NewGRFClass< RoadStopSpec, RoadStopClassID >::Get(), NewGRFClass< RoadStopSpec, RoadStopClassID >::GetClassCount(), NewGRFClass< Tspec, Tindex >::GetSpec(), NoAutoRoadConnection, ResetObjectToPlace(), ReverseDiagDir(), SND_1F_CONSTRUCTION_OTHER, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

Referenced by PlaceRoadStop().

◆ CmdBuildLongRoad()

CommandCost CmdBuildLongRoad ( DoCommandFlags flags,
TileIndex end_tile,
TileIndex start_tile,
RoadType rt,
Axis axis,
DisallowedRoadDirections drd,
bool start_half,
bool end_half,
bool is_ai )

Build a long piece of road.

Parameters
flagsoperation to perform
end_tileend tile of drag
start_tilestart tile of drag
rtroad type
axisdirection
drdset road direction
start_halfstart tile starts in the 2nd half of tile (p2 & 1). Only used if is_ai is set or if we are building a single tile
end_halfend tile starts in the 2nd half of tile (p2 & 2). Only used if is_ai is set or if we are building a single tile
is_aidefines two different behaviors for this command:
  • false = Build up to an obstacle. Do not build the first and last roadbits unless they can be connected to something, or if we are building a single tile
  • true = Fail if an obstacle is found. Always take into account start_half and end_half. This behavior is used for scripts
Returns
the cost of this operation or an error

Definition at line 969 of file road_cmd.cpp.

References CommandCost::AddCost(), AxisToDiagDir(), AxisToRoadBits(), CanConnectToRoad(), CMD_ERROR, Construction, DiagDirToRoadBits(), CommandCost::Failed(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Flip(), CommandCost::GetCost(), CommandCost::GetErrorMessage(), GetTunnelBridgeDirection(), IsBridge(), IsTileType(), IsValidAxis(), IsValidDisallowedRoadDirections(), Northbound, ReverseDiagDir(), Map::Size(), Southbound, TileOffsByDiagDir(), TileX(), TileY(), TunnelBridge, ValParamRoadType(), X, and Y.

◆ CmdBuildRoad()

CommandCost CmdBuildRoad ( DoCommandFlags flags,
TileIndex tile,
RoadBits pieces,
RoadType rt,
DisallowedRoadDirections toggle_drd,
TownID town_id )

Build a piece of road.

Parameters
flagsoperation to perform
tiletile where to build road
piecesroad pieces to build (RoadBits)
rtroad type
toggle_drddisallowed directions to toggle
town_idthe town that is building the road (TownID::Invalid() if not applicable)
Returns
the cost of this operation or an error

Definition at line 602 of file road_cmd.cpp.

References _current_company, _settings_game, CommandCost::AddCost(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::All(), All, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), Any, AxisToRoadBits(), AxisToTrack(), Town::cache, CalcClosestTownFromTile(), CheckOwnership(), CheckRoadSlope(), CheckTileOwnership(), CMD_ERROR, ComplementRoadBits(), Construction, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Count(), Crossing, Depot, DiagDirToRoadBits(), DirtyCompanyInfrastructureWindows(), DistanceSquare(), EnsureNoVehicleOnGround(), Execute, CommandCost::Failed(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Flip(), GetAnyRoadBits(), CommandCost::GetCost(), GetCrossingRoadAxis(), GetCrossingRoadBits(), GetDisallowedRoadDirections(), GetDriveThroughStopAxis(), GetOtherTunnelBridgeEnd(), GetRailReservationTrackBits(), GetRailTileType(), GetRailType(), GetRoadBits(), GetRoadFoundation(), GetRoadOwner(), GetRoadTileType(), GetRoadType(), GetTileOwner(), GetTileSlope(), GetTileType(), GetTrackBits(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasBit(), HasPowerOnRoad(), HasRoadWorks(), HasTileRoadType(), Company::infrastructure, INVALID_ROADTYPE, IsBridge(), IsDriveThroughStopTile(), IsNormalRoad(), IsNormalRoadTile(), IsSteepSlope(), IsStraightRoad(), IsTileType(), IsValidDisallowedRoadDirections(), IsValidRoadBits(), LEVELCROSSING_TRACKBIT_FACTOR, MakeRoadCrossing(), MakeRoadNormal(), MarkBridgeDirty(), MarkDirtyAdjacentLevelCrossingTiles(), MarkTileDirtyByTile(), MirrorRoadBits(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::None(), Normal, OtherAxis(), OWNER_DEITY, OWNER_NONE, OWNER_TOWN, CompanyInfrastructure::rail, RailNoLevelCrossings(), Railway, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), Road, ROAD_X, ROAD_Y, RoadBuildCost(), RoadNoLevelCrossing(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), SetCrossingReservation(), SetDisallowedRoadDirections(), SetRoadBits(), SetRoadOwner(), SetRoadType(), SetTownIndex(), TownCache::squared_town_zone_radius, Station, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), to_underlying(), TownEdge, Tram, TunnelBridge, TUNNELBRIDGE_TRACKBIT_FACTOR, TunnelBridgeIsFree(), UpdateCompanyRoadInfrastructure(), UpdateLevelCrossing(), VALID_LEVEL_CROSSING_SLOPES, ValParamRoadType(), X, Town::xy, Y, and YapfNotifyTrackLayoutChange().

◆ CmdBuildRoadDepot()

◆ CmdConvertRoad()

CommandCost CmdConvertRoad ( DoCommandFlags flags,
TileIndex tile,
TileIndex area_start,
RoadType to_type,
bool diagonal )

Convert one road subtype to another.

Not meant to convert from road to tram.

Parameters
flagsoperation to perform
tileend tile of road conversion drag
area_startstart tile of drag
to_typenew roadtype to convert to.
diagonalWhether a diagonal or orthogonal area is to be converted.
Returns
the cost of this operation or an error

Definition at line 2481 of file road_cmd.cpp.

References _current_company, _settings_game, CommandCost::AddCost(), CanConvertUnownedRoadType(), CheckforTownRating(), CheckOwnership(), ClosestTownFromTile(), CMD_ERROR, Construction, ConvertRoadTypeOwner(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Count(), TileIterator::Create(), EnsureNoVehicleOnGround(), Execute, CommandCost::Failed(), First, SpecializedVehicle< RoadVehicle, Type >::From(), GetAnyRoadBits(), GetEncodedStringWithArgs(), GetOtherTunnelBridgeEnd(), GetParamsForOwnedBy(), GetRoadOwner(), GetRoadType(), GetTileType(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasPowerOnRoad(), include(), INVALID_ROADTYPE, INVALID_TILE, InvalidateWindowData(), IsAnyRoadStop(), IsBayRoadStopTile(), IsBridge(), IsLevelCrossing(), IsLocalCompany(), IsRoadDepot(), IsRoadDepotTile(), CommandCost::MakeError(), MarkBridgeDirty(), MarkTileDirtyByTile(), MayHaveRoad(), OWNER_TOWN, Road, ROAD_DEPOT_TRACKBIT_FACTOR, ROAD_STOP_TRACKBIT_FACTOR, RoadConvertCost(), RoadNoLevelCrossing(), RoadRemove, CommandCost::SetEncodedMessage(), SetRoadType(), SetTunnelBridgeOwner(), Map::Size(), Station, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Tram, TunnelBridge, TUNNELBRIDGE_TRACKBIT_FACTOR, TunnelBridgeIsFree(), TunnelBridgeRemove, and ValParamRoadType().

◆ CmdRemoveLongRoad()

std::tuple< CommandCost, Money > CmdRemoveLongRoad ( DoCommandFlags flags,
TileIndex end_tile,
TileIndex start_tile,
RoadType rt,
Axis axis,
bool start_half,
bool end_half )

Remove a long piece of road.

Parameters
flagsoperation to perform
end_tileend tile of drag
start_tilestart tile of drag
rtroad type
axisdirection
start_halfstart tile starts in the 2nd half of tile
end_halfend tile starts in the 2nd half of tile (p2 & 2)
Returns
the cost of this operation or an error

Definition at line 1066 of file road_cmd.cpp.

References CommandCost::AddCost(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), AxisToRoadBits(), CMD_ERROR, Construction, Execute, ExtractCommandCost(), GetAvailableMoneyForCommand(), CommandCost::GetCost(), CommandCost::GetErrorMessage(), IsValidAxis(), NE, NW, RemoveRoad(), SE, Map::Size(), CommandCost::Succeeded(), SW, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TileOffsByAxis(), TileX(), TileY(), ValParamRoadType(), X, and Y.

Variable Documentation

◆ CcBuildRoadTunnel

CommandCallback CcBuildRoadTunnel

Definition at line 33 of file road_cmd.h.

◆ CcPlaySound_CONSTRUCTION_OTHER

CommandCallback CcPlaySound_CONSTRUCTION_OTHER

Definition at line 32 of file road_cmd.h.