OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
89 Train *other_multiheaded_part;
122 uint
Crash(
bool flooded =
false);
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a train vehicle image in the GUI.
Train * GetNextVehicle() const
Get the next real (non-articulated part) vehicle in the consist.
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Get the sprite to display the train.
@ VRF_TOGGLE_REVERSE
Used for vehicle var 0xFE bit 8 (toggled each time the train is reversed, accurate for first vehicle ...
@ TRACK_BIT_WORMHOLE
Bitflag for a wormhole (used for tunnels)
uint32 TileIndex
The index/ID of a Tile.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
@ CCF_CAPACITY
Allow vehicles to change capacity.
void PreDestructor()
Destroy all stuff that (still) needs the virtual functions to work properly.
Direction
Defines the 8 directions on the map.
ExpensesType GetExpenseType(bool income) const
Sets the expense type associated to this vehicle type.
bool TileMayHaveSlopedTrack() const
Checks if the vehicle is at a tile that can be sloped.
byte GetTractiveEffort() const
Allows to know the tractive effort value that this vehicle will use.
bool cached_tilt
train can tilt; feature provides a bonus in curves
EngineID first_engine
Cached EngineID of the front vehicle. INVALID_ENGINE for the front vehicle itself.
Train * Next() const
Get next vehicle in the chain.
@ PROP_TRAIN_TRACTIVE_EFFORT
Tractive effort coefficient in 1/256.
uint32 GetSlopeSteepness() const
Returns the slope steepness used by this vehicle.
@ VRF_POWEREDWAGON
Wagon is powered.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
uint16 crash_anim_pos
Crash animation counter.
static bool HasPowerOnRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType got power on a tile with a given RailType.
int UpdateSpeed()
This function looks at the vehicle and updates its speed (cur_speed and subspeed) variables.
AccelStatus GetAccelerationStatus() const
Checks the current acceleration status of this vehicle.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
byte user_def_data
Cached property 0x25. Can be set by Callback 0x36.
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse)
Locate the closest depot for this consist, and return the information to the caller.
VehicleRailFlags
Rail vehicle flags.
@ VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL
Electric train engine is allowed to run on normal rail. */.
uint16 last_speed
The last speed we did display, so we only have to redraw when this changes.
@ AS_ACCEL
We want to go faster, if possible of course.
bool IsRearDualheaded() const
Tell if we are dealing with the rear end of a multiheaded engine.
@ CCF_REFIT
Valid changes for refitting in a depot.
uint32 GetRollingFriction() const
Returns the rolling friction coefficient of this vehicle.
EngineImageType
Visualisation contexts of vehicles and engines.
uint16 cur_speed
current speed
Trackdir GetVehicleTrackdir() const
Get the tracks of the train vehicle.
uint16 GetPoweredPartPower(const Train *head) const
Returns a value if this articulated part is powered.
bool HasToUseGetSlopePixelZ()
Trains can always use the faster algorithm because they have always the same direction as the track u...
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
int GetCurrentMaxSpeed() const
Calculates the maximum speed of the vehicle under its current conditions.
@ VRF_LEAVING_STATION
Train is just leaving a station.
int GetAccelerationType() const
Allows to know the acceleration type of a vehicle.
@ VS_HIDDEN
Vehicle is not visible.
uint16 EngineID
Unique identification number of an engine.
RailType
Enumeration for all possible railtypes.
@ VRF_TRAIN_STUCK
Train can't get a path reservation.
uint8 train_slope_steepness
Steepness of hills for trains when using realistic acceleration.
virtual ~Train()
We want to 'destruct' the right class.
uint Crash(bool flooded=false)
The train vehicle crashed! Update its status and other parts around it.
TileIndex tile
Current tile index.
EngineID engine_type
The type of engine used for this vehicle.
uint8 cached_veh_length
Length of this vehicle in units of 1/VEHICLE_LENGTH of normal length. It is cached because this can b...
Sprite sequence for a vehicle part.
VehicleCargoList cargo
The cargo this vehicle is carrying.
@ CCF_ARRANGE
Valid changes for arranging the consist in a depot.
GroundVehicleCache gcache
Cache of often calculated values.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
uint16 GetCurrentSpeed() const
Calculates the current speed of this vehicle.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
@ VS_STOPPED
Vehicle is stopped by the player.
@ TRACK_BIT_X
X-axis track.
'Train' is either a loco or a wagon.
void FreeTrainTrackReservation(const Train *v)
Free the reserved path in front of a vehicle.
TileIndex GetOrderStationLocation(StationID station)
Get the location of the next station to visit.
uint8 weight
Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
Train()
We don't want GCC to zero our struct! It already is zeroed and has an index!
@ VRF_REVERSE_DIRECTION
Reverse the visible direction of the vehicle.
void MarkDirty()
Goods at the consist have changed, update the graphics, cargo, and acceleration.
Coordinates of a point in 2D.
ConsistChangeFlags
Flags for Train::ConsistChanged.
byte GetAirDragArea() const
Gets the area used for calculating air drag.
@ CCF_SAVELOAD
Valid changes when loading a savegame. (Everything that is not stored in the save....
int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, int *station_ahead, int *station_length)
Get the stop location of (the center) of the front vehicle of a train at a platform of a station.
void ReserveTrackUnderConsist() const
Tries to reserve track under whole train consist.
TrainForceProceeding
Modes for ignoring signals.
Direction direction
facing
int GetCurveSpeedLimit() const
Computes train speed limit caused by curves.
@ TRACK_BIT_DEPOT
Bitflag for a depot.
uint16 wait_counter
Ticks waiting in front of a signal, ticks being stuck or a counter for forced proceeding through sign...
uint8 acceleration_type
Acceleration type of this rail type.
VehicleCache vcache
Cache of often used vehicle values.
void PlayLeaveStationSound() const
Play a sound for a train leaving the station.
@ CCF_AUTOREFIT
Valid changes for autorefitting in stations.
@ PROP_TRAIN_WEIGHT
Weight in t (if dualheaded: for each single vehicle)
void OnNewDay()
Update day counters of the train vehicle.
void UpdateDeltaXY()
Updates the x and y offsets and the size of the sprite used for this vehicle.
@ CCF_LOADUNLOAD
Valid changes while vehicle is loading/unloading.
byte GetAirDrag() const
Gets the air drag coefficient of this vehicle.
bool TryPathReserve(Train *v, bool mark_as_stuck=false, bool first_tile_okay=false)
Try to reserve a path to a safe position.
void ConsistChanged(ConsistChangeFlags allowed_changes)
Recalculates the cached stuff of a train.
void GetTrainSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a train sprite heading west, or both heads (used for lists).
void UpdateAcceleration()
Update acceleration of the train from the cached power and weight.
Train * GetPrevUnit()
Get the previous real (non-articulated part and non rear part of dualheaded engine) vehicle in the co...
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
uint16 GetWeight() const
Allows to know the weight value that this vehicle will use.
Base class for all vehicles that move through ground.
uint16 cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
int cached_max_curve_speed
max consist speed limited by curves
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
TrackBits
Bitfield corresponding to Track.
int GetDisplayMaxSpeed() const
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
Variables that are cached to improve performance and such.
bool Tick()
Update train vehicle data for a tick.
uint16 GetMaxTrackSpeed() const
Gets the maximum speed allowed by the track for this vehicle.
Money GetRunningCost() const
Get running cost for the train consist.
@ EXPENSES_TRAIN_RUN
Running costs trains.
byte CargoID
Cargo slots to indicate a cargo type within a game.
@ TFP_SIGNAL
Ignore next signal, after the signal ignore being stuck.
@ CCF_LENGTH
Allow vehicles to change length.
void CheckTrainsLengths()
Checks if lengths of all rail vehicles are valid.
CargoID cargo_type
type of cargo this vehicle is carrying
bool IsInDepot() const
Check whether the vehicle is in the depot.
Train * GetNextUnit() const
Get the next real (non-articulated part and non rear part of dualheaded engine) vehicle in the consis...
@ TRACK_BIT_Y
Y-axis track.
int CalcNextVehicleOffset() const
Calculate the offset from this vehicle's center to the following center taking the vehicle lengths in...
@ CCF_TRACK
Valid changes while vehicle is driving, and possibly changing tracks.
VehicleSettings vehicle
options for vehicles
Trackdir
Enumeration for tracks and directions.
@ TFP_NONE
Normal operation.
@ TFP_STUCK
Proceed till next signal, but ignore being stuck till then. This includes force leaving depots.
uint16 GetPower() const
Allows to know the power value that this vehicle will use.
@ VEH_TRAIN
Train vehicle type.
@ AS_BRAKE
We want to stop.
ExpensesType
Types of expenses.
@ PROP_TRAIN_POWER
Power in hp (if dualheaded: sum of both vehicles)
RailTypes
The different railtypes we support, but then a bitmask of them.
Train * GetPrevVehicle() const
Get the previous real (non-articulated part) vehicle in the consist.
AccelStatus
What is the status of our acceleration?
int GetDisplaySpeed() const
Gets the speed in km-ish/h that can be sent into SetDParam for string processing.
@ EXPENSES_TRAIN_INC
Income from trains.
bool IsMultiheaded() const
Check if the vehicle is a multiheaded engine.
byte FreightWagonMult(CargoID cargo)
Return the cargo weight multiplier to use for a rail vehicle.