OpenTTD Source: src/vehicle_base.h Source File

OpenTTD Source 12.2

vehicle_base.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef VEHICLE_BASE_H
11 #define VEHICLE_BASE_H
12
13 #include "core/smallmap_type.hpp"
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"
26 #include <list>
27 #include <map>
28
30 enum VehStatus {
31 VS_HIDDEN = 0x01,
32 VS_STOPPED = 0x02,
33 VS_UNCLICKABLE = 0x04,
34 VS_DEFPAL = 0x08,
35 VS_TRAIN_SLOWING = 0x10,
36 VS_SHADOW = 0x20,
37 VS_AIRCRAFT_BROKEN = 0x40,
38 VS_CRASHED = 0x80,
39 };
40
42 enum VehicleFlags {
43 VF_LOADING_FINISHED,
44 VF_CARGO_UNLOADING,
45 VF_BUILT_AS_PROTOTYPE,
46 VF_TIMETABLE_STARTED,
47 VF_AUTOFILL_TIMETABLE,
48 VF_AUTOFILL_PRES_WAIT_TIME,
49 VF_STOP_LOADING,
50 VF_PATHFINDER_LOST,
51 VF_SERVINT_IS_CUSTOM,
52 VF_SERVINT_IS_PERCENT,
53 };
54
56 enum NewGRFCacheValidValues {
57 NCVV_POSITION_CONSIST_LENGTH = 0,
58 NCVV_POSITION_SAME_ID_LENGTH = 1,
59 NCVV_CONSIST_CARGO_INFORMATION = 2,
60 NCVV_COMPANY_INFORMATION = 3,
61 NCVV_POSITION_IN_VEHICLE = 4,
62 NCVV_END,
63 };
64
66 struct NewGRFCache {
67 /* Values calculated when they are requested for the first time after invalidating the NewGRF cache. */
68 uint32 position_consist_length;
69 uint32 position_same_id_length;
70 uint32 consist_cargo_information;
71 uint32 company_information;
72 uint32 position_in_vehicle;
73 uint8 cache_valid;
74 };
75
77 enum VisualEffect {
78 VE_OFFSET_START = 0,
79 VE_OFFSET_COUNT = 4,
80 VE_OFFSET_CENTRE = 8,
81
82 VE_TYPE_START = 4,
83 VE_TYPE_COUNT = 2,
84 VE_TYPE_DEFAULT = 0,
85 VE_TYPE_STEAM = 1,
86 VE_TYPE_DIESEL = 2,
87 VE_TYPE_ELECTRIC = 3,
88
89 VE_DISABLE_EFFECT = 6,
90 VE_ADVANCED_EFFECT = VE_DISABLE_EFFECT,
91 VE_DISABLE_WAGON_POWER = 7,
92
93 VE_DEFAULT = 0xFF,
94 };
95
97 enum VisualEffectSpawnModel {
98 VESM_NONE = 0,
99 VESM_STEAM,
100 VESM_DIESEL,
101 VESM_ELECTRIC,
102
103 VESM_END
104 };
105
111 enum GroundVehicleSubtypeFlags {
112 GVSF_FRONT = 0,
113 GVSF_ARTICULATED_PART = 1,
114 GVSF_WAGON = 2,
115 GVSF_ENGINE = 3,
116 GVSF_FREE_WAGON = 4,
117 GVSF_MULTIHEADED = 5,
118 };
119
121 struct VehicleCache {
122 uint16 cached_max_speed;
123 uint16 cached_cargo_age_period;
124
125 byte cached_vis_effect;
126 };
127
129 struct VehicleSpriteSeq {
130 PalSpriteID seq[4];
131 uint count;
132
133 bool operator==(const VehicleSpriteSeq &other) const
134 {
135 return this->count == other.count && MemCmpT<PalSpriteID>(this->seq, other.seq, this->count) == 0;
136 }
137
138 bool operator!=(const VehicleSpriteSeq &other) const
139 {
140 return !this->operator==(other);
141 }
142
146 bool IsValid() const
147 {
148 return this->count != 0;
149 }
150
154 void Clear()
155 {
156 this->count = 0;
157 }
158
162 void Set(SpriteID sprite)
163 {
164 this->count = 1;
165 this->seq[0].sprite = sprite;
166 this->seq[0].pal = 0;
167 }
168
172 void CopyWithoutPalette(const VehicleSpriteSeq &src)
173 {
174 this->count = src.count;
175 for (uint i = 0; i < src.count; ++i) {
176 this->seq[i].sprite = src.seq[i].sprite;
177 this->seq[i].pal = 0;
178 }
179 }
180
181 void GetBounds(Rect *bounds) const;
182 void Draw(int x, int y, PaletteID default_pal, bool force_pal) const;
183 };
184
189 struct MutableSpriteCache {
190 Direction last_direction;
191 bool revalidate_before_draw;
192 Rect old_coord;
193 bool is_viewport_candidate;
194 VehicleSpriteSeq sprite_seq;
195 };
196
198 typedef Pool<Vehicle, VehicleID, 512, 0xFF000> VehiclePool;
199 extern VehiclePool _vehicle_pool;
200
201 /* Some declarations of functions, so we can make them friendly */
202 struct GroundVehicleCache;
203 struct LoadgameState;
204 extern bool LoadOldVehicle(LoadgameState *ls, int num);
205 extern void FixOldVehicles();
206
207 struct GRFFile;
208
212 struct RefitDesc {
213 CargoID cargo;
214 uint16 capacity;
215 uint16 remaining;
216 RefitDesc(CargoID cargo, uint16 capacity, uint16 remaining) :
217 cargo(cargo), capacity(capacity), remaining(remaining) {}
218 };
219
221 struct Vehicle : VehiclePool::PoolItem<&_vehicle_pool>, BaseVehicle, BaseConsist {
222 private:
223 typedef std::list<RefitDesc> RefitList;
224 typedef std::map<CargoID, uint> CapacitiesMap;
225
226 Vehicle *next;
227 Vehicle *previous;
228 Vehicle *first;
229
230 Vehicle *next_shared;
231 Vehicle *previous_shared;
232
233 public:
234 friend void FixOldVehicles();
235 friend void AfterLoadVehicles(bool part_of_load);
236 friend bool LoadOldVehicle(LoadgameState *ls, int num);
237 /* So we can use private/protected variables in the saveload code */
238 friend class SlVehicleCommon;
239 friend class SlVehicleDisaster;
240 friend void Ptrs_VEHS();
241
242 TileIndex tile;
243
249 TileIndex dest_tile;
250
251 Money profit_this_year;
252 Money profit_last_year;
253 Money value;
254
255 CargoPayment *cargo_payment;
256
257 mutable Rect coord;
258
259 Vehicle *hash_viewport_next;
260 Vehicle **hash_viewport_prev;
261
262 Vehicle *hash_tile_next;
263 Vehicle **hash_tile_prev;
264 Vehicle **hash_tile_current;
265
266 SpriteID colourmap;
267
268 /* Related to age and service time */
269 Year build_year;
270 Date age;
271 Date max_age;
272 Date date_of_last_service;
273 uint16 reliability;
274 uint16 reliability_spd_dec;
275 byte breakdown_ctr;
276 byte breakdown_delay;
277 byte breakdowns_since_last_service;
278 byte breakdown_chance;
279
280 int32 x_pos;
281 int32 y_pos;
282 int32 z_pos;
283 Direction direction;
284
285 Owner owner;
286
291 byte spritenum;
292 byte x_extent;
293 byte y_extent;
294 byte z_extent;
295 int8 x_bb_offs;
296 int8 y_bb_offs;
297 int8 x_offs;
298 int8 y_offs;
299 EngineID engine_type;
300
301 TextEffectID fill_percent_te_id;
302 UnitID unitnumber;
303
304 uint16 cur_speed;
305 byte subspeed;
306 byte acceleration;
307 uint32 motion_counter;
308 byte progress;
309
310 byte random_bits;
311 byte waiting_triggers;
312
313 StationID last_station_visited;
314 StationID last_loading_station;
315
316 CargoID cargo_type;
317 byte cargo_subtype;
318 uint16 cargo_cap;
319 uint16 refit_cap;
320 VehicleCargoList cargo;
321 uint16 cargo_age_counter;
322 int8 trip_occupancy;
323
324 byte day_counter;
325 byte tick_counter;
326 byte running_ticks;
327
328 byte vehstatus;
329 Order current_order;
330
331 union {
332 OrderList *list;
333 Order *old;
334 } orders;
335
336 uint16 load_unload_ticks;
337 GroupID group_id;
338 byte subtype;
339
340 NewGRFCache grf_cache;
341 VehicleCache vcache;
342
343 mutable MutableSpriteCache sprite_cache;
344
345 Vehicle(VehicleType type = VEH_INVALID);
346
347 void PreDestructor();
349 virtual ~Vehicle();
350
351 void BeginLoading();
352 void CancelReservation(StationID next, Station *st);
353 void LeaveStation();
354
355 GroundVehicleCache *GetGroundVehicleCache();
356 const GroundVehicleCache *GetGroundVehicleCache() const;
357
358 uint16 &GetGroundVehicleFlags();
359 const uint16 &GetGroundVehicleFlags() const;
360
361 void DeleteUnreachedImplicitOrders();
362
363 void HandleLoading(bool mode = false);
364
365 void GetConsistFreeCapacities(SmallMap<CargoID, uint> &capacities) const;
366
367 uint GetConsistTotalCapacity() const;
368
377 virtual void MarkDirty() {}
378
383 virtual void UpdateDeltaXY() {}
384
398 inline uint GetOldAdvanceSpeed(uint speed)
399 {
400 return (this->direction & 1) ? speed : speed * 3 / 4;
401 }
402
415 static inline uint GetAdvanceSpeed(uint speed)
416 {
417 return speed * 3 / 4;
418 }
419
427 inline uint GetAdvanceDistance()
428 {
429 return (this->direction & 1) ? 192 : 256;
430 }
431
436 virtual ExpensesType GetExpenseType(bool income) const { return EXPENSES_OTHER; }
437
441 virtual void PlayLeaveStationSound() const {}
442
446 virtual bool IsPrimaryVehicle() const { return false; }
447
448 const Engine *GetEngine() const;
449
455 virtual void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const { result->Clear(); }
456
457 const GRFFile *GetGRF() const;
458 uint32 GetGRFID() const;
459
464 inline void InvalidateNewGRFCache()
465 {
466 this->grf_cache.cache_valid = 0;
467 }
468
473 inline void InvalidateNewGRFCacheOfChain()
474 {
475 for (Vehicle *u = this; u != nullptr; u = u->Next()) {
476 u->InvalidateNewGRFCache();
477 }
478 }
479
484 inline bool IsGroundVehicle() const
485 {
486 return this->type == VEH_TRAIN || this->type == VEH_ROAD;
487 }
488
493 virtual int GetDisplaySpeed() const { return 0; }
494
499 virtual int GetDisplayMaxSpeed() const { return 0; }
500
505 virtual int GetCurrentMaxSpeed() const { return 0; }
506
511 virtual Money GetRunningCost() const { return 0; }
512
517 virtual bool IsInDepot() const { return false; }
518
523 virtual bool IsChainInDepot() const { return this->IsInDepot(); }
524
529 bool IsStoppedInDepot() const
530 {
531 assert(this == this->First());
532 /* Free wagons have no VS_STOPPED state */
533 if (this->IsPrimaryVehicle() && !(this->vehstatus & VS_STOPPED)) return false;
534 return this->IsChainInDepot();
535 }
536
541 virtual bool Tick() { return true; };
542
546 virtual void OnNewDay() {};
547
548 void ShiftDates(int interval);
549
555 virtual uint Crash(bool flooded = false);
556
569 virtual Trackdir GetVehicleTrackdir() const { return INVALID_TRACKDIR; }
570
575 Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
576
581 Money GetDisplayProfitThisYear() const { return (this->profit_this_year >> 8); }
582
587 Money GetDisplayProfitLastYear() const { return (this->profit_last_year >> 8); }
588
589 void SetNext(Vehicle *next);
590
596 inline Vehicle *Next() const { return this->next; }
597
603 inline Vehicle *Previous() const { return this->previous; }
604
609 inline Vehicle *First() const { return this->first; }
610
615 inline Vehicle *Last()
616 {
617 Vehicle *v = this;
618 while (v->Next() != nullptr) v = v->Next();
619 return v;
620 }
621
626 inline const Vehicle *Last() const
627 {
628 const Vehicle *v = this;
629 while (v->Next() != nullptr) v = v->Next();
630 return v;
631 }
632
638 inline Vehicle *Move(int n)
639 {
640 Vehicle *v = this;
641 if (n < 0) {
642 for (int i = 0; i != n && v != nullptr; i--) v = v->Previous();
643 } else {
644 for (int i = 0; i != n && v != nullptr; i++) v = v->Next();
645 }
646 return v;
647 }
648
654 inline const Vehicle *Move(int n) const
655 {
656 const Vehicle *v = this;
657 if (n < 0) {
658 for (int i = 0; i != n && v != nullptr; i--) v = v->Previous();
659 } else {
660 for (int i = 0; i != n && v != nullptr; i++) v = v->Next();
661 }
662 return v;
663 }
664
669 inline Order *GetFirstOrder() const { return (this->orders.list == nullptr) ? nullptr : this->orders.list->GetFirstOrder(); }
670
671 void AddToShared(Vehicle *shared_chain);
672 void RemoveFromShared();
673
678 inline Vehicle *NextShared() const { return this->next_shared; }
679
684 inline Vehicle *PreviousShared() const { return this->previous_shared; }
685
690 inline Vehicle *FirstShared() const { return (this->orders.list == nullptr) ? this->First() : this->orders.list->GetFirstSharedVehicle(); }
691
696 inline bool IsOrderListShared() const { return this->orders.list != nullptr && this->orders.list->IsShared(); }
697
702 inline VehicleOrderID GetNumOrders() const { return (this->orders.list == nullptr) ? 0 : this->orders.list->GetNumOrders(); }
703
708 inline VehicleOrderID GetNumManualOrders() const { return (this->orders.list == nullptr) ? 0 : this->orders.list->GetNumManualOrders(); }
709
714 inline StationIDStack GetNextStoppingStation() const
715 {
716 return (this->orders.list == nullptr) ? INVALID_STATION : this->orders.list->GetNextStoppingStation(this);
717 }
718
719 void ResetRefitCaps();
720
727 inline void CopyVehicleConfigAndStatistics(const Vehicle *src)
728 {
729 this->CopyConsistPropertiesFrom(src);
730
731 this->unitnumber = src->unitnumber;
732
733 this->current_order = src->current_order;
734 this->dest_tile = src->dest_tile;
735
736 this->profit_this_year = src->profit_this_year;
737 this->profit_last_year = src->profit_last_year;
738 }
739
740
741 bool HandleBreakdown();
742
743 bool NeedsAutorenewing(const Company *c, bool use_renew_setting = true) const;
744
745 bool NeedsServicing() const;
746 bool NeedsAutomaticServicing() const;
747
755 virtual TileIndex GetOrderStationLocation(StationID station) { return INVALID_TILE; }
756
765 virtual bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse) { return false; }
766
767 virtual void SetDestTile(TileIndex tile) { this->dest_tile = tile; }
768
769 CommandCost SendToDepot(DoCommandFlag flags, DepotCommand command);
770
771 void UpdateVisualEffect(bool allow_power_change = true);
772 void ShowVisualEffect() const;
773
774 void UpdatePosition();
775 void UpdateViewport(bool dirty);
776 void UpdateBoundingBoxCoordinates(bool update_cache) const;
777 void UpdatePositionAndViewport();
778 bool MarkAllViewportsDirty() const;
779
780 inline uint16 GetServiceInterval() const { return this->service_interval; }
781
782 inline void SetServiceInterval(uint16 interval) { this->service_interval = interval; }
783
784 inline bool ServiceIntervalIsCustom() const { return HasBit(this->vehicle_flags, VF_SERVINT_IS_CUSTOM); }
785
786 inline bool ServiceIntervalIsPercent() const { return HasBit(this->vehicle_flags, VF_SERVINT_IS_PERCENT); }
787
788 inline void SetServiceIntervalIsCustom(bool on) { SB(this->vehicle_flags, VF_SERVINT_IS_CUSTOM, 1, on); }
789
790 inline void SetServiceIntervalIsPercent(bool on) { SB(this->vehicle_flags, VF_SERVINT_IS_PERCENT, 1, on); }
791
792 private:
797 void SkipToNextRealOrderIndex()
798 {
799 if (this->GetNumManualOrders() > 0) {
800 /* Advance to next real order */
801 do {
802 this->cur_real_order_index++;
803 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
804 } while (this->GetOrder(this->cur_real_order_index)->IsType(OT_IMPLICIT));
805 } else {
806 this->cur_real_order_index = 0;
807 }
808 }
809
810 public:
816 void IncrementImplicitOrderIndex()
817 {
818 if (this->cur_implicit_order_index == this->cur_real_order_index) {
819 /* Increment real order index as well */
820 this->SkipToNextRealOrderIndex();
821 }
822
823 assert(this->cur_real_order_index == 0 || this->cur_real_order_index < this->GetNumOrders());
824
825 /* Advance to next implicit order */
826 do {
827 this->cur_implicit_order_index++;
828 if (this->cur_implicit_order_index >= this->GetNumOrders()) this->cur_implicit_order_index = 0;
829 } while (this->cur_implicit_order_index != this->cur_real_order_index && !this->GetOrder(this->cur_implicit_order_index)->IsType(OT_IMPLICIT));
830
831 InvalidateVehicleOrder(this, 0);
832 }
833
840 void IncrementRealOrderIndex()
841 {
842 if (this->cur_implicit_order_index == this->cur_real_order_index) {
843 /* Increment both real and implicit order */
844 this->IncrementImplicitOrderIndex();
845 } else {
846 /* Increment real order only */
847 this->SkipToNextRealOrderIndex();
848 InvalidateVehicleOrder(this, 0);
849 }
850 }
851
855 void UpdateRealOrderIndex()
856 {
857 /* Make sure the index is valid */
858 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
859
860 if (this->GetNumManualOrders() > 0) {
861 /* Advance to next real order */
862 while (this->GetOrder(this->cur_real_order_index)->IsType(OT_IMPLICIT)) {
863 this->cur_real_order_index++;
864 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
865 }
866 } else {
867 this->cur_real_order_index = 0;
868 }
869 }
870
876 inline Order *GetOrder(int index) const
877 {
878 return (this->orders.list == nullptr) ? nullptr : this->orders.list->GetOrderAt(index);
879 }
880
885 inline Order *GetLastOrder() const
886 {
887 return (this->orders.list == nullptr) ? nullptr : this->orders.list->GetLastOrder();
888 }
889
890 bool IsEngineCountable() const;
891 bool HasEngineType() const;
892 bool HasDepotOrder() const;
893 void HandlePathfindingResult(bool path_found);
894
899 inline bool IsFrontEngine() const
900 {
901 return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_FRONT);
902 }
903
908 inline bool IsArticulatedPart() const
909 {
910 return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_ARTICULATED_PART);
911 }
912
917 inline bool HasArticulatedPart() const
918 {
919 return this->Next() != nullptr && this->Next()->IsArticulatedPart();
920 }
921
927 inline Vehicle *GetNextArticulatedPart() const
928 {
929 assert(this->HasArticulatedPart());
930 return this->Next();
931 }
932
937 inline Vehicle *GetFirstEnginePart()
938 {
939 Vehicle *v = this;
940 while (v->IsArticulatedPart()) v = v->Previous();
941 return v;
942 }
943
948 inline const Vehicle *GetFirstEnginePart() const
949 {
950 const Vehicle *v = this;
951 while (v->IsArticulatedPart()) v = v->Previous();
952 return v;
953 }
954
959 inline Vehicle *GetLastEnginePart()
960 {
961 Vehicle *v = this;
962 while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart();
963 return v;
964 }
965
970 inline Vehicle *GetNextVehicle() const
971 {
972 const Vehicle *v = this;
973 while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart();
974
975 /* v now contains the last articulated part in the engine */
976 return v->Next();
977 }
978
983 inline Vehicle *GetPrevVehicle() const
984 {
985 Vehicle *v = this->Previous();
986 while (v != nullptr && v->IsArticulatedPart()) v = v->Previous();
987
988 return v;
989 }
990
995 struct OrderIterator {
996 typedef Order value_type;
997 typedef Order* pointer;
998 typedef Order& reference;
999 typedef size_t difference_type;
1000 typedef std::forward_iterator_tag iterator_category;
1001
1002 explicit OrderIterator(OrderList *list) : list(list), prev(nullptr)
1003 {
1004 this->order = (this->list == nullptr) ? nullptr : this->list->GetFirstOrder();
1005 }
1006
1007 bool operator==(const OrderIterator &other) const { return this->order == other.order; }
1008 bool operator!=(const OrderIterator &other) const { return !(*this == other); }
1009 Order * operator*() const { return this->order; }
1010 OrderIterator & operator++()
1011 {
1012 this->prev = (this->prev == nullptr) ? this->list->GetFirstOrder() : this->prev->next;
1013 this->order = (this->prev == nullptr) ? nullptr : this->prev->next;
1014 return *this;
1015 }
1016
1017 private:
1018 OrderList *list;
1019 Order *order;
1020 Order *prev;
1021 };
1022
1026 struct IterateWrapper {
1027 OrderList *list;
1028 IterateWrapper(OrderList *list = nullptr) : list(list) {}
1029 OrderIterator begin() { return OrderIterator(this->list); }
1030 OrderIterator end() { return OrderIterator(nullptr); }
1031 bool empty() { return this->begin() == this->end(); }
1032 };
1033
1038 IterateWrapper Orders() const { return IterateWrapper(this->orders.list); }
1039 };
1040
1045 template <class T, VehicleType Type>
1046 struct SpecializedVehicle : public Vehicle {
1047 static const VehicleType EXPECTED_TYPE = Type;
1048
1049 typedef SpecializedVehicle<T, Type> SpecializedVehicleBase;
1050
1054 inline SpecializedVehicle<T, Type>() : Vehicle(Type)
1055 {
1056 this->sprite_cache.sprite_seq.count = 1;
1057 }
1058
1063 inline T *First() const { return (T *)this->Vehicle::First(); }
1064
1069 inline T *Last() { return (T *)this->Vehicle::Last(); }
1070
1075 inline const T *Last() const { return (const T *)this->Vehicle::Last(); }
1076
1081 inline T *Next() const { return (T *)this->Vehicle::Next(); }
1082
1087 inline T *Previous() const { return (T *)this->Vehicle::Previous(); }
1088
1094 inline T *GetNextArticulatedPart() { return (T *)this->Vehicle::GetNextArticulatedPart(); }
1095
1101 inline T *GetNextArticulatedPart() const { return (T *)this->Vehicle::GetNextArticulatedPart(); }
1102
1107 inline T *GetFirstEnginePart() { return (T *)this->Vehicle::GetFirstEnginePart(); }
1108
1113 inline const T *GetFirstEnginePart() const { return (const T *)this->Vehicle::GetFirstEnginePart(); }
1114
1119 inline T *GetLastEnginePart() { return (T *)this->Vehicle::GetLastEnginePart(); }
1120
1125 inline T *GetNextVehicle() const { return (T *)this->Vehicle::GetNextVehicle(); }
1126
1131 inline T *GetPrevVehicle() const { return (T *)this->Vehicle::GetPrevVehicle(); }
1132
1138 static inline bool IsValidID(size_t index)
1139 {
1140 return Vehicle::IsValidID(index) && Vehicle::Get(index)->type == Type;
1141 }
1142
1147 static inline T *Get(size_t index)
1148 {
1149 return (T *)Vehicle::Get(index);
1150 }
1151
1156 static inline T *GetIfValid(size_t index)
1157 {
1158 return IsValidID(index) ? Get(index) : nullptr;
1159 }
1160
1166 static inline T *From(Vehicle *v)
1167 {
1168 assert(v->type == Type);
1169 return (T *)v;
1170 }
1171
1177 static inline const T *From(const Vehicle *v)
1178 {
1179 assert(v->type == Type);
1180 return (const T *)v;
1181 }
1182
1188 inline void UpdateViewport(bool force_update, bool update_delta)
1189 {
1190 bool sprite_has_changed = false;
1191
1192 /* Skip updating sprites on dedicated servers without screen */
1193 if (_network_dedicated) return;
1194
1195 /* Explicitly choose method to call to prevent vtable dereference -
1196 * it gives ~3% runtime improvements in games with many vehicles */
1197 if (update_delta) ((T *)this)->T::UpdateDeltaXY();
1198
1199 /*
1200 * Only check for a new sprite sequence if the vehicle direction
1201 * has changed since we last checked it, assuming that otherwise
1202 * there won't be enough change in bounding box or offsets to need
1203 * to resolve a new sprite.
1204 */
1205 if (this->direction != this->sprite_cache.last_direction || this->sprite_cache.is_viewport_candidate) {
1206 VehicleSpriteSeq seq;
1207
1208 ((T*)this)->T::GetImage(this->direction, EIT_ON_MAP, &seq);
1209 if (this->sprite_cache.sprite_seq != seq) {
1210 sprite_has_changed = true;
1211 this->sprite_cache.sprite_seq = seq;
1212 }
1213
1214 this->sprite_cache.last_direction = this->direction;
1215 this->sprite_cache.revalidate_before_draw = false;
1216 } else {
1217 /*
1218 * A change that could potentially invalidate the sprite has been
1219 * made, signal that we should still resolve it before drawing on a
1220 * viewport.
1221 */
1222 this->sprite_cache.revalidate_before_draw = true;
1223 }
1224
1225 if (force_update || sprite_has_changed) {
1226 this->Vehicle::UpdateViewport(true);
1227 }
1228 }
1229
1235 static Pool::IterateWrapper<T> Iterate(size_t from = 0) { return Pool::IterateWrapper<T>(from); }
1236 };
1237
1239 struct FreeUnitIDGenerator {
1240 bool *cache;
1241 UnitID maxid;
1242 UnitID curid;
1243
1244 FreeUnitIDGenerator(VehicleType type, CompanyID owner);
1245 UnitID NextID();
1246
1248 ~FreeUnitIDGenerator() { free(this->cache); }
1249 };
1250
1252 static const int32 INVALID_COORD = 0x7fffffff;
1253
1254 #endif /* VEHICLE_BASE_H */
SpecializedVehicle::GetNextVehicle
T * GetNextVehicle() const
Get the next real (non-articulated part) vehicle in the consist.
Definition: vehicle_base.h:1125
GVSF_ENGINE
@ GVSF_ENGINE
Engine that can be front engine, but might be placed behind another engine (not used for road vehicle...
Definition: vehicle_base.h:115
Vehicle::GetGroundVehicleCache
GroundVehicleCache * GetGroundVehicleCache()
Access the ground vehicle cache of the vehicle.
Definition: vehicle.cpp:2905
Vehicle::IsChainInDepot
virtual bool IsChainInDepot() const
Check whether the whole vehicle chain is in the depot.
Definition: vehicle_base.h:523
BaseConsist::cur_implicit_order_index
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
Definition: base_consist.h:29
Vehicle::SkipToNextRealOrderIndex
void SkipToNextRealOrderIndex()
Advance cur_real_order_index to the next real order.
Definition: vehicle_base.h:797
VehicleOrderID
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition: order_type.h:15
MutableSpriteCache::is_viewport_candidate
bool is_viewport_candidate
This vehicle can potentially be drawn on a viewport.
Definition: vehicle_base.h:193
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:83
transport_type.h
LoadgameState
Definition: oldloader.h:19
SmallStack
Minimal stack that uses a pool to avoid pointers.
Definition: smallstack_type.hpp:136
MutableSpriteCache::last_direction
Direction last_direction
Last direction we obtained sprites for.
Definition: vehicle_base.h:190
VE_OFFSET_COUNT
@ VE_OFFSET_COUNT
Number of bits used for the offset.
Definition: vehicle_base.h:79
VE_DISABLE_EFFECT
@ VE_DISABLE_EFFECT
Flag to disable visual effect.
Definition: vehicle_base.h:89
Vehicle::PreDestructor
void PreDestructor()
Destroy all stuff that (still) needs the virtual functions to work properly.
Definition: vehicle.cpp:814
Pool::PoolItem<&_vehicle_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:24
Vehicle::y_pos
int32 y_pos
y coordinate.
Definition: vehicle_base.h:281
SpecializedVehicle::SpecializedVehicleBase
SpecializedVehicle< T, Type > SpecializedVehicleBase
Our type.
Definition: vehicle_base.h:1049
MutableSpriteCache::sprite_seq
VehicleSpriteSeq sprite_seq
Vehicle appearance.
Definition: vehicle_base.h:194
VehicleSpriteSeq::CopyWithoutPalette
void CopyWithoutPalette(const VehicleSpriteSeq &src)
Copy data from another sprite sequence, while dropping all recolouring information.
Definition: vehicle_base.h:172
Vehicle::PreviousShared
Vehicle * PreviousShared() const
Get the previous vehicle of the shared vehicle chain.
Definition: vehicle_base.h:684
Vehicle::GetNumManualOrders
VehicleOrderID GetNumManualOrders() const
Get the number of manually added orders this vehicle has.
Definition: vehicle_base.h:708
Vehicle::GetRunningCost
virtual Money GetRunningCost() const
Gets the running cost of a vehicle.
Definition: vehicle_base.h:511
Vehicle::value
Money value
Value of the vehicle.
Definition: vehicle_base.h:253
Vehicle::x_pos
int32 x_pos
x coordinate.
Definition: vehicle_base.h:280
_vehicle_pool
VehiclePool _vehicle_pool
The pool with all our precious vehicles.
RefitDesc::capacity
uint16 capacity
Capacity the vehicle will have.
Definition: vehicle_base.h:214
Vehicle::HasEngineType
bool HasEngineType() const
Check whether Vehicle::engine_type has any meaning.
Definition: vehicle.cpp:725
Vehicle::GetGroundVehicleFlags
uint16 & GetGroundVehicleFlags()
Access the ground vehicle flags of the vehicle.
Definition: vehicle.cpp:2935
Vehicle::IsEngineCountable
bool IsEngineCountable() const
Check if a vehicle is counted in num_engines in each company struct.
Definition: vehicle.cpp:708
Vehicle::Previous
Vehicle * Previous() const
Get the previous vehicle of this vehicle.
Definition: vehicle_base.h:603
Vehicle::GetNextVehicle
Vehicle * GetNextVehicle() const
Get the next real (non-articulated part) vehicle in the consist.
Definition: vehicle_base.h:970
Vehicle::UpdateDeltaXY
virtual void UpdateDeltaXY()
Updates the x and y offsets and the size of the sprite used for this vehicle.
Definition: vehicle_base.h:383
Vehicle::LeaveStation
void LeaveStation()
Perform all actions when leaving a station.
Definition: vehicle.cpp:2261
Vehicle::Next
Vehicle * Next() const
Get the next vehicle of this vehicle.
Definition: vehicle_base.h:596
SpecializedVehicle::Next
T * Next() const
Get next vehicle in the chain.
Definition: vehicle_base.h:1081
EXPENSES_OTHER
@ EXPENSES_OTHER
Other expenses.
Definition: economy_type.h:170
Vehicle::GetDisplayMaxSpeed
virtual int GetDisplayMaxSpeed() const
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
Definition: vehicle_base.h:499
Vehicle::y_extent
byte y_extent
y-extent of vehicle bounding box
Definition: vehicle_base.h:293
UnitID
uint16 UnitID
Type for the company global vehicle unit number.
Definition: transport_type.h:16
Station
Station data structure.
Definition: station_base.h:447
RefitDesc::remaining
uint16 remaining
Capacity remaining from before the previous refit.
Definition: vehicle_base.h:215
Vehicle::NeedsAutomaticServicing
bool NeedsAutomaticServicing() const
Checks if the current order should be interrupted for a service-in-depot order.
Definition: vehicle.cpp:252
Vehicle::z_pos
int32 z_pos
z coordinate.
Definition: vehicle_base.h:282
Vehicle::load_unload_ticks
uint16 load_unload_ticks
Ticks to wait before starting next cycle.
Definition: vehicle_base.h:336
Vehicle::GetLastEnginePart
Vehicle * GetLastEnginePart()
Get the last part of an articulated engine.
Definition: vehicle_base.h:959
VehicleSpriteSeq::Clear
void Clear()
Clear all information.
Definition: vehicle_base.h:154
VehicleSpriteSeq::Set
void Set(SpriteID sprite)
Assign a single sprite to the sequence.
Definition: vehicle_base.h:162
NewGRFCache::position_same_id_length
uint32 position_same_id_length
Cache for NewGRF var 41.
Definition: vehicle_base.h:69
FreeUnitIDGenerator::curid
UnitID curid
last ID returned; 0 if none
Definition: vehicle_base.h:1242
Vehicle::random_bits
byte random_bits
Bits used for determining which randomized variational spritegroups to use when drawing.
Definition: vehicle_base.h:310
Vehicle::vehstatus
byte vehstatus
Status.
Definition: vehicle_base.h:328
VE_DEFAULT
@ VE_DEFAULT
Default value to indicate that visual effect should be based on engine class.
Definition: vehicle_base.h:93
Vehicle::grf_cache
NewGRFCache grf_cache
Cache of often used calculated NewGRF values.
Definition: vehicle_base.h:340
VS_DEFPAL
@ VS_DEFPAL
Use default vehicle palette.
Definition: vehicle_base.h:34
Pool::PoolItem<&_vehicle_pool >::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
Vehicle::SetNext
void SetNext(Vehicle *next)
Set the next vehicle of this vehicle.
Definition: vehicle.cpp:2740
order_base.h
Vehicle::Crash
virtual uint Crash(bool flooded=false)
Crash the (whole) vehicle chain.
Definition: vehicle.cpp:260
Vehicle::acceleration
byte acceleration
used by train & aircraft
Definition: vehicle_base.h:306
PalSpriteID::sprite
SpriteID sprite
The 'real' sprite.
Definition: gfx_type.h:23
Vehicle::group_id
GroupID group_id
Index of group Pool array.
Definition: vehicle_base.h:337
Vehicle::Vehicle
Vehicle(VehicleType type=VEH_INVALID)
Vehicle constructor.
Definition: vehicle.cpp:345
Vehicle::old
Order * old
Only used during conversion of old save games.
Definition: vehicle_base.h:333
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
GroundVehicleSubtypeFlags
GroundVehicleSubtypeFlags
Enum to handle ground vehicle subtypes.
Definition: vehicle_base.h:111
VE_TYPE_ELECTRIC
@ VE_TYPE_ELECTRIC
Electric sparks.
Definition: vehicle_base.h:87
Vehicle::next
Vehicle * next
pointer to the next vehicle in the chain
Definition: vehicle_base.h:226
Vehicle::GetGRF
const GRFFile * GetGRF() const
Retrieve the NewGRF the vehicle is tied to.
Definition: vehicle.cpp:751
Year
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:18
NewGRFCache::cache_valid
uint8 cache_valid
Bitset that indicates which cache values are valid.
Definition: vehicle_base.h:73
VF_LOADING_FINISHED
@ VF_LOADING_FINISHED
Vehicle has finished loading.
Definition: vehicle_base.h:43
saveload.h
SpecializedVehicle::GetNextArticulatedPart
T * GetNextArticulatedPart()
Get the next part of an articulated engine.
Definition: vehicle_base.h:1094
Vehicle::running_ticks
byte running_ticks
Number of ticks this vehicle was not stopped this day.
Definition: vehicle_base.h:326
Vehicle::~Vehicle
virtual ~Vehicle()
We want to 'destruct' the right class.
Definition: vehicle.cpp:880
base_consist.h
VE_TYPE_COUNT
@ VE_TYPE_COUNT
Number of bits used for the effect type.
Definition: vehicle_base.h:83
Vehicle::GetConsistFreeCapacities
void GetConsistFreeCapacities(SmallMap< CargoID, uint > &capacities) const
Get a map of cargoes and free capacities in the consist.
Definition: vehicle.cpp:2358
VS_TRAIN_SLOWING
@ VS_TRAIN_SLOWING
Train is slowing down.
Definition: vehicle_base.h:35
Vehicle::OrderIterator
Iterator to iterate orders Supports deletion of current order.
Definition: vehicle_base.h:995
smallmap_type.hpp
Vehicle::GetNextArticulatedPart
Vehicle * GetNextArticulatedPart() const
Get the next part of an articulated engine.
Definition: vehicle_base.h:927
Vehicle::AfterLoadVehicles
friend void AfterLoadVehicles(bool part_of_load)
So we can set the previous and first pointers while loading.
Definition: vehicle_sl.cpp:242
Vehicle::orders
union Vehicle::@49 orders
The orders currently assigned to the vehicle.
EngineImageType
EngineImageType
Visualisation contexts of vehicles and engines.
Definition: vehicle_type.h:85
Engine
Definition: engine_base.h:27
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
Vehicle::cur_speed
uint16 cur_speed
current speed
Definition: vehicle_base.h:304
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:221
Vehicle::IsPrimaryVehicle
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
Definition: vehicle_base.h:446
Vehicle::IsGroundVehicle
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
Definition: vehicle_base.h:484
VehicleSpriteSeq::Draw
void Draw(int x, int y, PaletteID default_pal, bool force_pal) const
Draw the sprite sequence.
Definition: vehicle.cpp:126
Vehicle::owner
Owner owner
Which company owns the vehicle?
Definition: vehicle_base.h:285
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
VehicleCache::cached_cargo_age_period
uint16 cached_cargo_age_period
Number of ticks before carried cargo is aged.
Definition: vehicle_base.h:123
Vehicle::IsInDepot
virtual bool IsInDepot() const
Check whether the vehicle is in the depot.
Definition: vehicle_base.h:517
VS_AIRCRAFT_BROKEN
@ VS_AIRCRAFT_BROKEN
Aircraft is broken down.
Definition: vehicle_base.h:37
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition: command_type.h:346
VE_OFFSET_START
@ VE_OFFSET_START
First bit that contains the offset (0 = front, 8 = centre, 15 = rear)
Definition: vehicle_base.h:78
Vehicle::breakdowns_since_last_service
byte breakdowns_since_last_service
Counter for the amount of breakdowns.
Definition: vehicle_base.h:277
Vehicle::UpdateRealOrderIndex
void UpdateRealOrderIndex()
Skip implicit orders until cur_real_order_index is a non-implicit order.
Definition: vehicle_base.h:855
NCVV_POSITION_IN_VEHICLE
@ NCVV_POSITION_IN_VEHICLE
This bit will be set if the NewGRF var 4D currently stored is valid.
Definition: vehicle_base.h:61
SmallMap
Implementation of simple mapping class.
Definition: smallmap_type.hpp:26
Vehicle::IsArticulatedPart
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
Definition: vehicle_base.h:908
VehicleCargoList
CargoList that is used for vehicles.
Definition: cargopacket.h:269
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
VF_STOP_LOADING
@ VF_STOP_LOADING
Don't load anymore during the next load cycle.
Definition: vehicle_base.h:49
SlVehicleCommon
Definition: vehicle_sl.cpp:578
VE_TYPE_DIESEL
@ VE_TYPE_DIESEL
Diesel fumes.
Definition: vehicle_base.h:86
VESM_STEAM
@ VESM_STEAM
Steam model.
Definition: vehicle_base.h:99
Vehicle::GetDisplayRunningCost
Money GetDisplayRunningCost() const
Gets the running cost of a vehicle that can be sent into SetDParam for string processing.
Definition: vehicle_base.h:575
VF_AUTOFILL_TIMETABLE
@ VF_AUTOFILL_TIMETABLE
Whether the vehicle should fill in the timetable automatically.
Definition: vehicle_base.h:47
MutableSpriteCache
Cache for vehicle sprites and values relating to whether they should be updated before drawing,...
Definition: vehicle_base.h:189
Vehicle::Orders
IterateWrapper Orders() const
Returns an iterable ensemble of orders of a vehicle.
Definition: vehicle_base.h:1038
Vehicle::Last
const Vehicle * Last() const
Get the last vehicle of this vehicle chain.
Definition: vehicle_base.h:626
Vehicle::BeginLoading
void BeginLoading()
Prepare everything to begin the loading when arriving at a station.
Definition: vehicle.cpp:2113
Vehicle::breakdown_ctr
byte breakdown_ctr
Counter for managing breakdown events.
Definition: vehicle_base.h:275
VS_HIDDEN
@ VS_HIDDEN
Vehicle is not visible.
Definition: vehicle_base.h:31
EngineID
uint16 EngineID
Unique identification number of an engine.
Definition: engine_type.h:21
Vehicle::UpdateVisualEffect
void UpdateVisualEffect(bool allow_power_change=true)
Update the cached visual effect.
Definition: vehicle.cpp:2467
VehicleSpriteSeq::IsValid
bool IsValid() const
Check whether the sequence contains any sprites.
Definition: vehicle_base.h:146
Vehicle::dest_tile
TileIndex dest_tile
Heading for this tile.
Definition: vehicle_base.h:249
Vehicle::HandlePathfindingResult
void HandlePathfindingResult(bool path_found)
Handle the pathfinding result, especially the lost status.
Definition: vehicle.cpp:783
Vehicle::GetDisplayProfitThisYear
Money GetDisplayProfitThisYear() const
Gets the profit vehicle had this year.
Definition: vehicle_base.h:581
Vehicle::GetDisplaySpeed
virtual int GetDisplaySpeed() const
Gets the speed in km-ish/h that can be sent into SetDParam for string processing.
Definition: vehicle_base.h:493
Vehicle::GetPrevVehicle
Vehicle * GetPrevVehicle() const
Get the previous real (non-articulated part) vehicle in the consist.
Definition: vehicle_base.h:983
VE_TYPE_START
@ VE_TYPE_START
First bit used for the type of effect.
Definition: vehicle_base.h:82
GroundVehicleCache
Cached, frequently calculated values.
Definition: ground_vehicle.hpp:29
CommandCost
Common return value for all commands.
Definition: command_type.h:23
Vehicle::UpdateBoundingBoxCoordinates
void UpdateBoundingBoxCoordinates(bool update_cache) const
Update the bounding box co-ordinates of the vehicle.
Definition: vehicle.cpp:1619
BaseVehicle
Base vehicle class.
Definition: vehicle_type.h:50
Vehicle::GetCurrentMaxSpeed
virtual int GetCurrentMaxSpeed() const
Calculates the maximum speed of the vehicle under its current conditions.
Definition: vehicle_base.h:505
FreeUnitIDGenerator::NextID
UnitID NextID()
Returns next free UnitID.
Definition: vehicle.cpp:1792
Vehicle::AddToShared
void AddToShared(Vehicle *shared_chain)
Adds this vehicle to a shared vehicle chain.
Definition: vehicle.cpp:2769
VehStatus
VehStatus
Vehicle status bits in Vehicle::vehstatus.
Definition: vehicle_base.h:30
NewGRFCache::consist_cargo_information
uint32 consist_cargo_information
Cache for NewGRF var 42. (Note: The cargotype is untranslated in the cache because the accessing GRF ...
Definition: vehicle_base.h:70
Vehicle::RemoveFromShared
void RemoveFromShared()
Removes the vehicle from the shared order list.
Definition: vehicle.cpp:2792
VF_CARGO_UNLOADING
@ VF_CARGO_UNLOADING
Vehicle is unloading cargo.
Definition: vehicle_base.h:44
NCVV_POSITION_CONSIST_LENGTH
@ NCVV_POSITION_CONSIST_LENGTH
This bit will be set if the NewGRF var 40 currently stored is valid.
Definition: vehicle_base.h:57
Vehicle::tile
TileIndex tile
Current tile index.
Definition: vehicle_base.h:242
Vehicle::CancelReservation
void CancelReservation(StationID next, Station *st)
Return all reserved cargo packets to the station and reset all packets staged for transfer.
Definition: vehicle.cpp:2244
EIT_ON_MAP
@ EIT_ON_MAP
Vehicle drawn in viewport.
Definition: vehicle_type.h:86
Vehicle::engine_type
EngineID engine_type
The type of engine used for this vehicle.
Definition: vehicle_base.h:299
VS_CRASHED
@ VS_CRASHED
Vehicle is crashed.
Definition: vehicle_base.h:38
VehicleSpriteSeq
Sprite sequence for a vehicle part.
Definition: vehicle_base.h:129
SB
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Definition: bitmath_func.hpp:58
LoadOldVehicle
bool LoadOldVehicle(LoadgameState *ls, int num)
Load the vehicles of an old style savegame.
Definition: oldloader_sl.cpp:1221
Vehicle::last_station_visited
StationID last_station_visited
The last station we stopped at.
Definition: vehicle_base.h:313
Vehicle::GetVehicleTrackdir
virtual Trackdir GetVehicleTrackdir() const
Returns the Trackdir on which the vehicle is currently located.
Definition: vehicle_base.h:569
CargoPayment
Helper class to perform the cargo payment.
Definition: economy_base.h:24
Vehicle::cargo
VehicleCargoList cargo
The cargo this vehicle is carrying.
Definition: vehicle_base.h:320
Vehicle::GetOldAdvanceSpeed
uint GetOldAdvanceSpeed(uint speed)
Determines the effective direction-specific vehicle movement speed.
Definition: vehicle_base.h:398
VehicleFlags
VehicleFlags
Bit numbers in Vehicle::vehicle_flags.
Definition: vehicle_base.h:42
Vehicle::GetExpenseType
virtual ExpensesType GetExpenseType(bool income) const
Sets the expense type associated to this vehicle type.
Definition: vehicle_base.h:436
SpecializedVehicle
Class defining several overloaded accessors so we don't have to cast vehicle types that often.
Definition: vehicle_base.h:1046
Vehicle::hash_tile_current
Vehicle ** hash_tile_current
NOSAVE: Cache of the current hash chain.
Definition: vehicle_base.h:264
GVSF_ARTICULATED_PART
@ GVSF_ARTICULATED_PART
Articulated part of an engine.
Definition: vehicle_base.h:113
Vehicle::current_order
Order current_order
The current order (+ status, like: loading)
Definition: vehicle_base.h:329
FreeUnitIDGenerator::~FreeUnitIDGenerator
~FreeUnitIDGenerator()
Releases allocated memory.
Definition: vehicle_base.h:1248
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
Vehicle::max_age
Date max_age
Maximum age.
Definition: vehicle_base.h:271
Vehicle::IsFrontEngine
bool IsFrontEngine() const
Check if the vehicle is a front engine.
Definition: vehicle_base.h:899
Vehicle::GetLastOrder
Order * GetLastOrder() const
Returns the last order of a vehicle, or nullptr if it doesn't exists.
Definition: vehicle_base.h:885
FreeUnitIDGenerator
Generates sequence of free UnitID numbers.
Definition: vehicle_base.h:1239
SpecializedVehicle::Get
static T * Get(size_t index)
Gets vehicle with given index.
Definition: vehicle_base.h:1147
Pool::IterateWrapper
Definition: pool_type.hpp:175
VS_STOPPED
@ VS_STOPPED
Vehicle is stopped by the player.
Definition: vehicle_base.h:32
Vehicle::trip_occupancy
int8 trip_occupancy
NOSAVE: Occupancy of vehicle of the current trip (updated after leaving a station).
Definition: vehicle_base.h:322
Vehicle::GetGRFID
uint32 GetGRFID() const
Retrieve the GRF ID of the NewGRF the vehicle is tied to.
Definition: vehicle.cpp:761
VehicleCache
Cached often queried values common to all vehicles.
Definition: vehicle_base.h:121
Vehicle::ShowVisualEffect
void ShowVisualEffect() const
Draw visual effects (smoke and/or sparks) for a vehicle chain.
Definition: vehicle.cpp:2590
Vehicle::GetEngine
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
Definition: vehicle.cpp:741
VisualEffectSpawnModel
VisualEffectSpawnModel
Models for spawning visual effects.
Definition: vehicle_base.h:97
Vehicle::CopyVehicleConfigAndStatistics
void CopyVehicleConfigAndStatistics(const Vehicle *src)
Copy certain configurations and statistics of a vehicle after successful autoreplace/renew The functi...
Definition: vehicle_base.h:727
cargopacket.h
Vehicle::ResetRefitCaps
void ResetRefitCaps()
Reset all refit_cap in the consist to cargo_cap.
Definition: vehicle.cpp:2313
Vehicle::reliability_spd_dec
uint16 reliability_spd_dec
Reliability decrease speed.
Definition: vehicle_base.h:274
Vehicle::UpdateViewport
void UpdateViewport(bool dirty)
Update the vehicle on the viewport, updating the right hash and setting the new coordinates.
Definition: vehicle.cpp:1652
Vehicle::last_loading_station
StationID last_loading_station
Last station the vehicle has stopped at and could possibly leave from with any cargo loaded.
Definition: vehicle_base.h:314
VEH_INVALID
@ VEH_INVALID
Non-existing type of vehicle.
Definition: vehicle_type.h:35
VF_SERVINT_IS_CUSTOM
@ VF_SERVINT_IS_CUSTOM
Service interval is custom.
Definition: vehicle_base.h:51
Vehicle::previous_shared
Vehicle * previous_shared
NOSAVE: pointer to the previous vehicle in the shared order chain.
Definition: vehicle_base.h:231
DepotCommand
DepotCommand
Flags to add to p1 for goto depot commands.
Definition: vehicle_type.h:65
Vehicle::profit_this_year
Money profit_this_year
Profit this year << 8, low 8 bits are fract.
Definition: vehicle_base.h:251
VehiclePool
Pool< Vehicle, VehicleID, 512, 0xFF000 > VehiclePool
A vehicle pool for a little over 1 million vehicles.
Definition: vehicle_base.h:198
Vehicle::MarkAllViewportsDirty
bool MarkAllViewportsDirty() const
Marks viewports dirty where the vehicle's image is.
Definition: vehicle.cpp:1691
Vehicle::PlayLeaveStationSound
virtual void PlayLeaveStationSound() const
Play the sound associated with leaving the station.
Definition: vehicle_base.h:441
GVSF_WAGON
@ GVSF_WAGON
Wagon (not used for road vehicles).
Definition: vehicle_base.h:114
INVALID_TRACKDIR
@ INVALID_TRACKDIR
Flag for an invalid trackdir.
Definition: track_type.h:89
FixOldVehicles
void FixOldVehicles()
Convert the old style vehicles into something that resembles the old new style savegames.
Definition: oldloader_sl.cpp:171
VehicleCache::cached_vis_effect
byte cached_vis_effect
Visual effect to show (see VisualEffect)
Definition: vehicle_base.h:125
Vehicle::FindClosestDepot
virtual bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse)
Find the closest depot for this vehicle and tell us the location, DestinationID and whether we should...
Definition: vehicle_base.h:765
Vehicle::HandleLoading
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:2323
Vehicle::HasDepotOrder
bool HasDepotOrder() const
Checks if a vehicle has a depot in its order list.
Definition: order_cmd.cpp:1874
_network_dedicated
bool _network_dedicated
are we a dedicated server?
Definition: network.cpp:60
Vehicle::Move
const Vehicle * Move(int n) const
Get the vehicle at offset n of this vehicle chain.
Definition: vehicle_base.h:654
VisualEffect
VisualEffect
Meaning of the various bits of the visual effect.
Definition: vehicle_base.h:77
BaseConsist::vehicle_flags
uint16 vehicle_flags
Used for gradual loading and other miscellaneous things (.
Definition: base_consist.h:31
Vehicle::SendToDepot
CommandCost SendToDepot(DoCommandFlag flags, DepotCommand command)
Send this vehicle to the depot using the given command(s).
Definition: vehicle.cpp:2386
NewGRFCache::company_information
uint32 company_information
Cache for NewGRF var 43.
Definition: vehicle_base.h:71
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
Vehicle::sprite_cache
MutableSpriteCache sprite_cache
Cache of sprites and values related to recalculating them, see MutableSpriteCache.
Definition: vehicle_base.h:343
Vehicle::ShiftDates
void ShiftDates(int interval)
Shift all dates by given interval.
Definition: vehicle.cpp:771
Vehicle::IsOrderListShared
bool IsOrderListShared() const
Check if we share our orders with another vehicle.
Definition: vehicle_base.h:696
VE_TYPE_DEFAULT
@ VE_TYPE_DEFAULT
Use default from engine class.
Definition: vehicle_base.h:84
Vehicle::y_offs
int8 y_offs
y offset for vehicle sprite
Definition: vehicle_base.h:298
Vehicle::colourmap
SpriteID colourmap
NOSAVE: cached colour mapping.
Definition: vehicle_base.h:266
Vehicle::waiting_triggers
byte waiting_triggers
Triggers to be yet matched before rerandomizing the random bits.
Definition: vehicle_base.h:311
VESM_DIESEL
@ VESM_DIESEL
Diesel model.
Definition: vehicle_base.h:100
NewGRFCache::position_in_vehicle
uint32 position_in_vehicle
Cache for NewGRF var 4D.
Definition: vehicle_base.h:72
Vehicle::IncrementRealOrderIndex
void IncrementRealOrderIndex()
Advanced cur_real_order_index to the next real order, keeps care of the wrap-around and invalidates t...
Definition: vehicle_base.h:840
VF_BUILT_AS_PROTOTYPE
@ VF_BUILT_AS_PROTOTYPE
Vehicle is a prototype (accepted as exclusive preview).
Definition: vehicle_base.h:45
command_type.h
Vehicle::IterateWrapper
Iterable ensemble of orders.
Definition: vehicle_base.h:1026
Vehicle::direction
Direction direction
facing
Definition: vehicle_base.h:283
FreeUnitIDGenerator::cache
bool * cache
array of occupied unit id numbers
Definition: vehicle_base.h:1240
SpecializedVehicle::EXPECTED_TYPE
static const VehicleType EXPECTED_TYPE
Specialized type.
Definition: vehicle_base.h:1047
Vehicle::list
OrderList * list
Pointer to the order list for this vehicle.
Definition: vehicle_base.h:332
BaseConsist::cur_real_order_index
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
Definition: base_consist.h:28
Vehicle::next_shared
Vehicle * next_shared
pointer to the next vehicle that shares the order
Definition: vehicle_base.h:230
texteff.hpp
Vehicle::FirstShared
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
Definition: vehicle_base.h:690
Vehicle::x_extent
byte x_extent
x-extent of vehicle bounding box
Definition: vehicle_base.h:292
Vehicle::Move
Vehicle * Move(int n)
Get the vehicle at offset n of this vehicle chain.
Definition: vehicle_base.h:638
NCVV_CONSIST_CARGO_INFORMATION
@ NCVV_CONSIST_CARGO_INFORMATION
This bit will be set if the NewGRF var 42 currently stored is valid.
Definition: vehicle_base.h:59
Vehicle::GetFirstEnginePart
const Vehicle * GetFirstEnginePart() const
Get the first part of an articulated engine.
Definition: vehicle_base.h:948
Vehicle::vcache
VehicleCache vcache
Cache of often used vehicle values.
Definition: vehicle_base.h:341
Vehicle::motion_counter
uint32 motion_counter
counter to occasionally play a vehicle sound.
Definition: vehicle_base.h:307
GVSF_FREE_WAGON
@ GVSF_FREE_WAGON
First in a wagon chain (in depot) (not used for road vehicles).
Definition: vehicle_base.h:116
VESM_NONE
@ VESM_NONE
No visual effect.
Definition: vehicle_base.h:98
MutableSpriteCache::revalidate_before_draw
bool revalidate_before_draw
We need to do a GetImage() and check bounds before drawing this sprite.
Definition: vehicle_base.h:191
Vehicle::hash_viewport_next
Vehicle * hash_viewport_next
NOSAVE: Next vehicle in the visual location hash.
Definition: vehicle_base.h:259
Pool
Base class for all pools.
Definition: pool_type.hpp:81
Vehicle::First
Vehicle * First() const
Get the first vehicle of this vehicle chain.
Definition: vehicle_base.h:609
Vehicle::cargo_age_counter
uint16 cargo_age_counter
Ticks till cargo is aged next.
Definition: vehicle_base.h:321
Vehicle::tick_counter
byte tick_counter
Increased by one for each tick.
Definition: vehicle_base.h:325
Vehicle::cargo_cap
uint16 cargo_cap
total capacity
Definition: vehicle_base.h:318
GroupID
uint16 GroupID
Type for all group identifiers.
Definition: group_type.h:13
engine_type.h
Vehicle::IncrementImplicitOrderIndex
void IncrementImplicitOrderIndex()
Increments cur_implicit_order_index, keeps care of the wrap-around and invalidates the GUI.
Definition: vehicle_base.h:816
NCVV_POSITION_SAME_ID_LENGTH
@ NCVV_POSITION_SAME_ID_LENGTH
This bit will be set if the NewGRF var 41 currently stored is valid.
Definition: vehicle_base.h:58
Vehicle::x_offs
int8 x_offs
x offset for vehicle sprite
Definition: vehicle_base.h:297
Vehicle::subspeed
byte subspeed
fractional speed
Definition: vehicle_base.h:305
Vehicle::GetAdvanceSpeed
static uint GetAdvanceSpeed(uint speed)
Determines the effective vehicle movement speed.
Definition: vehicle_base.h:415
Vehicle::GetFirstOrder
Order * GetFirstOrder() const
Get the first order of the vehicles order list.
Definition: vehicle_base.h:669
SpecializedVehicle::From
static T * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Definition: vehicle_base.h:1166
Vehicle::z_extent
byte z_extent
z-extent of vehicle bounding box
Definition: vehicle_base.h:294
Vehicle::GetFirstEnginePart
Vehicle * GetFirstEnginePart()
Get the first part of an articulated engine.
Definition: vehicle_base.h:937
Vehicle::InvalidateNewGRFCacheOfChain
void InvalidateNewGRFCacheOfChain()
Invalidates cached NewGRF variables of all vehicles in the chain (after the current vehicle)
Definition: vehicle_base.h:473
PaletteID
uint32 PaletteID
The number of the palette.
Definition: gfx_type.h:18
FreeUnitIDGenerator::maxid
UnitID maxid
maximum ID at the moment of constructor call
Definition: vehicle_base.h:1241
OrderList
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Definition: order_base.h:253
VF_SERVINT_IS_PERCENT
@ VF_SERVINT_IS_PERCENT
Service interval is percent.
Definition: vehicle_base.h:52
Vehicle::cargo_payment
CargoPayment * cargo_payment
The cargo payment we're currently in.
Definition: vehicle_base.h:255
Vehicle::NextShared
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
Definition: vehicle_base.h:678
VE_DISABLE_WAGON_POWER
@ VE_DISABLE_WAGON_POWER
Flag to disable wagon power.
Definition: vehicle_base.h:91
SpecializedVehicle::IsValidID
static bool IsValidID(size_t index)
Tests whether given index is a valid index for vehicle of this type.
Definition: vehicle_base.h:1138
Vehicle::age
Date age
Age in days.
Definition: vehicle_base.h:270
Vehicle::HasArticulatedPart
bool HasArticulatedPart() const
Check if an engine has an articulated part.
Definition: vehicle_base.h:917
Vehicle::build_year
Year build_year
Year the vehicle has been built.
Definition: vehicle_base.h:269
Vehicle::profit_last_year
Money profit_last_year
Profit last year << 8, low 8 bits are fract.
Definition: vehicle_base.h:252
Vehicle::breakdown_chance
byte breakdown_chance
Current chance of breakdowns.
Definition: vehicle_base.h:278
GVSF_MULTIHEADED
@ GVSF_MULTIHEADED
Engine is multiheaded (not used for road vehicles).
Definition: vehicle_base.h:117
PalSpriteID
Combination of a palette sprite and a 'real' sprite.
Definition: gfx_type.h:22
Vehicle::unitnumber
UnitID unitnumber
unit number, for display purposes only
Definition: vehicle_base.h:302
SpecializedVehicle::GetIfValid
static T * GetIfValid(size_t index)
Returns vehicle if the index is a valid index for this vehicle type.
Definition: vehicle_base.h:1156
VehicleCache::cached_max_speed
uint16 cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
Definition: vehicle_base.h:122
VF_AUTOFILL_PRES_WAIT_TIME
@ VF_AUTOFILL_PRES_WAIT_TIME
Whether non-destructive auto-fill should preserve waiting times.
Definition: vehicle_base.h:48
SpecializedVehicle::Iterate
static Pool::IterateWrapper< T > Iterate(size_t from=0)
Returns an iterable ensemble of all valid vehicles of type T.
Definition: vehicle_base.h:1235
Vehicle::LoadOldVehicle
friend bool LoadOldVehicle(LoadgameState *ls, int num)
So we can set the proper next pointer while loading.
Definition: oldloader_sl.cpp:1221
NCVV_END
@ NCVV_END
End of the bits.
Definition: vehicle_base.h:62
VE_ADVANCED_EFFECT
@ VE_ADVANCED_EFFECT
Flag for advanced effects.
Definition: vehicle_base.h:90
Vehicle::x_bb_offs
int8 x_bb_offs
x offset of vehicle bounding box
Definition: vehicle_base.h:295
Vehicle::hash_viewport_prev
Vehicle ** hash_viewport_prev
NOSAVE: Previous vehicle in the visual location hash.
Definition: vehicle_base.h:260
Vehicle::breakdown_delay
byte breakdown_delay
Counter for managing breakdown length.
Definition: vehicle_base.h:276
Vehicle::Last
Vehicle * Last()
Get the last vehicle of this vehicle chain.
Definition: vehicle_base.h:615
Vehicle::coord
Rect coord
NOSAVE: Graphical bounding box of the vehicle, i.e. what to redraw on moves.
Definition: vehicle_base.h:257
Vehicle::NeedsServicing
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:184
Vehicle::InvalidateNewGRFCache
void InvalidateNewGRFCache()
Invalidates cached NewGRF variables.
Definition: vehicle_base.h:464
network.h
Vehicle::subtype
byte subtype
subtype (Filled with values from AircraftSubType/DisasterSubType/EffectVehicleType/GroundVehicleSubty...
Definition: vehicle_base.h:338
VF_TIMETABLE_STARTED
@ VF_TIMETABLE_STARTED
Whether the vehicle has started running on the timetable yet.
Definition: vehicle_base.h:46
OrderList::GetFirstOrder
Order * GetFirstOrder() const
Get the first order of the order chain.
Definition: order_base.h:293
Vehicle::day_counter
byte day_counter
Increased by one for each day.
Definition: vehicle_base.h:324
BaseConsist::service_interval
uint16 service_interval
The interval for (automatic) servicing; either in days or %.
Definition: base_consist.h:26
VS_UNCLICKABLE
@ VS_UNCLICKABLE
Vehicle is not clickable by the user (shadow vehicles).
Definition: vehicle_base.h:33
NewGRFCacheValidValues
NewGRFCacheValidValues
Bit numbers used to indicate which of the NewGRFCache values are valid.
Definition: vehicle_base.h:56
GVSF_FRONT
@ GVSF_FRONT
Leading engine of a consist.
Definition: vehicle_base.h:112
Vehicle::NeedsAutorenewing
bool NeedsAutorenewing(const Company *c, bool use_renew_setting=true) const
Function to tell if a vehicle needs to be autorenewed.
Definition: vehicle.cpp:140
VF_PATHFINDER_LOST
@ VF_PATHFINDER_LOST
Vehicle's pathfinder is lost.
Definition: vehicle_base.h:50
Vehicle::progress
byte progress
The percentage (if divided by 256) this vehicle already crossed the tile unit.
Definition: vehicle_base.h:308
OverflowSafeInt< int64 >
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:20
Vehicle::IsStoppedInDepot
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
Definition: vehicle_base.h:529
Vehicle::FixOldVehicles
friend void FixOldVehicles()
Convert the old style vehicles into something that resembles the old new style savegames.
Definition: oldloader_sl.cpp:171
Vehicle::previous
Vehicle * previous
NOSAVE: pointer to the previous vehicle in the chain.
Definition: vehicle_base.h:227
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:88
Vehicle::cargo_type
CargoID cargo_type
type of cargo this vehicle is carrying
Definition: vehicle_base.h:316
Vehicle::spritenum
byte spritenum
currently displayed sprite index 0xfd == custom sprite, 0xfe == custom second head sprite 0xff == res...
Definition: vehicle_base.h:291
NCVV_COMPANY_INFORMATION
@ NCVV_COMPANY_INFORMATION
This bit will be set if the NewGRF var 43 currently stored is valid.
Definition: vehicle_base.h:60
SlVehicleDisaster
Definition: vehicle_sl.cpp:917
FreeUnitIDGenerator::FreeUnitIDGenerator
FreeUnitIDGenerator(VehicleType type, CompanyID owner)
Initializes the structure.
Definition: vehicle.cpp:1767
SpecializedVehicle::GetLastEnginePart
T * GetLastEnginePart()
Get the last part of an articulated engine.
Definition: vehicle_base.h:1119
Vehicle::OnNewDay
virtual void OnNewDay()
Calls the new day handler of the vehicle.
Definition: vehicle_base.h:546
PalSpriteID::pal
PaletteID pal
The palette (use PAL_NONE) if not needed)
Definition: gfx_type.h:24
SpecializedVehicle::Previous
T * Previous() const
Get previous vehicle in the chain.
Definition: vehicle_base.h:1087
Trackdir
Trackdir
Enumeration for tracks and directions.
Definition: track_type.h:70
Vehicle::cargo_subtype
byte cargo_subtype
Used for livery refits (NewGRF variations)
Definition: vehicle_base.h:317
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
Pool::PoolItem<&_vehicle_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:326
Vehicle::GetAdvanceDistance
uint GetAdvanceDistance()
Determines the vehicle "progress" needed for moving a step.
Definition: vehicle_base.h:427
Vehicle::GetOrder
Order * GetOrder(int index) const
Returns order 'index' of a vehicle or nullptr when it doesn't exists.
Definition: vehicle_base.h:876
BaseVehicle::type
VehicleType type
Type of vehicle.
Definition: vehicle_type.h:52
Vehicle::Tick
virtual bool Tick()
Calls the tick handler of the vehicle.
Definition: vehicle_base.h:541
Vehicle::UpdatePositionAndViewport
void UpdatePositionAndViewport()
Update the position of the vehicle, and update the viewport.
Definition: vehicle.cpp:1681
Vehicle::reliability
uint16 reliability
Reliability.
Definition: vehicle_base.h:273
SpecializedVehicle::First
T * First() const
Get the first vehicle in the chain.
Definition: vehicle_base.h:1063
Vehicle::UpdatePosition
void UpdatePosition()
Update the position of the vehicle.
Definition: vehicle.cpp:1610
Vehicle::hash_tile_prev
Vehicle ** hash_tile_prev
NOSAVE: Previous vehicle in the tile location hash.
Definition: vehicle_base.h:263
ExpensesType
ExpensesType
Types of expenses.
Definition: economy_type.h:157
Vehicle::HandleBreakdown
bool HandleBreakdown()
Handle all of the aspects of a vehicle breakdown This includes adding smoke and sounds,...
Definition: vehicle.cpp:1312
Vehicle::y_bb_offs
int8 y_bb_offs
y offset of vehicle bounding box
Definition: vehicle_base.h:296
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: stdafx.h:460
NewGRFCache::position_consist_length
uint32 position_consist_length
Cache for NewGRF var 40.
Definition: vehicle_base.h:68
VESM_ELECTRIC
@ VESM_ELECTRIC
Electric model.
Definition: vehicle_base.h:101
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
Company
Definition: company_base.h:115
group_type.h
Vehicle::GetNumOrders
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
Definition: vehicle_base.h:702
BaseConsist
Various front vehicle properties that are preserved when autoreplacing, using order-backup or switchi...
Definition: base_consist.h:18
SpecializedVehicle::Last
T * Last()
Get the last vehicle in the chain.
Definition: vehicle_base.h:1069
InvalidateVehicleOrder
void InvalidateVehicleOrder(const Vehicle *v, int data)
Updates the widgets of a vehicle which contains the order-data.
Definition: order_cmd.cpp:250
VehicleSpriteSeq::GetBounds
void GetBounds(Rect *bounds) const
Determine shared bounds of all sprites.
Definition: vehicle.cpp:98
Vehicle::hash_tile_next
Vehicle * hash_tile_next
NOSAVE: Next vehicle in the tile location hash.
Definition: vehicle_base.h:262
Pool::PoolItem
Base class for all PoolItems.
Definition: pool_type.hpp:234
BaseConsist::CopyConsistPropertiesFrom
void CopyConsistPropertiesFrom(const BaseConsist *src)
Copy properties of other BaseConsist.
Definition: base_consist.cpp:22
Vehicle::DeleteUnreachedImplicitOrders
void DeleteUnreachedImplicitOrders()
Delete all implicit orders which were not reached.
Definition: vehicle.cpp:2074
Vehicle::first
Vehicle * first
NOSAVE: pointer to the first vehicle in the chain.
Definition: vehicle_base.h:228
Order::next
Order * next
Pointer to next order. If nullptr, end of list.
Definition: order_base.h:52
SpecializedVehicle::UpdateViewport
void UpdateViewport(bool force_update, bool update_delta)
Update vehicle sprite- and position caches.
Definition: vehicle_base.h:1188
Vehicle::fill_percent_te_id
TextEffectID fill_percent_te_id
a text-effect id to a loading indicator object
Definition: vehicle_base.h:301
Order
Definition: order_base.h:33
SpecializedVehicle::GetPrevVehicle
T * GetPrevVehicle() const
Get the previous real (non-articulated part) vehicle in the consist.
Definition: vehicle_base.h:1131
VS_SHADOW
@ VS_SHADOW
Vehicle is a shadow vehicle.
Definition: vehicle_base.h:36
INVALID_COORD
static const int32 INVALID_COORD
Sentinel for an invalid coordinate.
Definition: vehicle_base.h:1252
MutableSpriteCache::old_coord
Rect old_coord
Co-ordinates from the last valid bounding box.
Definition: vehicle_base.h:192
Vehicle::GetDisplayProfitLastYear
Money GetDisplayProfitLastYear() const
Gets the profit vehicle had last year.
Definition: vehicle_base.h:587
VE_OFFSET_CENTRE
@ VE_OFFSET_CENTRE
Value of offset corresponding to a position above the centre of the vehicle.
Definition: vehicle_base.h:80
SpecializedVehicle::GetFirstEnginePart
T * GetFirstEnginePart()
Get the first part of an articulated engine.
Definition: vehicle_base.h:1107
VE_TYPE_STEAM
@ VE_TYPE_STEAM
Steam plumes.
Definition: vehicle_base.h:85
RefitDesc
Simulated cargo type and capacity for prediction of future links.
Definition: vehicle_base.h:212
track_type.h
Vehicle::GetOrderStationLocation
virtual TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
Definition: vehicle_base.h:755
order_func.h
Vehicle::MarkDirty
virtual void MarkDirty()
Marks the vehicles to be redrawn and updates cached variables.
Definition: vehicle_base.h:377
GRFFile
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:105
Vehicle::refit_cap
uint16 refit_cap
Capacity left over from before last refit.
Definition: vehicle_base.h:319
NewGRFCache
Cached often queried (NewGRF) values.
Definition: vehicle_base.h:66
Vehicle::date_of_last_service
Date date_of_last_service
Last date the vehicle had a service at a depot.
Definition: vehicle_base.h:272
Vehicle::GetNextStoppingStation
StationIDStack GetNextStoppingStation() const
Get the next station the vehicle will stop at.
Definition: vehicle_base.h:714
RefitDesc::cargo
CargoID cargo
Cargo type the vehicle will be carrying.
Definition: vehicle_base.h:213
Vehicle::GetImage
virtual void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.
Definition: vehicle_base.h:455