OpenTTD Source 20260421-master-gc2fbc6fdeb
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 "texteff.hpp"
19#include "engine_type.h"
20#include "order_func.h"
21#include "transport_type.h"
22#include "group_type.h"
23#include "base_consist.h"
24#include "network/network.h"
25#include "saveload/saveload.h"
27
28const uint TILE_AXIAL_DISTANCE = 192;
29const uint TILE_CORNER_DISTANCE = 128;
30
32enum class VehState : uint8_t {
33 Hidden = 0,
34 Stopped = 1,
38 Shadow = 5,
40 Crashed = 7,
41};
42using VehStates = EnumBitSet<VehState, uint8_t>;
43
53
56 /* Values calculated when they are requested for the first time after invalidating the NewGRF cache. */
60 uint32_t company_information = 0;
61 uint32_t position_in_vehicle = 0;
62 uint8_t cache_valid = 0;
63
64 auto operator<=>(const NewGRFCache &) const = default;
65};
66
76
90
93 uint16_t cached_max_speed = 0;
95
96 uint8_t cached_vis_effect = 0;
97
98 auto operator<=>(const VehicleCache &) const = default;
99};
100
103 std::array<PalSpriteID, 8> seq;
104 uint count;
105
106 bool operator==(const VehicleSpriteSeq &other) const
107 {
108 return std::ranges::equal(std::span(this->seq.data(), this->count), std::span(other.seq.data(), other.count));
109 }
110
115 bool IsValid() const
116 {
117 return this->count != 0;
118 }
119
123 void Clear()
124 {
125 this->count = 0;
126 }
127
132 void Set(SpriteID sprite)
133 {
134 this->count = 1;
135 this->seq[0].sprite = sprite;
136 this->seq[0].pal = 0;
137 }
138
144 {
145 this->count = src.count;
146 for (uint i = 0; i < src.count; ++i) {
147 this->seq[i].sprite = src.seq[i].sprite;
148 this->seq[i].pal = 0;
149 }
150 }
151
152 void GetBounds(Rect *bounds) const;
153 void Draw(int x, int y, PaletteID default_pal, bool force_pal) const;
154};
155
167
171
172/* Some declarations of functions, so we can make them friendly */
173struct GroundVehicleCache;
174struct LoadgameState;
175struct GRFFile;
176
180struct RefitDesc {
182 uint16_t capacity;
183 uint16_t remaining;
184 RefitDesc(CargoType cargo, uint16_t capacity, uint16_t remaining) :
186};
187
192struct ClosestDepot {
193 TileIndex location = INVALID_TILE;
195 bool reverse = false;
196 bool found = false;
197
198 ClosestDepot() = default;
199
200 ClosestDepot(TileIndex location, DestinationID destination, bool reverse = false) :
201 location(location), destination(destination), reverse(reverse), found(true) {}
202};
203
205struct Vehicle : VehiclePool::PoolItem<&_vehicle_pool>, BaseVehicle, BaseConsist {
206private:
207 typedef std::list<RefitDesc> RefitList;
208
209 Vehicle *next = nullptr;
210 Vehicle *previous = nullptr;
211 Vehicle *first = nullptr;
212 Vehicle *last = nullptr;
213
214 Vehicle *next_shared = nullptr;
216
217public:
218 friend void FixOldVehicles(LoadgameState &ls);
219 friend void AfterLoadVehiclesPhase1(bool part_of_load);
220 friend bool LoadOldVehicle(LoadgameState &ls, int num);
221 /* So we can use private/protected variables in the saveload code */
222 friend class SlVehicleCommon;
223 friend class SlVehicleDisaster;
224 friend void Ptrs_VEHS();
225
227
234
237 Money value = 0;
238
240
241 mutable Rect coord{};
242
245
249
251
252 /* Related to age and service time */
259 uint16_t reliability = 0;
260 uint16_t reliability_spd_dec = 0;
261 uint8_t breakdown_ctr = 0;
262 uint8_t breakdown_delay = 0;
264 uint8_t breakdown_chance = 0;
265
266 int32_t x_pos = 0;
267 int32_t y_pos = 0;
268 int32_t z_pos = 0;
270
277 uint8_t spritenum = 0;
279 EngineID engine_type = EngineID::Invalid();
280
281 TextEffectID fill_percent_te_id = INVALID_TE_ID;
283
284 uint16_t cur_speed = 0;
285 uint8_t subspeed = 0;
286 uint8_t acceleration = 0;
287 uint32_t motion_counter = 0;
288 uint8_t progress = 0;
289
290 VehicleRandomTriggers waiting_random_triggers;
291 uint16_t random_bits = 0;
292
293 StationID last_station_visited = StationID::Invalid();
294 StationID last_loading_station = StationID::Invalid();
296
299 uint8_t cargo_subtype = 0;
300 uint16_t cargo_cap = 0;
301 uint16_t refit_cap = 0;
302 uint16_t cargo_age_counter = 0;
303 int8_t trip_occupancy = 0;
304
305 uint8_t day_counter = 0;
306 uint8_t tick_counter = 0;
307 uint8_t running_ticks = 0;
308 uint16_t load_unload_ticks = 0;
309
310 VehStates vehstatus{};
311 uint8_t subtype = 0;
313
314 union {
315 OrderList *orders = nullptr;
316 uint32_t old_orders;
317 };
318
321
322 GroupID group_id = GroupID::Invalid();
323
325
330 virtual uint16_t GetMaxWeight() const
331 {
332 return 0;
333 }
334
336
337 void PreDestructor();
339 ~Vehicle() override;
340
341 void BeginLoading();
342 void CancelReservation(StationID next, Station *st);
343 void LeaveStation();
344
347
348 uint16_t &GetGroundVehicleFlags();
349 const uint16_t &GetGroundVehicleFlags() const;
350
352
353 void HandleLoading(bool mode = false);
354
363 virtual void MarkDirty() {}
364
369 virtual void UpdateDeltaXY() {}
370
376
381 bool IsMovingFront() const { return this->First()->IsPrimaryVehicle() && (this->IsDrivingBackwards() ? this->Next() : this->Previous()) == nullptr; }
382
387 Vehicle *GetMovingFront() const { return this->IsDrivingBackwards() ? this->Last() : this->First(); }
388
393 Vehicle *GetMovingBack() const { return this->IsDrivingBackwards() ? this->First() : this->Last(); }
394
399 Vehicle *GetMovingNext() const { return this->IsDrivingBackwards() ? this->Previous() : this->Next(); }
400
405 Vehicle *GetMovingPrev() const { return this->IsDrivingBackwards() ? this->Next() : this->Previous(); }
406
411 Direction GetMovingDirection() const { return this->IsDrivingBackwards() ? ReverseDir(this->direction) : this->direction; }
412
417 void SetMovingDirection(Direction d) { this->direction = this->IsDrivingBackwards() ? ReverseDir(d) : d; }
418
432 inline uint GetOldAdvanceSpeed(uint speed)
433 {
434 return (this->GetMovingDirection() & 1) ? speed : speed * 3 / 4;
435 }
436
449 static inline uint GetAdvanceSpeed(uint speed)
450 {
451 return speed * 3 / 4;
452 }
453
461 inline uint GetAdvanceDistance()
462 {
464 }
465
471 virtual ExpensesType GetExpenseType([[maybe_unused]] bool income) const { return EXPENSES_OTHER; }
472
477 virtual void PlayLeaveStationSound([[maybe_unused]] bool force = false) const {}
478
483 virtual bool IsPrimaryVehicle() const { return false; }
484
485 const Engine *GetEngine() const;
486
493 virtual void GetImage([[maybe_unused]] Direction direction, [[maybe_unused]] EngineImageType image_type, [[maybe_unused]] VehicleSpriteSeq *result) const { result->Clear(); }
494
495 const GRFFile *GetGRF() const;
496 uint32_t GetGRFID() const;
497
503 {
504 this->grf_cache.cache_valid = 0;
505 }
506
512 {
513 for (Vehicle *u = this; u != nullptr; u = u->Next()) {
514 u->InvalidateNewGRFCache();
515 }
516 }
517
522 [[debug_inline]] inline bool IsGroundVehicle() const
523 {
524 return this->type == VEH_TRAIN || this->type == VEH_ROAD;
525 }
526
531 virtual int GetDisplaySpeed() const { return 0; }
532
537 virtual int GetDisplayMaxSpeed() const { return 0; }
538
543 virtual int GetCurrentMaxSpeed() const { return 0; }
544
549 virtual Money GetRunningCost() const { return 0; }
550
555 virtual bool IsInDepot() const { return false; }
556
561 virtual bool IsChainInDepot() const { return this->IsInDepot(); }
562
567 bool IsStoppedInDepot() const
568 {
569 assert(this == this->First());
570 /* Free wagons have no VehState::Stopped state */
571 if (this->IsPrimaryVehicle() && !this->vehstatus.Test(VehState::Stopped)) return false;
572 return this->IsChainInDepot();
573 }
574
579 virtual bool Tick() { return true; };
580
584 virtual void OnNewCalendarDay() {};
585
589 virtual void OnNewEconomyDay() {};
590
591 void ShiftDates(TimerGameEconomy::Date interval);
592
598 virtual uint Crash(bool flooded = false);
599
612 virtual Trackdir GetVehicleTrackdir() const { return INVALID_TRACKDIR; }
613
618 Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
619
624 Money GetDisplayProfitThisYear() const { return (this->profit_this_year >> 8); }
625
630 Money GetDisplayProfitLastYear() const { return (this->profit_last_year >> 8); }
631
632 void SetNext(Vehicle *next);
633
639 inline Vehicle *Next() const { return this->next; }
640
646 inline Vehicle *Previous() const { return this->previous; }
647
652 inline Vehicle *First() const { return this->first; }
653
658 inline Vehicle *Last() const { return this->last; }
659
665 inline Vehicle *Move(int n)
666 {
667 Vehicle *v = this;
668 if (n < 0) {
669 for (int i = 0; i != n && v != nullptr; i--) v = v->Previous();
670 } else {
671 for (int i = 0; i != n && v != nullptr; i++) v = v->Next();
672 }
673 return v;
674 }
675
681 inline const Vehicle *Move(int n) const
682 {
683 const Vehicle *v = this;
684 if (n < 0) {
685 for (int i = 0; i != n && v != nullptr; i--) v = v->Previous();
686 } else {
687 for (int i = 0; i != n && v != nullptr; i++) v = v->Next();
688 }
689 return v;
690 }
691
696 inline const Order *GetFirstOrder() const { return (this->orders == nullptr) ? nullptr : this->GetOrder(this->orders->GetFirstOrder()); }
697
698 inline std::span<const Order> Orders() const
699 {
700 if (this->orders == nullptr) return {};
701 return this->orders->GetOrders();
702 }
703
704 inline std::span<Order> Orders()
705 {
706 if (this->orders == nullptr) return {};
707 return this->orders->GetOrders();
708 }
709
710 void AddToShared(Vehicle *shared_chain);
711 void RemoveFromShared();
712
717 inline Vehicle *NextShared() const { return this->next_shared; }
718
723 inline Vehicle *PreviousShared() const { return this->previous_shared; }
724
729 inline Vehicle *FirstShared() const { return (this->orders == nullptr) ? this->First() : this->orders->GetFirstSharedVehicle(); }
730
735 inline bool IsOrderListShared() const { return this->orders != nullptr && this->orders->IsShared(); }
736
741 inline VehicleOrderID GetNumOrders() const { return (this->orders == nullptr) ? 0 : this->orders->GetNumOrders(); }
742
747 inline VehicleOrderID GetNumManualOrders() const { return (this->orders == nullptr) ? 0 : this->orders->GetNumManualOrders(); }
748
753 inline void GetNextStoppingStation(std::vector<StationID> &next_station) const
754 {
755 if (this->orders == nullptr) return;
756 this->orders->GetNextStoppingStation(next_station, this);
757 }
758
759 void ResetRefitCaps();
760
761 void ReleaseUnitNumber();
762
770 {
771 this->CopyConsistPropertiesFrom(src);
772
773 this->ReleaseUnitNumber();
774 this->unitnumber = src->unitnumber;
775
776 this->current_order = src->current_order;
777 this->dest_tile = src->dest_tile;
778
779 this->profit_this_year = src->profit_this_year;
780 this->profit_last_year = src->profit_last_year;
781
782 src->unitnumber = 0;
783 }
784
785
786 bool HandleBreakdown();
787
788 bool NeedsAutorenewing(const Company *c, bool use_renew_setting = true) const;
789
790 bool NeedsServicing() const;
791 bool NeedsAutomaticServicing() const;
792
800 virtual TileIndex GetOrderStationLocation([[maybe_unused]] StationID station) { return INVALID_TILE; }
801
806 virtual TileIndex GetCargoTile() const { return this->tile; }
807
813 virtual ClosestDepot FindClosestDepot() { return {}; }
814
819 virtual void SetDestTile(TileIndex tile) { this->dest_tile = tile; }
820
821 CommandCost SendToDepot(DoCommandFlags flags, DepotCommandFlags command);
822
823 void UpdateVisualEffect(bool allow_power_change = true);
824 void ShowVisualEffect() const;
825
826 void UpdatePosition();
827 void UpdateViewport(bool dirty);
828 void UpdateBoundingBoxCoordinates(bool update_cache) const;
830 bool MarkAllViewportsDirty() const;
831
832 inline uint16_t GetServiceInterval() const { return this->service_interval; }
833
834 inline void SetServiceInterval(uint16_t interval) { this->service_interval = interval; }
835
836 inline bool ServiceIntervalIsCustom() const { return this->vehicle_flags.Test(VehicleFlag::ServiceIntervalIsCustom); }
837
838 inline bool ServiceIntervalIsPercent() const { return this->vehicle_flags.Test(VehicleFlag::ServiceIntervalIsPercent); }
839
840 inline void SetServiceIntervalIsCustom(bool on) { this->vehicle_flags.Set(VehicleFlag::ServiceIntervalIsCustom, on); }
841
842 inline void SetServiceIntervalIsPercent(bool on) { this->vehicle_flags.Set(VehicleFlag::ServiceIntervalIsPercent, on); }
843
844 bool HasFullLoadOrder() const;
845 bool HasConditionalOrder() const;
846 bool HasUnbunchingOrder() const;
848 bool IsWaitingForUnbunching() const;
849
850private:
856 {
857 if (this->GetNumManualOrders() > 0) {
858 /* Advance to next real order */
859 do {
860 this->cur_real_order_index++;
861 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
862 } while (this->GetOrder(this->cur_real_order_index)->IsType(OT_IMPLICIT));
863 } else {
864 this->cur_real_order_index = 0;
865 }
866 }
867
868public:
875 {
877 /* Increment real order index as well */
879 }
880
882
883 /* Advance to next implicit order */
884 do {
886 if (this->cur_implicit_order_index >= this->GetNumOrders()) this->cur_implicit_order_index = 0;
887 } while (this->cur_implicit_order_index != this->cur_real_order_index && !this->GetOrder(this->cur_implicit_order_index)->IsType(OT_IMPLICIT));
888
889 InvalidateVehicleOrder(this, 0);
890 }
891
899 {
901 /* Increment both real and implicit order */
903 } else {
904 /* Increment real order only */
906 InvalidateVehicleOrder(this, 0);
907 }
908 }
909
914 {
915 /* Make sure the index is valid */
916 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
917
918 if (this->GetNumManualOrders() > 0) {
919 /* Advance to next real order */
920 while (this->GetOrder(this->cur_real_order_index)->IsType(OT_IMPLICIT)) {
921 this->cur_real_order_index++;
922 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
923 }
924 } else {
925 this->cur_real_order_index = 0;
926 }
927 }
928
934 inline Order *GetOrder(int index) const
935 {
936 return (this->orders == nullptr) ? nullptr : this->orders->GetOrderAt(index);
937 }
938
943 inline const Order *GetLastOrder() const
944 {
945 return (this->orders == nullptr) ? nullptr : this->orders->GetOrderAt(this->orders->GetLastOrder());
946 }
947
948 bool IsEngineCountable() const;
949 bool HasEngineType() const;
950 bool HasDepotOrder() const;
951 void HandlePathfindingResult(bool path_found);
952
957 [[debug_inline]] inline bool IsFrontEngine() const
958 {
959 return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_FRONT);
960 }
961
966 inline bool IsArticulatedPart() const
967 {
968 return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_ARTICULATED_PART);
969 }
970
975 inline bool HasArticulatedPart() const
976 {
977 return this->Next() != nullptr && this->Next()->IsArticulatedPart();
978 }
979
986 {
987 assert(this->HasArticulatedPart());
988 return this->Next();
989 }
990
996 {
997 Vehicle *v = this;
998 while (v->IsArticulatedPart()) v = v->Previous();
999 return v;
1000 }
1001
1006 inline const Vehicle *GetFirstEnginePart() const
1007 {
1008 const Vehicle *v = this;
1009 while (v->IsArticulatedPart()) v = v->Previous();
1010 return v;
1011 }
1012
1018 {
1019 Vehicle *v = this;
1020 while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart();
1021 return v;
1022 }
1023
1028 inline Vehicle *GetNextVehicle() const
1029 {
1030 const Vehicle *v = this;
1031 while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart();
1032
1033 /* v now contains the last articulated part in the engine */
1034 return v->Next();
1035 }
1036
1041 inline Vehicle *GetPrevVehicle() const
1042 {
1043 Vehicle *v = this->Previous();
1044 while (v != nullptr && v->IsArticulatedPart()) v = v->Previous();
1045
1046 return v;
1047 }
1048
1049 uint32_t GetDisplayMaxWeight() const;
1050 uint32_t GetDisplayMinPowerToWeight() const;
1051};
1052
1057template <class T, VehicleType Type>
1059 static const VehicleType EXPECTED_TYPE = Type;
1060
1062
1068 {
1069 this->sprite_cache.sprite_seq.count = 1;
1070 }
1071
1073 inline T *GetMovingFront() const { return (T *)this->Vehicle::GetMovingFront(); }
1075 inline T *GetMovingBack() const { return (T *)this->Vehicle::GetMovingBack(); }
1077 inline T *GetMovingNext() const { return (T *)this->Vehicle::GetMovingNext(); }
1079 inline T *GetMovingPrev() const { return (T *)this->Vehicle::GetMovingPrev(); }
1080
1085 inline T *First() const { return (T *)this->Vehicle::First(); }
1086
1091 inline T *Last() { return (T *)this->Vehicle::Last(); }
1092
1097 inline const T *Last() const { return (const T *)this->Vehicle::Last(); }
1098
1103 inline T *Next() const { return (T *)this->Vehicle::Next(); }
1104
1109 inline T *Previous() const { return (T *)this->Vehicle::Previous(); }
1110
1117
1123 inline T *GetNextArticulatedPart() const { return (T *)this->Vehicle::GetNextArticulatedPart(); }
1124
1129 inline T *GetFirstEnginePart() { return (T *)this->Vehicle::GetFirstEnginePart(); }
1130
1135 inline const T *GetFirstEnginePart() const { return (const T *)this->Vehicle::GetFirstEnginePart(); }
1136
1141 inline T *GetLastEnginePart() { return (T *)this->Vehicle::GetLastEnginePart(); }
1142
1147 inline T *GetNextVehicle() const { return (T *)this->Vehicle::GetNextVehicle(); }
1148
1153 inline T *GetPrevVehicle() const { return (T *)this->Vehicle::GetPrevVehicle(); }
1154
1160 static inline bool IsValidID(auto index)
1161 {
1162 return Vehicle::IsValidID(index) && Vehicle::Get(index)->type == Type;
1163 }
1164
1170 static inline T *Get(auto index)
1171 {
1172 return (T *)Vehicle::Get(index);
1173 }
1174
1180 static inline T *GetIfValid(auto index)
1181 {
1182 return IsValidID(index) ? Get(index) : nullptr;
1183 }
1184
1190 template <typename... Targs>
1191 static inline T *Create(Targs &&... args)
1192 {
1193 return Vehicle::Create<T>(std::forward<Targs&&>(args)...);
1194 }
1195
1202 template <typename... Targs>
1203 static inline T *CreateAtIndex(VehicleID index, Targs &&... args)
1204 {
1205 return Vehicle::CreateAtIndex<T>(index, std::forward<Targs&&>(args)...);
1206 }
1207
1213 static inline T *From(Vehicle *v)
1214 {
1215 assert(v->type == Type);
1216 return (T *)v;
1217 }
1218
1224 static inline const T *From(const Vehicle *v)
1225 {
1226 assert(v->type == Type);
1227 return (const T *)v;
1228 }
1229
1235 inline void UpdateViewport(bool force_update, bool update_delta)
1236 {
1237 bool sprite_has_changed = false;
1238
1239 /* Skip updating sprites on dedicated servers without screen */
1240 if (_network_dedicated) return;
1241
1242 /* Explicitly choose method to call to prevent vtable dereference -
1243 * it gives ~3% runtime improvements in games with many vehicles */
1244 if (update_delta) ((T *)this)->T::UpdateDeltaXY();
1245
1246 /*
1247 * Only check for a new sprite sequence if the vehicle direction
1248 * has changed since we last checked it, assuming that otherwise
1249 * there won't be enough change in bounding box or offsets to need
1250 * to resolve a new sprite.
1251 */
1252 if (this->direction != this->sprite_cache.last_direction || this->sprite_cache.is_viewport_candidate) {
1253 VehicleSpriteSeq seq;
1254
1255 ((T*)this)->T::GetImage(this->direction, EIT_ON_MAP, &seq);
1256 if (this->sprite_cache.sprite_seq != seq) {
1257 sprite_has_changed = true;
1258 this->sprite_cache.sprite_seq = seq;
1259 }
1260
1261 this->sprite_cache.last_direction = this->direction;
1262 this->sprite_cache.revalidate_before_draw = false;
1263 } else {
1264 /*
1265 * A change that could potentially invalidate the sprite has been
1266 * made, signal that we should still resolve it before drawing on a
1267 * viewport.
1268 */
1269 this->sprite_cache.revalidate_before_draw = true;
1270 }
1271
1272 if (force_update || sprite_has_changed) {
1273 this->Vehicle::UpdateViewport(true);
1274 }
1275 }
1276
1282 static Pool::IterateWrapper<T> Iterate(size_t from = 0) { return Pool::IterateWrapper<T>(from); }
1283};
1284
1286static const int32_t INVALID_COORD = 0x7fffffff;
1287
1288#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.
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:21
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.
static constexpr Owner INVALID_OWNER
An invalid owner.
Direction ReverseDir(Direction d)
Return the reverse of a direction.
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.
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.
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.
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:222
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:118
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 * CreateAtIndex(VehicleID index, Targs &&... args)
static Vehicle * Get(auto index)
static T * Create(Targs &&... args)
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.
uint16_t & GetGroundVehicleFlags()
Access the ground vehicle flags of the vehicle.
Definition vehicle.cpp:3225
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:2369
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:3008
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:2505
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:2599
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:2439
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:1712
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:2450
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:2353
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:2530
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).
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...
Vehicle(VehicleID index, VehicleType type=VEH_INVALID)
Vehicle constructor.
Definition vehicle.cpp:379
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:3299
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:1757
Money value
Value of the vehicle.
bool MarkAllViewportsDirty() const
Marks viewports dirty where the vehicle's image is.
Definition vehicle.cpp:1796
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.
uint32_t GetGRFID() const
Retrieve the GRF ID of the NewGRF the vehicle is tied to.
Definition vehicle.cpp:768
SpriteBounds bounds
Bounding box of vehicle.
GroundVehicleCache * GetGroundVehicleCache()
Access the ground vehicle cache of the vehicle.
Definition vehicle.cpp:3195
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:2485
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:2224
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:2577
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:2972
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:3284
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:3031
bool HandleBreakdown()
Handle all of the aspects of a vehicle breakdown This includes adding smoke and sounds,...
Definition vehicle.cpp:1377
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:1786
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:2496
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:1703
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:2431
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:2821
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:2186
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.
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:66
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
Definition track_type.h:85
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.
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.
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.
PoolID< uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF > VehicleID
The type all our vehicle IDs have.
VehicleType
Available vehicle types.
@ VEH_INVALID
Non-existing type of vehicle.
@ VEH_ROAD
Road vehicle type.
@ VEH_TRAIN
Train vehicle type.