author | dominik |
Sun, 14 Nov 2004 18:20:40 +0000 | |
changeset 409 | 620cbd1c9be4 |
parent 405 | 415546028e8d |
child 414 | 4629d4bf7f14 |
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; |
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
|
39 |
uint16 passanger_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
|
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; |
|
73 |
} Engine; |
|
74 |
||
75 |
||
76 |
enum { |
|
77 |
RVI_MULTIHEAD = 1, |
|
78 |
RVI_WAGON = 2, |
|
79 |
}; |
|
80 |
||
81 |
||
82 |
void StartupEngines(); |
|
83 |
||
84 |
||
85 |
extern byte _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO]; |
|
86 |
enum { |
|
87 |
CID_DEFAULT = 29, |
|
88 |
CID_PURCHASE = 30, |
|
89 |
NUM_CID = 31, |
|
90 |
}; |
|
91 |
extern byte _local_cargo_id_ctype[NUM_CID]; |
|
92 |
extern byte _local_cargo_id_landscape[NUM_CID]; |
|
93 |
||
94 |
extern uint32 _engine_refit_masks[256]; |
|
95 |
||
96 |
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
|
97 |
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
|
98 |
void SetCustomEngineSprites(byte engine, byte cargo, struct SpriteGroup *group); |
0 | 99 |
// loaded is in percents, overriding_engine 0xffff is none |
100 |
int GetCustomEngineSprite(byte engine, uint16 overriding_engine, byte cargo, byte loaded, byte in_motion, byte direction); |
|
101 |
#define GetCustomVehicleSprite(v, direction) \ |
|
102 |
GetCustomEngineSprite(v->engine_type, v->type == VEH_Train ? v->u.rail.first_engine : -1, \ |
|
103 |
_global_cargo_id[_opt.landscape][v->cargo_type], \ |
|
104 |
((v->cargo_count + 1) * 100) / (v->cargo_cap + 1), \ |
|
358
da81e0ef68cf
(svn r546) -newgrf: Use GetCustomVehicleIcon() for fetching sprites for vehicle selection dialogs. (Idea by octo, done by pasky).
darkvater
parents:
0
diff
changeset
|
105 |
!!v->cur_speed, direction) |
da81e0ef68cf
(svn r546) -newgrf: Use GetCustomVehicleIcon() for fetching sprites for vehicle selection dialogs. (Idea by octo, done by pasky).
darkvater
parents:
0
diff
changeset
|
106 |
#define GetCustomVehicleIcon(v, direction) \ |
da81e0ef68cf
(svn r546) -newgrf: Use GetCustomVehicleIcon() for fetching sprites for vehicle selection dialogs. (Idea by octo, done by pasky).
darkvater
parents:
0
diff
changeset
|
107 |
GetCustomEngineSprite(v, -1, CID_PURCHASE, 0, 0, direction) |
0 | 108 |
|
109 |
void SetCustomEngineName(int engine, char *name); |
|
110 |
StringID GetCustomEngineName(int engine); |
|
111 |
||
112 |
||
113 |
void DrawTrainEngine(int x, int y, int engine, uint32 image_ormod); |
|
114 |
void DrawRoadVehEngine(int x, int y, int engine, uint32 image_ormod); |
|
115 |
void DrawShipEngine(int x, int y, int engine, uint32 image_ormod); |
|
116 |
void DrawAircraftEngine(int x, int y, int engine, uint32 image_ormod); |
|
117 |
||
118 |
void DrawTrainEngineInfo(int engine, int x, int y, int maxw); |
|
119 |
void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw); |
|
120 |
void DrawShipEngineInfo(int engine, int x, int y, int maxw); |
|
121 |
void DrawAircraftEngineInfo(int engine, int x, int y, int maxw); |
|
122 |
||
123 |
void AcceptEnginePreview(Engine *e, int player); |
|
124 |
||
125 |
void LoadCustomEngineNames(); |
|
126 |
void DeleteCustomEngineNames(); |
|
127 |
||
128 |
||
129 |
enum { |
|
130 |
NUM_NORMAL_RAIL_ENGINES = 54, |
|
131 |
NUM_MONORAIL_ENGINES = 30, |
|
132 |
NUM_MAGLEV_ENGINES = 32, |
|
133 |
NUM_TRAIN_ENGINES = NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES + NUM_MAGLEV_ENGINES, |
|
134 |
NUM_ROAD_ENGINES = 88, |
|
135 |
NUM_SHIP_ENGINES = 11, |
|
136 |
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
|
137 |
TOTAL_NUM_ENGINES = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES + NUM_AIRCRAFT_ENGINES, |
0 | 138 |
AIRCRAFT_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES, |
139 |
SHIP_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES, |
|
140 |
ROAD_ENGINES_INDEX = NUM_TRAIN_ENGINES, |
|
141 |
}; |
|
142 |
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
|
143 |
#define DEREF_ENGINE(i) (&_engines[i]) |
0 | 144 |
VARDEF StringID _engine_name_strings[TOTAL_NUM_ENGINES]; |
145 |
||
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
|
146 |
/* 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
|
147 |
//#include "table/engines.h" |
0 | 148 |
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
|
149 |
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
|
150 |
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
|
151 |
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
|
152 |
extern RoadVehicleInfo _road_vehicle_info[NUM_ROAD_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
|
153 |
/* TODO: Change this to return a pointer type instead, for the sake of consistency. |
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
|
154 |
* --pasky. XXX - really needed? Why?. Best to remove the pointer type as well cause |
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
|
155 |
* _map uses it that way...less conflicts - Darkvater */ |
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 |
#define rail_vehinfo(e) _rail_vehicle_info[e] |
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 |
#define ship_vehicle_info(e) _ship_vehicle_info[e - SHIP_ENGINES_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
|
158 |
#define aircraft_vehinfo(e) _aircraft_vehicle_info[e - AIRCRAFT_ENGINES_INDEX] |
374
0309a855fc66
(svn r562) newgrf: Merge most of the road vehicle info to a single
celestar
parents:
369
diff
changeset
|
159 |
#define road_vehicle_info(e) (&_road_vehicle_info[e - ROAD_ENGINES_INDEX]) |
405
415546028e8d
(svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents:
389
diff
changeset
|
160 |
|
0 | 161 |
#endif |