OpenTTD
|
Functions related to roads. More...
Go to the source code of this file.
Macros | |
#define | FOR_EACH_SET_ROADTYPE(var, road_types) FOR_EACH_SET_BIT_EX(RoadType, var, RoadTypes, road_types) |
Iterate through each set RoadType in a RoadTypes value. |
Functions | |
static bool | IsValidRoadType (RoadType rt) |
Whether the given roadtype is valid. | |
static bool | IsValidRoadBits (RoadBits r) |
Whether the given roadtype is valid. | |
static RoadTypes | RoadTypeToRoadTypes (RoadType rt) |
Maps a RoadType to the corresponding RoadTypes value. | |
static RoadTypes | ComplementRoadTypes (RoadTypes r) |
Returns the RoadTypes which are not present in the given RoadTypes. | |
static RoadBits | ComplementRoadBits (RoadBits r) |
Calculate the complement of a RoadBits value. | |
static RoadBits | MirrorRoadBits (RoadBits r) |
Calculate the mirrored RoadBits. | |
static RoadBits | RotateRoadBits (RoadBits r, DiagDirDiff rot) |
Calculate rotated RoadBits. | |
static bool | IsStraightRoad (RoadBits r) |
Check if we've got a straight road. | |
static RoadBits | DiagDirToRoadBits (DiagDirection d) |
Create the road-part which belongs to the given DiagDirection. | |
static RoadBits | AxisToRoadBits (Axis a) |
Create the road-part which belongs to the given Axis. | |
static Money | RoadMaintenanceCost (RoadType roadtype, uint32 num) |
Calculates the maintenance cost of a number of road bits. | |
bool | HasRoadTypesAvail (const CompanyID company, const RoadTypes rts) |
Finds out, whether given company has all given RoadTypes available. | |
bool | ValParamRoadType (const RoadType rt) |
Validate functions for rail building. | |
RoadTypes | GetCompanyRoadtypes (const CompanyID company) |
Get the road types the given company can build. | |
void | UpdateLevelCrossing (TileIndex tile, bool sound=true) |
Sets correct crossing state. |
Functions related to roads.
Definition in file road_func.h.
#define FOR_EACH_SET_ROADTYPE | ( | var, | |
road_types | |||
) | FOR_EACH_SET_BIT_EX(RoadType, var, RoadTypes, road_types) |
Iterate through each set RoadType in a RoadTypes value.
For more informations see FOR_EACH_SET_BIT_EX.
var | Loop index variable that stores fallowing set road type. Must be of type RoadType. |
road_types | The value to iterate through (any expression). |
Definition at line 28 of file road_func.h.
Referenced by AfterLoadCompanyStats(), CmdBuildBridge(), CmdBuildRoadStop(), CmdBuildTunnel(), CmdRemoveRoadStop(), DoClearBridge(), DoClearTunnel(), and RemoveRoadStop().
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 159 of file road_func.h.
References AXIS_X, IsValidAxis(), ROAD_X, and ROAD_Y.
Referenced by CmdBuildLongRoad(), CmdBuildRoad(), CmdRemoveLongRoad(), CmdRemoveRoadStop(), GetAnyRoadBits(), RemoveRoad(), and RoadFindPathToDest().
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 85 of file road_func.h.
References IsValidRoadBits(), and ROAD_ALL.
Referenced by CmdBuildRoad(), and RemoveRoad().
Returns the RoadTypes which are not present in the given RoadTypes.
This function returns the complement of a given RoadTypes.
r | The given RoadTypes |
Definition at line 70 of file road_func.h.
References ROADTYPES_ALL.
Referenced by RemoveRoad().
|
inlinestatic |
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 144 of file road_func.h.
References IsValidDiagDirection(), and ROAD_NW.
Referenced by CanConnectToRoad(), CanFollowRoad(), CleanUpRoadBits(), CmdBuildLongRoad(), CmdBuildRoad(), ConnectRoadToStructure(), GetAnyRoadBits(), GetTownRoadGridElement(), GrowTownAtRoad(), GrowTownInTile(), GrowTownWithBridge(), IsNeighborRoadTile(), and RoadFindPathToDest().
Get the road types the given company can build.
company | the company to get the roadtypes for. |
Definition at line 139 of file road.cpp.
References _date, _settings_game, EngineInfo::climates, Engine::company_avail, DAYS_IN_YEAR, EF_ROAD_TRAM, GameSettings::game_creation, HasBit(), Engine::intro_date, GameCreationSettings::landscape, EngineInfo::misc_flags, ROADTYPE_ROAD, ROADTYPE_TRAM, ROADTYPES_NONE, SetBit(), and VEH_ROAD.
Referenced by AfterLoadGame(), DoStartupNewCompany(), and StartupEngines().
Finds out, whether given company has all given RoadTypes available.
company | ID of company |
rts | RoadTypes to test |
Definition at line 110 of file road.cpp.
References _generating_world, Company::avail_roadtypes, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), OWNER_DEITY, OWNER_TOWN, and ROADTYPES_ROAD.
Referenced by CmdBuildBridge(), CmdBuildRoadStop(), CmdBuildTunnel(), and ValParamRoadType().
|
inlinestatic |
Check if we've got a straight road.
r | The given RoadBits |
Definition at line 129 of file road_func.h.
References IsValidRoadBits(), ROAD_X, and ROAD_Y.
Referenced by CheckRoadSlope(), CmdBuildRoad(), and RemoveRoad().
|
inlinestatic |
Whether the given roadtype is valid.
rt | the roadtype to check for validness |
Definition at line 45 of file road_func.h.
References ROAD_END.
Referenced by ComplementRoadBits(), IsStraightRoad(), MirrorRoadBits(), and RotateRoadBits().
|
inlinestatic |
Whether the given roadtype is valid.
rt | the roadtype to check for validness |
Definition at line 35 of file road_func.h.
References ROADTYPE_ROAD, and ROADTYPE_TRAM.
Referenced by CmdBuildLongRoad(), CmdBuildRoad(), CmdBuildRoadDepot(), CmdRemoveLongRoad(), RoadMaintenanceCost(), and RoadTypeToRoadTypes().
Calculate the mirrored RoadBits.
Simply move the bits to their new position.
r | The given RoadBits value |
Definition at line 99 of file road_func.h.
References GB(), and IsValidRoadBits().
Referenced by CheckRoadSlope(), CleanUpRoadBits(), CmdBuildRoad(), and RemoveRoad().
Calculates the maintenance cost of a number of road bits.
roadtype | Road type to get the cost for. |
num | Number of road bits. |
Definition at line 172 of file road_func.h.
References IntSqrt(), IsValidRoadType(), and ROADTYPE_TRAM.
Referenced by CompaniesGenStatistics(), CompanyInfrastructureWindow::DrawWidget(), CompanyInfrastructureWindow::GetTotalMaintenanceCost(), and CompanyInfrastructureWindow::UpdateWidgetSize().
Maps a RoadType to the corresponding RoadTypes value.
rt | the roadtype to get the roadtypes from |
Definition at line 56 of file road_func.h.
References IsValidRoadType().
Referenced by AfterLoadVehicles(), CmdBuildRoad(), CmdBuildRoadVehicle(), MakeRoadDepot(), BuildRoadToolbarWindow::OnPlaceMouseUp(), BuildRoadToolbarWindow::OnPlaceObject(), BuildRoadToolbarWindow::OnPlacePresize(), RemoveRoad(), and ValParamRoadType().
|
inlinestatic |
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 114 of file road_func.h.
References GB(), and IsValidRoadBits().
void UpdateLevelCrossing | ( | TileIndex | tile, |
bool | sound | ||
) |
Sets correct crossing state.
tile | tile to update |
sound | should we play sound? |
Definition at line 1688 of file train_cmd.cpp.
References _settings_client, SoundSettings::ambient, HasCrossingReservation(), HasVehicleOnPos(), IsCrossingBarred(), IsLevelCrossingTile(), MarkTileDirtyByTile(), SetCrossingBarred(), ClientSettings::sound, TrainApproachingCrossing(), and TrainOnTileEnum().
Referenced by AfterLoadGame(), ChangeOwnershipOfCompanyItems(), CmdBuildRoad(), CmdBuildSingleRail(), Train::Crash(), DeleteLastWagon(), ReverseTrainDirection(), TrainController(), and UnreserveRailTrack().
bool ValParamRoadType | ( | const RoadType | rt | ) |
Validate functions for rail building.
rt | road type to check. |
Definition at line 129 of file road.cpp.
References _current_company, HasRoadTypesAvail(), and RoadTypeToRoadTypes().
Referenced by CmdBuildLongRoad(), CmdBuildRoad(), and CmdBuildRoadDepot().