Go to the documentation of this file.
93 Train *other_multiheaded_part;
122 int GetCursorImageOffset()
const;
125 bool Tick()
override;
127 uint
Crash(
bool flooded =
false)
override;
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a train vehicle image in the GUI.
bool IsInDepot() const override
Check whether the vehicle is in the depot.
Train * GetNextVehicle() const
Get the next real (non-articulated part) vehicle in the consist.
bool IsPrimaryVehicle() const override
Whether this is the primary vehicle in the chain.
@ 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)
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
uint16 GetMaxWeight() const override
Calculates the weight value that this vehicle will have when fully loaded with its current cargo.
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.
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
Money GetRunningCost() const override
Get running cost for the train consist.
int GetCurrentMaxSpeed() const override
Calculates the maximum speed of the vehicle under its current conditions.
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.
int cached_curve_speed_mod
curve speed modifier of the entire train
@ EXPENSES_TRAIN_REVENUE
Revenue from trains.
@ 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.
bool TrainOnCrossing(TileIndex tile)
Check if a level crossing tile has a train on it.
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.
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
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.
void MarkDirty() override
Goods at the consist have changed, update the graphics, cargo, and acceleration.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
@ VRF_LEAVING_STATION
Train is just leaving a station.
int GetAccelerationType() const
Allows to know the acceleration type of a vehicle.
uint Crash(bool flooded=false) override
The train vehicle crashed! Update its status and other parts around it.
@ VS_HIDDEN
Vehicle is not visible.
uint16 EngineID
Unique identification number of an engine.
void OnNewDay() override
Update day counters of the train vehicle.
RailType
Enumeration for all possible railtypes.
@ VRF_TRAIN_STUCK
Train can't get a path reservation.
Trackdir GetVehicleTrackdir() const override
Get the tracks of the train vehicle.
void UpdateDeltaXY() override
Updates the x and y offsets and the size of the sprite used for this vehicle.
uint8 train_slope_steepness
Steepness of hills for trains when using realistic acceleration.
virtual ~Train()
We want to 'destruct' the right class.
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.
int GetCurveSpeedModifier() const
Returns the curve speed modifier of this vehicle.
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.
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.
Coordinates of a point in 2D.
ExpensesType GetExpenseType(bool income) const override
Sets the expense type associated to this vehicle type.
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....
@ PROP_TRAIN_CURVE_SPEED_MOD
Modifier to maximum speed in curves.
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.
@ CCF_AUTOREFIT
Valid changes for autorefitting in stations.
@ PROP_TRAIN_WEIGHT
Weight in t (if dualheaded: for each single 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.
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse) override
Locate the closest depot for this consist, and return the information to the caller.
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
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const override
Get the sprite to display the train.
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
TrackBits
Bitfield corresponding to Track.
Variables that are cached to improve performance and such.
uint16 GetMaxTrackSpeed() const
Gets the maximum speed allowed by the track for this vehicle.
@ 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.
TileIndex GetOrderStationLocation(StationID station) override
Get the location of the next station to visit.
CargoID cargo_type
type of cargo this vehicle is carrying
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.
bool Tick() override
Update train vehicle data for a tick.
@ 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.
int GetDisplayMaxSpeed() const override
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
Train * GetPrevVehicle() const
Get the previous real (non-articulated part) vehicle in the consist.
AccelStatus
What is the status of our acceleration?
void NormalizeTrainVehInDepot(const Train *u)
Move all free vehicles in the depot to the train.
int GetDisplaySpeed() const override
Gets the speed in km-ish/h that can be sent into SetDParam for string processing.
void PlayLeaveStationSound(bool force=false) const override
Play a sound for a train leaving the station.
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.