Changeset - r4057:da82c9df7f29
[Not reviewed]
master
0 2 0
peter1138 - 18 years ago 2006-06-22 21:25:51
peter1138@openttd.org
(svn r5337) - NewGRF: pass the engine type to the engine resolver, to allow support for variable 7F for unbuilt vehicles (mart3p)
2 files changed with 20 insertions and 11 deletions:
0 comments (0 inline, 0 general)
newgrf_engine.c
Show inline comments
 
@@ -502,6 +502,15 @@ static void VehicleSetTriggers(const Res
 
}
 

	
 

	
 
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 @@ static uint32 VehicleGetVariable(const R
 
			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 @@ static uint32 VehicleGetVariable(const R
 
				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 const SpriteGroup *VehicleResolve
 
}
 

	
 

	
 
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 @@ static inline void NewVehicleResolver(Re
 
	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 @@ SpriteID GetCustomEngineSprite(EngineID 
 
	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 @@ SpriteID GetRotorOverrideSprite(EngineID
 
	/* 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 @@ uint16 GetVehicleCallback(uint16 callbac
 
	ResolverObject object;
 
	CargoID cargo;
 

	
 
	NewVehicleResolver(&object, v);
 
	NewVehicleResolver(&object, engine, v);
 

	
 
	object.callback        = callback;
 
	object.callback_param1 = param1;
 
@@ -941,7 +949,7 @@ uint16 GetVehicleCallbackParent(uint16 c
 
	ResolverObject object;
 
	CargoID cargo;
 

	
 
	NewVehicleResolver(&object, v);
 
	NewVehicleResolver(&object, engine, v);
 

	
 
	object.callback        = callback;
 
	object.callback_param1 = param1;
 
@@ -982,7 +990,7 @@ static void DoTriggerVehicle(Vehicle *v,
 
	/* We can't trigger a non-existent vehicle... */
 
	assert(v != NULL);
 

	
 
	NewVehicleResolver(&object, v);
 
	NewVehicleResolver(&object, v->engine_type, v);
 

	
 
	object.trigger = trigger;
 

	
newgrf_spritegroup.h
Show inline comments
 
@@ -171,6 +171,7 @@ typedef struct ResolverObject {
 
		struct {
 
			const struct Vehicle *self;
 
			const struct Vehicle *parent;
 
			EngineID self_type;
 
		} vehicle;
 
		struct {
 
			TileIndex tile;
0 comments (0 inline, 0 general)