diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/build_vehicle_gui.cpp | 6 | ||||
-rw-r--r-- | src/newgrf_engine.cpp | 11 | ||||
-rw-r--r-- | src/newgrf_engine.h | 1 |
3 files changed, 14 insertions, 4 deletions
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 3a230232c..b19b32f31 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -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; diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 48c92495a..e1b24de2e 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -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; diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h index 4f3c4d547..812f30b43 100644 --- a/src/newgrf_engine.h +++ b/src/newgrf_engine.h @@ -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, |