|
OpenTTD Source
1.10.0-RC1
|
Rail specific functions. More...
#include "rail_type.h"#include "track_type.h"#include "gfx_type.h"#include "core/bitmath_func.hpp"#include "economy_func.h"#include "slope_type.h"#include "strings_type.h"#include "date_type.h"#include "signal_type.h"#include "settings_type.h"Go to the source code of this file.
Data Structures | |
| class | RailtypeInfo |
| This struct contains all the info that is needed to draw and construct tracks. More... | |
Macros | |
| #define | FOR_ALL_SORTED_RAILTYPES(var) for (uint8 index = 0; index < _sorted_railtypes.size() && (var = _sorted_railtypes[index], true) ; index++) |
| Loop header for iterating over railtypes, sorted by sortorder. More... | |
Typedefs | |
| typedef std::vector< RailTypeLabel > | RailTypeLabelList |
| List of rail type labels. More... | |
Functions | |
| static const RailtypeInfo * | GetRailTypeInfo (RailType railtype) |
| Returns a pointer to the Railtype information for a given railtype. More... | |
| static bool | IsCompatibleRail (RailType enginetype, RailType tiletype) |
| Checks if an engine of the given RailType can drive on a tile with a given RailType. More... | |
| static bool | HasPowerOnRail (RailType enginetype, RailType tiletype) |
| Checks if an engine of the given RailType got power on a tile with a given RailType. More... | |
| static bool | RailNoLevelCrossings (RailType rt) |
| Test if a RailType disallows build of level crossings. More... | |
| static bool | Rail90DegTurnDisallowed (RailType rt1, RailType rt2, bool def=_settings_game.pf.forbid_90_deg) |
| Test if 90 degree turns are disallowed between two railtypes. More... | |
| static Money | RailBuildCost (RailType railtype) |
| Returns the cost of building the specified railtype. More... | |
| static Money | RailClearCost (RailType railtype) |
| Returns the 'cost' of clearing the specified railtype. More... | |
| static Money | RailConvertCost (RailType from, RailType to) |
| Calculates the cost of rail conversion. More... | |
| static Money | RailMaintenanceCost (RailType railtype, uint32 num, uint32 total_num) |
| Calculates the maintenance cost of a number of track bits. More... | |
| static Money | SignalMaintenanceCost (uint32 num) |
| Calculates the maintenance cost of a number of signals. More... | |
| void | DrawTrainDepotSprite (int x, int y, int image, RailType railtype) |
| int | TicksToLeaveDepot (const Train *v) |
| Compute number of ticks when next wagon will leave a depot. More... | |
| Foundation | GetRailFoundation (Slope tileh, TrackBits bits) |
| Checks if a track combination is valid on a specific slope and returns the needed foundation. More... | |
| bool | HasRailtypeAvail (const CompanyID company, const RailType railtype) |
| Finds out if a company has a certain buildable railtype available. More... | |
| bool | HasAnyRailtypesAvail (const CompanyID company) |
| Test if any buildable railtype is available for a company. More... | |
| bool | ValParamRailtype (const RailType rail) |
| Validate functions for rail building. More... | |
| RailTypes | AddDateIntroducedRailTypes (RailTypes current, Date date) |
| Add the rail types that are to be introduced at the given date. More... | |
| RailTypes | GetCompanyRailtypes (CompanyID company, bool introduces=true) |
| Get the rail types the given company can build. More... | |
| RailTypes | GetRailTypes (bool introduces) |
| Get list of rail types, regardless of company availability. More... | |
| RailType | GetRailTypeByLabel (RailTypeLabel label, bool allow_alternate_labels=true) |
| Get the rail type for a given label. More... | |
| void | ResetRailTypes () |
| Reset all rail type information to its default values. | |
| void | InitRailTypes () |
| Resolve sprites of custom rail types. | |
| RailType | AllocateRailType (RailTypeLabel label) |
| Allocate a new rail type label. | |
Variables | |
| std::vector< RailType > | _sorted_railtypes |
| RailTypes | _railtypes_hidden_mask |
Rail specific functions.
Definition in file rail.h.
| #define FOR_ALL_SORTED_RAILTYPES | ( | var | ) | for (uint8 index = 0; index < _sorted_railtypes.size() && (var = _sorted_railtypes[index], true) ; index++) |
Loop header for iterating over railtypes, sorted by sortorder.
| var | Railtype. |
Definition at line 471 of file rail.h.
Referenced by GetRailTypeDropDownList().
| typedef std::vector<RailTypeLabel> RailTypeLabelList |
| enum RailFenceOffset |
Offsets from base sprite for fence sprites.
These are in the order of the sprites in the original data files.
| enum RailTrackOffset |
Offsets for sprites within an overlay/underlay set.
These are the same for overlay and underlay sprites.
| enum RailTypeFlags |
Railtype flags.
| enum RailTypeSpriteGroup |
Sprite groups for a railtype.
| Enumerator | |
|---|---|
| RTSG_CURSORS | Cursor and toolbar icon images. |
| RTSG_OVERLAY | Images for overlaying track. |
| RTSG_GROUND | Main group of ground images. |
| RTSG_TUNNEL | Main group of ground images for snow or desert. |
| RTSG_WIRES | Catenary wires. |
| RTSG_PYLONS | Catenary pylons. |
| RTSG_BRIDGE | Bridge surface images. |
| RTSG_CROSSING | Level crossing overlay images. |
| RTSG_DEPOT | Depot images. |
| RTSG_FENCES | Fence images. |
| RTSG_TUNNEL_PORTAL | Tunnel portal overlay. |
| RTSG_SIGNALS | Signal images. |
| RTSG_GROUND_COMPLETE | Complete ground images. |
Add the rail types that are to be introduced at the given date.
| current | The currently available railtypes. |
| date | The date for the introduction comparisons. |
Definition at line 218 of file rail.cpp.
References AddDateIntroducedRailTypes(), GetRailTypeInfo(), RailtypeInfo::introduces_railtypes, RailtypeInfo::introduction_date, RailtypeInfo::introduction_required_railtypes, IsInsideMM(), RailtypeInfo::label, MAX_DAY, RAILTYPE_BEGIN, and RAILTYPE_END.
Referenced by AddDateIntroducedRailTypes(), and EnginesDailyLoop().
Get the rail types the given company can build.
| company | the company to get the rail types for. |
| introduces | If true, include rail types introduced by other rail types |
Definition at line 251 of file rail.cpp.
References _date, _settings_game, EngineInfo::climates, DAYS_IN_YEAR, GameSettings::game_creation, HasBit(), Engine::IterateType(), GameCreationSettings::landscape, RAILTYPES_NONE, RAILVEH_WAGON, and VEH_TRAIN.
Referenced by GetRailTypeDropDownList(), SettingsDisableElrail(), and StartupEngines().
| Foundation GetRailFoundation | ( | Slope | tileh, |
| TrackBits | bits | ||
| ) |
Checks if a track combination is valid on a specific slope and returns the needed foundation.
| tileh | Tile slope. |
| bits | Trackbits. |
Definition at line 329 of file rail_cmd.cpp.
References _valid_tracks_on_leveled_foundation, _valid_tracks_without_foundation, CornerToTrackBits(), FOUNDATION_INCLINED_X, FOUNDATION_INCLINED_Y, FOUNDATION_INVALID, FOUNDATION_NONE, FOUNDATION_STEEP_BOTH, FOUNDATION_STEEP_LOWER, GetHighestSlopeCorner(), HalftileFoundation(), IsSteepSlope(), TRACK_BIT_LEFT, TRACK_BIT_NONE, TRACK_BIT_X, TRACK_BIT_Y, and TracksOverlap().
Referenced by CheckRailSlope(), and TestAutoslopeOnRailTile().
| RailType GetRailTypeByLabel | ( | RailTypeLabel | label, |
| bool | allow_alternate_labels | ||
| ) |
Get the rail type for a given label.
| label | the railtype label. |
| allow_alternate_labels | Search in the alternate label lists as well. |
Definition at line 311 of file rail.cpp.
References RailtypeInfo::alternate_labels, GetRailTypeInfo(), INVALID_RAILTYPE, RailtypeInfo::label, RAILTYPE_BEGIN, and RAILTYPE_END.
|
inlinestatic |
Returns a pointer to the Railtype information for a given railtype.
| railtype | the rail type which the information is requested for |
Definition at line 304 of file rail.h.
Referenced by AddDateIntroducedRailTypes(), CompareRailTypes(), DrawBridgeMiddle(), DrawTile_Road(), DrawTile_TunnelBridge(), DrawTrackBits(), Train::GetAccelerationType(), GetGlobalVariable(), Train::GetMaxTrackSpeed(), GetPylonBase(), GetRailTypeByLabel(), GetRailTypeDropDownList(), GetReverseRailTypeTranslation(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::GetSpeedLimit(), GetWireBase(), HasPowerOnRail(), HasRailCatenary(), IsCompatibleRail(), IsEngineBuildable(), BuildRailToolbarWindow::OnClick(), BuildSignalWindow::OnInit(), ReplaceVehicleWindow::OnPaint(), Rail90DegTurnDisallowed(), RailNoLevelCrossings(), BuildRailToolbarWindow::SetStringParameters(), BuildVehicleWindow::SetStringParameters(), BuildRailToolbarWindow::SetupRailToolbar(), and ReplaceVehicleWindow::UpdateWidgetSize().
| RailTypes GetRailTypes | ( | bool | introduces | ) |
Get list of rail types, regardless of company availability.
| introduces | If true, include rail types introduced by other rail types |
Definition at line 282 of file rail.cpp.
References _settings_game, EngineInfo::climates, GameSettings::game_creation, HasBit(), Engine::IterateType(), GameCreationSettings::landscape, RAILTYPES_NONE, RAILVEH_WAGON, and VEH_TRAIN.
Referenced by GetRailTypeDropDownList().
| bool HasAnyRailtypesAvail | ( | const CompanyID | company | ) |
Test if any buildable railtype is available for a company.
| company | the company in question |
Definition at line 196 of file rail.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get().
Checks if an engine of the given RailType got power on a tile with a given RailType.
This would normally just be an equality check, but for electric rails (which also support non-electric engines).
| enginetype | The RailType of the engine we are considering. |
| tiletype | The RailType of the tile we are considering. |
Definition at line 332 of file rail.h.
References GetRailTypeInfo(), HasBit(), and RailtypeInfo::powered_railtypes.
Referenced by CmdBuildRailVehicle(), CmdConvertRail(), BuildVehicleWindow::FilterSingleEngine(), Train::GetPower(), Train::GetPoweredPartPower(), and RailConvertCost().
Finds out if a company has a certain buildable railtype available.
| company | the company in question |
| railtype | requested RailType |
Definition at line 186 of file rail.cpp.
References HasBit().
Referenced by ValParamRailtype().
Checks if an engine of the given RailType can drive on a tile with a given RailType.
This would normally just be an equality check, but for electric rails (which also support non-electric engines).
| enginetype | The RailType of the engine we are considering. |
| tiletype | The RailType of the tile we are considering. |
Definition at line 319 of file rail.h.
References RailtypeInfo::compatible_railtypes, GetRailTypeInfo(), and HasBit().
Referenced by CmdBuildRailWagon(), and CmdConvertRail().
|
inlinestatic |
Test if 90 degree turns are disallowed between two railtypes.
| rt1 | First railtype to test for. |
| rt2 | Second railtype to test for. |
| def | Default value to use if the rail type doesn't specify anything. |
Definition at line 354 of file rail.h.
References RailtypeInfo::flags, GetRailTypeInfo(), HasBit(), INVALID_RAILTYPE, RTF_ALLOW_90DEG, and RTF_DISALLOW_90DEG.
Referenced by ExtendTrainReservation(), and TrainCheckIfLineEnds().
Returns the cost of building the specified railtype.
| railtype | The railtype being built. |
Definition at line 372 of file rail.h.
Referenced by RailConvertCost().
Returns the 'cost' of clearing the specified railtype.
| railtype | The railtype being removed. |
Definition at line 383 of file rail.h.
Referenced by RailConvertCost().
Calculates the cost of rail conversion.
| from | The railtype we are converting from |
| to | The railtype we are converting to |
Definition at line 400 of file rail.h.
References HasPowerOnRail(), max(), min(), RailBuildCost(), and RailClearCost().
Referenced by CmdConvertRail().
Calculates the maintenance cost of a number of track bits.
| railtype | The railtype to get the cost of. |
| num | Number of track bits of this railtype. |
| total_num | Total number of track bits of all railtypes. |
Definition at line 427 of file rail.h.
Referenced by CompanyInfrastructureWindow::GetTotalMaintenanceCost().
|
inlinestatic |
Test if a RailType disallows build of level crossings.
| rt | The RailType to check. |
Definition at line 342 of file rail.h.
References RailtypeInfo::flags, GetRailTypeInfo(), HasBit(), and RTF_NO_LEVEL_CROSSING.
Referenced by CmdConvertRail().
|
inlinestatic |
Calculates the maintenance cost of a number of signals.
| num | Number of signals. |
Definition at line 438 of file rail.h.
Referenced by CompanyInfrastructureWindow::GetTotalMaintenanceCost().
| int TicksToLeaveDepot | ( | const Train * | v | ) |
Compute number of ticks when next wagon will leave a depot.
Negative means next wagon should have left depot n ticks before.
| v | vehicle outside (leaving) the depot |
Definition at line 2930 of file rail_cmd.cpp.
References Train::CalcNextVehicleOffset(), DIAGDIR_NE, GetRailDepotDirection(), Vehicle::tile, and Vehicle::x_pos.
Referenced by AdvanceWagonsAfterSwap(), and CheckTrainsLengths().
| bool ValParamRailtype | ( | const RailType | rail | ) |
Validate functions for rail building.
| rail | the railtype to check. |
Definition at line 206 of file rail.cpp.
References _current_company, HasRailtypeAvail(), and RAILTYPE_END.
Referenced by CmdBuildBridge(), CmdBuildRailStation(), CmdBuildSingleRail(), CmdBuildTrainDepot(), CmdBuildTunnel(), CmdConvertRail(), CmdRailTrackHelper(), and ShowBuildRailToolbar().