Changeset - r6517:6357a0cb600e
[Not reviewed]
master
0 3 0
peter1138 - 17 years ago 2007-04-20 21:42:06
peter1138@openttd.org
(svn r9703) -Codechange: support callback 36 in vehicle purchase lists
3 files changed with 14 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -420,13 +420,13 @@ static int DrawRailEnginePurchaseInfo(in
 
		SetDParam(0, ((rvi->weight << multihead) * 10 * rvi->tractive_effort) / 256);
 
		DrawString(x, y, STR_PURCHASE_INFO_MAX_TE, 0);
 
		y += 10;
 
	}
 

	
 
	/* Running cost */
 
	SetDParam(0, (rvi->running_cost_base * _price.running_rail[rvi->running_cost_class] >> 8) << multihead);
 
	SetDParam(0, (GetEngineProperty(engine_number, 0x0D, rvi->running_cost_base) * _price.running_rail[rvi->running_cost_class] >> 8) << multihead);
 
	DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
 
	y += 10;
 

	
 
	/* Powered wagons power - Powered wagons extra weight */
 
	if (rvi->pow_wag_power != 0) {
 
		SetDParam(0, rvi->pow_wag_power);
 
@@ -478,13 +478,13 @@ static int DrawShipPurchaseInfo(int x, i
 
	SetDParam(1, svi->capacity);
 
	SetDParam(2, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY);
 
	DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
 
	y += 10;
 

	
 
	/* Running cost */
 
	SetDParam(0, svi->running_cost * _price.ship_running >> 8);
 
	SetDParam(0, GetEngineProperty(engine_number, 0x0B, svi->running_cost) * _price.ship_running >> 8);
 
	DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
 
	y += 10;
 

	
 
	return y;
 
}
 

	
 
@@ -513,13 +513,13 @@ static int DrawAircraftPurchaseInfo(int 
 
		SetDParam(2, STR_9842_REFITTABLE);
 
		DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
 
	}
 
	y += 10;
 

	
 
	/* Running cost */
 
	SetDParam(0, avi->running_cost * _price.aircraft_running >> 8);
 
	SetDParam(0, GetEngineProperty(engine_number, 0x0E, avi->running_cost) * _price.aircraft_running >> 8);
 
	DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
 
	y += 10;
 

	
 
	return y;
 
}
 

	
src/newgrf_engine.cpp
Show inline comments
 
@@ -949,22 +949,31 @@ uint16 GetVehicleCallbackParent(uint16 c
 
	if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED;
 

	
 
	return group->g.callback.result;
 
}
 

	
 

	
 
/* Callback 36 handler */
 
/* Callback 36 handlers */
 
uint GetVehicleProperty(const Vehicle *v, uint8 property, uint orig_value)
 
{
 
	uint16 callback = GetVehicleCallback(CBID_VEHICLE_MODIFY_PROPERTY, property, 0, v->engine_type, v);
 
	if (callback != CALLBACK_FAILED) return callback;
 

	
 
	return orig_value;
 
}
 

	
 

	
 
uint GetEngineProperty(EngineID engine, uint8 property, uint orig_value)
 
{
 
	uint16 callback = GetVehicleCallback(CBID_VEHICLE_MODIFY_PROPERTY, property, 0, engine, NULL);
 
	if (callback != CALLBACK_FAILED) return callback;
 

	
 
	return orig_value;
 
}
 

	
 

	
 
static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, byte base_random_bits, bool first)
 
{
 
	const SpriteGroup *group;
 
	ResolverObject object;
 
	byte new_random_bits;
 

	
src/newgrf_engine.h
Show inline comments
 
@@ -35,12 +35,13 @@ bool UsesWagonOverride(const Vehicle *v)
 
#define GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)
 
#define GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction)
 

	
 
/* Handler to Evaluate callback 36. If the callback fails (i.e. most of the
 
 * time) orig_value is returned */
 
uint GetVehicleProperty(const Vehicle *v, uint8 property, uint orig_value);
 
uint GetEngineProperty(EngineID engine, uint8 property, uint orig_value);
 

	
 
enum VehicleTrigger {
 
	VEHICLE_TRIGGER_NEW_CARGO     = 1,
 
	/* Externally triggered only for the first vehicle in chain */
 
	VEHICLE_TRIGGER_DEPOT         = 2,
 
	/* Externally triggered only for the first vehicle in chain, only if whole chain is empty */
0 comments (0 inline, 0 general)