OpenTTD Source 20260721-master-g25ec12c62d
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef VEHICLE_BASE_H
11#define VEHICLE_BASE_H
12
13#include "sprite.h"
14#include "track_type.h"
15#include "command_type.h"
16#include "order_base.h"
17#include "cargopacket.h"
18#include "newgrf_type.h"
19#include "texteff.hpp"
20#include "engine_type.h"
21#include "order_func.h"
22#include "transport_type.h"
23#include "group_type.h"
24#include "base_consist.h"
25#include "network/network.h"
28
29const uint TILE_AXIAL_DISTANCE = 192;
30const uint TILE_CORNER_DISTANCE = 128;
31
33enum class VehState : uint8_t {
34 Hidden = 0,
35 Stopped = 1,
39 Shadow = 5,
41 Crashed = 7,
42};
43
46
56
59 /* Values calculated when they are requested for the first time after invalidating the NewGRF cache. */
63 uint32_t company_information = 0;
64 uint32_t position_in_vehicle = 0;
65 uint8_t cache_valid = 0;
66
67 auto operator<=>(const NewGRFCache &) const = default;
68};
69
83
86 uint16_t cached_max_speed = 0;
88
89 uint8_t cached_vis_effect = 0;
90
91 auto operator<=>(const VehicleCache &) const = default;
92};
93
96 std::array<PalSpriteID, 8> seq;
97 uint count;
98
99 bool operator==(const VehicleSpriteSeq &other) const
100 {
101 return std::ranges::equal(std::span(this->seq.data(), this->count), std::span(other.seq.data(), other.count));
102 }
103
108 bool IsValid() const
109 {
110 return this->count != 0;
111 }
112
116 void Clear()
117 {
118 this->count = 0;
119 }
120
125 void Set(SpriteID sprite)
126 {
127 this->count = 1;
128 this->seq[0].sprite = sprite;
129 this->seq[0].pal = 0;
130 }
131
137 {
138 this->count = src.count;
139 for (uint i = 0; i < src.count; ++i) {
140 this->seq[i].sprite = src.seq[i].sprite;
141 this->seq[i].pal = 0;
142 }
143 }
144
145 void GetBounds(Rect *bounds) const;
146 void Draw(int x, int y, PaletteID default_pal, bool force_pal) const;
147};
148
160
164
165/* Some declarations of functions, so we can make them friendly */
166struct GroundVehicleCache;
167struct LoadgameState;
168struct GRFFile;
169
173struct RefitDesc {
175 uint16_t capacity;
176 uint16_t remaining;
177 RefitDesc(CargoType cargo, uint16_t capacity, uint16_t remaining) :
179};
180
185struct ClosestDepot {
186 TileIndex location = INVALID_TILE;
188 bool reverse = false;
189 bool found = false;
190
191 ClosestDepot() = default;
192
193 ClosestDepot(TileIndex location, DestinationID destination, bool reverse = false) :
194 location(location), destination(destination), reverse(reverse), found(true) {}
195};
196
198struct Vehicle : VehiclePool::PoolItem<&_vehicle_pool>, BaseVehicle, BaseConsist {
199private:
200 typedef std::list<RefitDesc> RefitList;
201
202 Vehicle *next = nullptr;
203 Vehicle *previous = nullptr;
204 Vehicle *first = nullptr;
205 Vehicle *last = nullptr;
206
207 Vehicle *next_shared = nullptr;
209
210public:
211 friend void FixOldVehicles(LoadgameState &ls);
212 friend void AfterLoadVehiclesPhase1(bool part_of_load);
213 friend bool LoadOldVehicle(LoadgameState &ls, int num);
214 /* So we can use private/protected variables in the saveload code */
215 friend class SlVehicleCommon;
216 friend class SlVehicleDisaster;
217 friend void Ptrs_VEHS();
218
220
227
230 Money value = 0;
231
233
234 mutable Rect coord{};
235
238
242
244
245 /* Related to age and service time */
252 uint16_t reliability = 0;
253 uint16_t reliability_spd_dec = 0;
254 uint8_t breakdown_ctr = 0;
255 uint8_t breakdown_delay = 0;
257 uint8_t breakdown_chance = 0;
258
259 int32_t x_pos = 0;
260 int32_t y_pos = 0;
261 int32_t z_pos = 0;
263
270 uint8_t spritenum = 0;
272 EngineID engine_type = EngineID::Invalid();
273
274 TextEffectID fill_percent_te_id = INVALID_TE_ID;
276
277 uint16_t cur_speed = 0;
278 uint8_t subspeed = 0;
279 uint8_t acceleration = 0;
280 uint32_t motion_counter = 0;
281 uint8_t progress = 0;
282
284 uint16_t random_bits = 0;
285
286 StationID last_station_visited = StationID::Invalid();
287 StationID last_loading_station = StationID::Invalid();
289
292 uint8_t cargo_subtype = 0;
293 uint16_t cargo_cap = 0;
294 uint16_t refit_cap = 0;
295 uint16_t cargo_age_counter = 0;
296 int8_t trip_occupancy = 0;
297
298 uint8_t day_counter = 0;
299 uint8_t tick_counter = 0;
300 uint8_t running_ticks = 0;
301 uint16_t load_unload_ticks = 0;
302
304 uint8_t subtype = 0;
306
307 union {
308 OrderList *orders = nullptr;
309 uint32_t old_orders;
310 };
311
314
315 GroupID group_id = GroupID::Invalid();
316
318
323 virtual uint16_t GetMaxWeight() const
324 {
325 return 0;
326 }
327
329
330 void PreDestructor();
332 ~Vehicle() override;
333
334 void BeginLoading();
335 void CancelReservation(StationID next, Station *st);
336 void LeaveStation();
337
340
343
345
346 void HandleLoading(bool mode = false);
347
356 virtual void MarkDirty() {}
357
362 virtual void UpdateDeltaXY() {}
363
369
374 bool IsMovingFront() const { return this->First()->IsPrimaryVehicle() && (this->IsDrivingBackwards() ? this->Next() : this->Previous()) == nullptr; }
375
380 Vehicle *GetMovingFront() const { return this->IsDrivingBackwards() ? this->Last() : this->First(); }
381
386 Vehicle *GetMovingBack() const { return this->IsDrivingBackwards() ? this->First() : this->Last(); }
387
392 Vehicle *GetMovingNext() const { return this->IsDrivingBackwards() ? this->Previous() : this->Next(); }
393
398 Vehicle *GetMovingPrev() const { return this->IsDrivingBackwards() ? this->Next() : this->Previous(); }
399
404 Direction GetMovingDirection() const { return this->IsDrivingBackwards() ? ReverseDir(this->direction) : this->direction; }
405
410 void SetMovingDirection(Direction d) { this->direction = this->IsDrivingBackwards() ? ReverseDir(d) : d; }
411
425 inline uint GetOldAdvanceSpeed(uint speed)
426 {
427 return IsDiagonalDirection(this->GetMovingDirection()) ? speed : speed * 3 / 4;
428 }
429
442 static inline uint GetAdvanceSpeed(uint speed)
443 {
444 return speed * 3 / 4;
445 }
446
458
464 virtual ExpensesType GetExpenseType([[maybe_unused]] bool income) const { return ExpensesType::Other; }
465
470 virtual void PlayLeaveStationSound([[maybe_unused]] bool force = false) const {}
471
476 virtual bool IsPrimaryVehicle() const { return false; }
477
478 const Engine *GetEngine() const;
479
486 virtual void GetImage([[maybe_unused]] Direction direction, [[maybe_unused]] EngineImageType image_type, [[maybe_unused]] VehicleSpriteSeq *result) const { result->Clear(); }
487
488 const GRFFile *GetGRF() const;
489 GrfID GetGRFID() const;
490
496 {
497 this->grf_cache.cache_valid = 0;
498 }
499
505 {
506 for (Vehicle *u = this; u != nullptr; u = u->Next()) {
507 u->InvalidateNewGRFCache();
508 }
509 }
510
515 [[debug_inline]] inline bool IsGroundVehicle() const
516 {
517 return this->type == VehicleType::Train || this->type == VehicleType::Road;
518 }
519
524 virtual int GetDisplaySpeed() const { return 0; }
525
530 virtual int GetDisplayMaxSpeed() const { return 0; }
531
536 virtual int GetCurrentMaxSpeed() const { return 0; }
537
542 virtual Money GetRunningCost() const { return 0; }
543
548 virtual bool IsInDepot() const { return false; }
549
554 virtual bool IsChainInDepot() const { return this->IsInDepot(); }
555
560 bool IsStoppedInDepot() const
561 {
562 assert(this == this->First());
563 /* Free wagons have no VehState::Stopped state */
564 if (this->IsPrimaryVehicle() && !this->vehstatus.Test(VehState::Stopped)) return false;
565 return this->IsChainInDepot();
566 }
567
572 virtual bool Tick() { return true; };
573
577 virtual void OnNewCalendarDay() {};
578
582 virtual void OnNewEconomyDay() {};
583
584 void ShiftDates(TimerGameEconomy::Date interval);
585
591 virtual uint Crash(bool flooded = false);
592
606
611 Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
612
617 Money GetDisplayProfitThisYear() const { return (this->profit_this_year >> 8); }
618
623 Money GetDisplayProfitLastYear() const { return (this->profit_last_year >> 8); }
624
625 void SetNext(Vehicle *next);
626
632 inline Vehicle *Next() const { return this->next; }
633
639 inline Vehicle *Previous() const { return this->previous; }
640
645 inline Vehicle *First() const { return this->first; }
646
651 inline Vehicle *Last() const { return this->last; }
652
658 inline Vehicle *Move(int n)
659 {
660 Vehicle *v = this;
661 if (n < 0) {
662 for (int i = 0; i != n && v != nullptr; i--) v = v->Previous();
663 } else {
664 for (int i = 0; i != n && v != nullptr; i++) v = v->Next();
665 }
666 return v;
667 }
668
674 inline const Vehicle *Move(int n) const
675 {
676 const Vehicle *v = this;
677 if (n < 0) {
678 for (int i = 0; i != n && v != nullptr; i--) v = v->Previous();
679 } else {
680 for (int i = 0; i != n && v != nullptr; i++) v = v->Next();
681 }
682 return v;
683 }
684
689 inline const Order *GetFirstOrder() const { return (this->orders == nullptr) ? nullptr : this->GetOrder(this->orders->GetFirstOrder()); }
690
691 inline std::span<const Order> Orders() const
692 {
693 if (this->orders == nullptr) return {};
694 return this->orders->GetOrders();
695 }
696
697 inline std::span<Order> Orders()
698 {
699 if (this->orders == nullptr) return {};
700 return this->orders->GetOrders();
701 }
702
703 void AddToShared(Vehicle *shared_chain);
704 void RemoveFromShared();
705
710 inline Vehicle *NextShared() const { return this->next_shared; }
711
716 inline Vehicle *PreviousShared() const { return this->previous_shared; }
717
722 inline Vehicle *FirstShared() const { return (this->orders == nullptr) ? this->First() : this->orders->GetFirstSharedVehicle(); }
723
728 inline bool IsOrderListShared() const { return this->orders != nullptr && this->orders->IsShared(); }
729
734 inline VehicleOrderID GetNumOrders() const { return (this->orders == nullptr) ? 0 : this->orders->GetNumOrders(); }
735
740 inline VehicleOrderID GetNumManualOrders() const { return (this->orders == nullptr) ? 0 : this->orders->GetNumManualOrders(); }
741
746 inline void GetNextStoppingStation(std::vector<StationID> &next_station) const
747 {
748 if (this->orders == nullptr) return;
749 this->orders->GetNextStoppingStation(next_station, this);
750 }
751
752 void ResetRefitCaps();
753
754 void ReleaseUnitNumber();
755
763 {
764 this->CopyConsistPropertiesFrom(src);
765
766 this->ReleaseUnitNumber();
767 this->unitnumber = src->unitnumber;
768
769 this->current_order = src->current_order;
770 this->dest_tile = src->dest_tile;
771
772 this->profit_this_year = src->profit_this_year;
773 this->profit_last_year = src->profit_last_year;
774
775 src->unitnumber = 0;
776 }
777
778
779 bool HandleBreakdown();
780
781 bool NeedsAutorenewing(const Company *c, bool use_renew_setting = true) const;
782
783 bool NeedsServicing() const;
784 bool NeedsAutomaticServicing() const;
785
793 virtual TileIndex GetOrderStationLocation([[maybe_unused]] StationID station) { return INVALID_TILE; }
794
799 virtual TileIndex GetCargoTile() const { return this->tile; }
800
806 virtual ClosestDepot FindClosestDepot() { return {}; }
807
812 virtual void SetDestTile(TileIndex tile) { this->dest_tile = tile; }
813
815
816 void UpdateVisualEffect(bool allow_power_change = true);
817 void ShowVisualEffect() const;
818
819 void UpdatePosition();
820 void UpdateViewport(bool dirty);
821 void UpdateBoundingBoxCoordinates(bool update_cache) const;
823 bool MarkAllViewportsDirty() const;
824
825 inline uint16_t GetServiceInterval() const { return this->service_interval; }
826
827 inline void SetServiceInterval(uint16_t interval) { this->service_interval = interval; }
828
829 inline bool ServiceIntervalIsCustom() const { return this->vehicle_flags.Test(VehicleFlag::ServiceIntervalIsCustom); }
830
831 inline bool ServiceIntervalIsPercent() const { return this->vehicle_flags.Test(VehicleFlag::ServiceIntervalIsPercent); }
832
833 inline void SetServiceIntervalIsCustom(bool on) { this->vehicle_flags.Set(VehicleFlag::ServiceIntervalIsCustom, on); }
834
835 inline void SetServiceIntervalIsPercent(bool on) { this->vehicle_flags.Set(VehicleFlag::ServiceIntervalIsPercent, on); }
836
837 bool HasFullLoadOrder() const;
838 bool HasConditionalOrder() const;
839 bool HasUnbunchingOrder() const;
841 bool IsWaitingForUnbunching() const;
842
843private:
849 {
850 if (this->GetNumManualOrders() > 0) {
851 /* Advance to next real order */
852 do {
853 this->cur_real_order_index++;
854 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
855 } while (this->GetOrder(this->cur_real_order_index)->IsType(OT_IMPLICIT));
856 } else {
857 this->cur_real_order_index = 0;
858 }
859 }
860
861public:
868 {
870 /* Increment real order index as well */
872 }
873
875
876 /* Advance to next implicit order */
877 do {
879 if (this->cur_implicit_order_index >= this->GetNumOrders()) this->cur_implicit_order_index = 0;
880 } while (this->cur_implicit_order_index != this->cur_real_order_index && !this->GetOrder(this->cur_implicit_order_index)->IsType(OT_IMPLICIT));
881
882 InvalidateVehicleOrder(this, 0);
883 }
884
892 {
894 /* Increment both real and implicit order */
896 } else {
897 /* Increment real order only */
899 InvalidateVehicleOrder(this, 0);
900 }
901 }
902
907 {
908 /* Make sure the index is valid */
909 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
910
911 if (this->GetNumManualOrders() > 0) {
912 /* Advance to next real order */
913 while (this->GetOrder(this->cur_real_order_index)->IsType(OT_IMPLICIT)) {
914 this->cur_real_order_index++;
915 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
916 }
917 } else {
918 this->cur_real_order_index = 0;
919 }
920 }
921
927 inline Order *GetOrder(int index) const
928 {
929 return (this->orders == nullptr) ? nullptr : this->orders->GetOrderAt(index);
930 }
931
936 inline const Order *GetLastOrder() const
937 {
938 return (this->orders == nullptr) ? nullptr : this->orders->GetOrderAt(this->orders->GetLastOrder());
939 }
940
941 bool IsEngineCountable() const;
942 bool HasEngineType() const;
943 bool HasDepotOrder() const;
944 void HandlePathfindingResult(bool path_found);
945
950 [[debug_inline]] inline bool IsFrontEngine() const
951 {
952 return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_FRONT);
953 }
954
959 inline bool IsArticulatedPart() const
960 {
961 return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_ARTICULATED_PART);
962 }
963
968 inline bool HasArticulatedPart() const
969 {
970 return this->Next() != nullptr && this->Next()->IsArticulatedPart();
971 }
972
979 {
980 assert(this->HasArticulatedPart());
981 return this->Next();
982 }
983
989 {
990 Vehicle *v = this;
991 while (v->IsArticulatedPart()) v = v->Previous();
992 return v;
993 }
994
999 inline const Vehicle *GetFirstEnginePart() const
1000 {
1001 const Vehicle *v = this;
1002 while (v->IsArticulatedPart()) v = v->Previous();
1003 return v;
1004 }
1005
1011 {
1012 Vehicle *v = this;
1013 while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart();
1014 return v;
1015 }
1016
1021 inline Vehicle *GetNextVehicle() const
1022 {
1023 const Vehicle *v = this;
1024 while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart();
1025
1026 /* v now contains the last articulated part in the engine */
1027 return v->Next();
1028 }
1029
1034 inline Vehicle *GetPrevVehicle() const
1035 {
1036 Vehicle *v = this->Previous();
1037 while (v != nullptr && v->IsArticulatedPart()) v = v->Previous();
1038
1039 return v;
1040 }
1041
1042 uint32_t GetDisplayMaxWeight() const;
1043 uint32_t GetDisplayMinPowerToWeight() const;
1044};
1045
1050template <class T, VehicleType Type>
1052 static const VehicleType EXPECTED_TYPE = Type;
1053
1055
1061 {
1062 this->sprite_cache.sprite_seq.count = 1;
1063 }
1064
1066 inline T *GetMovingFront() const { return (T *)this->Vehicle::GetMovingFront(); }
1068 inline T *GetMovingBack() const { return (T *)this->Vehicle::GetMovingBack(); }
1070 inline T *GetMovingNext() const { return (T *)this->Vehicle::GetMovingNext(); }
1072 inline T *GetMovingPrev() const { return (T *)this->Vehicle::GetMovingPrev(); }
1073
1078 inline T *First() const { return (T *)this->Vehicle::First(); }
1079
1084 inline T *Last() { return (T *)this->Vehicle::Last(); }
1085
1090 inline const T *Last() const { return (const T *)this->Vehicle::Last(); }
1091
1096 inline T *Next() const { return (T *)this->Vehicle::Next(); }
1097
1102 inline T *Previous() const { return (T *)this->Vehicle::Previous(); }
1103
1110
1116 inline T *GetNextArticulatedPart() const { return (T *)this->Vehicle::GetNextArticulatedPart(); }
1117
1122 inline T *GetFirstEnginePart() { return (T *)this->Vehicle::GetFirstEnginePart(); }
1123
1128 inline const T *GetFirstEnginePart() const { return (const T *)this->Vehicle::GetFirstEnginePart(); }
1129
1134 inline T *GetLastEnginePart() { return (T *)this->Vehicle::GetLastEnginePart(); }
1135
1140 inline T *GetNextVehicle() const { return (T *)this->Vehicle::GetNextVehicle(); }
1141
1146 inline T *GetPrevVehicle() const { return (T *)this->Vehicle::GetPrevVehicle(); }
1147
1153 static inline bool IsValidID(auto index)
1154 {
1155 return Vehicle::IsValidID(index) && Vehicle::Get(index)->type == Type;
1156 }
1157
1163 static inline T *Get(auto index)
1164 {
1165 return (T *)Vehicle::Get(index);
1166 }
1167
1173 static inline T *GetIfValid(auto index)
1174 {
1175 return IsValidID(index) ? Get(index) : nullptr;
1176 }
1177
1183 template <typename... Targs>
1184 static inline T *Create(Targs &&... args)
1185 {
1186 return Vehicle::Create<T>(std::forward<Targs&&>(args)...);
1187 }
1188
1195 template <typename... Targs>
1196 static inline T *CreateAtIndex(VehicleID index, Targs &&... args)
1197 {
1198 return Vehicle::CreateAtIndex<T>(index, std::forward<Targs&&>(args)...);
1199 }
1200
1206 static inline T *From(Vehicle *v)
1207 {
1208 assert(v->type == Type);
1209 return (T *)v;
1210 }
1211
1217 static inline const T *From(const Vehicle *v)
1218 {
1219 assert(v->type == Type);
1220 return (const T *)v;
1221 }
1222
1228 inline void UpdateViewport(bool force_update, bool update_delta)
1229 {
1230 bool sprite_has_changed = false;
1231
1232 /* Skip updating sprites on dedicated servers without screen */
1233 if (_network_dedicated) return;
1234
1235 /* Explicitly choose method to call to prevent vtable dereference -
1236 * it gives ~3% runtime improvements in games with many vehicles */
1237 if (update_delta) ((T *)this)->T::UpdateDeltaXY();
1238
1239 /*
1240 * Only check for a new sprite sequence if the vehicle direction
1241 * has changed since we last checked it, assuming that otherwise
1242 * there won't be enough change in bounding box or offsets to need
1243 * to resolve a new sprite.
1244 */
1245 if (this->direction != this->sprite_cache.last_direction || this->sprite_cache.is_viewport_candidate) {
1246 VehicleSpriteSeq seq;
1247
1248 ((T*)this)->T::GetImage(this->direction, EngineImageType::OnMap, &seq);
1249 if (this->sprite_cache.sprite_seq != seq) {
1250 sprite_has_changed = true;
1251 this->sprite_cache.sprite_seq = seq;
1252 }
1253
1254 this->sprite_cache.last_direction = this->direction;
1255 this->sprite_cache.revalidate_before_draw = false;
1256 } else {
1257 /*
1258 * A change that could potentially invalidate the sprite has been
1259 * made, signal that we should still resolve it before drawing on a
1260 * viewport.
1261 */
1262 this->sprite_cache.revalidate_before_draw = true;
1263 }
1264
1265 if (force_update || sprite_has_changed) {
1266 this->Vehicle::UpdateViewport(true);
1267 }
1268 }
1269
1275 static Pool::IterateWrapper<T> Iterate(size_t from = 0) { return Pool::IterateWrapper<T>(from); }
1276};
1277
1279static const int32_t INVALID_COORD = 0x7fffffff;
1280
1281#endif /* VEHICLE_BASE_H */
Properties for front vehicles/consists.
@ ServiceIntervalIsCustom
Service interval is custom.
@ ServiceIntervalIsPercent
Service interval is percent.
@ DrivingBackwards
Vehicle is driving backwards.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:22
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.
Enum-as-bit-set wrapper.
uint64_t TickCounter
The type that the tick counter is stored in.
StrongType::Typedef< int32_t, struct YearTag< struct Calendar >, StrongType::Compare, StrongType::Integer > Year
StrongType::Typedef< int32_t, DateTag< struct Calendar >, StrongType::Compare, StrongType::Integer > Date
CargoList that is used for vehicles.
Types related to commands.
EnumBitSet< DoCommandFlag, uint16_t > DoCommandFlags
Bitset of DoCommandFlag elements.
static constexpr Owner INVALID_OWNER
An invalid owner.
Direction ReverseDir(Direction d)
Return the reverse of a direction.
bool IsDiagonalDirection(Direction dir)
Checks if a given Direction is diagonal.
Direction
Defines the 8 directions on the map.
@ Invalid
Flag for an invalid direction.
ExpensesType
Types of expenses.
@ Other
Other expenses.
Types related to engines.
PoolID< uint16_t, struct EngineIDTag, 64000, 0xFFFF > EngineID
Unique identification number of an engine.
Definition engine_type.h:26
#define T
Climate temperate.
Definition engines.h:91
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.
#define Rect
Macro that prevents name conflicts between included headers.
bool _network_dedicated
are we a dedicated server?
Definition network.cpp:70
Basic functions/variables used all over the place.
Commonly used types for the NewGRF implementation.
Label< struct GrfIDTag > GrfID
The unique identifier of a NewGRF.
Definition newgrf_type.h:17
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
Types often used outside the saveload code related to saving and loading games.
Base for drawing complex sprites.
#define debug_inline
When making a (pure) debug build, the compiler will by default disable inlining of functions.
Definition stdafx.h:212
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.
VehicleFlags vehicle_flags
Used for gradual loading and other miscellaneous things (.
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.
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:124
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:384
If you change this, keep in mind that it is also saved in 2 other places:
Definition order_base.h:34
static T * Create(Targs &&... args)
static T * CreateAtIndex(VehicleID index, Targs &&... args)
static Vehicle * Get(auto index)
Base class for all pools.
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.
T * GetMovingFront() const
Get the moving front of the vehicle chain.
T * GetMovingPrev() const
Get the previous vehicle in the vehicle chain, relative to its current movement.
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.
SpecializedVehicle(VehicleID index)
Set vehicle type correctly.
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.
void UpdateViewport(bool force_update, bool update_delta)
Update vehicle sprite- and position caches.
T * GetMovingNext() const
Get the next vehicle in the vehicle chain, relative to its current movement.
T * GetLastEnginePart()
Get the last part of an articulated engine.
static T * Create(Targs &&... args)
Creates a new T-object in the vehicle pool.
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.
T * GetMovingBack() const
Get the moving back of the vehicle chain.
static T * CreateAtIndex(VehicleID index, Targs &&... args)
Creates a new T-object in the vehicle pool.
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:123
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:151
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.
Vehicle * GetMovingPrev() const
Get the previous vehicle in the vehicle chain, relative to its current movement.
static uint GetAdvanceSpeed(uint speed)
Determines the effective vehicle movement speed.
int32_t z_pos
z coordinate.
Vehicle * last
NOSAVE: pointer for the last vehicle in the chain.
Direction direction
facing
void ShiftDates(TimerGameEconomy::Date interval)
Shift all dates by given interval.
Definition vehicle.cpp:778
const Order * GetLastOrder() const
Returns the last order of a vehicle, or nullptr if it doesn't exists.
friend void AfterLoadVehiclesPhase1(bool part_of_load)
So we can set the previous and first pointers while loading.
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:748
Direction GetMovingDirection() const
Get the moving direction of this vehicle chain.
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:300
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
bool IsMovingFront() const
Is this vehicle the moving front of the vehicle chain?
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.
virtual TileIndex GetCargoTile() const
Tile to use for economic calculations when moving cargo into or out of this vehicle.
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:2371
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:3020
VehicleCargoList cargo
The cargo this vehicle is carrying.
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:2507
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...
const Order * GetFirstOrder() const
Get the first order of the vehicles order list.
CommandCost SendToDepot(DoCommandFlags flags, DepotCommandFlags command)
Send this vehicle to the depot using the given command(s).
Definition vehicle.cpp:2601
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.
void SetMovingDirection(Direction d)
Set the movement direction 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:2441
virtual void SetDestTile(TileIndex tile)
Set the destination of this vehicle.
void UpdateBoundingBoxCoordinates(bool update_cache) const
Update the bounding box co-ordinates of the vehicle.
Definition vehicle.cpp:1708
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:2452
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.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
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:2355
Money profit_last_year
Profit last year << 8, low 8 bits are fract.
bool IsEngineCountable() const
Check if a vehicle is counted in num_engines in each company struct.
Definition vehicle.cpp:715
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:165
Vehicle * GetMovingBack() const
Get the moving back of the vehicle chain.
void UpdateVisualEffect(bool allow_power_change=true)
Update the cached visual effect.
Definition vehicle.cpp:2680
void LeaveUnbunchingDepot()
Leave an unbunching depot and calculate the next departure time for shared order vehicles.
Definition vehicle.cpp:2532
Vehicle * Move(int n)
Get the vehicle at offset n of this vehicle chain.
void GetNextStoppingStation(std::vector< StationID > &next_station) const
Get the next station the vehicle will stop at.
CargoType cargo_type
type of cargo this vehicle is carrying
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.
Order current_order
The current order (+ status, like: loading).
Vehicle(VehicleID index, VehicleType type=VehicleType::Invalid)
Vehicle constructor.
Definition vehicle.cpp:379
void PreDestructor()
Destroy all stuff that (still) needs the virtual functions to work properly.
Definition vehicle.cpp:826
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:792
Vehicle * Next() const
Get the next vehicle of this vehicle.
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:758
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:3312
Vehicle * GetMovingFront() const
Get the moving front of the vehicle chain.
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:1753
Money value
Value of the vehicle.
bool MarkAllViewportsDirty() const
Marks viewports dirty where the vehicle's image is.
Definition vehicle.cpp:1792
uint16_t refit_cap
Capacity left over from before last refit.
void InvalidateNewGRFCache()
Invalidates cached NewGRF variables.
VehicleRandomTriggers waiting_random_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.
SpriteBounds bounds
Bounding box of vehicle.
GroundVehicleCache * GetGroundVehicleCache()
Access the ground vehicle cache of the vehicle.
Definition vehicle.cpp:3208
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.
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:2487
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:2227
uint32_t old_orders
Only used during conversion of old save games.
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).
~Vehicle() override
We want to 'destruct' the right class.
Definition vehicle.cpp:893
bool IsFrontEngine() const
Check if the vehicle is a front engine.
bool HasEngineType() const
Check whether Vehicle::engine_type has any meaning.
Definition vehicle.cpp:732
Vehicle * GetMovingNext() const
Get the next vehicle in the vehicle chain, relative to its current movement.
TimerGameCalendar::Date age
Age in calendar days.
bool IsWaitingForUnbunching() const
Check whether a vehicle inside a depot is waiting for unbunching.
Definition vehicle.cpp:2579
TextEffectID fill_percent_te_id
a text-effect id to a loading indicator object
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:2984
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:3297
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:3043
bool HandleBreakdown()
Handle all of the aspects of a vehicle breakdown This includes adding smoke and sounds,...
Definition vehicle.cpp:1374
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:1782
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.
Vehicle * Last() const
Get the last vehicle of this vehicle chain.
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:210
bool HasConditionalOrder() const
Check if the current vehicle has a conditional order.
Definition vehicle.cpp:2498
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:1699
virtual Money GetRunningCost() const
Gets the running cost of a vehicle.
GroundVehicleFlags & GetGroundVehicleFlags()
Access the ground vehicle flags of the vehicle.
Definition vehicle.cpp:3238
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:2433
bool IsDrivingBackwards() const
Is this vehicle moving backwards?
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:2833
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:292
void DeleteUnreachedImplicitOrders()
Delete all implicit orders which were not reached.
Definition vehicle.cpp:2189
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.
GrfID GetGRFID() const
Retrieve the GRF ID of the NewGRF the vehicle is tied to.
Definition vehicle.cpp:768
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.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition tile_type.h:92
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:100
Definition of the game-calendar-timer.
All types related to tracks.
Trackdir
Enumeration for tracks and directions.
Definition track_type.h:63
@ Invalid
Flag for an invalid trackdir.
Definition track_type.h:82
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.
const uint TILE_AXIAL_DISTANCE
Logical length of the tile in any DiagDirection used in vehicle movement.
const uint TILE_CORNER_DISTANCE
Logical length of the tile corner crossing in any non-diagonal direction used in vehicle movement.
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.
EnumBitSet< VehState, uint8_t > VehStates
Bitset of VehState elements.
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...
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.
static const int32_t INVALID_COORD
Sentinel for an invalid coordinate.
EnumBitSet< DepotCommandFlag, uint8_t > DepotCommandFlags
Bitset of DepotCommandFlag elements.
EnumBitSet< VehicleRandomTrigger, uint8_t > VehicleRandomTriggers
Bitset of VehicleRandomTrigger elements.
EngineImageType
Visualisation contexts of vehicles and engines.
@ OnMap
Vehicle drawn in viewport.
PoolID< uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF > VehicleID
The type all our vehicle IDs have.
VehicleType
Available vehicle types.
@ Invalid
Non-existing type of vehicle.
@ Road
Road vehicle type.
@ Train
Train vehicle type.
EnumBitSet< GroundVehicleFlag, uint16_t > GroundVehicleFlags
Bitset of GroundVehicleFlag elements.