author | darkvater |
Fri, 12 Nov 2004 17:16:13 +0000 | |
changeset 358 | 6eb0d5ec99b1 |
parent 0 | 29654efe3188 |
child 369 | ab2266938fa8 |
permissions | -rw-r--r-- |
0 | 1 |
#ifndef ENGINE_H |
2 |
#define ENGINE_H |
|
3 |
||
4 |
typedef struct RailVehicleInfo { |
|
5 |
byte image_index; |
|
6 |
byte flags; /* 1=multihead engine, 2=wagon */ |
|
7 |
byte base_cost; |
|
8 |
uint16 max_speed; |
|
9 |
uint16 power; |
|
10 |
byte weight; |
|
11 |
byte running_cost_base; |
|
12 |
byte engclass; // 0: steam, 1: diesel, 2: electric |
|
13 |
byte capacity; |
|
14 |
byte cargo_type; |
|
15 |
} RailVehicleInfo; |
|
16 |
||
17 |
typedef struct ShipVehicleInfo { |
|
18 |
byte image_index; |
|
19 |
byte base_cost; |
|
20 |
uint16 max_speed; |
|
21 |
byte cargo_type; |
|
22 |
uint16 capacity; |
|
23 |
byte running_cost; |
|
24 |
byte sfx; |
|
25 |
byte refittable; |
|
26 |
} ShipVehicleInfo; |
|
27 |
||
28 |
||
29 |
typedef struct EngineInfo { |
|
30 |
uint16 base_intro; |
|
31 |
byte unk2; |
|
32 |
byte lifelength; |
|
33 |
byte base_life; |
|
34 |
byte railtype_climates; |
|
35 |
} EngineInfo; |
|
36 |
||
37 |
typedef struct Engine { |
|
38 |
uint16 intro_date; |
|
39 |
uint16 age; |
|
40 |
uint16 reliability; |
|
41 |
uint16 reliability_spd_dec; |
|
42 |
uint16 reliability_start, reliability_max, reliability_final; |
|
43 |
uint16 duration_phase_1, duration_phase_2, duration_phase_3; |
|
44 |
byte lifelength; |
|
45 |
byte flags; |
|
46 |
byte preview_player; |
|
47 |
byte preview_wait; |
|
48 |
byte railtype; |
|
49 |
byte player_avail; |
|
50 |
} Engine; |
|
51 |
||
52 |
||
53 |
enum { |
|
54 |
RVI_MULTIHEAD = 1, |
|
55 |
RVI_WAGON = 2, |
|
56 |
}; |
|
57 |
||
58 |
||
59 |
void StartupEngines(); |
|
60 |
||
61 |
||
62 |
struct SpriteSuperSet { |
|
63 |
// XXX: Would anyone ever need more than 16 spritesets? Maybe we should |
|
64 |
// use even less, now we take whole 8kb for custom sprites table, oh my! |
|
65 |
byte sprites_per_set; // means number of directions - 4 or 8 |
|
66 |
// Loaded = in motion, loading = not moving |
|
67 |
// Each superset contains several spritesets, for various loading stages |
|
68 |
byte loaded_count; |
|
69 |
uint16 loaded[16]; // sprite ids |
|
70 |
byte loading_count; |
|
71 |
uint16 loading[16]; // sprite ids |
|
72 |
}; |
|
73 |
||
74 |
extern byte _global_cargo_id[NUM_LANDSCAPE][NUM_CARGO]; |
|
75 |
enum { |
|
76 |
CID_DEFAULT = 29, |
|
77 |
CID_PURCHASE = 30, |
|
78 |
NUM_CID = 31, |
|
79 |
}; |
|
80 |
extern byte _local_cargo_id_ctype[NUM_CID]; |
|
81 |
extern byte _local_cargo_id_landscape[NUM_CID]; |
|
82 |
||
83 |
extern uint32 _engine_refit_masks[256]; |
|
84 |
||
85 |
extern byte _engine_original_sprites[256]; |
|
86 |
void SetWagonOverrideSprites(byte engine, struct SpriteSuperSet *superset, byte *train_id, int trains); |
|
87 |
void SetCustomEngineSprites(byte engine, byte cargo, struct SpriteSuperSet *superset); |
|
88 |
// loaded is in percents, overriding_engine 0xffff is none |
|
89 |
int GetCustomEngineSprite(byte engine, uint16 overriding_engine, byte cargo, byte loaded, byte in_motion, byte direction); |
|
90 |
#define GetCustomVehicleSprite(v, direction) \ |
|
91 |
GetCustomEngineSprite(v->engine_type, v->type == VEH_Train ? v->u.rail.first_engine : -1, \ |
|
92 |
_global_cargo_id[_opt.landscape][v->cargo_type], \ |
|
93 |
((v->cargo_count + 1) * 100) / (v->cargo_cap + 1), \ |
|
358
6eb0d5ec99b1
(svn r546) -newgrf: Use GetCustomVehicleIcon() for fetching sprites for vehicle selection dialogs. (Idea by octo, done by pasky).
darkvater
parents:
0
diff
changeset
|
94 |
!!v->cur_speed, direction) |
6eb0d5ec99b1
(svn r546) -newgrf: Use GetCustomVehicleIcon() for fetching sprites for vehicle selection dialogs. (Idea by octo, done by pasky).
darkvater
parents:
0
diff
changeset
|
95 |
#define GetCustomVehicleIcon(v, direction) \ |
6eb0d5ec99b1
(svn r546) -newgrf: Use GetCustomVehicleIcon() for fetching sprites for vehicle selection dialogs. (Idea by octo, done by pasky).
darkvater
parents:
0
diff
changeset
|
96 |
GetCustomEngineSprite(v, -1, CID_PURCHASE, 0, 0, direction) |
0 | 97 |
|
98 |
void SetCustomEngineName(int engine, char *name); |
|
99 |
StringID GetCustomEngineName(int engine); |
|
100 |
||
101 |
||
102 |
void DrawTrainEngine(int x, int y, int engine, uint32 image_ormod); |
|
103 |
void DrawRoadVehEngine(int x, int y, int engine, uint32 image_ormod); |
|
104 |
void DrawShipEngine(int x, int y, int engine, uint32 image_ormod); |
|
105 |
void DrawAircraftEngine(int x, int y, int engine, uint32 image_ormod); |
|
106 |
||
107 |
void DrawTrainEngineInfo(int engine, int x, int y, int maxw); |
|
108 |
void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw); |
|
109 |
void DrawShipEngineInfo(int engine, int x, int y, int maxw); |
|
110 |
void DrawAircraftEngineInfo(int engine, int x, int y, int maxw); |
|
111 |
||
112 |
void AcceptEnginePreview(Engine *e, int player); |
|
113 |
||
114 |
void LoadCustomEngineNames(); |
|
115 |
void DeleteCustomEngineNames(); |
|
116 |
||
117 |
||
118 |
enum { |
|
119 |
NUM_NORMAL_RAIL_ENGINES = 54, |
|
120 |
NUM_MONORAIL_ENGINES = 30, |
|
121 |
NUM_MAGLEV_ENGINES = 32, |
|
122 |
NUM_TRAIN_ENGINES = NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES + NUM_MAGLEV_ENGINES, |
|
123 |
NUM_ROAD_ENGINES = 88, |
|
124 |
NUM_SHIP_ENGINES = 11, |
|
125 |
NUM_AIRCRAFT_ENGINES = 41, |
|
126 |
TOTAL_NUM_ENGINES = NUM_NORMAL_RAIL_ENGINES+NUM_MONORAIL_ENGINES+NUM_MAGLEV_ENGINES+NUM_ROAD_ENGINES+NUM_SHIP_ENGINES+NUM_AIRCRAFT_ENGINES, |
|
127 |
AIRCRAFT_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES, |
|
128 |
SHIP_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES, |
|
129 |
ROAD_ENGINES_INDEX = NUM_TRAIN_ENGINES, |
|
130 |
}; |
|
131 |
VARDEF Engine _engines[TOTAL_NUM_ENGINES]; |
|
132 |
VARDEF StringID _engine_name_strings[TOTAL_NUM_ENGINES]; |
|
133 |
||
134 |
extern EngineInfo _engine_info[TOTAL_NUM_ENGINES]; |
|
135 |
extern RailVehicleInfo _rail_vehicle_info[]; |
|
136 |
#define ship_vehicle_info(e) _ship_vehicle_info[e - SHIP_ENGINES_INDEX] |
|
137 |
extern ShipVehicleInfo _ship_vehicle_info[]; |
|
138 |
||
139 |
#endif |