92 Train *other_multiheaded_part;
108 virtual ~Train() { this->PreDestructor(); }
121 int GetDisplayImageWidth(
Point *offset = NULL)
const;
125 uint
Crash(
bool flooded =
false);
130 void ReserveTrackUnderConsist()
const;
132 int GetCurveSpeedLimit()
const;
138 void UpdateAcceleration();
288 return 15 * (512 + this->GetCurrentSpeed()) / 512;
339 #define FOR_ALL_TRAINS(var) FOR_ALL_VEHICLES_OF_TYPE(Train, var) VehicleSettings vehicle
options for vehicles
static bool HasPowerOnRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType got power on a tile with a given RailType.
Vehicle is stopped by the player.
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
bool cached_tilt
train can tilt; feature provides a bonus in curves
VehicleCargoList cargo
The cargo this vehicle is carrying.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
ExpensesType GetExpenseType(bool income) const
Sets the expense type associated to this vehicle type.
int CalcNextVehicleOffset() const
Calculate the offset from this vehicle's center to the following center taking the vehicle lengths in...
Functions for NewGRF engines.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
RailTypes
The different roadtypes we support, but then a bitmask of them.
virtual void MarkDirty()
Marks the vehicles to be redrawn and updates cached variables.
uint8 weight
Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
AccelStatus
What is the status of our acceleration?
DirectionByte direction
facing
Train is just leaving a station.
uint16 GetCurrentSpeed() const
Calculates the current speed of this vehicle.
ConsistChangeFlags
Flags for Train::ConsistChanged.
bool TileMayHaveSlopedTrack() const
Checks if the vehicle is at a tile that can be sloped.
Power in hp (if dualheaded: sum of both vehicles)
void CheckTrainsLengths()
Checks if lengths of all rail vehicles are valid.
TrainForceProceeding
Modes for ignoring signals.
Train * GetPrevUnit()
Get the previous real (non-articulated part and non rear part of dualheaded engine) vehicle in the co...
uint16 cur_speed
current speed
Train * GetNextUnit() const
Get the next real (non-articulated part and non rear part of dualheaded engine) vehicle in the consis...
uint16 wait_counter
Ticks waiting in front of a signal, ticks being stuck or a counter for forced proceeding through sign...
uint32 GetRollingFriction() const
Returns the rolling friction coefficient of this vehicle.
virtual void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.
int GetDisplayMaxSpeed() const
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
bool IsMultiheaded() const
Check if the vehicle is a multiheaded engine.
byte user_def_data
Cached property 0x25. Can be set by Callback 0x36.
int GetDisplaySpeed() const
Gets the speed in km-ish/h that can be sent into SetDParam for string processing. ...
byte GetTractiveEffort() const
Allows to know the tractive effort value that this vehicle will use.
uint16 GetPoweredPartPower(const Train *head) const
Returns a value if this articulated part is powered.
Tractive effort coefficient in 1/256.
EngineImageType
Visualisation contexts of vehicles and engines.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
uint16 cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
Type (helpers) for enums.
Direction
Defines the 8 directions on the map.
bool HasToUseGetSlopePixelZ()
Trains can always use the faster algorithm because they have always the same direction as the track u...
Variables that are cached to improve performance and such.
EngineID first_engine
Cached EngineID of the front vehicle. INVALID_ENGINE for the front vehicle itself.
int GetAccelerationType() const
Allows to know the acceleration type of a vehicle.
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...
uint16 GetMaxTrackSpeed() const
Gets the maximum speed allowed by the track for this vehicle.
Train()
We don't want GCC to zero our struct! It already is zeroed and has an index!
uint16 crash_anim_pos
Crash animation counter.
virtual bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse)
Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should...
uint16 GetPower() const
Allows to know the power value that this vehicle will use.
T * Next() const
Get next vehicle in the chain.
uint32 GetSlopeSteepness() const
Returns the slope steepness used by this vehicle.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
AccelStatus GetAccelerationStatus() const
Checks the current acceleration status of this vehicle.
uint8 acceleration_type
Acceleration type of this rail type.
Trackdir
Enumeration for tracks and directions.
Valid changes for arranging the consist in a depot.
virtual int GetCurrentMaxSpeed() const
Calculates the maximum speed of the vehicle under its current conditions.
CargoID cargo_type
type of cargo this vehicle is carrying
bool IsFrontEngine() const
Check if the vehicle is a front engine.
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
TileIndex tile
Current tile index.
ExpensesType
Types of expenses.
Valid changes for autorefitting in stations.
bool IsRearDualheaded() const
Tell if we are dealing with the rear end of a multiheaded engine.
virtual TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
Sprite sequence for a vehicle part.
We want to go faster, if possible of course.
virtual ~Train()
We want to 'destruct' the right class.
bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
uint16 last_speed
The last speed we did display, so we only have to redraw when this changes.
'Train' is either a loco or a wagon.
virtual Money GetRunningCost() const
Gets the running cost of a vehicle.
uint8 train_slope_steepness
Steepness of hills for trains when using realistic acceleration.
Bitflag for a wormhole (used for tunnels)
static void OnNewDay()
Runs various procedures that have to be done daily.
Allow vehicles to change length.
Electric train engine is allowed to run on normal rail. */.
Train can't get a path reservation.
int cached_max_curve_speed
max consist speed limited by curves
byte FreightWagonMult(CargoID cargo)
Return the cargo weight multiplier to use for a rail vehicle.
Used for vehicle var 0xFE bit 8 (toggled each time the train is reversed, accurate for first vehicle ...
uint16 EngineID
Unique identification number of an engine.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
uint32 TileIndex
The index/ID of a Tile.
void FreeTrainTrackReservation(const Train *v)
Free the reserved path in front of a vehicle.
uint16 GetWeight() const
Allows to know the weight value that this vehicle will use.
virtual void UpdateDeltaXY(Direction direction)
Updates the x and y offsets and the size of the sprite used for this vehicle.
Valid changes while vehicle is loading/unloading.
byte GetAirDragArea() const
Gets the area used for calculating air drag.
Reverse the visible direction of the vehicle.
T * GetNextVehicle() const
Get the next real (non-articulated part) vehicle in the consist.
Types/functions related to cargoes.
Coordinates of a point in 2D.
Proceed till next signal, but ignore being stuck till then. This includes force leaving depots...
Ignore next signal, after the signal ignore being stuck.
Valid changes when loading a savegame. (Everything that is not stored in the save.)
uint8 cached_veh_length
Length of this vehicle in units of 1/VEHICLE_LENGTH of normal length. It is cached because this can b...
virtual Trackdir GetVehicleTrackdir() const
Returns the Trackdir on which the vehicle is currently located.
EngineID engine_type
The type of engine used for this vehicle.
virtual void PlayLeaveStationSound() const
Play the sound associated with leaving the station.
virtual bool Tick()
Calls the tick handler of the vehicle.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
byte CargoID
Cargo slots to indicate a cargo type within a game.
Weight in t (if dualheaded: for each single vehicle)
uint Crash(bool flooded)
Common code executed for crashed ground vehicles.
Base class for all vehicles that move through ground.
VehicleRailFlags
Rail vehicle flags.
T * GetPrevVehicle() const
Get the previous real (non-articulated part) vehicle in the consist.
byte GetAirDrag() const
Gets the air drag coefficient of this vehicle.
VehicleCache vcache
Cache of often used vehicle values.
bool TryPathReserve(Train *v, bool mark_as_stuck=false, bool first_tile_okay=false)
Try to reserve a path to a safe position.
Allow vehicles to change capacity.
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)...
Valid changes while vehicle is driving, and possibly changing tracks.
Base class and functions for all vehicles that move through ground.
Hides the direct accesses to the map array with map accessors.
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
Valid changes for refitting in a depot.
GroundVehicleCache gcache
Cache of often calculated values.
bool IsInDepot() const
Check whether the vehicle is in the depot.