OpenTTD Source 20241224-master-gf74b0cf984
|
Road specific functions. More...
#include "road_type.h"
#include "gfx_type.h"
#include "core/bitmath_func.hpp"
#include "strings_type.h"
#include "timer/timer_game_calendar.h"
#include "core/enum_type.hpp"
#include "newgrf.h"
#include "economy_func.h"
Go to the source code of this file.
Data Structures | |
class | RoadTypeInfo |
Typedefs | |
typedef std::vector< RoadTypeLabel > | RoadTypeLabelList |
List of road type labels. | |
Enumerations | |
enum | RoadTramType : bool { RTT_ROAD , RTT_TRAM } |
enum | RoadTramTypes : uint8_t { RTTB_ROAD = 1 << RTT_ROAD , RTTB_TRAM = 1 << RTT_TRAM } |
enum | RoadTypeFlag { ROTF_CATENARY = 0 , ROTF_NO_LEVEL_CROSSING , ROTF_NO_HOUSES , ROTF_HIDDEN , ROTF_TOWN_BUILD } |
Roadtype flag bit numbers. More... | |
enum | RoadTypeFlags : uint8_t { ROTFB_NONE = 0 , ROTFB_CATENARY = 1 << ROTF_CATENARY , ROTFB_NO_LEVEL_CROSSING = 1 << ROTF_NO_LEVEL_CROSSING , ROTFB_NO_HOUSES = 1 << ROTF_NO_HOUSES , ROTFB_HIDDEN = 1 << ROTF_HIDDEN , ROTFB_TOWN_BUILD = 1 << ROTF_TOWN_BUILD } |
Roadtype flags. More... | |
enum | RoadTypeSpriteGroup { ROTSG_CURSORS , ROTSG_OVERLAY , ROTSG_GROUND , ROTSG_TUNNEL , ROTSG_CATENARY_FRONT , ROTSG_CATENARY_BACK , ROTSG_BRIDGE , ROTSG_reserved2 , ROTSG_DEPOT , ROTSG_reserved3 , ROTSG_ROADSTOP , ROTSG_ONEWAY , ROTSG_END } |
Sprite groups for a roadtype. More... | |
Functions | |
bool | RoadTypeIsRoad (RoadType roadtype) |
bool | RoadTypeIsTram (RoadType roadtype) |
RoadTramType | GetRoadTramType (RoadType roadtype) |
RoadTramType | OtherRoadTramType (RoadTramType rtt) |
const RoadTypeInfo * | GetRoadTypeInfo (RoadType roadtype) |
Returns a pointer to the Roadtype information for a given roadtype. | |
bool | HasPowerOnRoad (RoadType enginetype, RoadType tiletype) |
Checks if an engine of the given RoadType got power on a tile with a given RoadType. | |
Money | RoadBuildCost (RoadType roadtype) |
Returns the cost of building the specified roadtype. | |
Money | RoadClearCost (RoadType roadtype) |
Returns the cost of clearing the specified roadtype. | |
Money | RoadConvertCost (RoadType from, RoadType to) |
Calculates the cost of road conversion. | |
bool | RoadNoLevelCrossing (RoadType roadtype) |
Test if road disallows level crossings. | |
RoadType | GetRoadTypeByLabel (RoadTypeLabel label, bool allow_alternate_labels=true) |
Get the road type for a given label. | |
void | ResetRoadTypes () |
Reset all road type information to its default values. | |
void | InitRoadTypes () |
Resolve sprites of custom road types. | |
RoadType | AllocateRoadType (RoadTypeLabel label, RoadTramType rtt) |
Allocate a new road type label. | |
bool | HasAnyRoadTypesAvail (CompanyID company, RoadTramType rtt) |
Test if any buildable RoadType is available for a company. | |
Variables | |
static const RoadTramType | _roadtramtypes [] = { RTT_ROAD, RTT_TRAM } |
RoadTypes | _roadtypes_type |
Bitmap of road/tram types. | |
std::vector< RoadType > | _sorted_roadtypes |
RoadTypes | _roadtypes_hidden_mask |
Road specific functions.
Definition in file road.h.
typedef std::vector<RoadTypeLabel> RoadTypeLabelList |
enum RoadTypeFlag |
Roadtype flag bit numbers.
Starts with RO instead of R because R is used for rails
enum RoadTypeFlags : uint8_t |
Roadtype flags.
Starts with RO instead of R because R is used for rails
enum RoadTypeSpriteGroup |
Sprite groups for a roadtype.
Enumerator | |
---|---|
ROTSG_CURSORS | Optional: Cursor and toolbar icon images. |
ROTSG_OVERLAY | Optional: Images for overlaying track. |
ROTSG_GROUND | Required: Main group of ground images. |
ROTSG_TUNNEL | Optional: Ground images for tunnels. |
ROTSG_CATENARY_FRONT | Optional: Catenary front. |
ROTSG_CATENARY_BACK | Optional: Catenary back. |
ROTSG_BRIDGE | Required: Bridge surface images. |
ROTSG_reserved2 | Placeholder, if we need specific level crossing sprites. |
ROTSG_DEPOT | Optional: Depot images. |
ROTSG_reserved3 | Placeholder, if we add road fences (for highways). |
ROTSG_ROADSTOP | Required: Bay stop surface. |
ROTSG_ONEWAY | Optional: One-way indicator images. |
RoadType AllocateRoadType | ( | RoadTypeLabel | label, |
RoadTramType | rtt | ||
) |
Allocate a new road type label.
Definition at line 134 of file road_cmd.cpp.
References _original_roadtypes, _roadtypes_type, RoadTypeInfo::alternate_labels, ClrBit(), RoadTypeInfo::flags, RoadTypeInfo::introduces_roadtypes, RoadTypeInfo::introduction_date, TimerGameConst< struct Calendar >::INVALID_DATE, INVALID_ROADTYPE, RoadTypeInfo::label, RoadTypeInfo::powered_roadtypes, ROADTYPE_BEGIN, ROADTYPE_END, ROADTYPE_ROAD, ROADTYPE_TRAM, ROTFB_NONE, SetBit(), and RoadTypeInfo::sorting_order.
RoadType GetRoadTypeByLabel | ( | RoadTypeLabel | label, |
bool | allow_alternate_labels | ||
) |
Get the road type for a given label.
label | the roadtype label. |
allow_alternate_labels | Search in the alternate label lists as well. |
Definition at line 254 of file road.cpp.
References RoadTypeInfo::alternate_labels, GetRoadTypeInfo(), INVALID_ROADTYPE, RoadTypeInfo::label, ROADTYPE_BEGIN, and ROADTYPE_END.
Referenced by AfterLoadGRFs(), ConvertRoadTypes(), RoadTypeResolverObject::GetFeature(), GetRoadTypeTranslation(), and RoadTypeChangeInfo().
|
inline |
Returns a pointer to the Roadtype information for a given roadtype.
roadtype | the road type which the information is requested for |
Definition at line 227 of file road.h.
References ROADTYPE_END.
Referenced by AddDateIntroducedRoadTypes(), AfterLoadVehiclesPhase2(), CheckAutoreplaceValidity(), CmdBuildRoadVehicle(), CompareRoadTypes(), DrawBridgeRoadBits(), DrawRoadBits(), DrawRoadDepotSprite(), DrawRoadStopTile(), DrawRoadTypeCatenary(), DrawTile_Road(), DrawTile_TunnelBridge(), CompanyInfrastructureWindow::DrawWidget(), GetCompanyRoadTypes(), GetEngineCategoryName(), RoadVehicle::GetMaxTrackSpeed(), GetReverseRoadTypeTranslation(), GetRoadTypeByLabel(), GetRoadTypes(), GetSmallMapRoutesPixels(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSpeedLimit(), GetTownRoadType(), GetTownRoadTypeFirstIntroductionDate(), HasPowerOnRoad(), HasRoadCatenary(), HasRoadTypeAvail(), IsEngineBuildable(), NewVehicleAvailable(), BuildRoadToolbarWindow::OnClick(), BuildRoadToolbarWindow::OnInit(), BuildRoadToolbarWindow::OnPlaceMouseUp(), BuildRoadToolbarWindow::OnPlaceObject(), RoadBuildCost(), RoadMaintenanceCost(), RoadNoLevelCrossing(), RoadTypesAllowHouseHere(), ROTTChunkHandler::Save(), SetCurrentLabelLists(), ReplaceVehicleWindow::SetStringParameters(), BuildVehicleWindow::SetStringParameters(), BuildRoadToolbarWindow::SetStringParameters(), TownCanGrowRoad(), ReplaceVehicleWindow::UpdateWidgetSize(), and CompanyInfrastructureWindow::UpdateWidgetSize().
bool HasAnyRoadTypesAvail | ( | CompanyID | company, |
RoadTramType | rtt | ||
) |
Test if any buildable RoadType is available for a company.
company | the company in question |
Definition at line 143 of file road.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), and ROADTYPES_NONE.
Referenced by CanBuildVehicleInfrastructure().
Checks if an engine of the given RoadType got power on a tile with a given RoadType.
This would normally just be an equality check, but for electrified roads (which also support non-electric vehicles).
enginetype | The RoadType of the engine we are considering. |
tiletype | The RoadType of the tile we are considering. |
Definition at line 242 of file road.h.
References GetRoadTypeInfo(), and HasBit().
Referenced by CanConnectToRoad(), CheckFlatLandRoadStop(), CmdBuildRoad(), and CmdConvertRoad().
void InitRoadTypes | ( | ) |
Resolve sprites of custom road types.
Definition at line 114 of file road_cmd.cpp.
References CompareRoadTypes(), RoadTypeInfo::flags, HasBit(), ROADTYPE_BEGIN, ROADTYPE_END, ROTF_HIDDEN, and SetBit().
Referenced by AfterLoadGRFs().
void ResetRoadTypes | ( | ) |
Reset all road type information to its default values.
Definition at line 67 of file road_cmd.cpp.
References _original_roadtypes, _roadtypes_type, lengthof, ROADTYPES_NONE, and ROADTYPES_TRAM.
Referenced by ResetNewGRFData().
Returns the cost of building the specified roadtype.
roadtype | The roadtype being built. |
Definition at line 252 of file road.h.
References GetRoadTypeInfo(), and ROADTYPE_END.
Referenced by CheckFlatLandRoadStop(), CmdBuildBridge(), CmdBuildRoad(), CmdBuildSingleRail(), CmdBuildTunnel(), RoadClearCost(), RoadConvertCost(), and ShowBuildBridgeWindow().
Returns the cost of clearing the specified roadtype.
roadtype | The roadtype being removed. |
Definition at line 263 of file road.h.
References RoadBuildCost(), and ROADTYPE_END.
Referenced by RemoveRoad(), RoadConvertCost(), and TunnelBridgeClearCost().
Calculates the cost of road conversion.
from | The roadtype we are converting from |
to | The roadtype we are converting to |
Definition at line 281 of file road.h.
References RoadBuildCost(), and RoadClearCost().
Referenced by CmdConvertRoad().
|
inline |
Test if road disallows level crossings.
roadtype | The roadtype we are testing |
Definition at line 295 of file road.h.
References GetRoadTypeInfo(), HasBit(), ROADTYPE_END, and ROTF_NO_LEVEL_CROSSING.
Referenced by CmdBuildRoad(), CmdBuildSingleRail(), and CmdConvertRoad().
|
static |
|
extern |
Definition at line 56 of file road_cmd.cpp.
|
extern |
Bitmap of road/tram types.
Bit if set if a roadtype is tram.
Definition at line 62 of file road_cmd.cpp.
Referenced by AllocateRoadType(), ScenarioEditorToolbarWindow::OnPaint(), ResetRoadTypes(), and BuildRoadToolbarWindow::RoadTramToolbarGlobalHotkeys().
|
extern |
Definition at line 55 of file road_cmd.cpp.