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
 
@@ -423,7 +423,7 @@ static int DrawRailEnginePurchaseInfo(in
 
	}
 

	
 
	/* 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;
 

	
 
@@ -481,7 +481,7 @@ static int DrawShipPurchaseInfo(int x, i
 
	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;
 

	
 
@@ -516,7 +516,7 @@ static int DrawAircraftPurchaseInfo(int 
 
	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;
 

	
src/newgrf_engine.cpp
Show inline comments
 
@@ -952,7 +952,7 @@ uint16 GetVehicleCallbackParent(uint16 c
 
}
 

	
 

	
 
/* 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);
 
@@ -962,6 +962,15 @@ uint GetVehicleProperty(const Vehicle *v
 
}
 

	
 

	
 
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;
src/newgrf_engine.h
Show inline comments
 
@@ -38,6 +38,7 @@ bool UsesWagonOverride(const Vehicle *v)
 
/* 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,
0 comments (0 inline, 0 general)