Mercurial > hg > openttd
changeset 3648:ed1f1b49492f draft
(svn r4559) - NewGRF: keep a record of which grf an engine is defined in. Will be used in the future.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Sun, 23 Apr 2006 22:25:33 +0000 |
parents | 461147884aab |
children | 42d25288b84c |
files | newgrf.c newgrf_engine.c newgrf_engine.h |
diffstat | 3 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/newgrf.c +++ b/newgrf.c @@ -1662,6 +1662,7 @@ SetWagonOverrideSprites(engine, _cur_grffile->spritegroups[groupid], last_engines, last_engines_count); } else { SetCustomEngineSprites(engine, ctype, _cur_grffile->spritegroups[groupid]); + SetEngineGRF(engine, _cur_grffile->grfid); last_engines[i] = engine; } }
--- a/newgrf_engine.c +++ b/newgrf_engine.c @@ -99,6 +99,7 @@ // may appear in future - however it's more convenient to store it like this in // memory. --pasky) static SpriteGroup *engine_custom_sprites[TOTAL_NUM_ENGINES][NUM_GLOBAL_CID]; +static uint32 _engine_grf[TOTAL_NUM_ENGINES]; void SetCustomEngineSprites(EngineID engine, byte cargo, SpriteGroup *group) { @@ -121,9 +122,23 @@ for (cargo = 0; cargo < NUM_GLOBAL_CID; cargo++) { engine_custom_sprites[engine][cargo] = NULL; } + _engine_grf[engine] = 0; } } +void SetEngineGRF(EngineID engine, uint32 grfid) +{ + assert(engine < TOTAL_NUM_ENGINES); + _engine_grf[engine] = grfid; +} + +uint32 GetEngineGRFID(EngineID engine) +{ + assert(engine < TOTAL_NUM_ENGINES); + return _engine_grf[engine]; +} + + static int MapOldSubType(const Vehicle *v) { if (v->type != VEH_Train) return v->subtype;
--- a/newgrf_engine.h +++ b/newgrf_engine.h @@ -18,6 +18,10 @@ void SetCustomEngineSprites(EngineID engine, byte cargo, struct SpriteGroup *group); // loaded is in percents, overriding_engine 0xffff is none int GetCustomEngineSprite(EngineID engine, const Vehicle* v, Direction direction); + +void SetEngineGRF(EngineID engine, uint32 grfid); +uint32 GetEngineGRFID(EngineID engine); + uint16 GetVehicleCallback(byte callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v); bool UsesWagonOverride(const Vehicle *v); #define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)