Mercurial > hg > openttd
annotate src/vehicle_base.h @ 13286:58de76f90067 draft
(svn r17795) -Codechange: split cargolist into one for vehicles and one for stations.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 18 Oct 2009 13:39:00 +0000 |
parents | 1fa162c4d082 |
children | 3b79b87a3fcb |
rev | line source |
---|---|
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
2 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12666
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12666
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12666
diff
changeset
|
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. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12666
diff
changeset
|
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. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12666
diff
changeset
|
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/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12666
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12666
diff
changeset
|
9 |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
10 /** @file vehicle_base.h Base class for all vehicles. */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
11 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
12 #ifndef VEHICLE_BASE_H |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
13 #define VEHICLE_BASE_H |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
14 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
15 #include "vehicle_type.h" |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
16 #include "track_type.h" |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
17 #include "cargo_type.h" |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
18 #include "direction_type.h" |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
19 #include "gfx_type.h" |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
20 #include "command_type.h" |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
21 #include "date_type.h" |
10208
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
22 #include "company_base.h" |
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
23 #include "company_type.h" |
11974
5328e400636a
(svn r16380) -Codechange: rename pool.hpp to pool_type.hpp
smatz <smatz@openttd.org>
parents:
11972
diff
changeset
|
24 #include "core/pool_type.hpp" |
8784
6280c0d48a6d
(svn r12488) -Codechange: split order.h into order_base.h and order_func.h.
rubidium <rubidium@openttd.org>
parents:
8777
diff
changeset
|
25 #include "order_base.h" |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
26 #include "cargopacket.h" |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
27 #include "texteff.hpp" |
8770
2dab0174bbb2
(svn r12469) -Codechange: split type related stuff from group.h (and openttd.h) to group_type.h.
rubidium <rubidium@openttd.org>
parents:
8666
diff
changeset
|
28 #include "group_type.h" |
8777
b8c9838f0585
(svn r12476) -Codechange: split type engine related types from engine.h (and openttd.h) to engine_type.h.
rubidium <rubidium@openttd.org>
parents:
8770
diff
changeset
|
29 #include "engine_type.h" |
9061
888b60158039
(svn r12913) -Add: ability to backup and restore a player's economic data and data for a vehicle (or chain of vehicles)
bjarni <bjarni@openttd.org>
parents:
9043
diff
changeset
|
30 #include "order_func.h" |
9126
8c450e1754e2
(svn r12986) -Codechange: move the landscape and transport related types from openttd.h to their own headers.
rubidium <rubidium@openttd.org>
parents:
9081
diff
changeset
|
31 #include "transport_type.h" |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
32 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
33 enum VehStatus { |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
34 VS_HIDDEN = 0x01, |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
35 VS_STOPPED = 0x02, |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
36 VS_UNCLICKABLE = 0x04, |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
37 VS_DEFPAL = 0x08, |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
38 VS_TRAIN_SLOWING = 0x10, |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
39 VS_SHADOW = 0x20, |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
40 VS_AIRCRAFT_BROKEN = 0x40, |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
41 VS_CRASHED = 0x80, |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
42 }; |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
43 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
44 enum VehicleFlags { |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
45 VF_LOADING_FINISHED, |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
46 VF_CARGO_UNLOADING, |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
47 VF_BUILT_AS_PROTOTYPE, |
10341
3f3ad0911cdc
(svn r14592) -Feature [FS#1124]: non-destructive autofill with option to keep waiting times (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10208
diff
changeset
|
48 VF_TIMETABLE_STARTED, ///< Whether the vehicle has started running on the timetable yet. |
3f3ad0911cdc
(svn r14592) -Feature [FS#1124]: non-destructive autofill with option to keep waiting times (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10208
diff
changeset
|
49 VF_AUTOFILL_TIMETABLE, ///< Whether the vehicle should fill in the timetable automatically. |
3f3ad0911cdc
(svn r14592) -Feature [FS#1124]: non-destructive autofill with option to keep waiting times (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10208
diff
changeset
|
50 VF_AUTOFILL_PRES_WAIT_TIME, ///< Whether non-destructive auto-fill should preserve waiting times |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
51 }; |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
52 |
11988
935e4f91c83c
(svn r16394) -Codechange: move (NewGRF) cache variables into a separate struct so (some vehicle related) NewGRF cache 'desyncs' can be tested easier.
rubidium <rubidium@openttd.org>
parents:
11987
diff
changeset
|
53 /** Cached oftenly queried (NewGRF) values */ |
935e4f91c83c
(svn r16394) -Codechange: move (NewGRF) cache variables into a separate struct so (some vehicle related) NewGRF cache 'desyncs' can be tested easier.
rubidium <rubidium@openttd.org>
parents:
11987
diff
changeset
|
54 struct VehicleCache { |
935e4f91c83c
(svn r16394) -Codechange: move (NewGRF) cache variables into a separate struct so (some vehicle related) NewGRF cache 'desyncs' can be tested easier.
rubidium <rubidium@openttd.org>
parents:
11987
diff
changeset
|
55 uint8 cache_valid; ///< Whether the caches are valid |
935e4f91c83c
(svn r16394) -Codechange: move (NewGRF) cache variables into a separate struct so (some vehicle related) NewGRF cache 'desyncs' can be tested easier.
rubidium <rubidium@openttd.org>
parents:
11987
diff
changeset
|
56 uint32 cached_var40; ///< Cache for NewGRF var 40 |
935e4f91c83c
(svn r16394) -Codechange: move (NewGRF) cache variables into a separate struct so (some vehicle related) NewGRF cache 'desyncs' can be tested easier.
rubidium <rubidium@openttd.org>
parents:
11987
diff
changeset
|
57 uint32 cached_var41; ///< Cache for NewGRF var 41 |
935e4f91c83c
(svn r16394) -Codechange: move (NewGRF) cache variables into a separate struct so (some vehicle related) NewGRF cache 'desyncs' can be tested easier.
rubidium <rubidium@openttd.org>
parents:
11987
diff
changeset
|
58 uint32 cached_var42; ///< Cache for NewGRF var 42 |
935e4f91c83c
(svn r16394) -Codechange: move (NewGRF) cache variables into a separate struct so (some vehicle related) NewGRF cache 'desyncs' can be tested easier.
rubidium <rubidium@openttd.org>
parents:
11987
diff
changeset
|
59 uint32 cached_var43; ///< Cache for NewGRF var 43 |
935e4f91c83c
(svn r16394) -Codechange: move (NewGRF) cache variables into a separate struct so (some vehicle related) NewGRF cache 'desyncs' can be tested easier.
rubidium <rubidium@openttd.org>
parents:
11987
diff
changeset
|
60 }; |
935e4f91c83c
(svn r16394) -Codechange: move (NewGRF) cache variables into a separate struct so (some vehicle related) NewGRF cache 'desyncs' can be tested easier.
rubidium <rubidium@openttd.org>
parents:
11987
diff
changeset
|
61 |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11971
diff
changeset
|
62 typedef Pool<Vehicle, VehicleID, 512, 64000> VehiclePool; |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11971
diff
changeset
|
63 extern VehiclePool _vehicle_pool; |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
64 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
65 /* Some declarations of functions, so we can make them friendly */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
66 struct SaveLoad; |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
67 extern const SaveLoad *GetVehicleDescription(VehicleType vt); |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
68 struct LoadgameState; |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
69 extern bool LoadOldVehicle(LoadgameState *ls, int num); |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11971
diff
changeset
|
70 extern bool AfterLoadGame(); |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11971
diff
changeset
|
71 extern void FixOldVehicles(); |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
72 |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11971
diff
changeset
|
73 struct Vehicle : VehiclePool::PoolItem<&_vehicle_pool>, BaseVehicle { |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
74 private: |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
75 Vehicle *next; ///< pointer to the next vehicle in the chain |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
76 Vehicle *previous; ///< NOSAVE: pointer to the previous vehicle in the chain |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
77 Vehicle *first; ///< NOSAVE: pointer to the first vehicle in the chain |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
78 |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
79 Vehicle *next_shared; ///< pointer to the next vehicle that shares the order |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
80 Vehicle *previous_shared; ///< NOSAVE: pointer to the previous vehicle in the shared order chain |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
81 public: |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
82 friend const SaveLoad *GetVehicleDescription(VehicleType vt); ///< So we can use private/protected variables in the saveload code |
11972
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11971
diff
changeset
|
83 friend bool AfterLoadGame(); |
fd10870d74d4
(svn r16378) -Codechange: replace OldPool with simpler Pool. Compilation time, binary size and run time (with asserts disabled) should be improved
smatz <smatz@openttd.org>
parents:
11971
diff
changeset
|
84 friend void FixOldVehicles(); |
10881
8e9bff1a3e56
(svn r15216) -Feature: native support for Transport Tycoon (Original) savegames. Based on SVXConverter's source code and documentation by Roman Vetter
smatz <smatz@openttd.org>
parents:
10647
diff
changeset
|
85 friend void AfterLoadVehicles(bool part_of_load); ///< So we can set the previous and first pointers while loading |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
86 friend bool LoadOldVehicle(LoadgameState *ls, int num); ///< So we can set the proper next pointer while loading |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
87 |
8258
6017c5ebeb7e
(svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138 <peter1138@openttd.org>
parents:
8254
diff
changeset
|
88 char *name; ///< Name of vehicle |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
89 |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
90 TileIndex tile; ///< Current tile index |
10447
561a608ed4bc
(svn r14702) -Documentation: Add a note about the meaning and validity of Vehicle::dest_tile.
frosch <frosch@openttd.org>
parents:
10341
diff
changeset
|
91 |
561a608ed4bc
(svn r14702) -Documentation: Add a note about the meaning and validity of Vehicle::dest_tile.
frosch <frosch@openttd.org>
parents:
10341
diff
changeset
|
92 /** |
561a608ed4bc
(svn r14702) -Documentation: Add a note about the meaning and validity of Vehicle::dest_tile.
frosch <frosch@openttd.org>
parents:
10341
diff
changeset
|
93 * Heading for this tile. |
561a608ed4bc
(svn r14702) -Documentation: Add a note about the meaning and validity of Vehicle::dest_tile.
frosch <frosch@openttd.org>
parents:
10341
diff
changeset
|
94 * For airports and train stations this tile does not necessarily belong to the destination station, |
561a608ed4bc
(svn r14702) -Documentation: Add a note about the meaning and validity of Vehicle::dest_tile.
frosch <frosch@openttd.org>
parents:
10341
diff
changeset
|
95 * but it can be used for heuristical purposes to estimate the distance. |
561a608ed4bc
(svn r14702) -Documentation: Add a note about the meaning and validity of Vehicle::dest_tile.
frosch <frosch@openttd.org>
parents:
10341
diff
changeset
|
96 */ |
561a608ed4bc
(svn r14702) -Documentation: Add a note about the meaning and validity of Vehicle::dest_tile.
frosch <frosch@openttd.org>
parents:
10341
diff
changeset
|
97 TileIndex dest_tile; |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
98 |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
99 Money profit_this_year; ///< Profit this year << 8, low 8 bits are fract |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
100 Money profit_last_year; ///< Profit last year << 8, low 8 bits are fract |
12279
329b186db8cd
(svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents:
12128
diff
changeset
|
101 Money value; ///< Value of the vehicle |
329b186db8cd
(svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents:
12128
diff
changeset
|
102 |
329b186db8cd
(svn r16694) -Fix [FS#2995] (rgradual loading, rnewindustries): only pay for whatever has been actually unloaded and perform the payment when unloading has finished. This fixes, amongst others:
rubidium <rubidium@openttd.org>
parents:
12128
diff
changeset
|
103 CargoPayment *cargo_payment; ///< The cargo payment we're currently in |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
104 |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
105 /* Used for timetabling. */ |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
106 uint32 current_order_time; ///< How many ticks have passed since this order started. |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
107 int32 lateness_counter; ///< How many ticks late (or early if negative) this vehicle is. |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
108 |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
109 /* Boundaries for the current position in the world and a next hash link. |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
110 * NOSAVE: All of those can be updated with VehiclePositionChanged() */ |
11322
0a63eacd2be7
(svn r15672) -Codechange: (left,right,top,bottom)_coord -> coord.(left,right,top,bottom), i.e. use Rect.
rubidium <rubidium@openttd.org>
parents:
11268
diff
changeset
|
111 Rect coord; |
12128
6e43d1f1af83
(svn r16544) -Codechange: use double-linked list for vehicle position caches in order to improve performance (~5% with many vehicles)
smatz <smatz@openttd.org>
parents:
12114
diff
changeset
|
112 Vehicle *next_hash, **prev_hash; |
6e43d1f1af83
(svn r16544) -Codechange: use double-linked list for vehicle position caches in order to improve performance (~5% with many vehicles)
smatz <smatz@openttd.org>
parents:
12114
diff
changeset
|
113 Vehicle *next_new_hash, **prev_new_hash; |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
114 Vehicle **old_new_hash; |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
115 |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11014
diff
changeset
|
116 SpriteID colourmap; // NOSAVE: cached colour mapping |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
117 |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
118 /* Related to age and service time */ |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
119 Year build_year; |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
120 Date age; // Age in days |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
121 Date max_age; // Maximum age |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
122 Date date_of_last_service; |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
123 Date service_interval; |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
124 uint16 reliability; |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
125 uint16 reliability_spd_dec; |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
126 byte breakdown_ctr; |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
127 byte breakdown_delay; |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
128 byte breakdowns_since_last_service; |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
129 byte breakdown_chance; |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
130 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
131 int32 x_pos; // coordinates |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
132 int32 y_pos; |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
133 byte z_pos; |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
134 DirectionByte direction; // facing |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
135 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10187
diff
changeset
|
136 OwnerByte owner; // which company owns the vehicle? |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
137 byte spritenum; // currently displayed sprite index |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
138 // 0xfd == custom sprite, 0xfe == custom second head sprite |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
139 // 0xff == reserved for another custom sprite |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
140 uint16 cur_image; // sprite number for this vehicle |
8793
27556e5b9388
(svn r12531) -Codechange: Rename some variables for consistency.
frosch <frosch@openttd.org>
parents:
8784
diff
changeset
|
141 byte x_extent; // x-extent of vehicle bounding box |
27556e5b9388
(svn r12531) -Codechange: Rename some variables for consistency.
frosch <frosch@openttd.org>
parents:
8784
diff
changeset
|
142 byte y_extent; // y-extent of vehicle bounding box |
27556e5b9388
(svn r12531) -Codechange: Rename some variables for consistency.
frosch <frosch@openttd.org>
parents:
8784
diff
changeset
|
143 byte z_extent; // z-extent of vehicle bounding box |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
144 int8 x_offs; // x offset for vehicle sprite |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
145 int8 y_offs; // y offset for vehicle sprite |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
146 EngineID engine_type; |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
147 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
148 TextEffectID fill_percent_te_id; // a text-effect id to a loading indicator object |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
149 UnitID unitnumber; // unit number, for display purposes only |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
150 |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
151 uint16 max_speed; ///< maximum speed |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
152 uint16 cur_speed; ///< current speed |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
153 byte subspeed; ///< fractional speed |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
154 byte acceleration; ///< used by train & aircraft |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
155 uint32 motion_counter; |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
156 byte progress; |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
157 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
158 /* for randomized variational spritegroups |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
159 * bitmask used to resolve them; parts of it get reseeded when triggers |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
160 * of corresponding spritegroups get matched */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
161 byte random_bits; |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
162 byte waiting_triggers; ///< triggers to be yet matched |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
163 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
164 StationID last_station_visited; |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
165 |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
166 CargoID cargo_type; ///< type of cargo this vehicle is carrying |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
167 byte cargo_subtype; ///< Used for livery refits (NewGRF variations) |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
168 uint16 cargo_cap; ///< total capacity |
13286
58de76f90067
(svn r17795) -Codechange: split cargolist into one for vehicles and one for stations.
rubidium <rubidium@openttd.org>
parents:
13054
diff
changeset
|
169 VehicleCargoList cargo; ///< The cargo this vehicle is carrying |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
170 |
8556
8aae08d562cc
(svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents:
8469
diff
changeset
|
171 byte day_counter; ///< Increased by one for each day |
8aae08d562cc
(svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents:
8469
diff
changeset
|
172 byte tick_counter; ///< Increased by one for each tick |
8aae08d562cc
(svn r12134) -Change: count the number of ticks a vehicle was running this day to calculate running cost
smatz <smatz@openttd.org>
parents:
8469
diff
changeset
|
173 byte running_ticks; ///< Number of ticks this vehicle was not stopped this day |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
174 |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
175 byte vehstatus; ///< Status |
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
176 Order current_order; ///< The current order (+ status, like: loading) |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
177 VehicleOrderID cur_order_index; ///< The index to the current order |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
178 |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
179 union { |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
180 OrderList *list; ///< Pointer to the order list for this vehicle |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
181 Order *old; ///< Only used during conversion of old save games |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
182 } orders; |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
183 |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
184 byte vehicle_flags; ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum) |
13054
1fa162c4d082
(svn r17552) -Codechange: rename load_unload_time_rem to something more generic as it's used for more than just load/unload. Also add some documentation about where it is used.
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
185 |
1fa162c4d082
(svn r17552) -Codechange: rename load_unload_time_rem to something more generic as it's used for more than just load/unload. Also add some documentation about where it is used.
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
186 /** |
1fa162c4d082
(svn r17552) -Codechange: rename load_unload_time_rem to something more generic as it's used for more than just load/unload. Also add some documentation about where it is used.
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
187 * Multi purpose variable used as counter for: |
1fa162c4d082
(svn r17552) -Codechange: rename load_unload_time_rem to something more generic as it's used for more than just load/unload. Also add some documentation about where it is used.
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
188 * - loading/unloading: ticks to wait before starting next cycle. |
1fa162c4d082
(svn r17552) -Codechange: rename load_unload_time_rem to something more generic as it's used for more than just load/unload. Also add some documentation about where it is used.
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
189 * - aircraft: ticks between each turn to prevent > 45 degree turns. |
1fa162c4d082
(svn r17552) -Codechange: rename load_unload_time_rem to something more generic as it's used for more than just load/unload. Also add some documentation about where it is used.
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
190 * - trains: ticks waiting in front of a signal, ticks being stuck or a counter for forced proceeding through signals. |
1fa162c4d082
(svn r17552) -Codechange: rename load_unload_time_rem to something more generic as it's used for more than just load/unload. Also add some documentation about where it is used.
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
191 */ |
1fa162c4d082
(svn r17552) -Codechange: rename load_unload_time_rem to something more generic as it's used for more than just load/unload. Also add some documentation about where it is used.
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
192 uint16 time_counter; |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
193 |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
194 GroupID group_id; ///< Index of group Pool array |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
195 |
9015
6d3b0bed5229
(svn r12814) -Codechange: reshuffle some variables in the Vehicle struct saving 20 bytes with a 32 bit compiler and 32 bytes on 64 bit compiler per vehicle.
rubidium <rubidium@openttd.org>
parents:
9009
diff
changeset
|
196 byte subtype; ///< subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes) |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
197 |
11988
935e4f91c83c
(svn r16394) -Codechange: move (NewGRF) cache variables into a separate struct so (some vehicle related) NewGRF cache 'desyncs' can be tested easier.
rubidium <rubidium@openttd.org>
parents:
11987
diff
changeset
|
198 VehicleCache vcache; ///< Cache of often used calculated values |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
199 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
200 /** Create a new vehicle */ |
12065
6ac064c3a427
(svn r16472) -Codechange: set vehicle type in SpecializedVehicle constructor instead of constructor of each vehicle type
smatz <smatz@openttd.org>
parents:
12038
diff
changeset
|
201 Vehicle(VehicleType type = VEH_INVALID); |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
202 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
203 /** Destroy all stuff that (still) needs the virtual functions to work properly */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
204 void PreDestructor(); |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
205 /** We want to 'destruct' the right class. */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
206 virtual ~Vehicle(); |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
207 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
208 void BeginLoading(); |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
209 void LeaveStation(); |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
210 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
211 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
212 * Handle the loading of the vehicle; when not it skips through dummy |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
213 * orders and does nothing in all other cases. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
214 * @param mode is the non-first call for this vehicle in this tick? |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
215 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
216 void HandleLoading(bool mode = false); |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
217 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
218 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
219 * Get a string 'representation' of the vehicle type. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
220 * @return the string representation. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
221 */ |
10647
592ae9307430
(svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents:
10571
diff
changeset
|
222 virtual const char *GetTypeString() const { return "base vehicle"; } |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
223 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
224 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
225 * Marks the vehicles to be redrawn and updates cached variables |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
226 * |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
227 * This method marks the area of the vehicle on the screen as dirty. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
228 * It can be use to repaint the vehicle. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
229 * |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
230 * @ingroup dirty |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
231 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
232 virtual void MarkDirty() {} |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
233 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
234 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
235 * Updates the x and y offsets and the size of the sprite used |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
236 * for this vehicle. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
237 * @param direction the direction the vehicle is facing |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
238 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
239 virtual void UpdateDeltaXY(Direction direction) {} |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
240 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
241 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
242 * Sets the expense type associated to this vehicle type |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
243 * @param income whether this is income or (running) expenses of the vehicle |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
244 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
245 virtual ExpensesType GetExpenseType(bool income) const { return EXPENSES_OTHER; } |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
246 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
247 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
248 * Play the sound associated with leaving the station |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
249 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
250 virtual void PlayLeaveStationSound() const {} |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
251 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
252 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
253 * Whether this is the primary vehicle in the chain. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
254 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
255 virtual bool IsPrimaryVehicle() const { return false; } |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
256 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
257 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
258 * Gets the sprite to show for the given direction |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
259 * @param direction the direction the vehicle is facing |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
260 * @return the sprite for the given vehicle in the given direction |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
261 */ |
9022
db43607c4798
(svn r12824) -Codechange: Standardise routines for drawing vehicle images, using correct types and less duplication.
peter1138 <peter1138@openttd.org>
parents:
9015
diff
changeset
|
262 virtual SpriteID GetImage(Direction direction) const { return 0; } |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
263 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
264 /** |
12073
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
265 * Invalidates cached NewGRF variables |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
266 * @see InvalidateNewGRFCacheOfChain |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
267 */ |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
268 FORCEINLINE void InvalidateNewGRFCache() |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
269 { |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
270 this->vcache.cache_valid = 0; |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
271 } |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
272 |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
273 /** |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
274 * Invalidates cached NewGRF variables of all vehicles in the chain (after the current vehicle) |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
275 * @see InvalidateNewGRFCache |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
276 */ |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
277 FORCEINLINE void InvalidateNewGRFCacheOfChain() |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
278 { |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
279 for (Vehicle *u = this; u != NULL; u = u->Next()) { |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
280 u->InvalidateNewGRFCache(); |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
281 } |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
282 } |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
283 |
02d3a628e6db
(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.
frosch <frosch@openttd.org>
parents:
12065
diff
changeset
|
284 /** |
10969
208ba3fba382
(svn r15308) -Codechange: Deduplicate km-ish/h -> mph conversions.
frosch <frosch@openttd.org>
parents:
10881
diff
changeset
|
285 * Gets the speed in km-ish/h that can be sent into SetDParam for string processing. |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
286 * @return the vehicle's speed |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
287 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
288 virtual int GetDisplaySpeed() const { return 0; } |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
289 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
290 /** |
10969
208ba3fba382
(svn r15308) -Codechange: Deduplicate km-ish/h -> mph conversions.
frosch <frosch@openttd.org>
parents:
10881
diff
changeset
|
291 * Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing. |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
292 * @return the vehicle's maximum speed |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
293 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
294 virtual int GetDisplayMaxSpeed() const { return 0; } |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
295 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
296 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
297 * Gets the running cost of a vehicle |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
298 * @return the vehicle's running cost |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
299 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
300 virtual Money GetRunningCost() const { return 0; } |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
301 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
302 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
303 * Check whether the vehicle is in the depot. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
304 * @return true if and only if the vehicle is in the depot. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
305 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
306 virtual bool IsInDepot() const { return false; } |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
307 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
308 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
309 * Check whether the vehicle is in the depot *and* stopped. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
310 * @return true if and only if the vehicle is in the depot and stopped. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
311 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
312 virtual bool IsStoppedInDepot() const { return this->IsInDepot() && (this->vehstatus & VS_STOPPED) != 0; } |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
313 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
314 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
315 * Calls the tick handler of the vehicle |
11970
2286db6ac0bb
(svn r16376) -Codechange: Vehicle::Tick() now returns false if the vehicle was deleted
smatz <smatz@openttd.org>
parents:
11930
diff
changeset
|
316 * @return is this vehicle still valid? |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
317 */ |
11970
2286db6ac0bb
(svn r16376) -Codechange: Vehicle::Tick() now returns false if the vehicle was deleted
smatz <smatz@openttd.org>
parents:
11930
diff
changeset
|
318 virtual bool Tick() { return true; }; |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
319 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
320 /** |
8467
284a76aa2868
(svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx <glx@openttd.org>
parents:
8258
diff
changeset
|
321 * Calls the new day handler of the vehicle |
284a76aa2868
(svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx <glx@openttd.org>
parents:
8258
diff
changeset
|
322 */ |
284a76aa2868
(svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx <glx@openttd.org>
parents:
8258
diff
changeset
|
323 virtual void OnNewDay() {}; |
284a76aa2868
(svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx <glx@openttd.org>
parents:
8258
diff
changeset
|
324 |
284a76aa2868
(svn r12037) -Codechange: replace OnNewDay_(Aircraft|RoadVeh|Ship|Train) with an OnNewDay method in the Vehicle class
glx <glx@openttd.org>
parents:
8258
diff
changeset
|
325 /** |
12666
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
326 * Update vehicle sprite- and position caches |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
327 * @param moved Was the vehicle moved? |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
328 * @param turned Did the vehicle direction change? |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
329 */ |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
330 inline void UpdateViewport(bool moved, bool turned) |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
331 { |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
332 extern void VehicleMove(Vehicle *v, bool update_viewport); |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
333 |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
334 if (turned) this->UpdateDeltaXY(this->direction); |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
335 SpriteID old_image = this->cur_image; |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
336 this->cur_image = this->GetImage(this->direction); |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
337 if (moved || this->cur_image != old_image) VehicleMove(this, true); |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
338 } |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
339 |
0275245c6c62
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
frosch <frosch@openttd.org>
parents:
12638
diff
changeset
|
340 /** |
11976
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
341 * Returns the Trackdir on which the vehicle is currently located. |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
342 * Works for trains and ships. |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
343 * Currently works only sortof for road vehicles, since they have a fuzzy |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
344 * concept of being "on" a trackdir. Dunno really what it returns for a road |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
345 * vehicle that is halfway a tile, never really understood that part. For road |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
346 * vehicles that are at the beginning or end of the tile, should just return |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
347 * the diagonal trackdir on which they are driving. I _think_. |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
348 * For other vehicles types, or vehicles with no clear trackdir (such as those |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
349 * in depots), returns 0xFF. |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
350 * @return the trackdir of the vehicle |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
351 */ |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
352 virtual Trackdir GetVehicleTrackdir() const { return INVALID_TRACKDIR; } |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
353 |
7f11f2a71193
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
rubidium <rubidium@openttd.org>
parents:
11974
diff
changeset
|
354 /** |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
355 * Gets the running cost of a vehicle that can be sent into SetDParam for string processing. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
356 * @return the vehicle's running cost |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
357 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
358 Money GetDisplayRunningCost() const { return (this->GetRunningCost() >> 8); } |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
359 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
360 /** |
8614
36bb76188638
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz <smatz@openttd.org>
parents:
8556
diff
changeset
|
361 * Gets the profit vehicle had this year. It can be sent into SetDParam for string processing. |
36bb76188638
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz <smatz@openttd.org>
parents:
8556
diff
changeset
|
362 * @return the vehicle's profit this year |
36bb76188638
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz <smatz@openttd.org>
parents:
8556
diff
changeset
|
363 */ |
36bb76188638
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz <smatz@openttd.org>
parents:
8556
diff
changeset
|
364 Money GetDisplayProfitThisYear() const { return (this->profit_this_year >> 8); } |
36bb76188638
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz <smatz@openttd.org>
parents:
8556
diff
changeset
|
365 |
36bb76188638
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz <smatz@openttd.org>
parents:
8556
diff
changeset
|
366 /** |
36bb76188638
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz <smatz@openttd.org>
parents:
8556
diff
changeset
|
367 * Gets the profit vehicle had last year. It can be sent into SetDParam for string processing. |
36bb76188638
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz <smatz@openttd.org>
parents:
8556
diff
changeset
|
368 * @return the vehicle's profit last year |
36bb76188638
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz <smatz@openttd.org>
parents:
8556
diff
changeset
|
369 */ |
36bb76188638
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz <smatz@openttd.org>
parents:
8556
diff
changeset
|
370 Money GetDisplayProfitLastYear() const { return (this->profit_last_year >> 8); } |
36bb76188638
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz <smatz@openttd.org>
parents:
8556
diff
changeset
|
371 |
36bb76188638
(svn r12197) -Fix [FS#1788](r12134): show correct last year profit when the train had negative income
smatz <smatz@openttd.org>
parents:
8556
diff
changeset
|
372 /** |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
373 * Set the next vehicle of this vehicle. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
374 * @param next the next vehicle. NULL removes the next vehicle. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
375 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
376 void SetNext(Vehicle *next); |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
377 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
378 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
379 * Get the next vehicle of this vehicle. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
380 * @note articulated parts are also counted as vehicles. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
381 * @return the next vehicle or NULL when there isn't a next vehicle. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
382 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
383 inline Vehicle *Next() const { return this->next; } |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
384 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
385 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
386 * Get the previous vehicle of this vehicle. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
387 * @note articulated parts are also counted as vehicles. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
388 * @return the previous vehicle or NULL when there isn't a previous vehicle. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
389 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
390 inline Vehicle *Previous() const { return this->previous; } |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
391 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
392 /** |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
393 * Get the first vehicle of this vehicle chain. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
394 * @return the first vehicle of the chain. |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
395 */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
396 inline Vehicle *First() const { return this->first; } |
8469
066d7c3ca93d
(svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas <belugas@openttd.org>
parents:
8467
diff
changeset
|
397 |
12460
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
398 /** |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
399 * Get the last vehicle of this vehicle chain. |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
400 * @return the last vehicle of the chain. |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
401 */ |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
402 inline Vehicle *Last() |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
403 { |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
404 Vehicle *v = this; |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
405 while (v->Next() != NULL) v = v->Next(); |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
406 return v; |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
407 } |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
408 |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
409 /** |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
410 * Get the last vehicle of this vehicle chain. |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
411 * @return the last vehicle of the chain. |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
412 */ |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
413 inline const Vehicle *Last() const |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
414 { |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
415 const Vehicle *v = this; |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
416 while (v->Next() != NULL) v = v->Next(); |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
417 return v; |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
418 } |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
419 |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
420 /** |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
421 * Get the first order of the vehicles order list. |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
422 * @return first order of order list. |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
423 */ |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
424 inline Order *GetFirstOrder() const { return (this->orders.list == NULL) ? NULL : this->orders.list->GetFirstOrder(); } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
425 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
426 /** |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
427 * Adds this vehicle to a shared vehicle chain. |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
428 * @param shared_chain a vehicle of the chain with shared vehicles. |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
429 * @pre !this->IsOrderListShared() |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
430 */ |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
431 void AddToShared(Vehicle *shared_chain); |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
432 |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
433 /** |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
434 * Removes the vehicle from the shared order list. |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
435 */ |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
436 void RemoveFromShared(); |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
437 |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
438 /** |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
439 * Get the next vehicle of the shared vehicle chain. |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
440 * @return the next shared vehicle or NULL when there isn't a next vehicle. |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
441 */ |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
442 inline Vehicle *NextShared() const { return this->next_shared; } |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
443 |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
444 /** |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
445 * Get the previous vehicle of the shared vehicle chain |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
446 * @return the previous shared vehicle or NULL when there isn't a previous vehicle. |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
447 */ |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
448 inline Vehicle *PreviousShared() const { return this->previous_shared; } |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
449 |
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
450 /** |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
451 * Get the first vehicle of this vehicle chain. |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
452 * @return the first vehicle of the chain. |
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
453 */ |
11014
1a4a901b1a95
(svn r15354) -Fix (r14803): first shared of a vehicle could be NULL making it impossible to (share-)clone the vehicle.
rubidium <rubidium@openttd.org>
parents:
10969
diff
changeset
|
454 inline Vehicle *FirstShared() const { return (this->orders.list == NULL) ? this->First() : this->orders.list->GetFirstSharedVehicle(); } |
9941
53ba5561b1c2
(svn r14096) -Codechange: merge the shared order's vehicle list management to a single location.
rubidium <rubidium@openttd.org>
parents:
9930
diff
changeset
|
455 |
8469
066d7c3ca93d
(svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas <belugas@openttd.org>
parents:
8467
diff
changeset
|
456 /** |
066d7c3ca93d
(svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas <belugas@openttd.org>
parents:
8467
diff
changeset
|
457 * Check if we share our orders with another vehicle. |
066d7c3ca93d
(svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas <belugas@openttd.org>
parents:
8467
diff
changeset
|
458 * @return true if there are other vehicles sharing the same order |
066d7c3ca93d
(svn r12040) -Codechange: Change IsOrderListShared from a simple function to a class member(MagicBuzz).
belugas <belugas@openttd.org>
parents:
8467
diff
changeset
|
459 */ |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
460 inline bool IsOrderListShared() const { return this->orders.list != NULL && this->orders.list->IsShared(); } |
8628
97445f45ba39
(svn r12230) -Codechange: [autoreplace] made a function to detect if a vehicle needs autorenewing
bjarni <bjarni@openttd.org>
parents:
8614
diff
changeset
|
461 |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
462 /** |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10498
diff
changeset
|
463 * Get the number of orders this vehicle has. |
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10498
diff
changeset
|
464 * @return the number of orders this vehicle has. |
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10498
diff
changeset
|
465 */ |
10546
9ceef3c92be2
(svn r14803) -Codechange: move order list management into it's own class and remove the order count from the savegame as we can easily count that (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10544
diff
changeset
|
466 inline VehicleOrderID GetNumOrders() const { return (this->orders.list == NULL) ? 0 : this->orders.list->GetNumOrders(); } |
10544
836dfaca2a32
(svn r14801) -Codechange: don't reference Vehicle::num_orders directly but through a method GetNumOrders() (PhilSophus)
rubidium <rubidium@openttd.org>
parents:
10498
diff
changeset
|
467 |
9928
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
468 /** |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
469 * Copy certain configurations and statistics of a vehicle after successful autoreplace/renew |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
470 * The function shall copy everything that cannot be copied by a command (like orders / group etc), |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
471 * and that shall not be resetted for the new vehicle. |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
472 * @param src The old vehicle |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
473 */ |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
474 inline void CopyVehicleConfigAndStatistics(const Vehicle *src) |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
475 { |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
476 this->unitnumber = src->unitnumber; |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
477 |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
478 this->cur_order_index = src->cur_order_index; |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
479 this->current_order = src->current_order; |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
480 this->dest_tile = src->dest_tile; |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
481 |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
482 this->profit_this_year = src->profit_this_year; |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
483 this->profit_last_year = src->profit_last_year; |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
484 |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
485 this->current_order_time = src->current_order_time; |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
486 this->lateness_counter = src->lateness_counter; |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
487 |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
488 this->service_interval = src->service_interval; |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
489 } |
0cc9c6c36c43
(svn r14083) -Fix [FS#1264, FS#2037, FS#2038, FS#2110]: Rewrite the autoreplace kernel.
frosch <frosch@openttd.org>
parents:
9808
diff
changeset
|
490 |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
10187
diff
changeset
|
491 bool NeedsAutorenewing(const Company *c) const; |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8793
diff
changeset
|
492 |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8793
diff
changeset
|
493 /** |
8862
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
494 * Check if the vehicle needs to go to a depot in near future (if a opportunity presents itself) for service or replacement. |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
495 * |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
496 * @see NeedsAutomaticServicing() |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
497 * @return true if the vehicle should go to a depot if a opportunity presents itself. |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
498 */ |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
499 bool NeedsServicing() const; |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
500 |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
501 /** |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
502 * Checks if the current order should be interupted for a service-in-depot-order. |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
503 * @see NeedsServicing() |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
504 * @return true if the current order should be interupted. |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
505 */ |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
506 bool NeedsAutomaticServicing() const; |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
507 |
1300bc87c872
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
frosch <frosch@openttd.org>
parents:
8827
diff
changeset
|
508 /** |
8827
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8793
diff
changeset
|
509 * Determine the location for the station where the vehicle goes to next. |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8793
diff
changeset
|
510 * Things done for example are allocating slots in a road stop or exact |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8793
diff
changeset
|
511 * location of the platform is determined for ships. |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8793
diff
changeset
|
512 * @param station the station to make the next location of the vehicle. |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8793
diff
changeset
|
513 * @return the location (tile) to aim for. |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8793
diff
changeset
|
514 */ |
095c429c5fa7
(svn r12575) -Codechange: unduplicate Process*Orders for trains, ships and road vehicles.
rubidium <rubidium@openttd.org>
parents:
8793
diff
changeset
|
515 virtual TileIndex GetOrderStationLocation(StationID station) { return INVALID_TILE; } |
8890
b1d45af72e04
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium <rubidium@openttd.org>
parents:
8862
diff
changeset
|
516 |
b1d45af72e04
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium <rubidium@openttd.org>
parents:
8862
diff
changeset
|
517 /** |
b1d45af72e04
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium <rubidium@openttd.org>
parents:
8862
diff
changeset
|
518 * Find the closest depot for this vehicle and tell us the location, |
b1d45af72e04
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium <rubidium@openttd.org>
parents:
8862
diff
changeset
|
519 * DestinationID and whether we should reverse. |
b1d45af72e04
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium <rubidium@openttd.org>
parents:
8862
diff
changeset
|
520 * @param location where do we go to? |
b1d45af72e04
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium <rubidium@openttd.org>
parents:
8862
diff
changeset
|
521 * @param destination what hangar do we go to? |
b1d45af72e04
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium <rubidium@openttd.org>
parents:
8862
diff
changeset
|
522 * @param reverse should the vehicle be reversed? |
b1d45af72e04
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium <rubidium@openttd.org>
parents:
8862
diff
changeset
|
523 * @return true if a depot could be found. |
b1d45af72e04
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium <rubidium@openttd.org>
parents:
8862
diff
changeset
|
524 */ |
b1d45af72e04
(svn r12657) -Codechange: add 'FindClosestDepot' to the vehicle class.
rubidium <rubidium@openttd.org>
parents:
8862
diff
changeset
|
525 virtual bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse) { return false; } |
8891
384f81a7ba31
(svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium <rubidium@openttd.org>
parents:
8890
diff
changeset
|
526 |
384f81a7ba31
(svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium <rubidium@openttd.org>
parents:
8890
diff
changeset
|
527 /** |
384f81a7ba31
(svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium <rubidium@openttd.org>
parents:
8890
diff
changeset
|
528 * Send this vehicle to the depot using the given command(s). |
384f81a7ba31
(svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium <rubidium@openttd.org>
parents:
8890
diff
changeset
|
529 * @param flags the command flags (like execute and such). |
384f81a7ba31
(svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium <rubidium@openttd.org>
parents:
8890
diff
changeset
|
530 * @param command the command to execute. |
384f81a7ba31
(svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium <rubidium@openttd.org>
parents:
8890
diff
changeset
|
531 * @return the cost of the depot action. |
384f81a7ba31
(svn r12658) -Codechange: unify a vast portion of the CmdSend<VehicleType>ToDepot commands.
rubidium <rubidium@openttd.org>
parents:
8890
diff
changeset
|
532 */ |
11090
df23c4e04638
(svn r15434) -Codechange: bit of type safety for the DC_xxx flags.
rubidium <rubidium@openttd.org>
parents:
11085
diff
changeset
|
533 CommandCost SendToDepot(DoCommandFlag flags, DepotCommand command); |
11866
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11322
diff
changeset
|
534 |
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11322
diff
changeset
|
535 /** |
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11322
diff
changeset
|
536 * Increments cur_order_index, keeps care of the wrap-around and invalidates the GUI. |
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11322
diff
changeset
|
537 * Note: current_order is not invalidated. |
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11322
diff
changeset
|
538 */ |
11867
8bf4312f1a12
(svn r16261) -Fix (r16260): Replace a space with a newline and a tab. (thanks smatz)
frosch <frosch@openttd.org>
parents:
11866
diff
changeset
|
539 void IncrementOrderIndex() |
8bf4312f1a12
(svn r16261) -Fix (r16260): Replace a space with a newline and a tab. (thanks smatz)
frosch <frosch@openttd.org>
parents:
11866
diff
changeset
|
540 { |
11866
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11322
diff
changeset
|
541 this->cur_order_index++; |
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11322
diff
changeset
|
542 if (this->cur_order_index >= this->GetNumOrders()) this->cur_order_index = 0; |
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11322
diff
changeset
|
543 InvalidateVehicleOrder(this, 0); |
1e159ef634d5
(svn r16260) -Codechange: Add Vehicle::IncrementOrderIndex() to deduplicate some code.
frosch <frosch@openttd.org>
parents:
11322
diff
changeset
|
544 } |
11991
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
545 |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
546 /** |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
547 * Returns order 'index' of a vehicle or NULL when it doesn't exists |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
548 * @param index the order to fetch |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
549 * @return the found (or not) order |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
550 */ |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
551 inline Order *GetOrder(int index) const |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
552 { |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
553 return (this->orders.list == NULL) ? NULL : this->orders.list->GetOrderAt(index); |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
554 } |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
555 |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
556 /** |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
557 * Returns the last order of a vehicle, or NULL if it doesn't exists |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
558 * @return last order of a vehicle, if available |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
559 */ |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
560 inline Order *GetLastOrder() const |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
561 { |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
562 return (this->orders.list == NULL) ? NULL : this->orders.list->GetLastOrder(); |
a4d3838349e6
(svn r16397) -Codechange: move GetVehicleOrder/GetLastVehicleOrder into Vehicle
rubidium <rubidium@openttd.org>
parents:
11988
diff
changeset
|
563 } |
12383
3c7e93b91c73
(svn r16813) -Codechange: make IsEngineCountable() member of Vehicle
smatz <smatz@openttd.org>
parents:
12279
diff
changeset
|
564 |
3c7e93b91c73
(svn r16813) -Codechange: make IsEngineCountable() member of Vehicle
smatz <smatz@openttd.org>
parents:
12279
diff
changeset
|
565 bool IsEngineCountable() const; |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
566 }; |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
567 |
12035
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
568 #define FOR_ALL_VEHICLES_FROM(var, start) FOR_ALL_ITEMS_FROM(Vehicle, vehicle_index, var, start) |
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
569 #define FOR_ALL_VEHICLES(var) FOR_ALL_VEHICLES_FROM(var, 0) |
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
570 |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
571 /** |
12034
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
572 * Class defining several overloaded accessors so we don't |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
573 * have to cast vehicle types that often |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
574 */ |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
575 template <class T, VehicleType Type> |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
576 struct SpecializedVehicle : public Vehicle { |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
577 static const VehicleType EXPECTED_TYPE = Type; ///< Specialized type |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
578 |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
579 /** |
12065
6ac064c3a427
(svn r16472) -Codechange: set vehicle type in SpecializedVehicle constructor instead of constructor of each vehicle type
smatz <smatz@openttd.org>
parents:
12038
diff
changeset
|
580 * Set vehicle type correctly |
6ac064c3a427
(svn r16472) -Codechange: set vehicle type in SpecializedVehicle constructor instead of constructor of each vehicle type
smatz <smatz@openttd.org>
parents:
12038
diff
changeset
|
581 */ |
6ac064c3a427
(svn r16472) -Codechange: set vehicle type in SpecializedVehicle constructor instead of constructor of each vehicle type
smatz <smatz@openttd.org>
parents:
12038
diff
changeset
|
582 FORCEINLINE SpecializedVehicle<T, Type>() : Vehicle(Type) { } |
6ac064c3a427
(svn r16472) -Codechange: set vehicle type in SpecializedVehicle constructor instead of constructor of each vehicle type
smatz <smatz@openttd.org>
parents:
12038
diff
changeset
|
583 |
6ac064c3a427
(svn r16472) -Codechange: set vehicle type in SpecializedVehicle constructor instead of constructor of each vehicle type
smatz <smatz@openttd.org>
parents:
12038
diff
changeset
|
584 /** |
12034
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
585 * Get the first vehicle in the chain |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
586 * @return first vehicle in the chain |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
587 */ |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
588 FORCEINLINE T *First() const { return (T *)this->Vehicle::First(); } |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
589 |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
590 /** |
12460
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
591 * Get the last vehicle in the chain |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
592 * @return last vehicle in the chain |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
593 */ |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
594 FORCEINLINE T *Last() { return (T *)this->Vehicle::Last(); } |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
595 |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
596 /** |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
597 * Get the last vehicle in the chain |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
598 * @return last vehicle in the chain |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
599 */ |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
600 FORCEINLINE const T *Last() const { return (const T *)this->Vehicle::Last(); } |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
601 |
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12383
diff
changeset
|
602 /** |
12034
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
603 * Get next vehicle in the chain |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
604 * @return next vehicle in the chain |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
605 */ |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
606 FORCEINLINE T *Next() const { return (T *)this->Vehicle::Next(); } |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
607 |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
608 /** |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
609 * Get previous vehicle in the chain |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
610 * @return previous vehicle in the chain |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
611 */ |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
612 FORCEINLINE T *Previous() const { return (T *)this->Vehicle::Previous(); } |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
613 |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
614 |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
615 /** |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
616 * Tests whether given index is a valid index for vehicle of this type |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
617 * @param index tested index |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
618 * @return is this index valid index of T? |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
619 */ |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
620 static FORCEINLINE bool IsValidID(size_t index) |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
621 { |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
622 return Vehicle::IsValidID(index) && Vehicle::Get(index)->type == Type; |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
623 } |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
624 |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
625 /** |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
626 * Gets vehicle with given index |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
627 * @return pointer to vehicle with given index casted to T * |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
628 */ |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
629 static FORCEINLINE T *Get(size_t index) |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
630 { |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
631 return (T *)Vehicle::Get(index); |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
632 } |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
633 |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
634 /** |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
635 * Returns vehicle if the index is a valid index for this vehicle type |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
636 * @return pointer to vehicle with given index if it's a vehicle of this type |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
637 */ |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
638 static FORCEINLINE T *GetIfValid(size_t index) |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
639 { |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
640 return IsValidID(index) ? Get(index) : NULL ; |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
641 } |
12114
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
642 |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
643 /** |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
644 * Converts a Vehicle to SpecializedVehicle with type checking. |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
645 * @param v Vehicle pointer |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
646 * @return pointer to SpecializedVehicle |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
647 */ |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
648 static FORCEINLINE T *From(Vehicle *v) |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
649 { |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
650 assert(v->type == Type); |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
651 return (T *)v; |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
652 } |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
653 |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
654 /** |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
655 * Converts a const Vehicle to const SpecializedVehicle with type checking. |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
656 * @param v Vehicle pointer |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
657 * @return pointer to SpecializedVehicle |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
658 */ |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
659 static FORCEINLINE const T *From(const Vehicle *v) |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
660 { |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
661 assert(v->type == Type); |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
662 return (const T *)v; |
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12095
diff
changeset
|
663 } |
12034
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
664 }; |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
665 |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
666 #define FOR_ALL_VEHICLES_OF_TYPE(name, var) FOR_ALL_ITEMS_FROM(name, vehicle_index, var, 0) if (var->type == name::EXPECTED_TYPE) |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
667 |
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
668 /** |
12038
35f1fb58cb5a
(svn r16445) -Codechange: update old comments (Yexo)
smatz <smatz@openttd.org>
parents:
12035
diff
changeset
|
669 * Disasters, like submarines, skyrangers and their shadows, belong to this class. |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
670 */ |
12034
aa140a9c419c
(svn r16441) -Codechange: new class SpecializedVehicle used as superclass for all vehicle types
smatz <smatz@openttd.org>
parents:
11991
diff
changeset
|
671 struct DisasterVehicle : public SpecializedVehicle<DisasterVehicle, VEH_DISASTER> { |
11979
6c50c7cd27fb
(svn r16385) -Codechange: move u.disaster to DisasterVehicle.
rubidium <rubidium@openttd.org>
parents:
11978
diff
changeset
|
672 uint16 image_override; |
6c50c7cd27fb
(svn r16385) -Codechange: move u.disaster to DisasterVehicle.
rubidium <rubidium@openttd.org>
parents:
11978
diff
changeset
|
673 VehicleID big_ufo_destroyer_target; |
6c50c7cd27fb
(svn r16385) -Codechange: move u.disaster to DisasterVehicle.
rubidium <rubidium@openttd.org>
parents:
11978
diff
changeset
|
674 |
12095
330c67eebb69
(svn r16505) -Fix [FS#2951] (r16472): since g++ 4.4 the implicit (default) constructor will zero the whole class. This caused all vehicle indices to be 0, which causes all kinds of trouble.
rubidium <rubidium@openttd.org>
parents:
12073
diff
changeset
|
675 /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ |
330c67eebb69
(svn r16505) -Fix [FS#2951] (r16472): since g++ 4.4 the implicit (default) constructor will zero the whole class. This caused all vehicle indices to be 0, which causes all kinds of trouble.
rubidium <rubidium@openttd.org>
parents:
12073
diff
changeset
|
676 DisasterVehicle() : SpecializedVehicle<DisasterVehicle, VEH_DISASTER>() {} |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
677 /** We want to 'destruct' the right class. */ |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
678 virtual ~DisasterVehicle() {} |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
679 |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
680 const char *GetTypeString() const { return "disaster vehicle"; } |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
681 void UpdateDeltaXY(Direction direction); |
11970
2286db6ac0bb
(svn r16376) -Codechange: Vehicle::Tick() now returns false if the vehicle was deleted
smatz <smatz@openttd.org>
parents:
11930
diff
changeset
|
682 bool Tick(); |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
683 }; |
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
684 |
12035
dcc31c1d758a
(svn r16442) -Codechange: use new Vehicle accessors at more places
smatz <smatz@openttd.org>
parents:
12034
diff
changeset
|
685 #define FOR_ALL_DISASTERVEHICLES(var) FOR_ALL_VEHICLES_OF_TYPE(DisasterVehicle, var) |
10498
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
686 |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
687 /** Generates sequence of free UnitID numbers */ |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
688 struct FreeUnitIDGenerator { |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
689 bool *cache; ///< array of occupied unit id numbers |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
690 UnitID maxid; ///< maximum ID at the moment of constructor call |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
691 UnitID curid; ///< last ID returned ; 0 if none |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
692 |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
693 /** Initializes the structure. Vehicle unit numbers are supposed not to change after |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
694 * struct initialization, except after each call to this->NextID() the returned value |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
695 * is assigned to a vehicle. |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
696 * @param type type of vehicle |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
697 * @param owner owner of vehicles |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
698 */ |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
699 FreeUnitIDGenerator(VehicleType type, CompanyID owner); |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
700 |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
701 /** Returns next free UnitID. Supposes the last returned value was assigned to a vehicle. */ |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
702 UnitID NextID(); |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
703 |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
704 /** Releases allocated memory */ |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
705 ~FreeUnitIDGenerator() { free(this->cache); } |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
706 }; |
730117b172e1
(svn r14753) -Fix (r1): after buying a company, one could have more vehicles with the same UnitID
smatz <smatz@openttd.org>
parents:
10490
diff
changeset
|
707 |
10571
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
10546
diff
changeset
|
708 static const int32 INVALID_COORD = 0x7fffffff; |
b6779abf2e96
(svn r14828) -Codechange: move most of save/load-specific code to separate files
smatz <smatz@openttd.org>
parents:
10546
diff
changeset
|
709 |
8144
d18c8a0bb638
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
710 #endif /* VEHICLE_BASE_H */ |