author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 1477 | 9389baf2bf3c |
child 1786 | 7cfd46c3fcc4 |
permissions | -rw-r--r-- |
0 | 1 |
#ifndef ENGINE_H |
2 |
#define ENGINE_H |
|
3 |
||
405
415546028e8d
(svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents:
389
diff
changeset
|
4 |
#include "sprite.h" |
415546028e8d
(svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents:
389
diff
changeset
|
5 |
|
0 | 6 |
typedef struct RailVehicleInfo { |
7 |
byte image_index; |
|
8 |
byte flags; /* 1=multihead engine, 2=wagon */ |
|
9 |
byte base_cost; |
|
10 |
uint16 max_speed; |
|
11 |
uint16 power; |
|
12 |
byte weight; |
|
13 |
byte running_cost_base; |
|
14 |
byte engclass; // 0: steam, 1: diesel, 2: electric |
|
15 |
byte capacity; |
|
16 |
byte cargo_type; |
|
17 |
} RailVehicleInfo; |
|
18 |
||
19 |
typedef struct ShipVehicleInfo { |
|
20 |
byte image_index; |
|
21 |
byte base_cost; |
|
22 |
uint16 max_speed; |
|
23 |
byte cargo_type; |
|
24 |
uint16 capacity; |
|
25 |
byte running_cost; |
|
26 |
byte sfx; |
|
27 |
byte refittable; |
|
28 |
} ShipVehicleInfo; |
|
29 |
||
376
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
30 |
typedef struct AircraftVehicleInfo { |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
31 |
byte image_index; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
32 |
byte base_cost; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
33 |
byte running_cost; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
34 |
byte subtype; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
35 |
byte sfx; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
36 |
byte acceleration; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
37 |
byte max_speed; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
38 |
byte mail_capacity; |
922
10035216cbaf
(svn r1410) Replaced all occurences of 'passanger' by 'passenger' in the code
celestar
parents:
842
diff
changeset
|
39 |
uint16 passenger_capacity; |
376
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
40 |
} AircraftVehicleInfo; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
41 |
|
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
42 |
typedef struct RoadVehicleInfo { |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
43 |
byte image_index; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
44 |
byte base_cost; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
45 |
byte running_cost; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
46 |
byte sfx; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
47 |
byte max_speed; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
48 |
byte capacity; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
49 |
byte cargo_type; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
50 |
} RoadVehicleInfo; |
0 | 51 |
|
52 |
typedef struct EngineInfo { |
|
53 |
uint16 base_intro; |
|
54 |
byte unk2; |
|
55 |
byte lifelength; |
|
56 |
byte base_life; |
|
57 |
byte railtype_climates; |
|
58 |
} EngineInfo; |
|
59 |
||
60 |
typedef struct Engine { |
|
61 |
uint16 intro_date; |
|
62 |
uint16 age; |
|
63 |
uint16 reliability; |
|
64 |
uint16 reliability_spd_dec; |
|
65 |
uint16 reliability_start, reliability_max, reliability_final; |
|
66 |
uint16 duration_phase_1, duration_phase_2, duration_phase_3; |
|
67 |
byte lifelength; |
|
68 |
byte flags; |
|
69 |
byte preview_player; |
|
70 |
byte preview_wait; |
|
71 |
byte railtype; |
|
72 |
byte player_avail; |
|
819
c425b7e22f6a
(svn r1290) Added type to typedef struct Engine and filled in the same data as in type in vehicle
bjarni
parents:
539
diff
changeset
|
73 |
byte type; // type, ie VEH_Road, VEH_Train, etc. Same as in vehicle.h |
0 | 74 |
} Engine; |
75 |
||
76 |
||
77 |
enum { |
|
78 |
RVI_MULTIHEAD = 1, |
|
79 |
RVI_WAGON = 2, |
|
80 |
}; |
|
81 |
||
82 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
922
diff
changeset
|
83 |
void AddTypeToEngines(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
922
diff
changeset
|
84 |
void StartupEngines(void); |
0 | 85 |
|
86 |
||
87 |
extern byte _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO]; |
|
88 |
enum { |
|
89 |
CID_DEFAULT = 29, |
|
90 |
CID_PURCHASE = 30, |
|
91 |
NUM_CID = 31, |
|
92 |
}; |
|
93 |
extern byte _local_cargo_id_ctype[NUM_CID]; |
|
94 |
extern byte _local_cargo_id_landscape[NUM_CID]; |
|
95 |
||
96 |
extern uint32 _engine_refit_masks[256]; |
|
97 |
||
98 |
extern byte _engine_original_sprites[256]; |
|
369
3742b39b6cca
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
358
diff
changeset
|
99 |
void SetWagonOverrideSprites(byte engine, struct SpriteGroup *group, byte *train_id, int trains); |
3742b39b6cca
(svn r557) -newgrf: Rename all 'superset' tokens to 'group' and some other small renamings (pasky and octo).
darkvater
parents:
358
diff
changeset
|
100 |
void SetCustomEngineSprites(byte engine, byte cargo, struct SpriteGroup *group); |
0 | 101 |
// loaded is in percents, overriding_engine 0xffff is none |
1475 | 102 |
int GetCustomEngineSprite(byte engine, const Vehicle *v, byte direction); |
414
4629d4bf7f14
(svn r611) -newgrf: Change GetCustomEngineSprite() calling convention (invisible to users of GetCustomVehicle*() wrappers). Needed for deterministic spritegroups support (pasky).
darkvater
parents:
405
diff
changeset
|
103 |
#define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction) |
4629d4bf7f14
(svn r611) -newgrf: Change GetCustomEngineSprite() calling convention (invisible to users of GetCustomVehicle*() wrappers). Needed for deterministic spritegroups support (pasky).
darkvater
parents:
405
diff
changeset
|
104 |
#define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction) |
0 | 105 |
|
1477 | 106 |
typedef enum VehicleTrigger { |
445
beafc0fb8f12
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
414
diff
changeset
|
107 |
VEHICLE_TRIGGER_NEW_CARGO = 1, |
beafc0fb8f12
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
414
diff
changeset
|
108 |
// Externally triggered only for the first vehicle in chain |
beafc0fb8f12
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
414
diff
changeset
|
109 |
VEHICLE_TRIGGER_DEPOT = 2, |
beafc0fb8f12
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
414
diff
changeset
|
110 |
// Externally triggered only for the first vehicle in chain, only if whole chain is empty |
beafc0fb8f12
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
414
diff
changeset
|
111 |
VEHICLE_TRIGGER_EMPTY = 4, |
beafc0fb8f12
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
414
diff
changeset
|
112 |
// Not triggered externally (called for the whole chain if we got NEW_CARGO) |
beafc0fb8f12
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
414
diff
changeset
|
113 |
VEHICLE_TRIGGER_ANY_NEW_CARGO = 8, |
1477 | 114 |
} VehicleTrigger; |
115 |
void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger); |
|
445
beafc0fb8f12
(svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky)
tron
parents:
414
diff
changeset
|
116 |
|
1329 | 117 |
void SetCustomEngineName(int engine, const char *name); |
0 | 118 |
StringID GetCustomEngineName(int engine); |
119 |
||
120 |
||
121 |
void DrawTrainEngine(int x, int y, int engine, uint32 image_ormod); |
|
122 |
void DrawRoadVehEngine(int x, int y, int engine, uint32 image_ormod); |
|
123 |
void DrawShipEngine(int x, int y, int engine, uint32 image_ormod); |
|
124 |
void DrawAircraftEngine(int x, int y, int engine, uint32 image_ormod); |
|
125 |
||
126 |
void DrawTrainEngineInfo(int engine, int x, int y, int maxw); |
|
127 |
void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw); |
|
128 |
void DrawShipEngineInfo(int engine, int x, int y, int maxw); |
|
129 |
void DrawAircraftEngineInfo(int engine, int x, int y, int maxw); |
|
130 |
||
131 |
void AcceptEnginePreview(Engine *e, int player); |
|
132 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
922
diff
changeset
|
133 |
void LoadCustomEngineNames(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
922
diff
changeset
|
134 |
void DeleteCustomEngineNames(void); |
0 | 135 |
|
1197 | 136 |
bool IsEngineBuildable(uint engine, byte type); |
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1329
diff
changeset
|
137 |
void UnInitNewgrEngines(void); |
0 | 138 |
|
139 |
enum { |
|
140 |
NUM_NORMAL_RAIL_ENGINES = 54, |
|
141 |
NUM_MONORAIL_ENGINES = 30, |
|
142 |
NUM_MAGLEV_ENGINES = 32, |
|
143 |
NUM_TRAIN_ENGINES = NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES + NUM_MAGLEV_ENGINES, |
|
144 |
NUM_ROAD_ENGINES = 88, |
|
145 |
NUM_SHIP_ENGINES = 11, |
|
146 |
NUM_AIRCRAFT_ENGINES = 41, |
|
376
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
147 |
TOTAL_NUM_ENGINES = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES + NUM_AIRCRAFT_ENGINES, |
0 | 148 |
AIRCRAFT_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES, |
149 |
SHIP_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES, |
|
150 |
ROAD_ENGINES_INDEX = NUM_TRAIN_ENGINES, |
|
151 |
}; |
|
152 |
VARDEF Engine _engines[TOTAL_NUM_ENGINES]; |
|
376
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
153 |
#define DEREF_ENGINE(i) (&_engines[i]) |
0 | 154 |
VARDEF StringID _engine_name_strings[TOTAL_NUM_ENGINES]; |
155 |
||
376
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
156 |
/* Access Vehicle Data */ |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
157 |
//#include "table/engines.h" |
0 | 158 |
extern EngineInfo _engine_info[TOTAL_NUM_ENGINES]; |
376
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
159 |
extern RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES]; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
160 |
extern ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES]; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
161 |
extern AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES]; |
6ffd7911bf39
(svn r565) -newgrf: fixed double work of RoadVehicleInfo[]; added AircraftVehicleInfo[] as well. table/engines.h is now the same as in the _map branch.
darkvater
parents:
374
diff
changeset
|
162 |
extern RoadVehicleInfo _road_vehicle_info[NUM_ROAD_ENGINES]; |
538
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
163 |
|
539 | 164 |
static inline RailVehicleInfo *RailVehInfo(uint e) |
538
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
165 |
{ |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
166 |
assert(e < lengthof(_rail_vehicle_info)); |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
167 |
return &_rail_vehicle_info[e]; |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
168 |
} |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
169 |
|
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
170 |
static inline ShipVehicleInfo *ShipVehInfo(uint e) |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
171 |
{ |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
172 |
assert(e - SHIP_ENGINES_INDEX < lengthof(_ship_vehicle_info)); |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
173 |
return &_ship_vehicle_info[e - SHIP_ENGINES_INDEX]; |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
174 |
} |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
175 |
|
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
176 |
static inline AircraftVehicleInfo *AircraftVehInfo(uint e) |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
177 |
{ |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
178 |
assert(e - AIRCRAFT_ENGINES_INDEX < lengthof(_aircraft_vehicle_info)); |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
179 |
return &_aircraft_vehicle_info[e - AIRCRAFT_ENGINES_INDEX]; |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
180 |
} |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
181 |
|
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
182 |
static inline RoadVehicleInfo *RoadVehInfo(uint e) |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
183 |
{ |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
184 |
assert(e - ROAD_ENGINES_INDEX < lengthof(_road_vehicle_info)); |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
185 |
return &_road_vehicle_info[e - ROAD_ENGINES_INDEX]; |
24fdb517fbe5
(svn r920) Replace vehicle info macros with inline functions and add asserts to check limits
tron
parents:
445
diff
changeset
|
186 |
} |
405
415546028e8d
(svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents:
389
diff
changeset
|
187 |
|
0 | 188 |
#endif |