|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
10 #ifndef VEHICLE_BASE_H
11 #define VEHICLE_BASE_H
28 const uint TILE_AXIAL_DISTANCE = 192;
29 const uint TILE_CORNER_DISTANCE = 128;
137 return this->count == other.count && MemCmpT<PalSpriteID>(this->seq, other.seq, this->count) == 0;
142 return !this->operator==(other);
150 return this->count != 0;
167 this->seq[0].
sprite = sprite;
168 this->seq[0].
pal = 0;
176 this->count = src.count;
177 for (uint i = 0; i < src.count; ++i) {
179 this->seq[i].
pal = 0;
184 void Draw(
int x,
int y,
PaletteID default_pal,
bool force_pal)
const;
242 typedef std::list<RefitDesc> RefitList;
258 friend void Ptrs_VEHS();
425 return (this->direction & 1) ? speed : speed * 3 / 4;
442 return speed * 3 / 4;
454 return (this->direction & 1) ? TILE_AXIAL_DISTANCE : TILE_CORNER_DISTANCE * 2;
501 for (
Vehicle *u =
this; u !=
nullptr; u = u->
Next()) {
502 u->InvalidateNewGRFCache();
557 assert(
this == this->
First());
567 virtual bool Tick() {
return true; };
579 void ShiftDates(TimerGameEconomy::Date interval);
586 virtual uint
Crash(
bool flooded =
false);
649 while (v->
Next() !=
nullptr) v = v->
Next();
660 while (v->
Next() !=
nullptr) v = v->
Next();
673 for (
int i = 0; i != n && v !=
nullptr; i--) v = v->
Previous();
675 for (
int i = 0; i != n && v !=
nullptr; i++) v = v->
Next();
689 for (
int i = 0; i != n && v !=
nullptr; i--) v = v->
Previous();
691 for (
int i = 0; i != n && v !=
nullptr; i++) v = v->
Next();
808 inline uint16_t GetServiceInterval()
const {
return this->
service_interval; }
810 inline void SetServiceInterval(uint16_t interval) { this->
service_interval = interval; }
1031 typedef size_t difference_type;
1032 typedef std::forward_iterator_tag iterator_category;
1036 this->order = (this->list ==
nullptr) ?
nullptr : this->list->
GetFirstOrder();
1039 bool operator==(
const OrderIterator &other)
const {
return this->order == other.order; }
1040 bool operator!=(
const OrderIterator &other)
const {
return !(*
this == other); }
1041 Order * operator*()
const {
return this->order; }
1044 this->prev = (this->prev ==
nullptr) ? this->list->
GetFirstOrder() : this->prev->
next;
1045 this->order = (this->prev ==
nullptr) ?
nullptr : this->prev->
next;
1063 bool empty() {
return this->begin() == this->end(); }
1080 template <
class T, VehicleType Type>
1203 assert(v->
type == Type);
1214 assert(v->
type == Type);
1215 return (
const T *)v;
1225 bool sprite_has_changed =
false;
1232 if (update_delta) ((T *)
this)->T::UpdateDeltaXY();
1245 sprite_has_changed =
true;
1260 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.
debug_inline bool IsFrontEngine() const
Check if the vehicle is a front engine.
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
int8_t x_bb_offs
x offset of vehicle bounding box
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.
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.
uint16_t cached_cargo_age_period
Number of ticks before carried cargo is aged.
@ VE_DISABLE_EFFECT
Flag to disable visual effect.
void PreDestructor()
Destroy all stuff that (still) needs the virtual functions to work properly.
uint16_t UnitID
Type for the company global vehicle unit number.
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.
uint16_t reliability_spd_dec
Reliability decrease speed.
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.
bool HasEngineType() const
Check whether Vehicle::engine_type has any meaning.
bool IsEngineCountable() const
Check if a vehicle is counted in num_engines in each company struct.
uint16_t cargo_cap
total capacity
static const int32_t INVALID_COORD
Sentinel for an invalid coordinate.
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.
uint16_t service_interval
The interval for (automatic) servicing; either in days or %.
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
bool NeedsAutomaticServicing() const
Checks if the current order should be interrupted for a service-in-depot order.
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.
UnitID curid
last ID returned; 0 if none
Order * old_orders
Only used during conversion of old save games.
@ 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.
uint32_t GetGRFID() const
Retrieve the GRF ID of the NewGRF the vehicle is tied to.
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.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
GroundVehicleSubtypeFlags
Enum to handle ground vehicle subtypes.
uint16_t vehicle_flags
Used for gradual loading and other miscellaneous things (.
virtual uint16_t GetMaxWeight() const
Calculates the weight value that this vehicle will have when fully loaded with its current cargo.
int8_t trip_occupancy
NOSAVE: Occupancy of vehicle of the current trip (updated after leaving a station).
@ 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.
TimerGameTick::TickCounter last_loading_tick
Last TimerGameTick::counter tick that the vehicle has stopped at a station and could possibly leave w...
@ 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.
uint32_t position_in_vehicle
Cache for NewGRF var 4D.
@ 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.
virtual ClosestDepot FindClosestDepot()
Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should...
@ VEH_ROAD
Road vehicle type.
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
bool IsShared() const
Is this a shared order list?
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.
uint64_t TickCounter
The type that the tick counter is stored in.
virtual bool IsInDepot() const
Check whether the vehicle is in the depot.
uint32_t PaletteID
The number of the palette.
debug_inline bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
@ VS_AIRCRAFT_BROKEN
Aircraft is broken down.
uint32_t motion_counter
counter to occasionally play a vehicle sound.
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.
int32_t x_pos
x coordinate.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
CargoList that is used for vehicles.
@ VF_STOP_LOADING
Don't load anymore during the next load cycle.
@ VE_TYPE_DIESEL
Diesel fumes.
TimerGameEconomy::Date date_of_last_service
Last economy date the vehicle had a service at a depot.
virtual void GetImage([[maybe_unused]] Direction direction, [[maybe_unused]] EngineImageType image_type, [[maybe_unused]] VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.
Money GetDisplayRunningCost() const
Gets the running cost of a vehicle that can be sent into SetDParam for string processing.
uint16_t cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
@ 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.
uint32_t position_consist_length
Cache for NewGRF var 40.
byte breakdown_ctr
Counter for managing breakdown events.
@ VS_HIDDEN
Vehicle is not visible.
void UpdateVisualEffect(bool allow_power_change=true)
Update the cached visual effect.
DepotCommand
Flags for goto depot commands.
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.
VehicleOrderID GetNumManualOrders() const
Get number of manually added orders in the order list.
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.
bool IsWaitingForUnbunching() const
Check whether a vehicle inside a depot is waiting for unbunching.
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.
void free(const void *ptr)
Version of the standard free that accepts const pointers.
@ EIT_ON_MAP
Vehicle drawn in viewport.
uint16_t random_bits
Bits used for randomized variational spritegroups.
EngineID engine_type
The type of engine used for this vehicle.
@ VS_CRASHED
Vehicle is crashed.
Sprite sequence for a vehicle part.
bool LoadOldVehicle(LoadgameState *ls, int num)
Load the vehicles of an old style savegame.
Vehicle * GetFirstSharedVehicle() const
Get the first vehicle of this vehicle chain.
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.
uint16_t remaining
Capacity remaining from before the previous refit.
VehicleFlags
Bit numbers in Vehicle::vehicle_flags.
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.
uint32_t consist_cargo_information
Cache for NewGRF var 42. (Note: The cargotype is untranslated in the cache because the accessing GRF ...
virtual ExpensesType GetExpenseType([[maybe_unused]] bool income) const
Sets the expense type associated to this vehicle type.
uint16_t cur_speed
current speed
Order * GetLastOrder() const
Returns the last order of a vehicle, or nullptr if it doesn't exists.
Generates sequence of free UnitID numbers.
TimerGameCalendar::Year build_year
Year the vehicle has been built.
static T * Get(size_t index)
Gets vehicle with given index.
@ VS_STOPPED
Vehicle is stopped by the player.
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.
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.
Money profit_this_year
Profit this year << 8, low 8 bits are fract.
virtual void PlayLeaveStationSound([[maybe_unused]] bool force=false) const
Play the sound associated with leaving the station.
int8_t y_bb_offs
y offset of vehicle bounding box
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 OnNewEconomyDay()
Calls the new economy day handler of the vehicle.
@ 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)
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.
uint16_t cargo_age_counter
Ticks till cargo is aged next.
bool _network_dedicated
are we a dedicated server?
const Vehicle * Move(int n) const
Get the vehicle at offset n of this vehicle chain.
StationIDStack GetNextStoppingStation(const Vehicle *v, const Order *first=nullptr, uint hops=0) const
Recursively determine the next deterministic station to stop at.
VisualEffect
Meaning of the various bits of the visual effect.
CommandCost SendToDepot(DoCommandFlag flags, DepotCommand command)
Send this vehicle to the depot using the given command(s).
VehicleType
Available vehicle types.
MutableSpriteCache sprite_cache
Cache of sprites and values related to recalculating them, see MutableSpriteCache.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
bool IsOrderListShared() const
Check if we share our orders with another vehicle.
@ VE_TYPE_DEFAULT
Use default from engine class.
SpriteID colourmap
NOSAVE: cached colour mapping.
byte waiting_triggers
Triggers to be yet matched before rerandomizing the random bits.
Order * GetOrderAt(int index) const
Get a certain order of the order chain.
@ VESM_DIESEL
Diesel model.
void IncrementRealOrderIndex()
Advanced cur_real_order_index to the next real order, keeps care of the wrap-around and invalidates t...
int32_t z_pos
z coordinate.
@ 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.
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
uint16_t load_unload_ticks
Ticks to wait before starting next cycle.
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_t position_same_id_length
Cache for NewGRF var 41.
@ 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.
TimerGameCalendar::Date max_age
Maximum age.
byte tick_counter
Increased by one for each tick.
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.
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.
int8_t x_offs
x offset for vehicle sprite
byte z_extent
z-extent of vehicle bounding box
TimerGameCalendar::Date date_of_last_service_newgrf
Last calendar date the vehicle had a service at a depot, unchanged by the date cheat to protect again...
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)
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...
uint16_t capacity
Capacity the vehicle will have.
@ VF_SERVINT_IS_PERCENT
Service interval is percent.
CargoPayment * cargo_payment
The cargo payment we're currently in.
uint16_t reliability
Reliability.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
Order * GetLastOrder() const
Get the last order of the order chain.
@ 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.
TimerGameCalendar::Date age
Age in days.
bool HasArticulatedPart() const
Check if an engine has an articulated part.
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).
uint16_t GroupID
Type for all group identifiers.
Combination of a palette sprite and a 'real' sprite.
UnitID unitnumber
unit number, for display purposes only
DestinationID destination
The DestinationID as used for orders.
static T * GetIfValid(size_t index)
Returns vehicle if the index is a valid index for this vehicle type.
bool HasUnbunchingOrder() const
Check if the current vehicle has an unbunching order.
@ 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.
@ NCVV_END
End of the bits.
@ VE_ADVANCED_EFFECT
Flag for advanced effects.
Vehicle ** hash_viewport_prev
NOSAVE: Previous vehicle in the visual location hash.
int32_t y_pos
y coordinate.
Structure to return information about the closest depot location, and whether it could be found.
byte breakdown_delay
Counter for managing breakdown length.
Vehicle * Last()
Get the last vehicle of this vehicle chain.
uint32_t GetDisplayMaxWeight() const
Calculates the maximum weight of the ground vehicle when loaded.
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.
@ 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.
uint32_t company_information
Cache for NewGRF var 43.
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.
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.
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
virtual void OnNewCalendarDay()
Calls the new calendar day handler of the vehicle.
PaletteID pal
The palette (use PAL_NONE) if not needed)
uint16_t & GetGroundVehicleFlags()
Access the ground vehicle flags of the vehicle.
uint16_t EngineID
Unique identification number of an engine.
T * Previous() const
Get previous vehicle in the chain.
Trackdir
Enumeration for tracks and directions.
byte cargo_subtype
Used for livery refits (NewGRF variations)
uint8_t cache_valid
Bitset that indicates which cache values are valid.
@ VEH_TRAIN
Train vehicle type.
virtual TileIndex GetOrderStationLocation([[maybe_unused]] StationID station)
Determine the location for the station where the vehicle goes to next.
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.
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,...
@ 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.
OrderList * orders
Pointer to the order list for this vehicle.
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.
void LeaveUnbunchingDepot()
Leave an unbunching depot and calculate the next departure time for shared order vehicles.
Rect old_coord
Co-ordinates from the last valid bounding box.
VehicleOrderID GetNumOrders() const
Get number of orders in the order list.
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.
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates by given interval.
T * GetFirstEnginePart()
Get the first part of an articulated engine.
@ VE_TYPE_STEAM
Steam plumes.
Simulated cargo type and capacity for prediction of future links.
int8_t y_offs
y offset for vehicle sprite
virtual void MarkDirty()
Marks the vehicles to be redrawn and updates cached variables.
Dynamic data of a loaded NewGRF.
uint16_t refit_cap
Capacity left over from before last refit.
Cached often queried (NewGRF) values.
StationIDStack GetNextStoppingStation() const
Get the next station the vehicle will stop at.
CargoID cargo
Cargo type the vehicle will be carrying.
uint32_t GetDisplayMinPowerToWeight() const
Calculates the minimum power-to-weight ratio using the maximum weight of the ground vehicle.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.