OpenTTD Source
20241108-master-g80f628063a
|
Functions related to roads. More...
#include "core/bitmath_func.hpp"
#include "road.h"
#include "economy_func.h"
#include "transparency.h"
Go to the source code of this file.
Functions | |
bool | IsValidRoadBits (RoadBits r) |
Whether the given roadtype is valid. More... | |
RoadBits | ComplementRoadBits (RoadBits r) |
Calculate the complement of a RoadBits value. More... | |
RoadBits | MirrorRoadBits (RoadBits r) |
Calculate the mirrored RoadBits. More... | |
RoadBits | RotateRoadBits (RoadBits r, DiagDirDiff rot) |
Calculate rotated RoadBits. More... | |
bool | IsStraightRoad (RoadBits r) |
Check if we've got a straight road. More... | |
RoadBits | DiagDirToRoadBits (DiagDirection d) |
Create the road-part which belongs to the given DiagDirection. More... | |
RoadBits | AxisToRoadBits (Axis a) |
Create the road-part which belongs to the given Axis. More... | |
Money | RoadMaintenanceCost (RoadType roadtype, uint32_t num, uint32_t total_num) |
Calculates the maintenance cost of a number of road bits. More... | |
bool | HasRoadCatenary (RoadType roadtype) |
Test if a road type has catenary. More... | |
bool | HasRoadCatenaryDrawn (RoadType roadtype) |
Test if we should draw road catenary. More... | |
bool | HasRoadTypeAvail (CompanyID company, RoadType roadtype) |
Finds out, whether given company has a given RoadType available for construction. More... | |
bool | ValParamRoadType (RoadType roadtype) |
Validate functions for rail building. More... | |
RoadTypes | GetCompanyRoadTypes (CompanyID company, bool introduces=true) |
Get the road types the given company can build. More... | |
RoadTypes | GetRoadTypes (bool introduces) |
Get list of road types, regardless of company availability. More... | |
RoadTypes | AddDateIntroducedRoadTypes (RoadTypes current, TimerGameCalendar::Date date) |
Add the road types that are to be introduced at the given date. More... | |
void | UpdateLevelCrossing (TileIndex tile, bool sound=true, bool force_bar=false) |
Update a level crossing to barred or open (crossing may include multiple adjacent tiles). More... | |
void | MarkDirtyAdjacentLevelCrossingTiles (TileIndex tile, Axis road_axis) |
Find adjacent level crossing tiles in this multi-track crossing and mark them dirty. More... | |
void | UpdateAdjacentLevelCrossingTilesOnLevelCrossingRemoval (TileIndex tile, Axis road_axis) |
Update adjacent level crossing tiles in this multi-track crossing, due to removal of a level crossing tile. More... | |
void | UpdateCompanyRoadInfrastructure (RoadType rt, Owner o, int count) |
Update road infrastructure counts for a company. More... | |
enum Roadside uint8_t void | DrawRoadOverlays (const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rit, uint road_offset, uint tram_offset, bool draw_underlay=true) |
Draw road underlay and overlay sprites. More... | |
void | DrawRoadGroundSprites (const TileInfo *ti, RoadBits road, RoadBits tram, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, Roadside roadside, bool snow_or_desert) |
Draw road ground sprites. More... | |
Functions related to roads.
Definition in file road_func.h.
Add the road types that are to be introduced at the given date.
rt | Roadtype |
current | The currently available roadtypes. |
date | The date for the introduction comparisons. |
Definition at line 166 of file road.cpp.
References GetRoadTypeInfo(), RoadTypeInfo::introduces_roadtypes, RoadTypeInfo::introduction_date, RoadTypeInfo::introduction_required_roadtypes, IsInsideMM(), RoadTypeInfo::label, TimerGameConst< struct Calendar >::MAX_DATE, ROADTYPE_BEGIN, and ROADTYPE_END.
Referenced by GetCompanyRoadTypes(), GetRoadTypes(), and NewVehicleAvailable().
Create the road-part which belongs to the given Axis.
This function returns a RoadBits value which belongs to the given Axis.
a | The Axis |
Definition at line 111 of file road_func.h.
References AXIS_X, IsValidAxis(), ROAD_X, and ROAD_Y.
Referenced by CmdBuildLongRoad(), CmdRemoveLongRoad(), and GetAnyRoadBits().
Calculate the complement of a RoadBits value.
Simply flips all bits in the RoadBits value to get the complement of the RoadBits.
r | The given RoadBits value |
Definition at line 37 of file road_func.h.
References IsValidRoadBits(), and ROAD_ALL.
|
inline |
Create the road-part which belongs to the given DiagDirection.
This function returns a RoadBits value which belongs to the given DiagDirection.
d | The DiagDirection |
Definition at line 96 of file road_func.h.
References IsValidDiagDirection(), and ROAD_NW.
Referenced by CanFollowRoad(), CanRoadContinueIntoNextTile(), CleanUpRoadBits(), CmdBuildLongRoad(), DrawRoadTypeCatenary(), GetAnyRoadBits(), GrowTownWithBridge(), GrowTownWithTunnel(), and IsNeighborRoadTile().
void DrawRoadGroundSprites | ( | const TileInfo * | ti, |
RoadBits | road, | ||
RoadBits | tram, | ||
const RoadTypeInfo * | road_rti, | ||
const RoadTypeInfo * | tram_rti, | ||
Roadside | roadside, | ||
bool | snow_or_desert | ||
) |
Draw road ground sprites.
ti | TileInfo |
road | Road bits |
tram | Tram bits |
road_rti | Road road type information |
tram_rti | Tram road type information |
roadside | Roadside type |
snow_or_desert | Whether to draw snow/desert ground sprites |
Definition at line 1605 of file road_cmd.cpp.
References GetRoadSpriteOffset(), and TileInfo::tileh.
enum Roadside uint8_t void DrawRoadOverlays | ( | const TileInfo * | ti, |
PaletteID | pal, | ||
const RoadTypeInfo * | road_rti, | ||
const RoadTypeInfo * | tram_rti, | ||
uint | road_offset, | ||
uint | tram_offset, | ||
bool | draw_underlay | ||
) |
Draw road underlay and overlay sprites.
ti | TileInfo |
road_rti | Road road type information |
tram_rti | Tram road type information |
road_offset | Road sprite offset (based on road bits) |
tram_offset | Tram sprite offset (based on road bits) |
draw_underlay | Whether to draw underlays |
Definition at line 1515 of file road_cmd.cpp.
References DrawGroundSprite(), GetCustomRoadSprite(), ROTSG_GROUND, and TileInfo::tile.
Get the road types the given company can build.
company | the company to get the road types for. |
introduces | If true, include road types introduced by other road types |
Definition at line 199 of file road.cpp.
References _settings_game, AddDateIntroducedRoadTypes(), EngineInfo::climates, TimerGameCalendar::date, TimerGameConst< struct Calendar >::DAYS_IN_YEAR, GameSettings::game_creation, GetRoadTypeInfo(), HasBit(), RoadTypeInfo::introduces_roadtypes, Engine::IterateType(), GameCreationSettings::landscape, RoadVehicleInfo::roadtype, ROADTYPE_END, ROADTYPES_NONE, SetBit(), and VEH_ROAD.
Referenced by DisableEngineForCompany(), and EnableEngineForCompany().
RoadTypes GetRoadTypes | ( | bool | introduces | ) |
Get list of road types, regardless of company availability.
introduces | If true, include road types introduced by other road types |
Definition at line 227 of file road.cpp.
References _settings_game, AddDateIntroducedRoadTypes(), EngineInfo::climates, GameSettings::game_creation, GetRoadTypeInfo(), HasBit(), RoadTypeInfo::introduces_roadtypes, Engine::IterateType(), GameCreationSettings::landscape, TimerGameConst< struct Calendar >::MAX_DATE, RoadVehicleInfo::roadtype, ROADTYPE_END, ROADTYPES_NONE, SetBit(), and VEH_ROAD.
Referenced by ScenarioEditorToolbarWindow::OnPaint().
|
inline |
Test if a road type has catenary.
roadtype | Road type to test |
Definition at line 135 of file road_func.h.
References GetRoadTypeInfo(), HasBit(), ROADTYPE_END, and ROTF_CATENARY.
Referenced by HasRoadCatenaryDrawn().
|
inline |
Test if we should draw road catenary.
roadtype | Road type to test |
Definition at line 145 of file road_func.h.
References HasRoadCatenary(), IsInvisibilitySet(), and TO_CATENARY.
Finds out, whether given company has a given RoadType available for construction.
company | ID of company |
roadtypet | RoadType to test |
Definition at line 111 of file road.cpp.
References OWNER_DEITY, and OWNER_TOWN.
Referenced by ValParamRoadType().
|
inline |
Check if we've got a straight road.
r | The given RoadBits |
Definition at line 81 of file road_func.h.
References IsValidRoadBits(), ROAD_X, and ROAD_Y.
|
inline |
Whether the given roadtype is valid.
r | the roadtype to check for validness |
Definition at line 23 of file road_func.h.
References ROAD_END.
Referenced by ComplementRoadBits(), IsStraightRoad(), MirrorRoadBits(), and RotateRoadBits().
Find adjacent level crossing tiles in this multi-track crossing and mark them dirty.
tile | The tile which causes the update. |
road_axis | The road axis. |
Definition at line 1805 of file train_cmd.cpp.
References AxisToDiagDir(), GetCrossingRoadAxis(), IsLevelCrossingTile(), MarkTileDirtyByTile(), ReverseDiagDir(), Map::Size(), and TileAddByDiagDir().
Calculate the mirrored RoadBits.
Simply move the bits to their new position.
r | The given RoadBits value |
Definition at line 51 of file road_func.h.
References GB(), and IsValidRoadBits().
Referenced by CleanUpRoadBits().
Calculates the maintenance cost of a number of road bits.
roadtype | Road type to get the cost for. |
num | Number of road bits. |
total_num | Total number of road bits of all road/tram-types. |
Definition at line 125 of file road_func.h.
References ROADTYPE_END.
Referenced by CompaniesGenStatistics(), and CompanyInfrastructureWindow::GetTotalMaintenanceCost().
|
inline |
Calculate rotated RoadBits.
Move the Roadbits clockwise until they are in their final position.
r | The given RoadBits value |
rot | The given Rotation angle |
Definition at line 66 of file road_func.h.
References GB(), and IsValidRoadBits().
Update adjacent level crossing tiles in this multi-track crossing, due to removal of a level crossing tile.
tile | The crossing tile which has been or is about to be removed, and which caused the update. |
road_axis | The road axis. |
Definition at line 1822 of file train_cmd.cpp.
References AxisToDiagDir(), CheckLevelCrossing(), GetCrossingRoadAxis(), IsCrossingBarred(), IsLevelCrossingTile(), MarkTileDirtyByTile(), ReverseDiagDir(), SetCrossingBarred(), Map::Size(), and TileOffsByDiagDir().
Update road infrastructure counts for a company.
rt | Road type to update count of. |
o | Owner of road piece. |
count | Number of road pieces to adjust. |
Definition at line 190 of file road_cmd.cpp.
References DirtyCompanyInfrastructureWindows(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Company::infrastructure, INVALID_ROADTYPE, and CompanyInfrastructure::road.
void UpdateLevelCrossing | ( | TileIndex | tile, |
bool | sound, | ||
bool | force_bar | ||
) |
Update a level crossing to barred or open (crossing may include multiple adjacent tiles).
tile | Tile which causes the update. |
sound | Should we play sound? |
force_bar | Should we force the crossing to be barred? |
Definition at line 1773 of file train_cmd.cpp.
References AxisToDiagDir(), CheckLevelCrossing(), GetCrossingRoadAxis(), IsLevelCrossingTile(), ReverseDiagDir(), Map::Size(), TileAddByDiagDir(), and UpdateLevelCrossingTile().
Referenced by Train::Crash(), MaybeBarCrossingWithSound(), TryReserveRailTrack(), and UnreserveRailTrack().
bool ValParamRoadType | ( | RoadType | roadtype | ) |
Validate functions for rail building.
roadtype | road type to check. |
Definition at line 153 of file road.cpp.
References _current_company, HasRoadTypeAvail(), and ROADTYPE_END.
Referenced by CmdBuildBridge(), CmdBuildLongRoad(), CmdBuildRoadDepot(), CmdBuildTunnel(), CmdConvertRoad(), CmdRemoveLongRoad(), BuildRoadToolbarWindow::OnInvalidateData(), and ShowBuildRoadToolbar().