diff options
author | peter1138 <peter1138@openttd.org> | 2006-05-31 17:31:08 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-05-31 17:31:08 +0000 |
commit | 4aa2054b1a98eb9455f02204426f8e65d6ce1c6d (patch) | |
tree | 47880daffd609ae00254f49f017f3505d8d32876 /newgrf_engine.c | |
parent | ef211c35cea51761555ea060bd65009469a1c19d (diff) | |
download | openttd-4aa2054b1a98eb9455f02204426f8e65d6ce1c6d.tar.xz |
(svn r5059) - NewGRF: store a GRFFile pointer reference for each pointer, instead of just the GRF ID.
Diffstat (limited to 'newgrf_engine.c')
-rw-r--r-- | newgrf_engine.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/newgrf_engine.c b/newgrf_engine.c index 8d33c9eab..5460c5932 100644 --- a/newgrf_engine.c +++ b/newgrf_engine.c @@ -10,6 +10,7 @@ #include "player.h" #include "station.h" #include "airport.h" +#include "newgrf.h" #include "newgrf_callbacks.h" #include "newgrf_engine.h" #include "newgrf_station.h" @@ -141,7 +142,7 @@ void UnloadWagonOverrides(void) // may appear in future - however it's more convenient to store it like this in // memory. --pasky) static const SpriteGroup *engine_custom_sprites[TOTAL_NUM_ENGINES][NUM_GLOBAL_CID]; -static uint32 _engine_grf[TOTAL_NUM_ENGINES]; +static const GRFFile *_engine_grf[TOTAL_NUM_ENGINES]; void SetCustomEngineSprites(EngineID engine, byte cargo, const SpriteGroup *group) { @@ -194,19 +195,44 @@ void UnloadRotorOverrideSprites(void) } } -void SetEngineGRF(EngineID engine, uint32 grfid) + +/** + * Tie a GRFFile entry to an engine, to allow us to retrieve GRF parameters + * etc during a game. + * @param engine Engine ID to tie the GRFFile to. + * @param file Pointer of GRFFile to tie. + */ +void SetEngineGRF(EngineID engine, const GRFFile *file) { assert(engine < TOTAL_NUM_ENGINES); - _engine_grf[engine] = grfid; + _engine_grf[engine] = file; } -uint32 GetEngineGRFID(EngineID engine) + +/** + * Retrieve the GRFFile tied to an engine + * @param engine Engine ID to retrieve. + * @return Pointer to GRFFile. + */ +const GRFFile *GetEngineGRF(EngineID engine) { assert(engine < TOTAL_NUM_ENGINES); return _engine_grf[engine]; } +/** + * Retrieve the GRF ID of the GRFFile tied to an engine + * @param engine Engine ID to retrieve. + * @return 32 bit GRFID value. + */ +uint32 GetEngineGRFID(EngineID engine) +{ + assert(engine < TOTAL_NUM_ENGINES); + return _engine_grf[engine]->grfid; +} + + static int MapOldSubType(const Vehicle *v) { if (v->type != VEH_Train) return v->subtype; |