(svn r4632) - NewGRF: support loading of helicopter rotor sprites (mart3p)

This commit is contained in:
2006-04-30 18:41:16 +00:00
parent 967752fe7c
commit ddbb61199b
3 changed files with 64 additions and 2 deletions

View File

@@ -125,6 +125,32 @@ void UnloadCustomEngineSprites(void)
}
}
static const SpriteGroup *heli_rotor_custom_sprites[NUM_AIRCRAFT_ENGINES];
/** Load a rotor override sprite group for an aircraft */
void SetRotorOverrideSprites(EngineID engine, const SpriteGroup *group)
{
assert(engine >= AIRCRAFT_ENGINES_INDEX);
assert(engine < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES);
if (heli_rotor_custom_sprites[engine - AIRCRAFT_ENGINES_INDEX] != NULL) {
DEBUG(grf, 6)("SetRotorOverrideSprites: engine `%d' already has group -- replacing.", engine);
}
heli_rotor_custom_sprites[engine - AIRCRAFT_ENGINES_INDEX] = group;
}
/** Unload all rotor override sprite groups */
void UnloadRotorOverrideSprites(void)
{
EngineID engine;
/* Starting at AIRCRAFT_ENGINES_INDEX may seem pointless, but it means
* the context of EngineID is correct */
for (engine = AIRCRAFT_ENGINES_INDEX; engine < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; engine++) {
heli_rotor_custom_sprites[engine - AIRCRAFT_ENGINES_INDEX] = NULL;
}
}
void SetEngineGRF(EngineID engine, uint32 grfid)
{
assert(engine < TOTAL_NUM_ENGINES);
@@ -435,6 +461,30 @@ SpriteID GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction dire
}
SpriteID GetRotorOverrideSprite(EngineID engine, const Vehicle *v)
{
const SpriteGroup *group;
ResolverObject object;
assert(engine >= AIRCRAFT_ENGINES_INDEX);
assert(engine < AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES);
/* Only valid for helicopters */
assert((AircraftVehInfo(engine)->subtype & 1) == 0);
NewVehicleResolver(&object, v);
group = heli_rotor_custom_sprites[engine - AIRCRAFT_ENGINES_INDEX];
group = Resolve(group, &object);
if (group == NULL || group->type != SGT_RESULT) return 0;
if (v == NULL) return group->g.result.sprite;
return group->g.result.sprite + v->next->next->u.air.state;
}
/**
* Check if a wagon is currently using a wagon override
* @param v The wagon to check