OpenTTD Source 20241224-master-gf74b0cf984
|
Road related functions. More...
Go to the source code of this file.
Functions | |
void | DrawRoadDepotSprite (int x, int y, DiagDirection dir, RoadType rt) |
Draw the road depot sprite. | |
void | UpdateNearestTownForRoadTiles (bool invalidate) |
Updates cached nearest town for all road tiles. | |
CommandCost | CmdBuildLongRoad (DoCommandFlag 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 (DoCommandFlag 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 (DoCommandFlag flags, TileIndex tile, RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id) |
Build a piece of road. | |
CommandCost | CmdBuildRoadDepot (DoCommandFlag flags, TileIndex tile, RoadType rt, DiagDirection dir) |
Build a road depot. | |
CommandCost | CmdConvertRoad (DoCommandFlag flags, TileIndex tile, TileIndex area_start, RoadType to_type) |
Convert one road subtype to another. | |
void | CcRoadDepot (Commands cmd, const CommandCost &result, TileIndex tile, RoadType rt, DiagDirection dir) |
void | CcRoadStop (Commands cmd, 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 |
Road related functions.
Definition in file road_cmd.h.
void CcRoadDepot | ( | Commands | cmd, |
const CommandCost & | result, | ||
TileIndex | tile, | ||
RoadType | rt, | ||
DiagDirection | dir | ||
) |
Definition at line 173 of file road_gui.cpp.
void CcRoadStop | ( | Commands | cmd, |
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.
result | Result of the build road stop command. |
tile | Start tile. |
width | Width of the road stop. |
length | Length of the road stop. |
is_drive_through | False for normal stops, true for drive-through. |
dir | Entrance direction (DiagDirection) for normal stops. Converted to the axis for drive-through stops. |
spec_class | Road stop spec class. |
spec_index | Road stop spec index. |
Definition at line 194 of file road_gui.cpp.
References _settings_client, SoundSettings::confirm, ConnectRoadToStructure(), CommandCost::Failed(), NewGRFClass< Tspec, Tindex, Tmax >::Get(), NewGRFClass< Tspec, Tindex, Tmax >::GetClassCount(), NewGRFClass< Tspec, Tindex, Tmax >::GetSpec(), ClientSettings::gui, HasBit(), GUISettings::persistent_buildingtools, ResetObjectToPlace(), ReverseDiagDir(), RSF_NO_AUTO_ROAD_CONNECTION, SND_1F_CONSTRUCTION_OTHER, and ClientSettings::sound.
Referenced by PlaceRoadStop().
CommandCost CmdBuildLongRoad | ( | DoCommandFlag | 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.
flags | operation to perform |
end_tile | end tile of drag |
start_tile | start tile of drag |
rt | road type |
axis | direction |
drd | set road direction |
start_half | start 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_half | end 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_ai | defines two different behaviors for this command:
|
Definition at line 979 of file road_cmd.cpp.
References CommandCost::AddCost(), AXIS_X, AXIS_Y, AxisToDiagDir(), AxisToRoadBits(), CanConnectToRoad(), CMD_ERROR, DiagDirToRoadBits(), DRD_BOTH, DRD_NORTHBOUND, DRD_SOUTHBOUND, EXPENSES_CONSTRUCTION, CommandCost::Failed(), CommandCost::GetErrorMessage(), GetTunnelBridgeDirection(), IsBridge(), IsTileType(), IsValidAxis(), IsValidDisallowedRoadDirections(), MP_TUNNELBRIDGE, ReverseDiagDir(), Map::Size(), TileOffsByDiagDir(), TileX(), TileY(), and ValParamRoadType().
CommandCost CmdBuildRoad | ( | DoCommandFlag | flags, |
TileIndex | tile, | ||
RoadBits | pieces, | ||
RoadType | rt, | ||
DisallowedRoadDirections | toggle_drd, | ||
TownID | town_id | ||
) |
Build a piece of road.
flags | operation to perform |
tile | tile where to build road |
pieces | road pieces to build (RoadBits) |
rt | road type |
toggle_drd | disallowed directions to toggle |
town_id | the town that is building the road (0 if not applicable) |
Definition at line 610 of file road_cmd.cpp.
References _current_company, _settings_game, CommandCost::AddCost(), AXIS_X, AXIS_Y, AxisToRoadBits(), AxisToTrack(), ConstructionSettings::build_on_slopes, Town::cache, CalcClosestTownFromTile(), CheckOwnership(), CheckRoadSlope(), CheckTileOwnership(), CMD_ERROR, ComplementRoadBits(), GameSettings::construction, CountBits(), ConstructionSettings::crossing_with_competitor, DC_EXEC, DiagDirToRoadBits(), DirtyCompanyInfrastructureWindows(), DistanceSquare(), DRD_NONE, EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), GetAnyRoadBits(), CommandCost::GetCost(), GetCrossingRoadAxis(), GetCrossingRoadBits(), GetDisallowedRoadDirections(), GetDriveThroughStopAxis(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), GetOtherTunnelBridgeEnd(), GetRailReservationTrackBits(), GetRailTileType(), GetRailType(), GetRoadBits(), GetRoadFoundation(), GetRoadOwner(), GetRoadTileType(), GetTileOwner(), GetTileSlope(), GetTileType(), GetTrackBits(), GetTunnelBridgeDirection(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasBit(), HasExactlyOneBit(), HasPowerOnRoad(), HasRoadWorks(), HasTileRoadType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Company::infrastructure, INVALID_ROADTYPE, IsBridge(), IsDriveThroughStopTile(), IsNormalRoad(), IsNormalRoadTile(), IsSteepSlope(), IsStraightRoad(), IsTileType(), IsValidDisallowedRoadDirections(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::IsValidID(), IsValidRoadBits(), LEVELCROSSING_TRACKBIT_FACTOR, MakeRoadCrossing(), MakeRoadNormal(), MarkBridgeDirty(), MarkDirtyAdjacentLevelCrossingTiles(), MarkTileDirtyByTile(), MirrorRoadBits(), MP_RAILWAY, MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, OtherAxis(), OWNER_DEITY, OWNER_NONE, OWNER_TOWN, CompanyInfrastructure::rail, RAIL_TILE_NORMAL, RailNoLevelCrossings(), ROAD_NONE, ROAD_TILE_CROSSING, ROAD_TILE_DEPOT, ROAD_TILE_NORMAL, ROAD_X, ROAD_Y, RoadBuildCost(), RoadNoLevelCrossing(), SetCrossingReservation(), SetDisallowedRoadDirections(), SetRoadBits(), SetRoadOwner(), SetRoadType(), SetTownIndex(), TownCache::squared_town_zone_radius, TRACK_BIT_X, TRACK_BIT_Y, TRANSPORT_ROAD, TUNNELBRIDGE_TRACKBIT_FACTOR, TunnelBridgeIsFree(), UpdateCompanyRoadInfrastructure(), UpdateLevelCrossing(), VALID_LEVEL_CROSSING_SLOPES, ValParamRoadType(), Town::xy, and YapfNotifyTrackLayoutChange().
CommandCost CmdBuildRoadDepot | ( | DoCommandFlag | flags, |
TileIndex | tile, | ||
RoadType | rt, | ||
DiagDirection | dir | ||
) |
Build a road depot.
tile | tile where to build the depot |
flags | operation to perform |
rt | road type |
dir | entrance direction |
Definition at line 1149 of file road_cmd.cpp.
References _current_company, _settings_game, CommandCost::AddCost(), Depot::build_date, ConstructionSettings::build_on_slopes, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_depot_pool >::CanAllocateItem(), CanBuildDepotByTileh(), CheckTileOwnership(), CMD_ERROR, GameSettings::construction, TimerGameCalendar::date, DC_EXEC, EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), GetRoadDepotDirection(), GetTileSlope(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsBridgeAbove(), IsRoadDepotTile(), IsValidDiagDirection(), MakeDefaultName(), MakeRoadDepot(), MarkTileDirtyByTile(), ROAD_DEPOT_TRACKBIT_FACTOR, SetRoadDepotExitDirection(), SLOPE_FLAT, UpdateCompanyRoadInfrastructure(), and ValParamRoadType().
CommandCost CmdConvertRoad | ( | DoCommandFlag | flags, |
TileIndex | tile, | ||
TileIndex | area_start, | ||
RoadType | to_type | ||
) |
Convert one road subtype to another.
Not meant to convert from road to tram.
flags | operation to perform |
tile | end tile of road conversion drag |
area_start | start tile of drag |
to_type | new roadtype to convert to. |
Definition at line 2442 of file road_cmd.cpp.
References _current_company, _settings_game, CommandCost::AddCost(), CanConvertUnownedRoadType(), CheckforTownRating(), CheckOwnership(), ClosestTownFromTile(), CMD_ERROR, ConvertRoadTypeOwner(), CountBits(), DC_EXEC, DC_NONE, EconomySettings::dist_local_authority, GameSettings::economy, EnsureNoVehicleOnGround(), EXPENSES_CONSTRUCTION, CommandCost::Failed(), FindVehicleOnPos(), GetAnyRoadBits(), GetOtherTunnelBridgeEnd(), GetRoadOwner(), GetTileType(), GetTunnelBridgeLength(), GetTunnelBridgeTransportType(), HasPowerOnRoad(), INVALID_ROADTYPE, INVALID_TILE, InvalidateWindowData(), IsAnyRoadStop(), IsBayRoadStopTile(), IsBridge(), IsLevelCrossing(), IsRoadDepot(), IsRoadDepotTile(), CommandCost::MakeError(), MarkBridgeDirty(), MarkTileDirtyByTile(), MayHaveRoad(), MP_ROAD, MP_STATION, MP_TUNNELBRIDGE, OWNER_TOWN, ROAD_DEPOT_TRACKBIT_FACTOR, ROAD_REMOVE, ROAD_STOP_TRACKBIT_FACTOR, RoadConvertCost(), RoadNoLevelCrossing(), SetDParamsForOwnedBy(), SetRoadType(), SetTunnelBridgeOwner(), Map::Size(), TRANSPORT_ROAD, TUNNELBRIDGE_REMOVE, TUNNELBRIDGE_TRACKBIT_FACTOR, TunnelBridgeIsFree(), UpdateRoadVehPowerProc(), ValParamRoadType(), WC_BUILD_VEHICLE, and WC_VEHICLE_DEPOT.
std::tuple< CommandCost, Money > CmdRemoveLongRoad | ( | DoCommandFlag | flags, |
TileIndex | end_tile, | ||
TileIndex | start_tile, | ||
RoadType | rt, | ||
Axis | axis, | ||
bool | start_half, | ||
bool | end_half | ||
) |
Remove a long piece of road.
flags | operation to perform |
end_tile | end tile of drag |
start_tile | start tile of drag |
rt | road type |
axis | direction |
start_half | start tile starts in the 2nd half of tile |
end_half | end tile starts in the 2nd half of tile (p2 & 2) |
Definition at line 1075 of file road_cmd.cpp.
References CommandCost::AddCost(), AXIS_X, AXIS_Y, AxisToRoadBits(), CMD_ERROR, DC_EXEC, EXPENSES_CONSTRUCTION, GetAvailableMoneyForCommand(), CommandCost::GetCost(), CommandCost::GetErrorMessage(), IsValidAxis(), RemoveRoad(), ROAD_NE, ROAD_NW, ROAD_SE, ROAD_SW, Map::Size(), CommandCost::Succeeded(), TileOffsByAxis(), TileX(), TileY(), and ValParamRoadType().
void DrawRoadDepotSprite | ( | int | x, |
int | y, | ||
DiagDirection | dir, | ||
RoadType | rt | ||
) |
Draw the road depot sprite.
x | The x offset to draw at. |
y | The y offset to draw at. |
dir | The direction the depot must be facing. |
rt | The road type of the depot to draw. |
Definition at line 1875 of file road_cmd.cpp.
References _loaded_newgrf_features, _local_company, DiagDirToRoadBits(), DrawRailTileSeqInGUI(), DrawSprite(), RoadTypeInfo::flags, GetCustomRoadSprite(), GetRoadSpriteOffset(), GetRoadTypeInfo(), DrawTileSprites::ground, HasBit(), INVALID_TILE, ROTF_CATENARY, ROTSG_DEPOT, ROTSG_OVERLAY, SLOPE_FLAT, PalSpriteID::sprite, GRFLoadedFeatures::tram, and TRAMWAY_REPLACE_DEPOT_WITH_TRACK.
Referenced by BuildRoadDepotWindow::DrawWidget().
void UpdateNearestTownForRoadTiles | ( | bool | invalidate | ) |
Updates cached nearest town for all road tiles.
invalidate | are we just invalidating cached data? |
Definition at line 1918 of file road_cmd.cpp.
References _generating_world, CalcClosestTownFromTile(), HasTownOwnedRoad(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsRoadDepot(), IsTileType(), Map::Iterate(), MP_ROAD, and SetTownIndex().
Referenced by AfterLoadGame(), CmdFoundTown(), FoundTownWindow::OnClick(), and Town::PostDestructor().
CommandCallback CcBuildRoadTunnel |
Definition at line 35 of file road_cmd.h.
CommandCallback CcPlaySound_CONSTRUCTION_OTHER |
Definition at line 34 of file road_cmd.h.