8 #include "engine.h" |
8 #include "engine.h" |
9 #include "train.h" |
9 #include "train.h" |
10 #include "player.h" |
10 #include "player.h" |
11 #include "station.h" |
11 #include "station.h" |
12 #include "airport.h" |
12 #include "airport.h" |
|
13 #include "newgrf.h" |
13 #include "newgrf_callbacks.h" |
14 #include "newgrf_callbacks.h" |
14 #include "newgrf_engine.h" |
15 #include "newgrf_engine.h" |
15 #include "newgrf_station.h" |
16 #include "newgrf_station.h" |
16 #include "newgrf_spritegroup.h" |
17 #include "newgrf_spritegroup.h" |
17 #include "newgrf_cargo.h" |
18 #include "newgrf_cargo.h" |
139 // 0 - 28 are cargos, 29 is default, 30 is the advert (purchase list) |
140 // 0 - 28 are cargos, 29 is default, 30 is the advert (purchase list) |
140 // (It isn't and shouldn't be like this in the GRF files since new cargo types |
141 // (It isn't and shouldn't be like this in the GRF files since new cargo types |
141 // may appear in future - however it's more convenient to store it like this in |
142 // may appear in future - however it's more convenient to store it like this in |
142 // memory. --pasky) |
143 // memory. --pasky) |
143 static const SpriteGroup *engine_custom_sprites[TOTAL_NUM_ENGINES][NUM_GLOBAL_CID]; |
144 static const SpriteGroup *engine_custom_sprites[TOTAL_NUM_ENGINES][NUM_GLOBAL_CID]; |
144 static uint32 _engine_grf[TOTAL_NUM_ENGINES]; |
145 static const GRFFile *_engine_grf[TOTAL_NUM_ENGINES]; |
145 |
146 |
146 void SetCustomEngineSprites(EngineID engine, byte cargo, const SpriteGroup *group) |
147 void SetCustomEngineSprites(EngineID engine, byte cargo, const SpriteGroup *group) |
147 { |
148 { |
148 assert(engine < TOTAL_NUM_ENGINES); |
149 assert(engine < TOTAL_NUM_ENGINES); |
149 if (engine_custom_sprites[engine][cargo] != NULL) { |
150 if (engine_custom_sprites[engine][cargo] != NULL) { |
192 for (engine = AIRCRAFT_ENGINES_INDEX; engine < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; engine++) { |
193 for (engine = AIRCRAFT_ENGINES_INDEX; engine < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; engine++) { |
193 heli_rotor_custom_sprites[engine - AIRCRAFT_ENGINES_INDEX] = NULL; |
194 heli_rotor_custom_sprites[engine - AIRCRAFT_ENGINES_INDEX] = NULL; |
194 } |
195 } |
195 } |
196 } |
196 |
197 |
197 void SetEngineGRF(EngineID engine, uint32 grfid) |
198 |
|
199 /** |
|
200 * Tie a GRFFile entry to an engine, to allow us to retrieve GRF parameters |
|
201 * etc during a game. |
|
202 * @param engine Engine ID to tie the GRFFile to. |
|
203 * @param file Pointer of GRFFile to tie. |
|
204 */ |
|
205 void SetEngineGRF(EngineID engine, const GRFFile *file) |
198 { |
206 { |
199 assert(engine < TOTAL_NUM_ENGINES); |
207 assert(engine < TOTAL_NUM_ENGINES); |
200 _engine_grf[engine] = grfid; |
208 _engine_grf[engine] = file; |
201 } |
209 } |
202 |
210 |
203 uint32 GetEngineGRFID(EngineID engine) |
211 |
|
212 /** |
|
213 * Retrieve the GRFFile tied to an engine |
|
214 * @param engine Engine ID to retrieve. |
|
215 * @return Pointer to GRFFile. |
|
216 */ |
|
217 const GRFFile *GetEngineGRF(EngineID engine) |
204 { |
218 { |
205 assert(engine < TOTAL_NUM_ENGINES); |
219 assert(engine < TOTAL_NUM_ENGINES); |
206 return _engine_grf[engine]; |
220 return _engine_grf[engine]; |
|
221 } |
|
222 |
|
223 |
|
224 /** |
|
225 * Retrieve the GRF ID of the GRFFile tied to an engine |
|
226 * @param engine Engine ID to retrieve. |
|
227 * @return 32 bit GRFID value. |
|
228 */ |
|
229 uint32 GetEngineGRFID(EngineID engine) |
|
230 { |
|
231 assert(engine < TOTAL_NUM_ENGINES); |
|
232 return _engine_grf[engine]->grfid; |
207 } |
233 } |
208 |
234 |
209 |
235 |
210 static int MapOldSubType(const Vehicle *v) |
236 static int MapOldSubType(const Vehicle *v) |
211 { |
237 { |