Go to the documentation of this file.
10 #ifndef VEHICLE_BASE_H
11 #define VEHICLE_BASE_H
134 return this->count == other.count && MemCmpT<PalSpriteID>(this->seq, other.seq, this->count) == 0;
139 return !this->operator==(other);
147 return this->count != 0;
164 this->seq[0].
sprite = sprite;
165 this->seq[0].
pal = 0;
173 this->count = src.count;
174 for (uint i = 0; i < src.count; ++i) {
176 this->seq[i].
pal = 0;
181 void Draw(
int x,
int y,
PaletteID default_pal,
bool force_pal)
const;
224 typedef std::list<RefitDesc> RefitList;
225 typedef std::map<CargoID, uint> CapacitiesMap;
365 uint GetConsistTotalCapacity()
const;
398 return (this->direction & 1) ? speed : speed * 3 / 4;
415 return speed * 3 / 4;
427 return (this->direction & 1) ? 192 : 256;
473 for (
Vehicle *u =
this; u !=
nullptr; u = u->
Next()) {
474 u->InvalidateNewGRFCache();
529 assert(
this == this->
First());
539 virtual bool Tick() {
return true; };
551 virtual uint
Crash(
bool flooded =
false);
614 while (v->
Next() !=
nullptr) v = v->
Next();
625 while (v->
Next() !=
nullptr) v = v->
Next();
638 for (
int i = 0; i != n && v !=
nullptr; i--) v = v->
Previous();
640 for (
int i = 0; i != n && v !=
nullptr; i++) v = v->
Next();
654 for (
int i = 0; i != n && v !=
nullptr; i--) v = v->
Previous();
656 for (
int i = 0; i != n && v !=
nullptr; i++) v = v->
Next();
712 return (this->
orders.list ==
nullptr) ? INVALID_STATION : this->
orders.list->GetNextStoppingStation(
this);
778 inline void SetServiceInterval(uint16 interval) { this->
service_interval = interval; }
874 return (this->
orders.list ==
nullptr) ? nullptr : this->
orders.list->GetOrderAt(index);
883 return (this->
orders.list ==
nullptr) ? nullptr : this->
orders.list->GetLastOrder();
995 typedef size_t difference_type;
996 typedef std::forward_iterator_tag iterator_category;
1000 this->order = (this->list ==
nullptr) ?
nullptr : this->list->
GetFirstOrder();
1003 bool operator==(
const OrderIterator &other)
const {
return this->order == other.order; }
1004 bool operator!=(
const OrderIterator &other)
const {
return !(*
this == other); }
1005 Order * operator*()
const {
return this->order; }
1008 this->prev = (this->prev ==
nullptr) ? this->list->
GetFirstOrder() : this->prev->
next;
1009 this->order = (this->prev ==
nullptr) ?
nullptr : this->prev->
next;
1027 bool empty() {
return this->begin() == this->end(); }
1041 template <
class T, VehicleType Type>
1164 assert(v->
type == Type);
1175 assert(v->
type == Type);
1176 return (
const T *)v;
1186 bool sprite_has_changed =
false;
1193 if (update_delta) ((T *)
this)->T::UpdateDeltaXY();
1206 sprite_has_changed =
true;
1221 if (force_update || sprite_has_changed) {
T * GetNextVehicle() const
Get the next real (non-articulated part) vehicle in the consist.
@ GVSF_ENGINE
Engine that can be front engine, but might be placed behind another engine (not used for road vehicle...
GroundVehicleCache * GetGroundVehicleCache()
Access the ground vehicle cache of the vehicle.
virtual bool IsChainInDepot() const
Check whether the whole vehicle chain is in the depot.
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
void SkipToNextRealOrderIndex()
Advance cur_real_order_index to the next real order.
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
bool is_viewport_candidate
This vehicle can potentially be drawn on a viewport.
uint32 TileIndex
The index/ID of a Tile.
Minimal stack that uses a pool to avoid pointers.
Direction last_direction
Last direction we obtained sprites for.
@ VE_OFFSET_COUNT
Number of bits used for the offset.
@ VE_DISABLE_EFFECT
Flag to disable visual effect.
void PreDestructor()
Destroy all stuff that (still) needs the virtual functions to work properly.
static Titem * Get(size_t index)
Returns Titem with given index.
Direction
Defines the 8 directions on the map.
SpecializedVehicle< T, Type > SpecializedVehicleBase
Our type.
VehicleSpriteSeq sprite_seq
Vehicle appearance.
void CopyWithoutPalette(const VehicleSpriteSeq &src)
Copy data from another sprite sequence, while dropping all recolouring information.
Vehicle * PreviousShared() const
Get the previous vehicle of the shared vehicle chain.
VehicleOrderID GetNumManualOrders() const
Get the number of manually added orders this vehicle has.
virtual Money GetRunningCost() const
Gets the running cost of a vehicle.
Money value
Value of the vehicle.
VehiclePool _vehicle_pool
The pool with all our precious vehicles.
uint16 capacity
Capacity the vehicle will have.
bool HasEngineType() const
Check whether Vehicle::engine_type has any meaning.
uint16 & GetGroundVehicleFlags()
Access the ground vehicle flags of the vehicle.
bool IsEngineCountable() const
Check if a vehicle is counted in num_engines in each company struct.
Vehicle * Previous() const
Get the previous vehicle of this vehicle.
Vehicle * GetNextVehicle() const
Get the next real (non-articulated part) vehicle in the consist.
virtual void UpdateDeltaXY()
Updates the x and y offsets and the size of the sprite used for this vehicle.
void LeaveStation()
Perform all actions when leaving a station.
Vehicle * Next() const
Get the next vehicle of this vehicle.
T * Next() const
Get next vehicle in the chain.
@ EXPENSES_OTHER
Other expenses.
virtual int GetDisplayMaxSpeed() const
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
byte y_extent
y-extent of vehicle bounding box
uint16 UnitID
Type for the company global vehicle unit number.
uint16 remaining
Capacity remaining from before the previous refit.
bool NeedsAutomaticServicing() const
Checks if the current order should be interrupted for a service-in-depot order.
uint16 load_unload_ticks
Ticks to wait before starting next cycle.
Vehicle * GetLastEnginePart()
Get the last part of an articulated engine.
void Clear()
Clear all information.
void Set(SpriteID sprite)
Assign a single sprite to the sequence.
uint32 position_same_id_length
Cache for NewGRF var 41.
UnitID curid
last ID returned; 0 if none
byte random_bits
Bits used for determining which randomized variational spritegroups to use when drawing.
@ VE_DEFAULT
Default value to indicate that visual effect should be based on engine class.
NewGRFCache grf_cache
Cache of often used calculated NewGRF values.
@ VS_DEFPAL
Use default vehicle palette.
Tindex index
Index of this pool item.
void SetNext(Vehicle *next)
Set the next vehicle of this vehicle.
virtual uint Crash(bool flooded=false)
Crash the (whole) vehicle chain.
byte acceleration
used by train & aircraft
SpriteID sprite
The 'real' sprite.
GroupID group_id
Index of group Pool array.
Vehicle(VehicleType type=VEH_INVALID)
Vehicle constructor.
Order * old
Only used during conversion of old save games.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
GroundVehicleSubtypeFlags
Enum to handle ground vehicle subtypes.
@ VE_TYPE_ELECTRIC
Electric sparks.
Vehicle * next
pointer to the next vehicle in the chain
const GRFFile * GetGRF() const
Retrieve the NewGRF the vehicle is tied to.
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
uint8 cache_valid
Bitset that indicates which cache values are valid.
@ VF_LOADING_FINISHED
Vehicle has finished loading.
T * GetNextArticulatedPart()
Get the next part of an articulated engine.
byte running_ticks
Number of ticks this vehicle was not stopped this day.
virtual ~Vehicle()
We want to 'destruct' the right class.
@ VE_TYPE_COUNT
Number of bits used for the effect type.
void GetConsistFreeCapacities(SmallMap< CargoID, uint > &capacities) const
Get a map of cargoes and free capacities in the consist.
@ VS_TRAIN_SLOWING
Train is slowing down.
Iterator to iterate orders Supports deletion of current order.
Vehicle * GetNextArticulatedPart() const
Get the next part of an articulated engine.
friend void AfterLoadVehicles(bool part_of_load)
So we can set the previous and first pointers while loading.
EngineImageType
Visualisation contexts of vehicles and engines.
@ VEH_ROAD
Road vehicle type.
uint16 cur_speed
current speed
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
void Draw(int x, int y, PaletteID default_pal, bool force_pal) const
Draw the sprite sequence.
Owner owner
Which company owns the vehicle?
Owner
Enum for all companies/owners.
uint16 cached_cargo_age_period
Number of ticks before carried cargo is aged.
virtual bool IsInDepot() const
Check whether the vehicle is in the depot.
@ VS_AIRCRAFT_BROKEN
Aircraft is broken down.
DoCommandFlag
List of flags for a command.
@ VE_OFFSET_START
First bit that contains the offset (0 = front, 8 = centre, 15 = rear)
byte breakdowns_since_last_service
Counter for the amount of breakdowns.
void UpdateRealOrderIndex()
Skip implicit orders until cur_real_order_index is a non-implicit order.
@ NCVV_POSITION_IN_VEHICLE
This bit will be set if the NewGRF var 4D currently stored is valid.
Implementation of simple mapping class.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
CargoList that is used for vehicles.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
@ VF_STOP_LOADING
Don't load anymore during the next load cycle.
@ VE_TYPE_DIESEL
Diesel fumes.
Money GetDisplayRunningCost() const
Gets the running cost of a vehicle that can be sent into SetDParam for string processing.
@ VF_AUTOFILL_TIMETABLE
Whether the vehicle should fill in the timetable automatically.
Cache for vehicle sprites and values relating to whether they should be updated before drawing,...
IterateWrapper Orders() const
Returns an iterable ensemble of orders of a vehicle.
const Vehicle * Last() const
Get the last vehicle of this vehicle chain.
void BeginLoading()
Prepare everything to begin the loading when arriving at a station.
byte breakdown_ctr
Counter for managing breakdown events.
@ VS_HIDDEN
Vehicle is not visible.
uint16 EngineID
Unique identification number of an engine.
void UpdateVisualEffect(bool allow_power_change=true)
Update the cached visual effect.
bool IsValid() const
Check whether the sequence contains any sprites.
TileIndex dest_tile
Heading for this tile.
void HandlePathfindingResult(bool path_found)
Handle the pathfinding result, especially the lost status.
Money GetDisplayProfitThisYear() const
Gets the profit vehicle had this year.
virtual int GetDisplaySpeed() const
Gets the speed in km-ish/h that can be sent into SetDParam for string processing.
Vehicle * GetPrevVehicle() const
Get the previous real (non-articulated part) vehicle in the consist.
@ VE_TYPE_START
First bit used for the type of effect.
Cached, frequently calculated values.
Common return value for all commands.
void UpdateBoundingBoxCoordinates(bool update_cache) const
Update the bounding box co-ordinates of the vehicle.
virtual int GetCurrentMaxSpeed() const
Calculates the maximum speed of the vehicle under its current conditions.
UnitID NextID()
Returns next free UnitID.
void AddToShared(Vehicle *shared_chain)
Adds this vehicle to a shared vehicle chain.
VehStatus
Vehicle status bits in Vehicle::vehstatus.
uint32 consist_cargo_information
Cache for NewGRF var 42. (Note: The cargotype is untranslated in the cache because the accessing GRF ...
void RemoveFromShared()
Removes the vehicle from the shared order list.
@ VF_CARGO_UNLOADING
Vehicle is unloading cargo.
@ NCVV_POSITION_CONSIST_LENGTH
This bit will be set if the NewGRF var 40 currently stored is valid.
TileIndex tile
Current tile index.
void CancelReservation(StationID next, Station *st)
Return all reserved cargo packets to the station and reset all packets staged for transfer.
@ EIT_ON_MAP
Vehicle drawn in viewport.
EngineID engine_type
The type of engine used for this vehicle.
@ VS_CRASHED
Vehicle is crashed.
Sprite sequence for a vehicle part.
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
bool LoadOldVehicle(LoadgameState *ls, int num)
Load the vehicles of an old style savegame.
StationID last_station_visited
The last station we stopped at.
virtual Trackdir GetVehicleTrackdir() const
Returns the Trackdir on which the vehicle is currently located.
Helper class to perform the cargo payment.
VehicleCargoList cargo
The cargo this vehicle is carrying.
uint GetOldAdvanceSpeed(uint speed)
Determines the effective direction-specific vehicle movement speed.
VehicleFlags
Bit numbers in Vehicle::vehicle_flags.
virtual ExpensesType GetExpenseType(bool income) const
Sets the expense type associated to this vehicle type.
Class defining several overloaded accessors so we don't have to cast vehicle types that often.
Vehicle ** hash_tile_current
NOSAVE: Cache of the current hash chain.
@ GVSF_ARTICULATED_PART
Articulated part of an engine.
Order current_order
The current order (+ status, like: loading)
~FreeUnitIDGenerator()
Releases allocated memory.
int32 Date
The type to store our dates in.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
Order * GetLastOrder() const
Returns the last order of a vehicle, or nullptr if it doesn't exists.
Generates sequence of free UnitID numbers.
static T * Get(size_t index)
Gets vehicle with given index.
@ VS_STOPPED
Vehicle is stopped by the player.
int8 trip_occupancy
NOSAVE: Occupancy of vehicle of the current trip (updated after leaving a station).
uint32 GetGRFID() const
Retrieve the GRF ID of the NewGRF the vehicle is tied to.
Cached often queried values common to all vehicles.
void ShowVisualEffect() const
Draw visual effects (smoke and/or sparks) for a vehicle chain.
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
VisualEffectSpawnModel
Models for spawning visual effects.
void CopyVehicleConfigAndStatistics(const Vehicle *src)
Copy certain configurations and statistics of a vehicle after successful autoreplace/renew The functi...
void ResetRefitCaps()
Reset all refit_cap in the consist to cargo_cap.
uint16 reliability_spd_dec
Reliability decrease speed.
void UpdateViewport(bool dirty)
Update the vehicle on the viewport, updating the right hash and setting the new coordinates.
StationID last_loading_station
Last station the vehicle has stopped at and could possibly leave from with any cargo loaded.
@ VEH_INVALID
Non-existing type of vehicle.
@ VF_SERVINT_IS_CUSTOM
Service interval is custom.
Vehicle * previous_shared
NOSAVE: pointer to the previous vehicle in the shared order chain.
DepotCommand
Flags to add to p1 for goto depot commands.
Money profit_this_year
Profit this year << 8, low 8 bits are fract.
Pool< Vehicle, VehicleID, 512, 0xFF000 > VehiclePool
A vehicle pool for a little over 1 million vehicles.
bool MarkAllViewportsDirty() const
Marks viewports dirty where the vehicle's image is.
virtual void PlayLeaveStationSound() const
Play the sound associated with leaving the station.
@ GVSF_WAGON
Wagon (not used for road vehicles).
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
void FixOldVehicles()
Convert the old style vehicles into something that resembles the old new style savegames.
byte cached_vis_effect
Visual effect to show (see VisualEffect)
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...
void HandleLoading(bool mode=false)
Handle the loading of the vehicle; when not it skips through dummy orders and does nothing in all oth...
bool HasDepotOrder() const
Checks if a vehicle has a depot in its order list.
bool _network_dedicated
are we a dedicated server?
const Vehicle * Move(int n) const
Get the vehicle at offset n of this vehicle chain.
VisualEffect
Meaning of the various bits of the visual effect.
uint16 vehicle_flags
Used for gradual loading and other miscellaneous things (.
CommandCost SendToDepot(DoCommandFlag flags, DepotCommand command)
Send this vehicle to the depot using the given command(s).
uint32 company_information
Cache for NewGRF var 43.
MutableSpriteCache sprite_cache
Cache of sprites and values related to recalculating them, see MutableSpriteCache.
VehicleType
Available vehicle types.
bool IsOrderListShared() const
Check if we share our orders with another vehicle.
@ VE_TYPE_DEFAULT
Use default from engine class.
int8 y_offs
y offset for vehicle sprite
SpriteID colourmap
NOSAVE: cached colour mapping.
byte waiting_triggers
Triggers to be yet matched before rerandomizing the random bits.
@ VESM_DIESEL
Diesel model.
uint32 position_in_vehicle
Cache for NewGRF var 4D.
void IncrementRealOrderIndex()
Advanced cur_real_order_index to the next real order, keeps care of the wrap-around and invalidates t...
@ VF_BUILT_AS_PROTOTYPE
Vehicle is a prototype (accepted as exclusive preview).
Iterable ensemble of orders.
Direction direction
facing
bool * cache
array of occupied unit id numbers
static const VehicleType EXPECTED_TYPE
Specialized type.
OrderList * list
Pointer to the order list for this vehicle.
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
Vehicle * next_shared
pointer to the next vehicle that shares the order
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
byte x_extent
x-extent of vehicle bounding box
Vehicle * Move(int n)
Get the vehicle at offset n of this vehicle chain.
@ NCVV_CONSIST_CARGO_INFORMATION
This bit will be set if the NewGRF var 42 currently stored is valid.
const Vehicle * GetFirstEnginePart() const
Get the first part of an articulated engine.
VehicleCache vcache
Cache of often used vehicle values.
uint32 motion_counter
counter to occasionally play a vehicle sound.
@ GVSF_FREE_WAGON
First in a wagon chain (in depot) (not used for road vehicles).
@ VESM_NONE
No visual effect.
bool revalidate_before_draw
We need to do a GetImage() and check bounds before drawing this sprite.
Vehicle * hash_viewport_next
NOSAVE: Next vehicle in the visual location hash.
Base class for all pools.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
uint16 cargo_age_counter
Ticks till cargo is aged next.
byte tick_counter
Increased by one for each tick.
uint16 cargo_cap
total capacity
uint16 GroupID
Type for all group identifiers.
void IncrementImplicitOrderIndex()
Increments cur_implicit_order_index, keeps care of the wrap-around and invalidates the GUI.
@ NCVV_POSITION_SAME_ID_LENGTH
This bit will be set if the NewGRF var 41 currently stored is valid.
int8 x_offs
x offset for vehicle sprite
byte subspeed
fractional speed
static uint GetAdvanceSpeed(uint speed)
Determines the effective vehicle movement speed.
Order * GetFirstOrder() const
Get the first order of the vehicles order list.
static T * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
byte z_extent
z-extent of vehicle bounding box
Vehicle * GetFirstEnginePart()
Get the first part of an articulated engine.
void InvalidateNewGRFCacheOfChain()
Invalidates cached NewGRF variables of all vehicles in the chain (after the current vehicle)
uint32 PaletteID
The number of the palette.
UnitID maxid
maximum ID at the moment of constructor call
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
@ VF_SERVINT_IS_PERCENT
Service interval is percent.
CargoPayment * cargo_payment
The cargo payment we're currently in.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
union Vehicle::@51 orders
The orders currently assigned to the vehicle.
@ VE_DISABLE_WAGON_POWER
Flag to disable wagon power.
static bool IsValidID(size_t index)
Tests whether given index is a valid index for vehicle of this type.
bool HasArticulatedPart() const
Check if an engine has an articulated part.
Year build_year
Year the vehicle has been built.
Money profit_last_year
Profit last year << 8, low 8 bits are fract.
byte breakdown_chance
Current chance of breakdowns.
@ GVSF_MULTIHEADED
Engine is multiheaded (not used for road vehicles).
Combination of a palette sprite and a 'real' sprite.
UnitID unitnumber
unit number, for display purposes only
static T * GetIfValid(size_t index)
Returns vehicle if the index is a valid index for this vehicle type.
uint16 cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
@ VF_AUTOFILL_PRES_WAIT_TIME
Whether non-destructive auto-fill should preserve waiting times.
static Pool::IterateWrapper< T > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
friend bool LoadOldVehicle(LoadgameState *ls, int num)
So we can set the proper next pointer while loading.
const friend SaveLoad * GetVehicleDescription(VehicleType vt)
So we can use private/protected variables in the saveload code.
@ NCVV_END
End of the bits.
@ VE_ADVANCED_EFFECT
Flag for advanced effects.
int8 x_bb_offs
x offset of vehicle bounding box
Vehicle ** hash_viewport_prev
NOSAVE: Previous vehicle in the visual location hash.
byte breakdown_delay
Counter for managing breakdown length.
Vehicle * Last()
Get the last vehicle of this vehicle chain.
Rect coord
NOSAVE: Graphical bounding box of the vehicle, i.e. what to redraw on moves.
bool NeedsServicing() const
Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for ser...
void InvalidateNewGRFCache()
Invalidates cached NewGRF variables.
byte subtype
subtype (Filled with values from AircraftSubType/DisasterSubType/EffectVehicleType/GroundVehicleSubty...
@ VF_TIMETABLE_STARTED
Whether the vehicle has started running on the timetable yet.
Order * GetFirstOrder() const
Get the first order of the order chain.
byte day_counter
Increased by one for each day.
uint16 service_interval
The interval for (automatic) servicing; either in days or %.
@ VS_UNCLICKABLE
Vehicle is not clickable by the user (shadow vehicles).
NewGRFCacheValidValues
Bit numbers used to indicate which of the NewGRFCache values are valid.
@ GVSF_FRONT
Leading engine of a consist.
bool NeedsAutorenewing(const Company *c, bool use_renew_setting=true) const
Function to tell if a vehicle needs to be autorenewed.
@ VF_PATHFINDER_LOST
Vehicle's pathfinder is lost.
byte progress
The percentage (if divided by 256) this vehicle already crossed the tile unit.
byte CargoID
Cargo slots to indicate a cargo type within a game.
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
friend void FixOldVehicles()
Convert the old style vehicles into something that resembles the old new style savegames.
Vehicle * previous
NOSAVE: pointer to the previous vehicle in the chain.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
CargoID cargo_type
type of cargo this vehicle is carrying
byte spritenum
currently displayed sprite index 0xfd == custom sprite, 0xfe == custom second head sprite 0xff == res...
@ NCVV_COMPANY_INFORMATION
This bit will be set if the NewGRF var 43 currently stored is valid.
FreeUnitIDGenerator(VehicleType type, CompanyID owner)
Initializes the structure.
T * GetLastEnginePart()
Get the last part of an articulated engine.
virtual void OnNewDay()
Calls the new day handler of the vehicle.
PaletteID pal
The palette (use PAL_NONE) if not needed)
T * Previous() const
Get previous vehicle in the chain.
Trackdir
Enumeration for tracks and directions.
byte cargo_subtype
Used for livery refits (NewGRF variations)
@ VEH_TRAIN
Train vehicle type.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
uint GetAdvanceDistance()
Determines the vehicle "progress" needed for moving a step.
Order * GetOrder(int index) const
Returns order 'index' of a vehicle or nullptr when it doesn't exists.
VehicleType type
Type of vehicle.
virtual bool Tick()
Calls the tick handler of the vehicle.
void UpdatePositionAndViewport()
Update the position of the vehicle, and update the viewport.
uint16 reliability
Reliability.
T * First() const
Get the first vehicle in the chain.
void UpdatePosition()
Update the position of the vehicle.
Vehicle ** hash_tile_prev
NOSAVE: Previous vehicle in the tile location hash.
ExpensesType
Types of expenses.
bool HandleBreakdown()
Handle all of the aspects of a vehicle breakdown This includes adding smoke and sounds,...
int8 y_bb_offs
y offset of vehicle bounding box
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
uint32 position_consist_length
Cache for NewGRF var 40.
@ VESM_ELECTRIC
Electric model.
Specification of a rectangle with absolute coordinates of all edges.
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
Various front vehicle properties that are preserved when autoreplacing, using order-backup or switchi...
T * Last()
Get the last vehicle in the chain.
void InvalidateVehicleOrder(const Vehicle *v, int data)
Updates the widgets of a vehicle which contains the order-data.
void GetBounds(Rect *bounds) const
Determine shared bounds of all sprites.
Vehicle * hash_tile_next
NOSAVE: Next vehicle in the tile location hash.
Base class for all PoolItems.
void CopyConsistPropertiesFrom(const BaseConsist *src)
Copy properties of other BaseConsist.
void DeleteUnreachedImplicitOrders()
Delete all implicit orders which were not reached.
Vehicle * first
NOSAVE: pointer to the first vehicle in the chain.
Order * next
Pointer to next order. If nullptr, end of list.
void UpdateViewport(bool force_update, bool update_delta)
Update vehicle sprite- and position caches.
TextEffectID fill_percent_te_id
a text-effect id to a loading indicator object
T * GetPrevVehicle() const
Get the previous real (non-articulated part) vehicle in the consist.
@ VS_SHADOW
Vehicle is a shadow vehicle.
static const int32 INVALID_COORD
Sentinel for an invalid coordinate.
Rect old_coord
Co-ordinates from the last valid bounding box.
Money GetDisplayProfitLastYear() const
Gets the profit vehicle had last year.
@ VE_OFFSET_CENTRE
Value of offset corresponding to a position above the centre of the vehicle.
T * GetFirstEnginePart()
Get the first part of an articulated engine.
@ VE_TYPE_STEAM
Steam plumes.
const SaveLoad * GetVehicleDescription(VehicleType vt)
Make it possible to make the saveload tables "friends" of other classes.
Simulated cargo type and capacity for prediction of future links.
virtual TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
virtual void MarkDirty()
Marks the vehicles to be redrawn and updates cached variables.
Dynamic data of a loaded NewGRF.
uint16 refit_cap
Capacity left over from before last refit.
Cached often queried (NewGRF) values.
Date date_of_last_service
Last date the vehicle had a service at a depot.
StationIDStack GetNextStoppingStation() const
Get the next station the vehicle will stop at.
CargoID cargo
Cargo type the vehicle will be carrying.
virtual void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.