OpenTTD Source 20250312-master-gcdcc6b491d
vehicle_base.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef VEHICLE_BASE_H
11#define VEHICLE_BASE_H
12
13#include "track_type.h"
14#include "command_type.h"
15#include "order_base.h"
16#include "cargopacket.h"
17#include "texteff.hpp"
18#include "engine_type.h"
19#include "order_func.h"
20#include "transport_type.h"
21#include "group_type.h"
22#include "base_consist.h"
23#include "network/network.h"
24#include "saveload/saveload.h"
26#include "core/mem_func.hpp"
27
28const uint TILE_AXIAL_DISTANCE = 192; // Logical length of the tile in any DiagDirection used in vehicle movement.
29const uint TILE_CORNER_DISTANCE = 128; // Logical length of the tile corner crossing in any non-diagonal direction used in vehicle movement.
30
32enum class VehState : uint8_t {
33 Hidden = 0,
34 Stopped = 1,
35 Unclickable = 2,
36 DefaultPalette = 3,
37 TrainSlowing = 4,
38 Shadow = 5,
39 AircraftBroken = 6,
40 Crashed = 7,
41};
43
57
67
70 /* Values calculated when they are requested for the first time after invalidating the NewGRF cache. */
74 uint32_t company_information = 0;
75 uint32_t position_in_vehicle = 0;
76 uint8_t cache_valid = 0;
77
78 auto operator<=>(const NewGRFCache &) const = default;
79};
80
100
110
124
127 uint16_t cached_max_speed = 0;
129
130 uint8_t cached_vis_effect = 0;
131
132 auto operator<=>(const VehicleCache &) const = default;
133};
134
137 PalSpriteID seq[8];
138 uint count;
139
140 bool operator==(const VehicleSpriteSeq &other) const
141 {
142 return this->count == other.count && MemCmpT<PalSpriteID>(this->seq, other.seq, this->count) == 0;
143 }
144
148 bool IsValid() const
149 {
150 return this->count != 0;
151 }
152
156 void Clear()
157 {
158 this->count = 0;
159 }
160
164 void Set(SpriteID sprite)
165 {
166 this->count = 1;
167 this->seq[0].sprite = sprite;
168 this->seq[0].pal = 0;
169 }
170
175 {
176 this->count = src.count;
177 for (uint i = 0; i < src.count; ++i) {
178 this->seq[i].sprite = src.seq[i].sprite;
179 this->seq[i].pal = 0;
180 }
181 }
182
183 void GetBounds(Rect *bounds) const;
184 void Draw(int x, int y, PaletteID default_pal, bool force_pal) const;
185};
186
198
202
203/* Some declarations of functions, so we can make them friendly */
204struct GroundVehicleCache;
205struct LoadgameState;
206extern bool LoadOldVehicle(LoadgameState &ls, int num);
207extern void FixOldVehicles(LoadgameState &ls);
208
209struct GRFFile;
210
221
227 TileIndex location = INVALID_TILE;
229 bool reverse = false;
230 bool found = false;
231
232 ClosestDepot() = default;
233
234 ClosestDepot(TileIndex location, DestinationID destination, bool reverse = false) :
235 location(location), destination(destination), reverse(reverse), found(true) {}
236};
237
240private:
241 typedef std::list<RefitDesc> RefitList;
242
243 Vehicle *next = nullptr;
244 Vehicle *previous = nullptr;
245 Vehicle *first = nullptr;
246
247 Vehicle *next_shared = nullptr;
249
250public:
251 friend void FixOldVehicles(LoadgameState &ls);
252 friend void AfterLoadVehiclesPhase1(bool part_of_load);
253 friend bool LoadOldVehicle(LoadgameState &ls, int num);
254 /* So we can use private/protected variables in the saveload code */
255 friend class SlVehicleCommon;
256 friend class SlVehicleDisaster;
257 friend void Ptrs_VEHS();
258
260
267
271
273
274 mutable Rect coord{};
275
278
282
284
285 /* Related to age and service time */
288 TimerGameEconomy::Date economy_age{};
290 TimerGameEconomy::Date date_of_last_service{};
292 uint16_t reliability = 0;
293 uint16_t reliability_spd_dec = 0;
294 uint8_t breakdown_ctr = 0;
295 uint8_t breakdown_delay = 0;
297 uint8_t breakdown_chance = 0;
298
299 int32_t x_pos = 0;
300 int32_t y_pos = 0;
301 int32_t z_pos = 0;
303
310 uint8_t spritenum = 0;
311 uint8_t x_extent = 0;
312 uint8_t y_extent = 0;
313 uint8_t z_extent = 0;
314 int8_t x_bb_offs = 0;
315 int8_t y_bb_offs = 0;
316 int8_t x_offs = 0;
317 int8_t y_offs = 0;
318 EngineID engine_type = EngineID::Invalid();
319
320 TextEffectID fill_percent_te_id = INVALID_TE_ID;
322
323 uint16_t cur_speed = 0;
324 uint8_t subspeed = 0;
325 uint8_t acceleration = 0;
326 uint32_t motion_counter = 0;
327 uint8_t progress = 0;
328
329 uint8_t waiting_triggers = 0;
330 uint16_t random_bits = 0;
331
332 StationID last_station_visited = StationID::Invalid();
333 StationID last_loading_station = StationID::Invalid();
335
338 uint8_t cargo_subtype = 0;
339 uint16_t cargo_cap = 0;
340 uint16_t refit_cap = 0;
341 uint16_t cargo_age_counter = 0;
342 int8_t trip_occupancy = 0;
343
344 uint8_t day_counter = 0;
345 uint8_t tick_counter = 0;
346 uint8_t running_ticks = 0;
347 uint16_t load_unload_ticks = 0;
348
350 uint8_t subtype = 0;
352
353 union {
354 OrderList *orders = nullptr;
356 };
357
360
361 GroupID group_id = GroupID::Invalid();
362
364
369 virtual uint16_t GetMaxWeight() const
370 {
371 return 0;
372 }
373
375
376 void PreDestructor();
378 virtual ~Vehicle();
379
380 void BeginLoading();
382 void LeaveStation();
383
386
387 uint16_t &GetGroundVehicleFlags();
388 const uint16_t &GetGroundVehicleFlags() const;
389
391
392 void HandleLoading(bool mode = false);
393
402 virtual void MarkDirty() {}
403
408 virtual void UpdateDeltaXY() {}
409
423 inline uint GetOldAdvanceSpeed(uint speed)
424 {
425 return (this->direction & 1) ? speed : speed * 3 / 4;
426 }
427
440 static inline uint GetAdvanceSpeed(uint speed)
441 {
442 return speed * 3 / 4;
443 }
444
452 inline uint GetAdvanceDistance()
453 {
454 return (this->direction & 1) ? TILE_AXIAL_DISTANCE : TILE_CORNER_DISTANCE * 2;
455 }
456
461 virtual ExpensesType GetExpenseType([[maybe_unused]] bool income) const { return EXPENSES_OTHER; }
462
467 virtual void PlayLeaveStationSound([[maybe_unused]] bool force = false) const {}
468
472 virtual bool IsPrimaryVehicle() const { return false; }
473
474 const Engine *GetEngine() const;
475
481 virtual void GetImage([[maybe_unused]] Direction direction, [[maybe_unused]] EngineImageType image_type, [[maybe_unused]] VehicleSpriteSeq *result) const { result->Clear(); }
482
483 const GRFFile *GetGRF() const;
484 uint32_t GetGRFID() const;
485
491 {
492 this->grf_cache.cache_valid = 0;
493 }
494
500 {
501 for (Vehicle *u = this; u != nullptr; u = u->Next()) {
502 u->InvalidateNewGRFCache();
503 }
504 }
505
510 debug_inline bool IsGroundVehicle() const
511 {
512 return this->type == VEH_TRAIN || this->type == VEH_ROAD;
513 }
514
519 virtual int GetDisplaySpeed() const { return 0; }
520
525 virtual int GetDisplayMaxSpeed() const { return 0; }
526
531 virtual int GetCurrentMaxSpeed() const { return 0; }
532
537 virtual Money GetRunningCost() const { return 0; }
538
543 virtual bool IsInDepot() const { return false; }
544
549 virtual bool IsChainInDepot() const { return this->IsInDepot(); }
550
555 bool IsStoppedInDepot() const
556 {
557 assert(this == this->First());
558 /* Free wagons have no VehState::Stopped state */
559 if (this->IsPrimaryVehicle() && !this->vehstatus.Test(VehState::Stopped)) return false;
560 return this->IsChainInDepot();
561 }
562
567 virtual bool Tick() { return true; };
568
572 virtual void OnNewCalendarDay() {};
573
577 virtual void OnNewEconomyDay() {};
578
579 void ShiftDates(TimerGameEconomy::Date interval);
580
586 virtual uint Crash(bool flooded = false);
587
600 virtual Trackdir GetVehicleTrackdir() const { return INVALID_TRACKDIR; }
601
606 Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
607
612 Money GetDisplayProfitThisYear() const { return (this->profit_this_year >> 8); }
613
618 Money GetDisplayProfitLastYear() const { return (this->profit_last_year >> 8); }
619
620 void SetNext(Vehicle *next);
621
627 inline Vehicle *Next() const { return this->next; }
628
634 inline Vehicle *Previous() const { return this->previous; }
635
640 inline Vehicle *First() const { return this->first; }
641
646 inline Vehicle *Last()
647 {
648 Vehicle *v = this;
649 while (v->Next() != nullptr) v = v->Next();
650 return v;
651 }
652
657 inline const Vehicle *Last() const
658 {
659 const Vehicle *v = this;
660 while (v->Next() != nullptr) v = v->Next();
661 return v;
662 }
663
669 inline Vehicle *Move(int n)
670 {
671 Vehicle *v = this;
672 if (n < 0) {
673 for (int i = 0; i != n && v != nullptr; i--) v = v->Previous();
674 } else {
675 for (int i = 0; i != n && v != nullptr; i++) v = v->Next();
676 }
677 return v;
678 }
679
685 inline const Vehicle *Move(int n) const
686 {
687 const Vehicle *v = this;
688 if (n < 0) {
689 for (int i = 0; i != n && v != nullptr; i--) v = v->Previous();
690 } else {
691 for (int i = 0; i != n && v != nullptr; i++) v = v->Next();
692 }
693 return v;
694 }
695
700 inline Order *GetFirstOrder() const { return (this->orders == nullptr) ? nullptr : this->orders->GetFirstOrder(); }
701
702 void AddToShared(Vehicle *shared_chain);
703 void RemoveFromShared();
704
709 inline Vehicle *NextShared() const { return this->next_shared; }
710
715 inline Vehicle *PreviousShared() const { return this->previous_shared; }
716
721 inline Vehicle *FirstShared() const { return (this->orders == nullptr) ? this->First() : this->orders->GetFirstSharedVehicle(); }
722
727 inline bool IsOrderListShared() const { return this->orders != nullptr && this->orders->IsShared(); }
728
733 inline VehicleOrderID GetNumOrders() const { return (this->orders == nullptr) ? 0 : this->orders->GetNumOrders(); }
734
739 inline VehicleOrderID GetNumManualOrders() const { return (this->orders == nullptr) ? 0 : this->orders->GetNumManualOrders(); }
740
746 {
747 return (this->orders == nullptr) ? StationID::Invalid().base() : this->orders->GetNextStoppingStation(this);
748 }
749
750 void ResetRefitCaps();
751
752 void ReleaseUnitNumber();
753
761 {
762 this->CopyConsistPropertiesFrom(src);
763
764 this->ReleaseUnitNumber();
765 this->unitnumber = src->unitnumber;
766
767 this->current_order = src->current_order;
768 this->dest_tile = src->dest_tile;
769
770 this->profit_this_year = src->profit_this_year;
771 this->profit_last_year = src->profit_last_year;
772
773 src->unitnumber = 0;
774 }
775
776
777 bool HandleBreakdown();
778
779 bool NeedsAutorenewing(const Company *c, bool use_renew_setting = true) const;
780
781 bool NeedsServicing() const;
782 bool NeedsAutomaticServicing() const;
783
791 virtual TileIndex GetOrderStationLocation([[maybe_unused]] StationID station) { return INVALID_TILE; }
792
793 virtual TileIndex GetCargoTile() const { return this->tile; }
794
800 virtual ClosestDepot FindClosestDepot() { return {}; }
801
802 virtual void SetDestTile(TileIndex tile) { this->dest_tile = tile; }
803
805
806 void UpdateVisualEffect(bool allow_power_change = true);
807 void ShowVisualEffect() const;
808
809 void UpdatePosition();
810 void UpdateViewport(bool dirty);
811 void UpdateBoundingBoxCoordinates(bool update_cache) const;
813 bool MarkAllViewportsDirty() const;
814
815 inline uint16_t GetServiceInterval() const { return this->service_interval; }
816
817 inline void SetServiceInterval(uint16_t interval) { this->service_interval = interval; }
818
819 inline bool ServiceIntervalIsCustom() const { return HasBit(this->vehicle_flags, VF_SERVINT_IS_CUSTOM); }
820
821 inline bool ServiceIntervalIsPercent() const { return HasBit(this->vehicle_flags, VF_SERVINT_IS_PERCENT); }
822
823 inline void SetServiceIntervalIsCustom(bool on) { AssignBit(this->vehicle_flags, VF_SERVINT_IS_CUSTOM, on); }
824
825 inline void SetServiceIntervalIsPercent(bool on) { AssignBit(this->vehicle_flags, VF_SERVINT_IS_PERCENT, on); }
826
827 bool HasFullLoadOrder() const;
828 bool HasConditionalOrder() const;
829 bool HasUnbunchingOrder() const;
831 bool IsWaitingForUnbunching() const;
832
833private:
839 {
840 if (this->GetNumManualOrders() > 0) {
841 /* Advance to next real order */
842 do {
843 this->cur_real_order_index++;
844 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
845 } while (this->GetOrder(this->cur_real_order_index)->IsType(OT_IMPLICIT));
846 } else {
847 this->cur_real_order_index = 0;
848 }
849 }
850
851public:
858 {
860 /* Increment real order index as well */
862 }
863
864 assert(this->cur_real_order_index == 0 || this->cur_real_order_index < this->GetNumOrders());
865
866 /* Advance to next implicit order */
867 do {
869 if (this->cur_implicit_order_index >= this->GetNumOrders()) this->cur_implicit_order_index = 0;
870 } while (this->cur_implicit_order_index != this->cur_real_order_index && !this->GetOrder(this->cur_implicit_order_index)->IsType(OT_IMPLICIT));
871
872 InvalidateVehicleOrder(this, 0);
873 }
874
882 {
884 /* Increment both real and implicit order */
886 } else {
887 /* Increment real order only */
889 InvalidateVehicleOrder(this, 0);
890 }
891 }
892
897 {
898 /* Make sure the index is valid */
899 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
900
901 if (this->GetNumManualOrders() > 0) {
902 /* Advance to next real order */
903 while (this->GetOrder(this->cur_real_order_index)->IsType(OT_IMPLICIT)) {
904 this->cur_real_order_index++;
905 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
906 }
907 } else {
908 this->cur_real_order_index = 0;
909 }
910 }
911
917 inline Order *GetOrder(int index) const
918 {
919 return (this->orders == nullptr) ? nullptr : this->orders->GetOrderAt(index);
920 }
921
926 inline Order *GetLastOrder() const
927 {
928 return (this->orders == nullptr) ? nullptr : this->orders->GetLastOrder();
929 }
930
931 bool IsEngineCountable() const;
932 bool HasEngineType() const;
933 bool HasDepotOrder() const;
934 void HandlePathfindingResult(bool path_found);
935
940 debug_inline bool IsFrontEngine() const
941 {
942 return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_FRONT);
943 }
944
949 inline bool IsArticulatedPart() const
950 {
951 return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_ARTICULATED_PART);
952 }
953
958 inline bool HasArticulatedPart() const
959 {
960 return this->Next() != nullptr && this->Next()->IsArticulatedPart();
961 }
962
969 {
970 assert(this->HasArticulatedPart());
971 return this->Next();
972 }
973
979 {
980 Vehicle *v = this;
981 while (v->IsArticulatedPart()) v = v->Previous();
982 return v;
983 }
984
989 inline const Vehicle *GetFirstEnginePart() const
990 {
991 const Vehicle *v = this;
992 while (v->IsArticulatedPart()) v = v->Previous();
993 return v;
994 }
995
1001 {
1002 Vehicle *v = this;
1003 while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart();
1004 return v;
1005 }
1006
1011 inline Vehicle *GetNextVehicle() const
1012 {
1013 const Vehicle *v = this;
1014 while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart();
1015
1016 /* v now contains the last articulated part in the engine */
1017 return v->Next();
1018 }
1019
1024 inline Vehicle *GetPrevVehicle() const
1025 {
1026 Vehicle *v = this->Previous();
1027 while (v != nullptr && v->IsArticulatedPart()) v = v->Previous();
1028
1029 return v;
1030 }
1031
1037 typedef Order value_type;
1038 typedef Order *pointer;
1039 typedef Order &reference;
1040 typedef size_t difference_type;
1041 typedef std::forward_iterator_tag iterator_category;
1042
1043 explicit OrderIterator(OrderList *list) : list(list), prev(nullptr)
1044 {
1045 this->order = (this->list == nullptr) ? nullptr : this->list->GetFirstOrder();
1046 }
1047
1048 bool operator==(const OrderIterator &other) const { return this->order == other.order; }
1049 Order * operator*() const { return this->order; }
1050 OrderIterator & operator++()
1051 {
1052 this->prev = (this->prev == nullptr) ? this->list->GetFirstOrder() : this->prev->next;
1053 this->order = (this->prev == nullptr) ? nullptr : this->prev->next;
1054 return *this;
1055 }
1056
1057 private:
1058 OrderList *list;
1059 Order *order;
1060 Order *prev;
1061 };
1062
1067 OrderList *list;
1068 IterateWrapper(OrderList *list = nullptr) : list(list) {}
1069 OrderIterator begin() { return OrderIterator(this->list); }
1070 OrderIterator end() { return OrderIterator(nullptr); }
1071 bool empty() { return this->begin() == this->end(); }
1072 };
1073
1078 IterateWrapper Orders() const { return IterateWrapper(this->orders); }
1079
1080 uint32_t GetDisplayMaxWeight() const;
1081 uint32_t GetDisplayMinPowerToWeight() const;
1082};
1083
1088template <class T, VehicleType Type>
1090 static const VehicleType EXPECTED_TYPE = Type;
1091
1093
1098 {
1099 this->sprite_cache.sprite_seq.count = 1;
1100 }
1101
1106 inline T *First() const { return (T *)this->Vehicle::First(); }
1107
1112 inline T *Last() { return (T *)this->Vehicle::Last(); }
1113
1118 inline const T *Last() const { return (const T *)this->Vehicle::Last(); }
1119
1124 inline T *Next() const { return (T *)this->Vehicle::Next(); }
1125
1130 inline T *Previous() const { return (T *)this->Vehicle::Previous(); }
1131
1137 inline T *GetNextArticulatedPart() { return (T *)this->Vehicle::GetNextArticulatedPart(); }
1138
1144 inline T *GetNextArticulatedPart() const { return (T *)this->Vehicle::GetNextArticulatedPart(); }
1145
1150 inline T *GetFirstEnginePart() { return (T *)this->Vehicle::GetFirstEnginePart(); }
1151
1156 inline const T *GetFirstEnginePart() const { return (const T *)this->Vehicle::GetFirstEnginePart(); }
1157
1162 inline T *GetLastEnginePart() { return (T *)this->Vehicle::GetLastEnginePart(); }
1163
1168 inline T *GetNextVehicle() const { return (T *)this->Vehicle::GetNextVehicle(); }
1169
1174 inline T *GetPrevVehicle() const { return (T *)this->Vehicle::GetPrevVehicle(); }
1175
1181 static inline bool IsValidID(auto index)
1182 {
1183 return Vehicle::IsValidID(index) && Vehicle::Get(index)->type == Type;
1184 }
1185
1190 static inline T *Get(auto index)
1191 {
1192 return (T *)Vehicle::Get(index);
1193 }
1194
1199 static inline T *GetIfValid(auto index)
1200 {
1201 return IsValidID(index) ? Get(index) : nullptr;
1202 }
1203
1209 static inline T *From(Vehicle *v)
1210 {
1211 assert(v->type == Type);
1212 return (T *)v;
1213 }
1214
1220 static inline const T *From(const Vehicle *v)
1221 {
1222 assert(v->type == Type);
1223 return (const T *)v;
1224 }
1225
1231 inline void UpdateViewport(bool force_update, bool update_delta)
1232 {
1233 bool sprite_has_changed = false;
1234
1235 /* Skip updating sprites on dedicated servers without screen */
1236 if (_network_dedicated) return;
1237
1238 /* Explicitly choose method to call to prevent vtable dereference -
1239 * it gives ~3% runtime improvements in games with many vehicles */
1240 if (update_delta) ((T *)this)->T::UpdateDeltaXY();
1241
1242 /*
1243 * Only check for a new sprite sequence if the vehicle direction
1244 * has changed since we last checked it, assuming that otherwise
1245 * there won't be enough change in bounding box or offsets to need
1246 * to resolve a new sprite.
1247 */
1248 if (this->direction != this->sprite_cache.last_direction || this->sprite_cache.is_viewport_candidate) {
1249 VehicleSpriteSeq seq;
1250
1251 ((T*)this)->T::GetImage(this->direction, EIT_ON_MAP, &seq);
1252 if (this->sprite_cache.sprite_seq != seq) {
1253 sprite_has_changed = true;
1254 this->sprite_cache.sprite_seq = seq;
1255 }
1256
1259 } else {
1260 /*
1261 * A change that could potentially invalidate the sprite has been
1262 * made, signal that we should still resolve it before drawing on a
1263 * viewport.
1264 */
1266 }
1267
1268 if (force_update || sprite_has_changed) {
1269 this->Vehicle::UpdateViewport(true);
1270 }
1271 }
1272
1278 static Pool::IterateWrapper<T> Iterate(size_t from = 0) { return Pool::IterateWrapper<T>(from); }
1279};
1280
1282static const int32_t INVALID_COORD = 0x7fffffff;
1283
1284#endif /* VEHICLE_BASE_H */
Properties for front vehicles/consists.
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr T AssignBit(T &x, const uint8_t y, bool value)
Assigns a bit in a variable.
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:23
Base class for cargo packets.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Common return value for all commands.
Minimal stack that uses a pool to avoid pointers.
uint64_t TickCounter
The type that the tick counter is stored in.
CargoList that is used for vehicles.
Types related to commands.
static constexpr Owner INVALID_OWNER
An invalid owner.
Direction
Defines the 8 directions on the map.
@ INVALID_DIR
Flag for an invalid direction.
ExpensesType
Types of expenses.
@ EXPENSES_OTHER
Other expenses.
Types related to engines.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:17
uint32_t PaletteID
The number of the palette.
Definition gfx_type.h:18
virtual void MarkDirty()
Marks the vehicles to be redrawn and updates cached variables.
Types of a group.
Functions related to memory operations.
bool _network_dedicated
are we a dedicated server?
Definition network.cpp:68
Basic functions/variables used all over the place.
Base class for orders.
void InvalidateVehicleOrder(const Vehicle *v, int data)
Updates the widgets of a vehicle which contains the order-data.
Functions related to orders.
uint8_t VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition order_type.h:18
Functions/types related to saving and loading games.
Various front vehicle properties that are preserved when autoreplacing, using order-backup or switchi...
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
uint16_t service_interval
The interval for (automatic) servicing; either in days or %.
void CopyConsistPropertiesFrom(const BaseConsist *src)
Copy properties of other BaseConsist.
uint16_t vehicle_flags
Used for gradual loading and other miscellaneous things (.
Base vehicle class.
VehicleType type
Type of vehicle.
Helper class to perform the cargo payment.
Structure to return information about the closest depot location, and whether it could be found.
DestinationID destination
The DestinationID as used for orders.
Dynamic data of a loaded NewGRF.
Definition newgrf.h:111
Cached, frequently calculated values.
Cache for vehicle sprites and values relating to whether they should be updated before drawing,...
bool revalidate_before_draw
We need to do a GetImage() and check bounds before drawing this sprite.
VehicleSpriteSeq sprite_seq
Vehicle appearance.
bool is_viewport_candidate
This vehicle can potentially be drawn on a viewport.
Direction last_direction
Last direction we obtained sprites for.
Rect old_coord
Co-ordinates from the last valid bounding box.
Cached often queried (NewGRF) values.
uint32_t position_in_vehicle
Cache for NewGRF var 4D.
uint32_t position_consist_length
Cache for NewGRF var 40.
uint32_t consist_cargo_information
Cache for NewGRF var 42. (Note: The cargotype is untranslated in the cache because the accessing GRF ...
uint8_t cache_valid
Bitset that indicates which cache values are valid.
uint32_t company_information
Cache for NewGRF var 43.
uint32_t position_same_id_length
Cache for NewGRF var 41.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Definition order_base.h:258
Order * GetLastOrder() const
Get the last order of the order chain.
Definition order_base.h:302
StationIDStack GetNextStoppingStation(const Vehicle *v, const Order *first=nullptr, uint hops=0) const
Recursively determine the next deterministic station to stop at.
Order * GetOrderAt(int index) const
Get a certain order of the order chain.
Vehicle * GetFirstSharedVehicle() const
Get the first vehicle of this vehicle chain.
Definition order_base.h:341
Order * GetFirstOrder() const
Get the first order of the order chain.
Definition order_base.h:294
VehicleOrderID GetNumOrders() const
Get number of orders in the order list.
Definition order_base.h:316
VehicleOrderID GetNumManualOrders() const
Get number of manually added orders in the order list.
Definition order_base.h:322
bool IsShared() const
Is this a shared order list?
Definition order_base.h:335
Order * next
Pointer to next order. If nullptr, end of list.
Definition order_base.h:59
Combination of a palette sprite and a 'real' sprite.
Definition gfx_type.h:22
SpriteID sprite
The 'real' sprite.
Definition gfx_type.h:23
PaletteID pal
The palette (use PAL_NONE) if not needed)
Definition gfx_type.h:24
Base class for all PoolItems.
static Titem * Get(auto index)
Returns Titem with given index.
Tindex index
Index of this pool item.
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Base class for all pools.
Specification of a rectangle with absolute coordinates of all edges.
Simulated cargo type and capacity for prediction of future links.
CargoType cargo
Cargo type the vehicle will be carrying.
uint16_t capacity
Capacity the vehicle will have.
uint16_t remaining
Capacity remaining from before the previous refit.
Class defining several overloaded accessors so we don't have to cast vehicle types that often.
T * Next() const
Get next vehicle in the chain.
static Pool::IterateWrapper< T > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
T * Previous() const
Get previous vehicle in the chain.
static const T * From(const Vehicle *v)
Converts a const Vehicle to const SpecializedVehicle with type checking.
static T * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
T * GetNextArticulatedPart()
Get the next part of an articulated engine.
static bool IsValidID(auto index)
Tests whether given index is a valid index for vehicle of this type.
static T * GetIfValid(auto index)
Returns vehicle if the index is a valid index for this vehicle type.
const T * GetFirstEnginePart() const
Get the first part of an articulated engine.
T * First() const
Get the first vehicle in the chain.
T * GetPrevVehicle() const
Get the previous real (non-articulated part) vehicle in the consist.
T * GetNextVehicle() const
Get the next real (non-articulated part) vehicle in the consist.
T * GetNextArticulatedPart() const
Get the next part of an articulated engine.
static T * Get(auto index)
Gets vehicle with given index.
SpecializedVehicle()
Set vehicle type correctly.
void UpdateViewport(bool force_update, bool update_delta)
Update vehicle sprite- and position caches.
T * GetLastEnginePart()
Get the last part of an articulated engine.
T * GetFirstEnginePart()
Get the first part of an articulated engine.
SpecializedVehicle< T, Type > SpecializedVehicleBase
Our type.
T * Last()
Get the last vehicle in the chain.
static const VehicleType EXPECTED_TYPE
Specialized type.
const T * Last() const
Get the last vehicle in the chain.
Station data structure.
Cached often queried values common to all vehicles.
uint8_t cached_vis_effect
Visual effect to show (see VisualEffect)
uint16_t cached_cargo_age_period
Number of ticks before carried cargo is aged.
uint16_t cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
Sprite sequence for a vehicle part.
bool IsValid() const
Check whether the sequence contains any sprites.
void GetBounds(Rect *bounds) const
Determine shared bounds of all sprites.
Definition vehicle.cpp:103
void Set(SpriteID sprite)
Assign a single sprite to the sequence.
void Clear()
Clear all information.
void CopyWithoutPalette(const VehicleSpriteSeq &src)
Copy data from another sprite sequence, while dropping all recolouring information.
void Draw(int x, int y, PaletteID default_pal, bool force_pal) const
Draw the sprite sequence.
Definition vehicle.cpp:131
Iterable ensemble of orders.
Iterator to iterate orders Supports deletion of current order.
Vehicle data structure.
Money GetDisplayProfitThisYear() const
Gets the profit vehicle had this year.
CargoPayment * cargo_payment
The cargo payment we're currently in.
EngineID engine_type
The type of engine used for this vehicle.
uint16_t cargo_age_counter
Ticks till cargo is aged next.
virtual int GetDisplaySpeed() const
Gets the speed in km-ish/h that can be sent into string parameters for string processing.
static uint GetAdvanceSpeed(uint speed)
Determines the effective vehicle movement speed.
int32_t z_pos
z coordinate.
uint16_t & GetGroundVehicleFlags()
Access the ground vehicle flags of the vehicle.
Definition vehicle.cpp:3174
Direction direction
facing
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates by given interval.
Definition vehicle.cpp:774
friend void AfterLoadVehiclesPhase1(bool part_of_load)
So we can set the previous and first pointers while loading.
StationIDStack GetNextStoppingStation() const
Get the next station the vehicle will stop at.
TimerGameEconomy::Date economy_age
Age in economy days.
bool IsOrderListShared() const
Check if we share our orders with another vehicle.
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
Definition vehicle.cpp:744
void IncrementRealOrderIndex()
Advanced cur_real_order_index to the next real order, keeps care of the wrap-around and invalidates t...
virtual uint Crash(bool flooded=false)
Crash the (whole) vehicle chain.
Definition vehicle.cpp:280
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
virtual ExpensesType GetExpenseType(bool income) const
Sets the expense type associated to this vehicle type.
Vehicle * GetNextArticulatedPart() const
Get the next part of an articulated engine.
Order * GetOrder(int index) const
Returns order 'index' of a vehicle or nullptr when it doesn't exists.
bool HasDepotOrder() const
Checks if a vehicle has a depot in its order list.
friend void FixOldVehicles(LoadgameState &ls)
Convert the old style vehicles into something that resembles the old new style savegames.
void LeaveStation()
Perform all actions when leaving a station.
Definition vehicle.cpp:2341
virtual bool IsChainInDepot() const
Check whether the whole vehicle chain is in the depot.
void AddToShared(Vehicle *shared_chain)
Adds this vehicle to a shared vehicle chain.
Definition vehicle.cpp:2957
VehicleCargoList cargo
The cargo this vehicle is carrying.
uint8_t x_extent
x-extent of vehicle bounding box
Vehicle ** hash_tile_prev
NOSAVE: Previous vehicle in the tile location hash.
bool HasUnbunchingOrder() const
Check if the current vehicle has an unbunching order.
Definition vehicle.cpp:2480
TimerGameEconomy::Date date_of_last_service
Last economy date the vehicle had a service at a depot.
uint16_t cargo_cap
total capacity
StationID last_loading_station
Last station the vehicle has stopped at and could possibly leave from with any cargo loaded.
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
Vehicle * GetFirstEnginePart()
Get the first part of an articulated engine.
uint8_t subtype
subtype (Filled with values from AircraftSubType/DisasterSubType/EffectVehicleType/GroundVehicleSubty...
CommandCost SendToDepot(DoCommandFlags flags, DepotCommandFlags command)
Send this vehicle to the depot using the given command(s).
Definition vehicle.cpp:2574
friend bool LoadOldVehicle(LoadgameState &ls, int num)
So we can set the proper next pointer while loading.
virtual void UpdateDeltaXY()
Updates the x and y offsets and the size of the sprite used for this vehicle.
Vehicle * Last()
Get the last vehicle of this vehicle chain.
uint16_t random_bits
Bits used for randomized variational spritegroups.
void ReleaseUnitNumber()
Release the vehicle's unit number.
Definition vehicle.cpp:2410
void UpdateBoundingBoxCoordinates(bool update_cache) const
Update the bounding box co-ordinates of the vehicle.
Definition vehicle.cpp:1693
uint8_t day_counter
Increased by one for each day.
void HandleLoading(bool mode=false)
Handle the loading of the vehicle; when not it skips through dummy orders and does nothing in all oth...
Definition vehicle.cpp:2421
Money profit_this_year
Profit this year << 8, low 8 bits are fract.
bool HasArticulatedPart() const
Check if an engine has an articulated part.
SpriteID colourmap
NOSAVE: cached colour mapping.
uint8_t breakdown_ctr
Counter for managing breakdown events.
uint GetOldAdvanceSpeed(uint speed)
Determines the effective direction-specific vehicle movement speed.
uint8_t breakdown_delay
Counter for managing breakdown length.
Vehicle * GetNextVehicle() const
Get the next real (non-articulated part) vehicle in the consist.
uint GetAdvanceDistance()
Determines the vehicle "progress" needed for moving a step.
GroupID group_id
Index of group Pool array.
const Vehicle * Move(int n) const
Get the vehicle at offset n of this vehicle chain.
virtual int GetDisplayMaxSpeed() const
Gets the maximum speed in km-ish/h that can be sent into string parameters for string processing.
void IncrementImplicitOrderIndex()
Increments cur_implicit_order_index, keeps care of the wrap-around and invalidates the GUI.
uint8_t z_extent
z-extent of vehicle bounding box
VehStates vehstatus
Status.
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 * first
NOSAVE: pointer to the first vehicle in the chain.
void CancelReservation(StationID next, Station *st)
Return all reserved cargo packets to the station and reset all packets staged for transfer.
Definition vehicle.cpp:2325
Money profit_last_year
Profit last year << 8, low 8 bits are fract.
Order * GetFirstOrder() const
Get the first order of the vehicles order list.
bool IsEngineCountable() const
Check if a vehicle is counted in num_engines in each company struct.
Definition vehicle.cpp:711
virtual ~Vehicle()
We want to 'destruct' the right class.
Definition vehicle.cpp:889
uint8_t subspeed
fractional speed
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
bool NeedsAutorenewing(const Company *c, bool use_renew_setting=true) const
Function to tell if a vehicle needs to be autorenewed.
Definition vehicle.cpp:145
void UpdateVisualEffect(bool allow_power_change=true)
Update the cached visual effect.
Definition vehicle.cpp:2655
void LeaveUnbunchingDepot()
Leave an unbunching depot and calculate the next departure time for shared order vehicles.
Definition vehicle.cpp:2505
Vehicle * Move(int n)
Get the vehicle at offset n of this vehicle chain.
int8_t y_offs
y offset for vehicle sprite
CargoType cargo_type
type of cargo this vehicle is carrying
debug_inline bool IsFrontEngine() const
Check if the vehicle is a front engine.
uint8_t acceleration
used by train & aircraft
Vehicle * previous_shared
NOSAVE: pointer to the previous vehicle in the shared order chain.
VehicleOrderID GetNumManualOrders() const
Get the number of manually added orders this vehicle has.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
int8_t trip_occupancy
NOSAVE: Occupancy of vehicle of the current trip (updated after leaving a station).
virtual TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
int8_t x_bb_offs
x offset of vehicle bounding box
Order current_order
The current order (+ status, like: loading)
void PreDestructor()
Destroy all stuff that (still) needs the virtual functions to work properly.
Definition vehicle.cpp:822
TimerGameTick::TickCounter last_loading_tick
Last TimerGameTick::counter tick that the vehicle has stopped at a station and could possibly leave w...
void HandlePathfindingResult(bool path_found)
Handle the pathfinding result, especially the lost status.
Definition vehicle.cpp:788
Vehicle * Next() const
Get the next vehicle of this vehicle.
int8_t x_offs
x offset for vehicle sprite
int32_t y_pos
y coordinate.
int32_t x_pos
x coordinate.
const GRFFile * GetGRF() const
Retrieve the NewGRF the vehicle is tied to.
Definition vehicle.cpp:754
OrderList * orders
Pointer to the order list for this vehicle.
uint32_t GetDisplayMinPowerToWeight() const
Calculates the minimum power-to-weight ratio using the maximum weight of the ground vehicle.
Definition vehicle.cpp:3248
uint8_t y_extent
y-extent of vehicle bounding box
virtual ClosestDepot FindClosestDepot()
Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should...
void UpdateViewport(bool dirty)
Update the vehicle on the viewport, updating the right hash and setting the new coordinates.
Definition vehicle.cpp:1726
Order * old_orders
Only used during conversion of old save games.
Money value
Value of the vehicle.
bool MarkAllViewportsDirty() const
Marks viewports dirty where the vehicle's image is.
Definition vehicle.cpp:1765
uint16_t refit_cap
Capacity left over from before last refit.
void InvalidateNewGRFCache()
Invalidates cached NewGRF variables.
uint8_t waiting_triggers
Triggers to be yet matched before rerandomizing the random bits.
VehicleCache vcache
Cache of often used vehicle values.
Vehicle * GetLastEnginePart()
Get the last part of an articulated engine.
uint32_t motion_counter
counter to occasionally play a vehicle sound.
NewGRFCache grf_cache
Cache of often used calculated NewGRF values.
uint32_t GetGRFID() const
Retrieve the GRF ID of the NewGRF the vehicle is tied to.
Definition vehicle.cpp:764
GroundVehicleCache * GetGroundVehicleCache()
Access the ground vehicle cache of the vehicle.
Definition vehicle.cpp:3144
virtual void OnNewEconomyDay()
Calls the new economy day handler of the vehicle.
Vehicle ** hash_tile_current
NOSAVE: Cache of the current hash chain.
virtual void OnNewCalendarDay()
Calls the new calendar day handler of the vehicle.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
int8_t y_bb_offs
y offset of vehicle bounding box
virtual int GetCurrentMaxSpeed() const
Calculates the maximum speed of the vehicle under its current conditions.
bool HasFullLoadOrder() const
Check if the current vehicle has a full load order.
Definition vehicle.cpp:2456
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
void BeginLoading()
Prepare everything to begin the loading when arriving at a station.
Definition vehicle.cpp:2194
Order * GetLastOrder() const
Returns the last order of a vehicle, or nullptr if it doesn't exists.
uint16_t load_unload_ticks
Ticks to wait before starting next cycle.
Money GetDisplayProfitLastYear() const
Gets the profit vehicle had last year.
Vehicle * hash_tile_next
NOSAVE: Next vehicle in the tile location hash.
uint8_t spritenum
currently displayed sprite index 0xfd == custom sprite, 0xfe == custom second head sprite 0xff == res...
uint16_t cur_speed
current speed
Vehicle * previous
NOSAVE: pointer to the previous vehicle in the chain.
uint8_t cargo_subtype
Used for livery refits (NewGRF variations)
bool HasEngineType() const
Check whether Vehicle::engine_type has any meaning.
Definition vehicle.cpp:728
TimerGameCalendar::Date age
Age in calendar days.
bool IsWaitingForUnbunching() const
Check whether a vehicle inside a depot is waiting for unbunching.
Definition vehicle.cpp:2552
TextEffectID fill_percent_te_id
a text-effect id to a loading indicator object
IterateWrapper Orders() const
Returns an iterable ensemble of orders of a vehicle.
Money GetDisplayRunningCost() const
Gets the running cost of a vehicle that can be sent into string parameters for string processing.
void SetNext(Vehicle *next)
Set the next vehicle of this vehicle.
Definition vehicle.cpp:2928
uint8_t breakdowns_since_last_service
Counter for the amount of breakdowns.
Vehicle * next
pointer to the next vehicle in the chain
TimerGameCalendar::Date max_age
Maximum age.
MutableSpriteCache sprite_cache
Cache of sprites and values related to recalculating them, see MutableSpriteCache.
uint16_t reliability
Reliability.
uint32_t GetDisplayMaxWeight() const
Calculates the maximum weight of the ground vehicle when loaded.
Definition vehicle.cpp:3233
const Vehicle * Last() const
Get the last vehicle of this vehicle chain.
Vehicle * PreviousShared() const
Get the previous vehicle of the shared vehicle chain.
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
void RemoveFromShared()
Removes the vehicle from the shared order list.
Definition vehicle.cpp:2980
bool HandleBreakdown()
Handle all of the aspects of a vehicle breakdown This includes adding smoke and sounds,...
Definition vehicle.cpp:1357
debug_inline bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
uint8_t progress
The percentage (if divided by 256) this vehicle already crossed the tile unit.
void UpdatePositionAndViewport()
Update the position of the vehicle, and update the viewport.
Definition vehicle.cpp:1755
Vehicle * Previous() const
Get the previous vehicle of this vehicle.
virtual void PlayLeaveStationSound(bool force=false) const
Play the sound associated with leaving the station.
Vehicle * GetPrevVehicle() const
Get the previous real (non-articulated part) vehicle in the consist.
Rect coord
NOSAVE: Graphical bounding box of the vehicle, i.e. what to redraw on moves.
uint16_t reliability_spd_dec
Reliability decrease speed.
uint8_t tick_counter
Increased by one for each tick.
void SkipToNextRealOrderIndex()
Advance cur_real_order_index to the next real order.
virtual bool IsInDepot() const
Check whether the vehicle is in the depot.
TileIndex tile
Current tile index.
virtual bool Tick()
Calls the tick handler of the vehicle.
TileIndex dest_tile
Heading for this tile.
void CopyVehicleConfigAndStatistics(Vehicle *src)
Copy certain configurations and statistics of a vehicle after successful autoreplace/renew The functi...
bool NeedsServicing() const
Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for ser...
Definition vehicle.cpp:190
bool HasConditionalOrder() const
Check if the current vehicle has a conditional order.
Definition vehicle.cpp:2468
virtual uint16_t GetMaxWeight() const
Calculates the weight value that this vehicle will have when fully loaded with its current cargo.
void UpdatePosition()
Update the position of the vehicle.
Definition vehicle.cpp:1684
virtual Money GetRunningCost() const
Gets the running cost of a vehicle.
StationID last_station_visited
The last station we stopped at.
void ResetRefitCaps()
Reset all refit_cap in the consist to cargo_cap.
Definition vehicle.cpp:2402
void InvalidateNewGRFCacheOfChain()
Invalidates cached NewGRF variables of all vehicles in the chain (after the current vehicle)
uint8_t breakdown_chance
Current chance of breakdowns.
void ShowVisualEffect() const
Draw visual effects (smoke and/or sparks) for a vehicle chain.
Definition vehicle.cpp:2778
TimerGameCalendar::Year build_year
Year the vehicle has been built.
Owner owner
Which company owns the vehicle?
UnitID unitnumber
unit number, for display purposes only
Vehicle * next_shared
pointer to the next vehicle that shares the order
bool NeedsAutomaticServicing() const
Checks if the current order should be interrupted for a service-in-depot order.
Definition vehicle.cpp:272
void DeleteUnreachedImplicitOrders()
Delete all implicit orders which were not reached.
Definition vehicle.cpp:2155
uint8_t running_ticks
Number of ticks this vehicle was not stopped this day.
Vehicle ** hash_viewport_prev
NOSAVE: Previous vehicle in the visual location hash.
virtual void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.
Vehicle * hash_viewport_next
NOSAVE: Next vehicle in the visual location hash.
virtual Trackdir GetVehicleTrackdir() const
Returns the Trackdir on which the vehicle is currently located.
void UpdateRealOrderIndex()
Skip implicit orders until cur_real_order_index is a non-implicit order.
const Vehicle * GetFirstEnginePart() const
Get the first part of an articulated engine.
Functions related to text effects.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:95
Definition of the game-calendar-timer.
All types related to tracks.
Trackdir
Enumeration for tracks and directions.
Definition track_type.h:67
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
Definition track_type.h:86
Base types related to transport.
uint16_t UnitID
Type for the company global vehicle unit number.
VehiclePool _vehicle_pool("Vehicle")
The pool with all our precious vehicles.
void FixOldVehicles(LoadgameState &ls)
Convert the old style vehicles into something that resembles the old new style savegames.
bool LoadOldVehicle(LoadgameState &ls, int num)
Load the vehicles of an old style savegame.
VisualEffect
Meaning of the various bits of the visual effect.
@ VE_TYPE_DEFAULT
Use default from engine class.
@ VE_TYPE_COUNT
Number of bits used for the effect type.
@ VE_OFFSET_CENTRE
Value of offset corresponding to a position above the centre of the vehicle.
@ VE_TYPE_ELECTRIC
Electric sparks.
@ VE_TYPE_START
First bit used for the type of effect.
@ VE_OFFSET_COUNT
Number of bits used for the offset.
@ VE_ADVANCED_EFFECT
Flag for advanced effects.
@ VE_DISABLE_EFFECT
Flag to disable visual effect.
@ VE_TYPE_STEAM
Steam plumes.
@ VE_TYPE_DIESEL
Diesel fumes.
@ VE_DEFAULT
Default value to indicate that visual effect should be based on engine class.
@ VE_OFFSET_START
First bit that contains the offset (0 = front, 8 = centre, 15 = rear)
@ VE_DISABLE_WAGON_POWER
Flag to disable wagon power.
VehState
Vehicle state bits in Vehicle::vehstatus.
@ Unclickable
Vehicle is not clickable by the user (shadow vehicles).
@ Crashed
Vehicle is crashed.
@ Shadow
Vehicle is a shadow vehicle.
@ TrainSlowing
Train is slowing down.
@ AircraftBroken
Aircraft is broken down.
@ Hidden
Vehicle is not visible.
@ DefaultPalette
Use default vehicle palette.
@ Stopped
Vehicle is stopped by the player.
GroundVehicleSubtypeFlags
Enum to handle ground vehicle subtypes.
@ GVSF_ARTICULATED_PART
Articulated part of an engine.
@ GVSF_FRONT
Leading engine of a consist.
@ GVSF_MULTIHEADED
Engine is multiheaded (not used for road vehicles).
@ GVSF_FREE_WAGON
First in a wagon chain (in depot) (not used for road vehicles).
@ GVSF_WAGON
Wagon (not used for road vehicles).
@ GVSF_ENGINE
Engine that can be front engine, but might be placed behind another engine (not used for road vehicle...
VisualEffectSpawnModel
Models for spawning visual effects.
@ VESM_ELECTRIC
Electric model.
@ VESM_STEAM
Steam model.
@ VESM_DIESEL
Diesel model.
@ VESM_NONE
No visual effect.
Pool< Vehicle, VehicleID, 512 > VehiclePool
A vehicle pool for a little over 1 million vehicles.
NewGRFCacheValidValues
Bit numbers used to indicate which of the NewGRFCache values are valid.
@ NCVV_COMPANY_INFORMATION
This bit will be set if the NewGRF var 43 currently stored is valid.
@ NCVV_CONSIST_CARGO_INFORMATION
This bit will be set if the NewGRF var 42 currently stored is valid.
@ NCVV_POSITION_CONSIST_LENGTH
This bit will be set if the NewGRF var 40 currently stored is valid.
@ NCVV_POSITION_SAME_ID_LENGTH
This bit will be set if the NewGRF var 41 currently stored is valid.
@ NCVV_POSITION_IN_VEHICLE
This bit will be set if the NewGRF var 4D currently stored is valid.
@ NCVV_END
End of the bits.
VehicleFlags
Bit numbers in Vehicle::vehicle_flags.
@ VF_STOP_LOADING
Don't load anymore during the next load cycle.
@ VF_SERVINT_IS_PERCENT
Service interval is percent.
@ VF_BUILT_AS_PROTOTYPE
Vehicle is a prototype (accepted as exclusive preview).
@ VF_CARGO_UNLOADING
Vehicle is unloading cargo.
@ VF_AUTOFILL_TIMETABLE
Whether the vehicle should fill in the timetable automatically.
@ VF_PATHFINDER_LOST
Vehicle's pathfinder is lost.
@ VF_AUTOFILL_PRES_WAIT_TIME
Whether non-destructive auto-fill should preserve waiting times.
@ VF_LOADING_FINISHED
Vehicle has finished loading.
@ VF_SERVINT_IS_CUSTOM
Service interval is custom.
@ VF_TIMETABLE_STARTED
Whether the vehicle has started running on the timetable yet.
static const int32_t INVALID_COORD
Sentinel for an invalid coordinate.
EngineImageType
Visualisation contexts of vehicles and engines.
@ EIT_ON_MAP
Vehicle drawn in viewport.
VehicleType
Available vehicle types.
@ VEH_INVALID
Non-existing type of vehicle.
@ VEH_ROAD
Road vehicle type.
@ VEH_TRAIN
Train vehicle type.