(svn r9703) -Codechange: support callback 36 in vehicle purchase lists

This commit is contained in:
peter1138 2007-04-20 21:42:06 +00:00
parent 15bfaba259
commit 1052b0e8f1
3 changed files with 14 additions and 4 deletions

View File

@ -423,7 +423,7 @@ static int DrawRailEnginePurchaseInfo(int x, int y, EngineID engine_number, cons
}
/* 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, int y, EngineID engine_number, const Ship
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 x, int y, EngineID engine_number, const
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;

View File

@ -952,7 +952,7 @@ uint16 GetVehicleCallbackParent(uint16 callback, uint32 param1, uint32 param2, E
}
/* 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, uint8 property, uint 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;

View File

@ -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,