Mercurial > hg > openttd
changeset 4057:4debead5004d draft
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Thu, 22 Jun 2006 21:25:51 +0000 |
parents | 203a2feb6ab2 |
children | 0718dffb813f |
files | newgrf_engine.c newgrf_spritegroup.h |
diffstat | 2 files changed, 20 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/newgrf_engine.c +++ b/newgrf_engine.c @@ -502,6 +502,15 @@ } +static uint32 GetGRFParameter(EngineID engine_type, byte parameter) +{ + const GRFFile *file = GetEngineGRF(engine_type); + + if (parameter >= file->param_end) return 0; + return file->param[parameter]; +} + + static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) { const Vehicle *v = GRV(object); @@ -513,6 +522,7 @@ case 0x46: return 0; /* Motion counter */ case 0xC4: return _cur_year; /* Build year */ case 0xDA: return INVALID_VEHICLE; /* Next vehicle */ + case 0x7F: return GetGRFParameter(object->u.vehicle.self_type, parameter); /* Read GRF parameter */ } *available = false; @@ -628,11 +638,7 @@ return count; } - case 0x7F: { /* Read GRF parameter */ - const GRFFile *file = GetEngineGRF(v->engine_type); - if (parameter >= file->param_end) return 0; - return file->param[parameter]; - } + case 0x7F: return GetGRFParameter(v->engine_type, parameter); /* Read GRF parameter */ } /* General vehicle properties */ @@ -788,7 +794,7 @@ } -static inline void NewVehicleResolver(ResolverObject *res, const Vehicle *v) +static inline void NewVehicleResolver(ResolverObject *res, EngineID engine_type, const Vehicle *v) { res->GetRandomBits = &VehicleGetRandomBits; res->GetTriggers = &VehicleGetTriggers; @@ -799,6 +805,8 @@ res->u.vehicle.self = v; res->u.vehicle.parent = (v != NULL && v->type == VEH_Train) ? GetFirstVehicleInChain(v) : v; + res->u.vehicle.self_type = engine_type; + res->info_view = false; res->callback = 0; @@ -816,7 +824,7 @@ ResolverObject object; CargoID cargo = GC_PURCHASE; - NewVehicleResolver(&object, v); + NewVehicleResolver(&object, engine, v); if (v != NULL) { cargo = _global_cargo_id[_opt.landscape][v->cargo_type]; @@ -855,7 +863,7 @@ /* Only valid for helicopters */ assert(!(AircraftVehInfo(engine)->subtype & AIR_CTOL)); - NewVehicleResolver(&object, v); + NewVehicleResolver(&object, engine, v); object.info_view = info_view; @@ -896,7 +904,7 @@ ResolverObject object; CargoID cargo; - NewVehicleResolver(&object, v); + NewVehicleResolver(&object, engine, v); object.callback = callback; object.callback_param1 = param1; @@ -941,7 +949,7 @@ ResolverObject object; CargoID cargo; - NewVehicleResolver(&object, v); + NewVehicleResolver(&object, engine, v); object.callback = callback; object.callback_param1 = param1; @@ -982,7 +990,7 @@ /* We can't trigger a non-existent vehicle... */ assert(v != NULL); - NewVehicleResolver(&object, v); + NewVehicleResolver(&object, v->engine_type, v); object.trigger = trigger;