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), \
|
|
94 |
!!v->cur_speed, direction);
|
|
95 |
|
|
96 |
void SetCustomEngineName(int engine, char *name);
|
|
97 |
StringID GetCustomEngineName(int engine);
|
|
98 |
|
|
99 |
|
|
100 |
void DrawTrainEngine(int x, int y, int engine, uint32 image_ormod);
|
|
101 |
void DrawRoadVehEngine(int x, int y, int engine, uint32 image_ormod);
|
|
102 |
void DrawShipEngine(int x, int y, int engine, uint32 image_ormod);
|
|
103 |
void DrawAircraftEngine(int x, int y, int engine, uint32 image_ormod);
|
|
104 |
|
|
105 |
void DrawTrainEngineInfo(int engine, int x, int y, int maxw);
|
|
106 |
void DrawRoadVehEngineInfo(int engine, int x, int y, int maxw);
|
|
107 |
void DrawShipEngineInfo(int engine, int x, int y, int maxw);
|
|
108 |
void DrawAircraftEngineInfo(int engine, int x, int y, int maxw);
|
|
109 |
|
|
110 |
void AcceptEnginePreview(Engine *e, int player);
|
|
111 |
|
|
112 |
void LoadCustomEngineNames();
|
|
113 |
void DeleteCustomEngineNames();
|
|
114 |
|
|
115 |
|
|
116 |
enum {
|
|
117 |
NUM_NORMAL_RAIL_ENGINES = 54,
|
|
118 |
NUM_MONORAIL_ENGINES = 30,
|
|
119 |
NUM_MAGLEV_ENGINES = 32,
|
|
120 |
NUM_TRAIN_ENGINES = NUM_NORMAL_RAIL_ENGINES + NUM_MONORAIL_ENGINES + NUM_MAGLEV_ENGINES,
|
|
121 |
NUM_ROAD_ENGINES = 88,
|
|
122 |
NUM_SHIP_ENGINES = 11,
|
|
123 |
NUM_AIRCRAFT_ENGINES = 41,
|
|
124 |
TOTAL_NUM_ENGINES = NUM_NORMAL_RAIL_ENGINES+NUM_MONORAIL_ENGINES+NUM_MAGLEV_ENGINES+NUM_ROAD_ENGINES+NUM_SHIP_ENGINES+NUM_AIRCRAFT_ENGINES,
|
|
125 |
AIRCRAFT_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES,
|
|
126 |
SHIP_ENGINES_INDEX = NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES,
|
|
127 |
ROAD_ENGINES_INDEX = NUM_TRAIN_ENGINES,
|
|
128 |
};
|
|
129 |
VARDEF Engine _engines[TOTAL_NUM_ENGINES];
|
|
130 |
VARDEF StringID _engine_name_strings[TOTAL_NUM_ENGINES];
|
|
131 |
|
|
132 |
extern EngineInfo _engine_info[TOTAL_NUM_ENGINES];
|
|
133 |
extern RailVehicleInfo _rail_vehicle_info[];
|
|
134 |
#define ship_vehicle_info(e) _ship_vehicle_info[e - SHIP_ENGINES_INDEX]
|
|
135 |
extern ShipVehicleInfo _ship_vehicle_info[];
|
|
136 |
|
|
137 |
#endif
|