OpenTTD

vehicle_base.h
Go to the documentation of this file.
1 /* $Id: vehicle_base.h 27822 2017-03-24 07:33:31Z peter1138 $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #ifndef VEHICLE_BASE_H
13 #define VEHICLE_BASE_H
14
15 #include "core/smallmap_type.hpp"
16 #include "track_type.h"
17 #include "command_type.h"
18 #include "order_base.h"
19 #include "cargopacket.h"
20 #include "texteff.hpp"
21 #include "engine_type.h"
22 #include "order_func.h"
23 #include "transport_type.h"
24 #include "group_type.h"
25 #include "base_consist.h"
26 #include "network/network.h"
27 #include <list>
28 #include <map>
29
31 enum VehStatus {
32 VS_HIDDEN = 0x01,
33 VS_STOPPED = 0x02,
34 VS_UNCLICKABLE = 0x04,
35 VS_DEFPAL = 0x08,
36 VS_TRAIN_SLOWING = 0x10,
37 VS_SHADOW = 0x20,
38 VS_AIRCRAFT_BROKEN = 0x40,
39 VS_CRASHED = 0x80,
40 };
41
43 enum VehicleFlags {
44 VF_LOADING_FINISHED,
45 VF_CARGO_UNLOADING,
46 VF_BUILT_AS_PROTOTYPE,
47 VF_TIMETABLE_STARTED,
48 VF_AUTOFILL_TIMETABLE,
49 VF_AUTOFILL_PRES_WAIT_TIME,
50 VF_STOP_LOADING,
51 VF_PATHFINDER_LOST,
52 VF_SERVINT_IS_CUSTOM,
53 VF_SERVINT_IS_PERCENT,
54 };
55
57 enum NewGRFCacheValidValues {
58 NCVV_POSITION_CONSIST_LENGTH = 0,
59 NCVV_POSITION_SAME_ID_LENGTH = 1,
60 NCVV_CONSIST_CARGO_INFORMATION = 2,
61 NCVV_COMPANY_INFORMATION = 3,
62 NCVV_POSITION_IN_VEHICLE = 4,
63 NCVV_END,
64 };
65
67 struct NewGRFCache {
68 /* Values calculated when they are requested for the first time after invalidating the NewGRF cache. */
69 uint32 position_consist_length;
70 uint32 position_same_id_length;
71 uint32 consist_cargo_information;
72 uint32 company_information;
73 uint32 position_in_vehicle;
74 uint8 cache_valid;
75 };
76
78 enum VisualEffect {
79 VE_OFFSET_START = 0,
80 VE_OFFSET_COUNT = 4,
81 VE_OFFSET_CENTRE = 8,
82
83 VE_TYPE_START = 4,
84 VE_TYPE_COUNT = 2,
85 VE_TYPE_DEFAULT = 0,
86 VE_TYPE_STEAM = 1,
87 VE_TYPE_DIESEL = 2,
88 VE_TYPE_ELECTRIC = 3,
89
90 VE_DISABLE_EFFECT = 6,
91 VE_ADVANCED_EFFECT = VE_DISABLE_EFFECT,
92 VE_DISABLE_WAGON_POWER = 7,
93
94 VE_DEFAULT = 0xFF,
95 };
96
98 enum VisualEffectSpawnModel {
99 VESM_NONE = 0,
100 VESM_STEAM,
101 VESM_DIESEL,
102 VESM_ELECTRIC,
103
104 VESM_END
105 };
106
112 enum GroundVehicleSubtypeFlags {
113 GVSF_FRONT = 0,
114 GVSF_ARTICULATED_PART = 1,
115 GVSF_WAGON = 2,
116 GVSF_ENGINE = 3,
117 GVSF_FREE_WAGON = 4,
118 GVSF_MULTIHEADED = 5,
119 };
120
122 struct VehicleCache {
123 uint16 cached_max_speed;
124 uint16 cached_cargo_age_period;
125
126 byte cached_vis_effect;
127 };
128
130 struct VehicleSpriteSeq {
131 PalSpriteID seq[4];
132 uint count;
133
134 bool operator==(const VehicleSpriteSeq &other) const
135 {
136 return this->count == other.count && MemCmpT<PalSpriteID>(this->seq, other.seq, this->count) == 0;
137 }
138
139 bool operator!=(const VehicleSpriteSeq &other) const
140 {
141 return !this->operator==(other);
142 }
143
147 bool IsValid() const
148 {
149 return this->count != 0;
150 }
151
155 void Clear()
156 {
157 this->count = 0;
158 }
159
163 void Set(SpriteID sprite)
164 {
165 this->count = 1;
166 this->seq[0].sprite = sprite;
167 this->seq[0].pal = 0;
168 }
169
173 void CopyWithoutPalette(const VehicleSpriteSeq &src)
174 {
175 this->count = src.count;
176 for (uint i = 0; i < src.count; ++i) {
177 this->seq[i].sprite = src.seq[i].sprite;
178 this->seq[i].pal = 0;
179 }
180 }
181
182 void GetBounds(Rect *bounds) const;
183 void Draw(int x, int y, PaletteID default_pal, bool force_pal) const;
184 };
185
187 typedef Pool<Vehicle, VehicleID, 512, 0xFF000> VehiclePool;
188 extern VehiclePool _vehicle_pool;
189
190 /* Some declarations of functions, so we can make them friendly */
191 struct SaveLoad;
192 struct GroundVehicleCache;
193 extern const SaveLoad *GetVehicleDescription(VehicleType vt);
194 struct LoadgameState;
195 extern bool LoadOldVehicle(LoadgameState *ls, int num);
196 extern void FixOldVehicles();
197
198 struct GRFFile;
199
203 struct RefitDesc {
204 CargoID cargo;
205 uint16 capacity;
206 uint16 remaining;
207 RefitDesc(CargoID cargo, uint16 capacity, uint16 remaining) :
208 cargo(cargo), capacity(capacity), remaining(remaining) {}
209 };
210
212 struct Vehicle : VehiclePool::PoolItem<&_vehicle_pool>, BaseVehicle, BaseConsist {
213 private:
214 typedef std::list<RefitDesc> RefitList;
215 typedef std::map<CargoID, uint> CapacitiesMap;
216
217 Vehicle *next;
218 Vehicle *previous;
219 Vehicle *first;
220
221 Vehicle *next_shared;
222 Vehicle *previous_shared;
223
224 public:
225 friend const SaveLoad *GetVehicleDescription(VehicleType vt);
226 friend void FixOldVehicles();
227 friend void AfterLoadVehicles(bool part_of_load);
228 friend bool LoadOldVehicle(LoadgameState *ls, int num);
229
230 TileIndex tile;
231
237 TileIndex dest_tile;
238
239 Money profit_this_year;
240 Money profit_last_year;
241 Money value;
242
243 CargoPayment *cargo_payment;
244
245 Rect coord;
246
247 Vehicle *hash_viewport_next;
248 Vehicle **hash_viewport_prev;
249
250 Vehicle *hash_tile_next;
251 Vehicle **hash_tile_prev;
252 Vehicle **hash_tile_current;
253
254 SpriteID colourmap;
255
256 /* Related to age and service time */
257 Year build_year;
258 Date age;
259 Date max_age;
260 Date date_of_last_service;
261 uint16 reliability;
262 uint16 reliability_spd_dec;
263 byte breakdown_ctr;
264 byte breakdown_delay;
265 byte breakdowns_since_last_service;
266 byte breakdown_chance;
267
268 int32 x_pos;
269 int32 y_pos;
270 int32 z_pos;
271 DirectionByte direction;
272
273 OwnerByte owner;
274
279 byte spritenum;
280 VehicleSpriteSeq sprite_seq;
281 byte x_extent;
282 byte y_extent;
283 byte z_extent;
284 int8 x_bb_offs;
285 int8 y_bb_offs;
286 int8 x_offs;
287 int8 y_offs;
288 EngineID engine_type;
289
290 TextEffectID fill_percent_te_id;
291 UnitID unitnumber;
292
293 uint16 cur_speed;
294 byte subspeed;
295 byte acceleration;
296 uint32 motion_counter;
297 byte progress;
298
299 byte random_bits;
300 byte waiting_triggers;
301
302 StationID last_station_visited;
303 StationID last_loading_station;
304
305 CargoID cargo_type;
306 byte cargo_subtype;
307 uint16 cargo_cap;
308 uint16 refit_cap;
309 VehicleCargoList cargo;
310 uint16 cargo_age_counter;
311 int8 trip_occupancy;
312
313 byte day_counter;
314 byte tick_counter;
315 byte running_ticks;
316
317 byte vehstatus;
318 Order current_order;
319
320 union {
321 OrderList *list;
322 Order *old;
323 } orders;
324
325 uint16 load_unload_ticks;
326 GroupID group_id;
327 byte subtype;
328
329 NewGRFCache grf_cache;
330 VehicleCache vcache;
331
332 Vehicle(VehicleType type = VEH_INVALID);
333
334 void PreDestructor();
336 virtual ~Vehicle();
337
338 void BeginLoading();
339 void CancelReservation(StationID next, Station *st);
340 void LeaveStation();
341
342 GroundVehicleCache *GetGroundVehicleCache();
343 const GroundVehicleCache *GetGroundVehicleCache() const;
344
345 uint16 &GetGroundVehicleFlags();
346 const uint16 &GetGroundVehicleFlags() const;
347
348 void DeleteUnreachedImplicitOrders();
349
350 void HandleLoading(bool mode = false);
351
352 void GetConsistFreeCapacities(SmallMap<CargoID, uint> &capacities) const;
353
354 uint GetConsistTotalCapacity() const;
355
364 virtual void MarkDirty() {}
365
371 virtual void UpdateDeltaXY(Direction direction) {}
372
386 inline uint GetOldAdvanceSpeed(uint speed)
387 {
388 return (this->direction & 1) ? speed : speed * 3 / 4;
389 }
390
403 static inline uint GetAdvanceSpeed(uint speed)
404 {
405 return speed * 3 / 4;
406 }
407
415 inline uint GetAdvanceDistance()
416 {
417 return (this->direction & 1) ? 192 : 256;
418 }
419
424 virtual ExpensesType GetExpenseType(bool income) const { return EXPENSES_OTHER; }
425
429 virtual void PlayLeaveStationSound() const {}
430
434 virtual bool IsPrimaryVehicle() const { return false; }
435
436 const Engine *GetEngine() const;
437
443 virtual void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const { result->Clear(); }
444
445 const GRFFile *GetGRF() const;
446 uint32 GetGRFID() const;
447
452 inline void InvalidateNewGRFCache()
453 {
454 this->grf_cache.cache_valid = 0;
455 }
456
461 inline void InvalidateNewGRFCacheOfChain()
462 {
463 for (Vehicle *u = this; u != NULL; u = u->Next()) {
464 u->InvalidateNewGRFCache();
465 }
466 }
467
472 inline bool IsGroundVehicle() const
473 {
474 return this->type == VEH_TRAIN || this->type == VEH_ROAD;
475 }
476
481 virtual int GetDisplaySpeed() const { return 0; }
482
487 virtual int GetDisplayMaxSpeed() const { return 0; }
488
493 virtual int GetCurrentMaxSpeed() const { return 0; }
494
499 virtual Money GetRunningCost() const { return 0; }
500
505 virtual bool IsInDepot() const { return false; }
506
511 virtual bool IsChainInDepot() const { return this->IsInDepot(); }
512
517 bool IsStoppedInDepot() const
518 {
519 assert(this == this->First());
520 /* Free wagons have no VS_STOPPED state */
521 if (this->IsPrimaryVehicle() && !(this->vehstatus & VS_STOPPED)) return false;
522 return this->IsChainInDepot();
523 }
524
529 virtual bool Tick() { return true; };
530
534 virtual void OnNewDay() {};
535
541 virtual uint Crash(bool flooded = false);
542
555 virtual Trackdir GetVehicleTrackdir() const { return INVALID_TRACKDIR; }
556
561 Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); }
562
567 Money GetDisplayProfitThisYear() const { return (this->profit_this_year >> 8); }
568
573 Money GetDisplayProfitLastYear() const { return (this->profit_last_year >> 8); }
574
575 void SetNext(Vehicle *next);
576
582 inline Vehicle *Next() const { return this->next; }
583
589 inline Vehicle *Previous() const { return this->previous; }
590
595 inline Vehicle *First() const { return this->first; }
596
601 inline Vehicle *Last()
602 {
603 Vehicle *v = this;
604 while (v->Next() != NULL) v = v->Next();
605 return v;
606 }
607
612 inline const Vehicle *Last() const
613 {
614 const Vehicle *v = this;
615 while (v->Next() != NULL) v = v->Next();
616 return v;
617 }
618
624 inline Vehicle *Move(int n)
625 {
626 Vehicle *v = this;
627 if (n < 0) {
628 for (int i = 0; i != n && v != NULL; i--) v = v->Previous();
629 } else {
630 for (int i = 0; i != n && v != NULL; i++) v = v->Next();
631 }
632 return v;
633 }
634
640 inline const Vehicle *Move(int n) const
641 {
642 const Vehicle *v = this;
643 if (n < 0) {
644 for (int i = 0; i != n && v != NULL; i--) v = v->Previous();
645 } else {
646 for (int i = 0; i != n && v != NULL; i++) v = v->Next();
647 }
648 return v;
649 }
650
655 inline Order *GetFirstOrder() const { return (this->orders.list == NULL) ? NULL : this->orders.list->GetFirstOrder(); }
656
657 void AddToShared(Vehicle *shared_chain);
658 void RemoveFromShared();
659
664 inline Vehicle *NextShared() const { return this->next_shared; }
665
670 inline Vehicle *PreviousShared() const { return this->previous_shared; }
671
676 inline Vehicle *FirstShared() const { return (this->orders.list == NULL) ? this->First() : this->orders.list->GetFirstSharedVehicle(); }
677
682 inline bool IsOrderListShared() const { return this->orders.list != NULL && this->orders.list->IsShared(); }
683
688 inline VehicleOrderID GetNumOrders() const { return (this->orders.list == NULL) ? 0 : this->orders.list->GetNumOrders(); }
689
694 inline VehicleOrderID GetNumManualOrders() const { return (this->orders.list == NULL) ? 0 : this->orders.list->GetNumManualOrders(); }
695
700 inline StationIDStack GetNextStoppingStation() const
701 {
702 return (this->orders.list == NULL) ? INVALID_STATION : this->orders.list->GetNextStoppingStation(this);
703 }
704
705 void ResetRefitCaps();
706
713 inline void CopyVehicleConfigAndStatistics(const Vehicle *src)
714 {
715 this->CopyConsistPropertiesFrom(src);
716
717 this->unitnumber = src->unitnumber;
718
719 this->current_order = src->current_order;
720 this->dest_tile = src->dest_tile;
721
722 this->profit_this_year = src->profit_this_year;
723 this->profit_last_year = src->profit_last_year;
724 }
725
726
727 bool HandleBreakdown();
728
729 bool NeedsAutorenewing(const Company *c, bool use_renew_setting = true) const;
730
731 bool NeedsServicing() const;
732 bool NeedsAutomaticServicing() const;
733
741 virtual TileIndex GetOrderStationLocation(StationID station) { return INVALID_TILE; }
742
751 virtual bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse) { return false; }
752
753 CommandCost SendToDepot(DoCommandFlag flags, DepotCommand command);
754
755 void UpdateVisualEffect(bool allow_power_change = true);
756 void ShowVisualEffect() const;
757
758 void UpdatePosition();
759 void UpdateViewport(bool dirty);
760 void UpdatePositionAndViewport();
761 void MarkAllViewportsDirty() const;
762
763 inline uint16 GetServiceInterval() const { return this->service_interval; }
764
765 inline void SetServiceInterval(uint16 interval) { this->service_interval = interval; }
766
767 inline bool ServiceIntervalIsCustom() const { return HasBit(this->vehicle_flags, VF_SERVINT_IS_CUSTOM); }
768
769 inline bool ServiceIntervalIsPercent() const { return HasBit(this->vehicle_flags, VF_SERVINT_IS_PERCENT); }
770
771 inline void SetServiceIntervalIsCustom(bool on) { SB(this->vehicle_flags, VF_SERVINT_IS_CUSTOM, 1, on); }
772
773 inline void SetServiceIntervalIsPercent(bool on) { SB(this->vehicle_flags, VF_SERVINT_IS_PERCENT, 1, on); }
774
775 private:
780 void SkipToNextRealOrderIndex()
781 {
782 if (this->GetNumManualOrders() > 0) {
783 /* Advance to next real order */
784 do {
785 this->cur_real_order_index++;
786 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
787 } while (this->GetOrder(this->cur_real_order_index)->IsType(OT_IMPLICIT));
788 } else {
789 this->cur_real_order_index = 0;
790 }
791 }
792
793 public:
799 void IncrementImplicitOrderIndex()
800 {
801 if (this->cur_implicit_order_index == this->cur_real_order_index) {
802 /* Increment real order index as well */
803 this->SkipToNextRealOrderIndex();
804 }
805
806 assert(this->cur_real_order_index == 0 || this->cur_real_order_index < this->GetNumOrders());
807
808 /* Advance to next implicit order */
809 do {
810 this->cur_implicit_order_index++;
811 if (this->cur_implicit_order_index >= this->GetNumOrders()) this->cur_implicit_order_index = 0;
812 } while (this->cur_implicit_order_index != this->cur_real_order_index && !this->GetOrder(this->cur_implicit_order_index)->IsType(OT_IMPLICIT));
813
814 InvalidateVehicleOrder(this, 0);
815 }
816
823 void IncrementRealOrderIndex()
824 {
825 if (this->cur_implicit_order_index == this->cur_real_order_index) {
826 /* Increment both real and implicit order */
827 this->IncrementImplicitOrderIndex();
828 } else {
829 /* Increment real order only */
830 this->SkipToNextRealOrderIndex();
831 InvalidateVehicleOrder(this, 0);
832 }
833 }
834
838 void UpdateRealOrderIndex()
839 {
840 /* Make sure the index is valid */
841 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
842
843 if (this->GetNumManualOrders() > 0) {
844 /* Advance to next real order */
845 while (this->GetOrder(this->cur_real_order_index)->IsType(OT_IMPLICIT)) {
846 this->cur_real_order_index++;
847 if (this->cur_real_order_index >= this->GetNumOrders()) this->cur_real_order_index = 0;
848 }
849 } else {
850 this->cur_real_order_index = 0;
851 }
852 }
853
859 inline Order *GetOrder(int index) const
860 {
861 return (this->orders.list == NULL) ? NULL : this->orders.list->GetOrderAt(index);
862 }
863
868 inline Order *GetLastOrder() const
869 {
870 return (this->orders.list == NULL) ? NULL : this->orders.list->GetLastOrder();
871 }
872
873 bool IsEngineCountable() const;
874 bool HasEngineType() const;
875 bool HasDepotOrder() const;
876 void HandlePathfindingResult(bool path_found);
877
882 inline bool IsFrontEngine() const
883 {
884 return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_FRONT);
885 }
886
891 inline bool IsArticulatedPart() const
892 {
893 return this->IsGroundVehicle() && HasBit(this->subtype, GVSF_ARTICULATED_PART);
894 }
895
900 inline bool HasArticulatedPart() const
901 {
902 return this->Next() != NULL && this->Next()->IsArticulatedPart();
903 }
904
910 inline Vehicle *GetNextArticulatedPart() const
911 {
912 assert(this->HasArticulatedPart());
913 return this->Next();
914 }
915
920 inline Vehicle *GetFirstEnginePart()
921 {
922 Vehicle *v = this;
923 while (v->IsArticulatedPart()) v = v->Previous();
924 return v;
925 }
926
931 inline const Vehicle *GetFirstEnginePart() const
932 {
933 const Vehicle *v = this;
934 while (v->IsArticulatedPart()) v = v->Previous();
935 return v;
936 }
937
942 inline Vehicle *GetLastEnginePart()
943 {
944 Vehicle *v = this;
945 while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart();
946 return v;
947 }
948
953 inline Vehicle *GetNextVehicle() const
954 {
955 const Vehicle *v = this;
956 while (v->HasArticulatedPart()) v = v->GetNextArticulatedPart();
957
958 /* v now contains the last articulated part in the engine */
959 return v->Next();
960 }
961
966 inline Vehicle *GetPrevVehicle() const
967 {
968 Vehicle *v = this->Previous();
969 while (v != NULL && v->IsArticulatedPart()) v = v->Previous();
970
971 return v;
972 }
973 };
974
980 #define FOR_ALL_VEHICLES_FROM(var, start) FOR_ALL_ITEMS_FROM(Vehicle, vehicle_index, var, start)
981
986 #define FOR_ALL_VEHICLES(var) FOR_ALL_VEHICLES_FROM(var, 0)
987
992 template <class T, VehicleType Type>
993 struct SpecializedVehicle : public Vehicle {
994 static const VehicleType EXPECTED_TYPE = Type;
995
996 typedef SpecializedVehicle<T, Type> SpecializedVehicleBase;
997
1001 inline SpecializedVehicle<T, Type>() : Vehicle(Type)
1002 {
1003 this->sprite_seq.count = 1;
1004 }
1005
1010 inline T *First() const { return (T *)this->Vehicle::First(); }
1011
1016 inline T *Last() { return (T *)this->Vehicle::Last(); }
1017
1022 inline const T *Last() const { return (const T *)this->Vehicle::Last(); }
1023
1028 inline T *Next() const { return (T *)this->Vehicle::Next(); }
1029
1034 inline T *Previous() const { return (T *)this->Vehicle::Previous(); }
1035
1041 inline T *GetNextArticulatedPart() { return (T *)this->Vehicle::GetNextArticulatedPart(); }
1042
1048 inline T *GetNextArticulatedPart() const { return (T *)this->Vehicle::GetNextArticulatedPart(); }
1049
1054 inline T *GetFirstEnginePart() { return (T *)this->Vehicle::GetFirstEnginePart(); }
1055
1060 inline const T *GetFirstEnginePart() const { return (const T *)this->Vehicle::GetFirstEnginePart(); }
1061
1066 inline T *GetLastEnginePart() { return (T *)this->Vehicle::GetLastEnginePart(); }
1067
1072 inline T *GetNextVehicle() const { return (T *)this->Vehicle::GetNextVehicle(); }
1073
1078 inline T *GetPrevVehicle() const { return (T *)this->Vehicle::GetPrevVehicle(); }
1079
1085 static inline bool IsValidID(size_t index)
1086 {
1087 return Vehicle::IsValidID(index) && Vehicle::Get(index)->type == Type;
1088 }
1089
1094 static inline T *Get(size_t index)
1095 {
1096 return (T *)Vehicle::Get(index);
1097 }
1098
1103 static inline T *GetIfValid(size_t index)
1104 {
1105 return IsValidID(index) ? Get(index) : NULL;
1106 }
1107
1113 static inline T *From(Vehicle *v)
1114 {
1115 assert(v->type == Type);
1116 return (T *)v;
1117 }
1118
1124 static inline const T *From(const Vehicle *v)
1125 {
1126 assert(v->type == Type);
1127 return (const T *)v;
1128 }
1129
1135 inline void UpdateViewport(bool force_update, bool update_delta)
1136 {
1137 /* Skip updating sprites on dedicated servers without screen */
1138 if (_network_dedicated) return;
1139
1140 /* Explicitly choose method to call to prevent vtable dereference -
1141 * it gives ~3% runtime improvements in games with many vehicles */
1142 if (update_delta) ((T *)this)->T::UpdateDeltaXY(this->direction);
1143 VehicleSpriteSeq seq;
1144 ((T *)this)->T::GetImage(this->direction, EIT_ON_MAP, &seq);
1145 if (force_update || this->sprite_seq != seq) {
1146 this->sprite_seq = seq;
1147 this->Vehicle::UpdateViewport(true);
1148 }
1149 }
1150 };
1151
1157 #define FOR_ALL_VEHICLES_OF_TYPE(name, var) FOR_ALL_ITEMS_FROM(name, vehicle_index, var, 0) if (var->type == name::EXPECTED_TYPE)
1158
1160 struct FreeUnitIDGenerator {
1161 bool *cache;
1162 UnitID maxid;
1163 UnitID curid;
1164
1165 FreeUnitIDGenerator(VehicleType type, CompanyID owner);
1166 UnitID NextID();
1167
1169 ~FreeUnitIDGenerator() { free(this->cache); }
1170 };
1171
1173 static const int32 INVALID_COORD = 0x7fffffff;
1174
1175 #endif /* VEHICLE_BASE_H */
track_type.h
All types related to tracks.
LoadgameState
Definition: oldloader.h:21
NewGRFCache
Cached often queried (NewGRF) values.
Definition: vehicle_base.h:67
Vehicle::max_age
Date max_age
Maximum age.
Definition: vehicle_base.h:259
NCVV_POSITION_SAME_ID_LENGTH
This bit will be set if the NewGRF var 41 currently stored is valid.
Definition: vehicle_base.h:59
PaletteID
uint32 PaletteID
The number of the palette.
Definition: gfx_type.h:20
Vehicle::Previous
Vehicle * Previous() const
Get the previous vehicle of this vehicle.
Definition: vehicle_base.h:589
VS_STOPPED
Vehicle is stopped by the player.
Definition: vehicle_base.h:33
Vehicle::cargo
VehicleCargoList cargo
The cargo this vehicle is carrying.
Definition: vehicle_base.h:309
Vehicle::motion_counter
uint32 motion_counter
counter to occasionally play a vehicle sound.
Definition: vehicle_base.h:296
Vehicle::value
Money value
Value of the vehicle.
Definition: vehicle_base.h:241
RefitDesc::capacity
uint16 capacity
Capacity the vehicle will have.
Definition: vehicle_base.h:205
NCVV_POSITION_CONSIST_LENGTH
This bit will be set if the NewGRF var 40 currently stored is valid.
Definition: vehicle_base.h:58
Vehicle::MarkDirty
virtual void MarkDirty()
Marks the vehicles to be redrawn and updates cached variables.
Definition: vehicle_base.h:364
SmallStack
Minimal stack that uses a pool to avoid pointers.
Definition: smallstack_type.hpp:138
Vehicle::GetDisplayProfitThisYear
Money GetDisplayProfitThisYear() const
Gets the profit vehicle had this year.
Definition: vehicle_base.h:567
Vehicle::direction
DirectionByte direction
facing
Definition: vehicle_base.h:271
VEH_INVALID
Non-existing type of vehicle.
Definition: vehicle_type.h:35
Vehicle::hash_tile_next
Vehicle * hash_tile_next
NOSAVE: Next vehicle in the tile location hash.
Definition: vehicle_base.h:250
Vehicle::GetFirstEnginePart
Vehicle * GetFirstEnginePart()
Get the first part of an articulated engine.
Definition: vehicle_base.h:920
VF_LOADING_FINISHED
Vehicle has finished loading.
Definition: vehicle_base.h:44
VS_AIRCRAFT_BROKEN
Aircraft is broken down.
Definition: vehicle_base.h:38
InvalidateVehicleOrder
void InvalidateVehicleOrder(const Vehicle *v, int data)
Updates the widgets of a vehicle which contains the order-data.
Definition: order_cmd.cpp:252
Pool::PoolItem<&_vehicle_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:246
VF_TIMETABLE_STARTED
Whether the vehicle has started running on the timetable yet.
Definition: vehicle_base.h:47
Vehicle::hash_viewport_prev
Vehicle ** hash_viewport_prev
NOSAVE: Previous vehicle in the visual location hash.
Definition: vehicle_base.h:248
RefitDesc
Simulated cargo type and capacity for prediction of future links.
Definition: vehicle_base.h:203
Vehicle::breakdown_delay
byte breakdown_delay
Counter for managing breakdown length.
Definition: vehicle_base.h:264
VS_DEFPAL
Use default vehicle palette.
Definition: vehicle_base.h:35
VS_SHADOW
Vehicle is a shadow vehicle.
Definition: vehicle_base.h:37
VehicleSpriteSeq::CopyWithoutPalette
void CopyWithoutPalette(const VehicleSpriteSeq &src)
Copy data from another sprite sequence, while dropping all recolouring information.
Definition: vehicle_base.h:173
EIT_ON_MAP
Vehicle drawn in viewport.
Definition: vehicle_type.h:88
Vehicle::cur_speed
uint16 cur_speed
current speed
Definition: vehicle_base.h:293
VehicleCache::cached_cargo_age_period
uint16 cached_cargo_age_period
Number of ticks before carried cargo is aged.
Definition: vehicle_base.h:124
VESM_NONE
No visual effect.
Definition: vehicle_base.h:99
Vehicle::cargo_age_counter
uint16 cargo_age_counter
Ticks till cargo is aged next.
Definition: vehicle_base.h:310
engine_type.h
Types related to engines.
transport_type.h
Base types related to transport.
GVSF_FRONT
Leading engine of a consist.
Definition: vehicle_base.h:113
Vehicle::spritenum
byte spritenum
currently displayed sprite index 0xfd == custom sprite, 0xfe == custom second head sprite 0xff == res...
Definition: vehicle_base.h:279
Vehicle::IsStoppedInDepot
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
Definition: vehicle_base.h:517
VehStatus
VehStatus
Vehicle status bits in Vehicle::vehstatus.
Definition: vehicle_base.h:31
Vehicle::list
OrderList * list
Pointer to the order list for this vehicle.
Definition: vehicle_base.h:321
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:303
Vehicle::hash_tile_prev
Vehicle ** hash_tile_prev
NOSAVE: Previous vehicle in the tile location hash.
Definition: vehicle_base.h:251
Vehicle::dest_tile
TileIndex dest_tile
Heading for this tile.
Definition: vehicle_base.h:237
SmallMap
Implementation of simple mapping class.
Definition: smallmap_type.hpp:42
Vehicle::IncrementImplicitOrderIndex
void IncrementImplicitOrderIndex()
Increments cur_implicit_order_index, keeps care of the wrap-around and invalidates the GUI...
Definition: vehicle_base.h:799
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:823
NCVV_COMPANY_INFORMATION
This bit will be set if the NewGRF var 43 currently stored is valid.
Definition: vehicle_base.h:61
PalSpriteID
Combination of a palette sprite and a &#39;real&#39; sprite.
Definition: gfx_type.h:24
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:212
VehicleSpriteSeq::Clear
void Clear()
Clear all information.
Definition: vehicle_base.h:155
LoadOldVehicle
bool LoadOldVehicle(LoadgameState *ls, int num)
Load the vehicles of an old style savegame.
Definition: oldloader_sl.cpp:1233
VehicleSpriteSeq::Set
void Set(SpriteID sprite)
Assign a single sprite to the sequence.
Definition: vehicle_base.h:163
order_func.h
Functions related to orders.
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:443
VehicleCache
Cached often queried values common to all vehicles.
Definition: vehicle_base.h:122
SpecializedVehicle::UpdateViewport
void UpdateViewport(bool force_update, bool update_delta)
Update vehicle sprite- and position caches.
Definition: vehicle_base.h:1135
VF_CARGO_UNLOADING
Vehicle is unloading cargo.
Definition: vehicle_base.h:45
GVSF_ENGINE
Engine that can be front engine, but might be placed behind another engine (not used for road vehicle...
Definition: vehicle_base.h:116
Vehicle::last_station_visited
StationID last_station_visited
The last station we stopped at.
Definition: vehicle_base.h:302
Vehicle::reliability_spd_dec
uint16 reliability_spd_dec
Reliability decrease speed.
Definition: vehicle_base.h:262
NewGRFCache::position_consist_length
uint32 position_consist_length
Cache for NewGRF var 40.
Definition: vehicle_base.h:69
VESM_ELECTRIC
Electric model.
Definition: vehicle_base.h:102
Vehicle::UpdateViewport
void UpdateViewport(bool dirty)
Update the vehicle on the viewport, updating the right hash and setting the new coordinates.
Definition: vehicle.cpp:1557
VE_OFFSET_START
First bit that contains the offset (0 = front, 8 = centre, 15 = rear)
Definition: vehicle_base.h:79
CommandCost
Common return value for all commands.
Definition: command_type.h:25
Year
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:20
Order
Definition: order_base.h:34
GVSF_WAGON
Wagon (not used for road vehicles).
Definition: vehicle_base.h:115
Vehicle::vehstatus
byte vehstatus
Status.
Definition: vehicle_base.h:317
EngineImageType
EngineImageType
Visualisation contexts of vehicles and engines.
Definition: vehicle_type.h:87
GroundVehicleCache
Cached, frequently calculated values.
Definition: ground_vehicle.hpp:31
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:123
FreeUnitIDGenerator
Generates sequence of free UnitID numbers.
Definition: vehicle_base.h:1160
Vehicle::next_shared
Vehicle * next_shared
pointer to the next vehicle that shares the order
Definition: vehicle_base.h:221
VE_TYPE_DEFAULT
Use default from engine class.
Definition: vehicle_base.h:85
Vehicle::sprite_seq
VehicleSpriteSeq sprite_seq
Vehicle appearance.
Definition: vehicle_base.h:280
Direction
Direction
Defines the 8 directions on the map.
Definition: direction_type.h:26
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:60
Vehicle::hash_viewport_next
Vehicle * hash_viewport_next
NOSAVE: Next vehicle in the visual location hash.
Definition: vehicle_base.h:247
command_type.h
Types related to commands.
Vehicle::x_bb_offs
int8 x_bb_offs
x offset of vehicle bounding box
Definition: vehicle_base.h:284
DepotCommand
DepotCommand
Flags to add to p1 for goto depot commands.
Definition: vehicle_type.h:67
order_base.h
Base class for orders.
Vehicle::profit_last_year
Money profit_last_year
Profit last year << 8, low 8 bits are fract.
Definition: vehicle_base.h:240
_network_dedicated
bool _network_dedicated
are we a dedicated server?
Definition: network.cpp:59
Vehicle::FirstShared
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
Definition: vehicle_base.h:676
VESM_DIESEL
Diesel model.
Definition: vehicle_base.h:101
smallmap_type.hpp
Simple mapping class targeted for small sets of data.
Vehicle::SkipToNextRealOrderIndex
void SkipToNextRealOrderIndex()
Advance cur_real_order_index to the next real order.
Definition: vehicle_base.h:780
VE_OFFSET_CENTRE
Value of offset corresponding to a position above the centre of the vehicle.
Definition: vehicle_base.h:81
Vehicle::hash_tile_current
Vehicle ** hash_tile_current
NOSAVE: Cache of the current hash chain.
Definition: vehicle_base.h:252
INVALID_COORD
static const int32 INVALID_COORD
Sentinel for an invalid coordinate.
Definition: vehicle_base.h:1173
Vehicle::y_bb_offs
int8 y_bb_offs
y offset of vehicle bounding box
Definition: vehicle_base.h:285
Vehicle::breakdown_ctr
byte breakdown_ctr
Counter for managing breakdown events.
Definition: vehicle_base.h:263
Vehicle::Move
Vehicle * Move(int n)
Get the vehicle at offset n of this vehicle chain.
Definition: vehicle_base.h:624
cargopacket.h
Base class for cargo packets.
Vehicle::subtype
byte subtype
subtype (Filled with values from #EffectVehicles/#TrainSubTypes/#AircraftSubTypes) ...
Definition: vehicle_base.h:327
Vehicle::fill_percent_te_id
TextEffectID fill_percent_te_id
a text-effect id to a loading indicator object
Definition: vehicle_base.h:290
Vehicle::cargo_cap
uint16 cargo_cap
total capacity
Definition: vehicle_base.h:307
OrderList
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Definition: order_base.h:252
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:487
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:561
SpecializedVehicle
Class defining several overloaded accessors so we don&#39;t have to cast vehicle types that often...
Definition: vehicle_base.h:993
VS_CRASHED
Vehicle is crashed.
Definition: vehicle_base.h:39
VF_BUILT_AS_PROTOTYPE
Vehicle is a prototype (accepted as exclusive preview).
Definition: vehicle_base.h:46
Vehicle::acceleration
byte acceleration
used by train & aircraft
Definition: vehicle_base.h:295
VE_TYPE_START
First bit used for the type of effect.
Definition: vehicle_base.h:83
Vehicle::IsPrimaryVehicle
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
Definition: vehicle_base.h:434
BaseConsist
Various front vehicle properties that are preserved when autoreplacing, using order-backup or switchi...
Definition: base_consist.h:19
Vehicle::unitnumber
UnitID unitnumber
unit number, for display purposes only
Definition: vehicle_base.h:291
Vehicle::cargo_subtype
byte cargo_subtype
Used for livery refits (NewGRF variations)
Definition: vehicle_base.h:306
operator!=
bool operator!=(const MultiMapIterator< Tmap_iter1, Tlist_iter1, Tkey, Tvalue1, Tcompare > &iter1, const MultiMapIterator< Tmap_iter2, Tlist_iter2, Tkey, Tvalue2, Tcompare > &iter2)
Inverse of operator==().
Definition: multimap.hpp:222
VehicleSpriteSeq::IsValid
bool IsValid() const
Check whether the sequence contains any sprites.
Definition: vehicle_base.h:147
RefitDesc::remaining
uint16 remaining
Capacity remaining from before the previous refit.
Definition: vehicle_base.h:206
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:751
Vehicle::y_offs
int8 y_offs
y offset for vehicle sprite
Definition: vehicle_base.h:287
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
MarkAllViewportsDirty
void MarkAllViewportsDirty(int left, int top, int right, int bottom)
Mark all viewports that display an area as dirty (in need of repaint).
Definition: viewport.cpp:1872
VF_STOP_LOADING
Don&#39;t load anymore during the next load cycle.
Definition: vehicle_base.h:50
FreeUnitIDGenerator::maxid
UnitID maxid
maximum ID at the moment of constructor call
Definition: vehicle_base.h:1162
Vehicle::GetFirstEnginePart
const Vehicle * GetFirstEnginePart() const
Get the first part of an articulated engine.
Definition: vehicle_base.h:931
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition: command_type.h:340
VisualEffectSpawnModel
VisualEffectSpawnModel
Models for spawning visual effects.
Definition: vehicle_base.h:98
Vehicle::GetExpenseType
virtual ExpensesType GetExpenseType(bool income) const
Sets the expense type associated to this vehicle type.
Definition: vehicle_base.h:424
Vehicle::IsArticulatedPart
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
Definition: vehicle_base.h:891
Vehicle::x_extent
byte x_extent
x-extent of vehicle bounding box
Definition: vehicle_base.h:281
VehiclePool
Pool< Vehicle, VehicleID, 512, 0xFF000 > VehiclePool
A vehicle pool for a little over 1 million vehicles.
Definition: vehicle_base.h:187
Vehicle::InvalidateNewGRFCacheOfChain
void InvalidateNewGRFCacheOfChain()
Invalidates cached NewGRF variables of all vehicles in the chain (after the current vehicle) ...
Definition: vehicle_base.h:461
Vehicle::GetNextVehicle
Vehicle * GetNextVehicle() const
Get the next real (non-articulated part) vehicle in the consist.
Definition: vehicle_base.h:953
NewGRFCacheValidValues
NewGRFCacheValidValues
Bit numbers used to indicate which of the NewGRFCache values are valid.
Definition: vehicle_base.h:57
Vehicle::waiting_triggers
byte waiting_triggers
Triggers to be yet matched before rerandomizing the random bits.
Definition: vehicle_base.h:300
VE_TYPE_ELECTRIC
Electric sparks.
Definition: vehicle_base.h:88
GroupID
uint16 GroupID
Type for all group identifiers.
Definition: group_type.h:15
NewGRFCache::position_same_id_length
uint32 position_same_id_length
Cache for NewGRF var 41.
Definition: vehicle_base.h:70
Vehicle::z_extent
byte z_extent
z-extent of vehicle bounding box
Definition: vehicle_base.h:283
Trackdir
Trackdir
Enumeration for tracks and directions.
Definition: track_type.h:74
Vehicle::UpdateRealOrderIndex
void UpdateRealOrderIndex()
Skip implicit orders until cur_real_order_index is a non-implicit order.
Definition: vehicle_base.h:838
VF_SERVINT_IS_CUSTOM
Service interval is custom.
Definition: vehicle_base.h:52
Vehicle::GetCurrentMaxSpeed
virtual int GetCurrentMaxSpeed() const
Calculates the maximum speed of the vehicle under its current conditions.
Definition: vehicle_base.h:493
operator==
bool operator==(const MultiMapIterator< Tmap_iter1, Tlist_iter1, Tkey, Tvalue1, Tcompare > &iter1, const MultiMapIterator< Tmap_iter2, Tlist_iter2, Tkey, Tvalue2, Tcompare > &iter2)
Compare two MultiMap iterators.
Definition: multimap.hpp:205
Vehicle::cargo_type
CargoID cargo_type
type of cargo this vehicle is carrying
Definition: vehicle_base.h:305
VF_AUTOFILL_TIMETABLE
Whether the vehicle should fill in the timetable automatically.
Definition: vehicle_base.h:48
Vehicle::load_unload_ticks
uint16 load_unload_ticks
Ticks to wait before starting next cycle.
Definition: vehicle_base.h:325
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:1085
Vehicle::old
Order * old
Only used during conversion of old save games.
Definition: vehicle_base.h:322
Vehicle::IsFrontEngine
bool IsFrontEngine() const
Check if the vehicle is a front engine.
Definition: vehicle_base.h:882
base_consist.h
Properties for front vehicles/consists.
Vehicle::tile
TileIndex tile
Current tile index.
Definition: vehicle_base.h:230
NCVV_CONSIST_CARGO_INFORMATION
This bit will be set if the NewGRF var 42 currently stored is valid.
Definition: vehicle_base.h:60
ExpensesType
ExpensesType
Types of expenses.
Definition: economy_type.h:150
Vehicle::HasArticulatedPart
bool HasArticulatedPart() const
Check if an engine has an articulated part.
Definition: vehicle_base.h:900
Vehicle::Last
const Vehicle * Last() const
Get the last vehicle of this vehicle chain.
Definition: vehicle_base.h:612
VESM_STEAM
Steam model.
Definition: vehicle_base.h:100
Vehicle::IsInDepot
virtual bool IsInDepot() const
Check whether the vehicle is in the depot.
Definition: vehicle_base.h:505
network.h
Basic functions/variables used all over the place.
Vehicle::GetOrderStationLocation
virtual TileIndex GetOrderStationLocation(StationID station)
Determine the location for the station where the vehicle goes to next.
Definition: vehicle_base.h:741
Vehicle::x_offs
int8 x_offs
x offset for vehicle sprite
Definition: vehicle_base.h:286
VehicleSpriteSeq
Sprite sequence for a vehicle part.
Definition: vehicle_base.h:130
VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
CargoPayment
Helper class to perform the cargo payment.
Definition: economy_base.h:26
Vehicle::GetLastOrder
Order * GetLastOrder() const
Returns the last order of a vehicle, or NULL if it doesn&#39;t exists.
Definition: vehicle_base.h:868
Vehicle::refit_cap
uint16 refit_cap
Capacity left over from before last refit.
Definition: vehicle_base.h:308
Vehicle::random_bits
byte random_bits
Bits used for determining which randomized variational spritegroups to use when drawing.
Definition: vehicle_base.h:299
Vehicle::breakdowns_since_last_service
byte breakdowns_since_last_service
Counter for the amount of breakdowns.
Definition: vehicle_base.h:265
Vehicle::reliability
uint16 reliability
Reliability.
Definition: vehicle_base.h:261
TinyEnumT< Direction >
Vehicle::First
Vehicle * First() const
Get the first vehicle of this vehicle chain.
Definition: vehicle_base.h:595
VF_PATHFINDER_LOST
Vehicle&#39;s pathfinder is lost.
Definition: vehicle_base.h:51
Vehicle::tick_counter
byte tick_counter
Increased by one for each tick.
Definition: vehicle_base.h:314
Vehicle::GetFirstOrder
Order * GetFirstOrder() const
Get the first order of the vehicles order list.
Definition: vehicle_base.h:655
FreeUnitIDGenerator::curid
UnitID curid
last ID returned; 0 if none
Definition: vehicle_base.h:1163
Pool::PoolItem
Base class for all PoolItems.
Definition: pool_type.hpp:146
Vehicle::build_year
Year build_year
Year the vehicle has been built.
Definition: vehicle_base.h:257
Engine
Definition: engine_base.h:23
GVSF_MULTIHEADED
Engine is multiheaded (not used for road vehicles).
Definition: vehicle_base.h:118
Pool
Base class for all pools.
Definition: pool_type.hpp:83
Vehicle::GetRunningCost
virtual Money GetRunningCost() const
Gets the running cost of a vehicle.
Definition: vehicle_base.h:499
FreeUnitIDGenerator::~FreeUnitIDGenerator
~FreeUnitIDGenerator()
Releases allocated memory.
Definition: vehicle_base.h:1169
Vehicle::breakdown_chance
byte breakdown_chance
Current chance of breakdowns.
Definition: vehicle_base.h:266
VE_TYPE_DIESEL
Diesel fumes.
Definition: vehicle_base.h:87
Company
Definition: company_base.h:110
NCVV_POSITION_IN_VEHICLE
This bit will be set if the NewGRF var 4D currently stored is valid.
Definition: vehicle_base.h:62
Vehicle::trip_occupancy
int8 trip_occupancy
NOSAVE: Occupancy of vehicle of the current trip (updated after leaving a station).
Definition: vehicle_base.h:311
GetNextArticulatedPart
static EngineID GetNextArticulatedPart(uint index, EngineID front_type, Vehicle *front=NULL, bool *mirrored=NULL)
Determines the next articulated part to attach.
Definition: articulated_vehicles.cpp:34
VE_DISABLE_EFFECT
Flag to disable visual effect.
Definition: vehicle_base.h:90
VE_TYPE_STEAM
Steam plumes.
Definition: vehicle_base.h:86
NewGRFCache::company_information
uint32 company_information
Cache for NewGRF var 43.
Definition: vehicle_base.h:72
Vehicle::GetPrevVehicle
Vehicle * GetPrevVehicle() const
Get the previous real (non-articulated part) vehicle in the consist.
Definition: vehicle_base.h:966
GVSF_ARTICULATED_PART
Articulated part of an engine.
Definition: vehicle_base.h:114
Vehicle::IsGroundVehicle
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
Definition: vehicle_base.h:472
Vehicle::subspeed
byte subspeed
fractional speed
Definition: vehicle_base.h:294
VehicleCargoList
CargoList that is used for vehicles.
Definition: cargopacket.h:283
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:19
Vehicle::GetLastEnginePart
Vehicle * GetLastEnginePart()
Get the last part of an articulated engine.
Definition: vehicle_base.h:942
EngineID
uint16 EngineID
Unique identification number of an engine.
Definition: engine_type.h:22
VE_TYPE_COUNT
Number of bits used for the effect type.
Definition: vehicle_base.h:84
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
_vehicle_pool
VehiclePool _vehicle_pool
The pool with all our precious vehicles.
Vehicle::GetAdvanceDistance
uint GetAdvanceDistance()
Determines the vehicle "progress" needed for moving a step.
Definition: vehicle_base.h:415
Vehicle::Next
Vehicle * Next() const
Get the next vehicle of this vehicle.
Definition: vehicle_base.h:582
Vehicle::date_of_last_service
Date date_of_last_service
Last date the vehicle had a service at a depot.
Definition: vehicle_base.h:260
Vehicle::cargo_payment
CargoPayment * cargo_payment
The cargo payment we&#39;re currently in.
Definition: vehicle_base.h:243
Vehicle::PreviousShared
Vehicle * PreviousShared() const
Get the previous vehicle of the shared vehicle chain.
Definition: vehicle_base.h:670
RefitDesc::cargo
CargoID cargo
Cargo type the vehicle will be carrying.
Definition: vehicle_base.h:204
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:71
FixOldVehicles
void FixOldVehicles()
Convert the old style vehicles into something that resembles the old new style savegames.
Definition: oldloader_sl.cpp:174
Vehicle::owner
OwnerByte owner
Which company owns the vehicle?
Definition: vehicle_base.h:273
NewGRFCache::position_in_vehicle
uint32 position_in_vehicle
Cache for NewGRF var 4D.
Definition: vehicle_base.h:73
Vehicle::GetNextStoppingStation
StationIDStack GetNextStoppingStation() const
Get the next station the vehicle will stop at.
Definition: vehicle_base.h:700
Vehicle::GetNextArticulatedPart
Vehicle * GetNextArticulatedPart() const
Get the next part of an articulated engine.
Definition: vehicle_base.h:910
SpecializedVehicle::SpecializedVehicleBase
SpecializedVehicle< T, Type > SpecializedVehicleBase
Our type.
Definition: vehicle_base.h:996
GroundVehicleSubtypeFlags
GroundVehicleSubtypeFlags
Enum to handle ground vehicle subtypes.
Definition: vehicle_base.h:112
Vehicle::UpdateDeltaXY
virtual void UpdateDeltaXY(Direction direction)
Updates the x and y offsets and the size of the sprite used for this vehicle.
Definition: vehicle_base.h:371
Vehicle::next
Vehicle * next
pointer to the next vehicle in the chain
Definition: vehicle_base.h:217
AfterLoadVehicles
void AfterLoadVehicles(bool part_of_load)
Called after load to update coordinates.
Definition: vehicle_sl.cpp:249
GVSF_FREE_WAGON
First in a wagon chain (in depot) (not used for road vehicles).
Definition: vehicle_base.h:117
Vehicle::previous_shared
Vehicle * previous_shared
NOSAVE: pointer to the previous vehicle in the shared order chain.
Definition: vehicle_base.h:222
NCVV_END
End of the bits.
Definition: vehicle_base.h:63
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:713
Vehicle::OnNewDay
virtual void OnNewDay()
Calls the new day handler of the vehicle.
Definition: vehicle_base.h:534
VE_DEFAULT
Default value to indicate that visual effect should be based on engine class.
Definition: vehicle_base.h:94
Vehicle::z_pos
int32 z_pos
z coordinate.
Definition: vehicle_base.h:270
VS_HIDDEN
Vehicle is not visible.
Definition: vehicle_base.h:32
Vehicle::previous
Vehicle * previous
NOSAVE: pointer to the previous vehicle in the chain.
Definition: vehicle_base.h:218
Pool::PoolItem<&_vehicle_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
Definition: pool_type.hpp:235
BaseVehicle
Base vehicle class.
Definition: vehicle_type.h:52
UnitID
uint16 UnitID
Type for the company global vehicle unit number.
Definition: transport_type.h:18
FreeUnitIDGenerator::cache
bool * cache
array of occupied unit id numbers
Definition: vehicle_base.h:1161
Vehicle::GetOrder
Order * GetOrder(int index) const
Returns order &#39;index&#39; of a vehicle or NULL when it doesn&#39;t exists.
Definition: vehicle_base.h:859
Vehicle::GetNumOrders
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
Definition: vehicle_base.h:688
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:16
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: depend.cpp:114
Vehicle::IsOrderListShared
bool IsOrderListShared() const
Check if we share our orders with another vehicle.
Definition: vehicle_base.h:682
Vehicle::running_ticks
byte running_ticks
Number of ticks this vehicle was not stopped this day.
Definition: vehicle_base.h:315
Vehicle::GetVehicleTrackdir
virtual Trackdir GetVehicleTrackdir() const
Returns the Trackdir on which the vehicle is currently located.
Definition: vehicle_base.h:555
Vehicle::y_extent
byte y_extent
y-extent of vehicle bounding box
Definition: vehicle_base.h:282
VE_DISABLE_WAGON_POWER
Flag to disable wagon power.
Definition: vehicle_base.h:92
Vehicle::engine_type
EngineID engine_type
The type of engine used for this vehicle.
Definition: vehicle_base.h:288
SaveLoad
SaveLoad type struct.
Definition: saveload.h:208
VehicleCache::cached_vis_effect
byte cached_vis_effect
Visual effect to show (see VisualEffect)
Definition: vehicle_base.h:126
Vehicle::PlayLeaveStationSound
virtual void PlayLeaveStationSound() const
Play the sound associated with leaving the station.
Definition: vehicle_base.h:429
Vehicle::x_pos
int32 x_pos
x coordinate.
Definition: vehicle_base.h:268
Vehicle::Tick
virtual bool Tick()
Calls the tick handler of the vehicle.
Definition: vehicle_base.h:529
VehicleOrderID
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition: order_type.h:17
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:105
Vehicle::Move
const Vehicle * Move(int n) const
Get the vehicle at offset n of this vehicle chain.
Definition: vehicle_base.h:640
NewGRFCache::cache_valid
uint8 cache_valid
Bitset that indicates which cache values are valid.
Definition: vehicle_base.h:74
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:85
VF_AUTOFILL_PRES_WAIT_TIME
Whether non-destructive auto-fill should preserve waiting times.
Definition: vehicle_base.h:49
Vehicle::progress
byte progress
The percentage (if divided by 256) this vehicle already crossed the tile unit.
Definition: vehicle_base.h:297
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:481
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:40
CargoID
byte CargoID
Cargo slots to indicate a cargo type within a game.
Definition: cargo_type.h:22
Vehicle::y_pos
int32 y_pos
y coordinate.
Definition: vehicle_base.h:269
EXPENSES_OTHER
Other expenses.
Definition: economy_type.h:163
Vehicle::GetAdvanceSpeed
static uint GetAdvanceSpeed(uint speed)
Determines the effective vehicle movement speed.
Definition: vehicle_base.h:403
Vehicle::NextShared
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
Definition: vehicle_base.h:664
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:20
Vehicle::IsChainInDepot
virtual bool IsChainInDepot() const
Check whether the whole vehicle chain is in the depot.
Definition: vehicle_base.h:511
VE_ADVANCED_EFFECT
Flag for advanced effects.
Definition: vehicle_base.h:91
INVALID_TRACKDIR
Flag for an invalid trackdir.
Definition: track_type.h:93
Vehicle::Last
Vehicle * Last()
Get the last vehicle of this vehicle chain.
Definition: vehicle_base.h:601
VehicleFlags
VehicleFlags
Bit numbers in Vehicle::vehicle_flags.
Definition: vehicle_base.h:43
texteff.hpp
Functions related to text effects.
PalSpriteID::sprite
SpriteID sprite
The &#39;real&#39; sprite.
Definition: gfx_type.h:25
Vehicle::profit_this_year
Money profit_this_year
Profit this year << 8, low 8 bits are fract.
Definition: vehicle_base.h:239
GetVehicleDescription
const SaveLoad * GetVehicleDescription(VehicleType vt)
Make it possible to make the saveload tables "friends" of other classes.
Definition: vehicle_sl.cpp:574
Vehicle::vcache
VehicleCache vcache
Cache of often used vehicle values.
Definition: vehicle_base.h:330
VE_OFFSET_COUNT
Number of bits used for the offset.
Definition: vehicle_base.h:80
VisualEffect
VisualEffect
Meaning of the various bits of the visual effect.
Definition: vehicle_base.h:78
Vehicle::coord
Rect coord
NOSAVE: Graphical bounding box of the vehicle, i.e. what to redraw on moves.
Definition: vehicle_base.h:245
Vehicle::first
Vehicle * first
NOSAVE: pointer to the first vehicle in the chain.
Definition: vehicle_base.h:219
Vehicle::age
Date age
Age in days.
Definition: vehicle_base.h:258
BaseVehicle::type
VehicleTypeByte type
Type of vehicle.
Definition: vehicle_type.h:54
group_type.h
Types of a group.
Station
Station data structure.
Definition: station_base.h:446
Vehicle::grf_cache
NewGRFCache grf_cache
Cache of often used calculated NewGRF values.
Definition: vehicle_base.h:329
Vehicle::InvalidateNewGRFCache
void InvalidateNewGRFCache()
Invalidates cached NewGRF variables.
Definition: vehicle_base.h:452
Vehicle::GetDisplayProfitLastYear
Money GetDisplayProfitLastYear() const
Gets the profit vehicle had last year.
Definition: vehicle_base.h:573
Vehicle::GetOldAdvanceSpeed
uint GetOldAdvanceSpeed(uint speed)
Determines the effective direction-specific vehicle movement speed.
Definition: vehicle_base.h:386
OverflowSafeInt< int64, INT64_MAX, INT64_MIN >
VS_TRAIN_SLOWING
Train is slowing down.
Definition: vehicle_base.h:36
Vehicle::day_counter
byte day_counter
Increased by one for each day.
Definition: vehicle_base.h:313
Vehicle::current_order
Order current_order
The current order (+ status, like: loading)
Definition: vehicle_base.h:318
Vehicle::group_id
GroupID group_id
Index of group Pool array.
Definition: vehicle_base.h:326
VS_UNCLICKABLE
Vehicle is not clickable by the user (shadow vehicles).
Definition: vehicle_base.h:34
Vehicle::colourmap
SpriteID colourmap
NOSAVE: cached colour mapping.
Definition: vehicle_base.h:254
Vehicle::GetNumManualOrders
VehicleOrderID GetNumManualOrders() const
Get the number of manually added orders this vehicle has.
Definition: vehicle_base.h:694
VF_SERVINT_IS_PERCENT
Service interval is percent.
Definition: vehicle_base.h:53
GRFFile
Dynamic data of a loaded NewGRF.
Definition: newgrf.h:104
VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
PalSpriteID::pal
PaletteID pal
The palette (use PAL_NONE) if not needed)
Definition: gfx_type.h:26