summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/engine.cpp12
-rw-r--r--src/newgrf_engine.cpp9
-rw-r--r--src/newgrf_engine.h2
3 files changed, 10 insertions, 13 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index bd0f9c317..c756aa46e 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -213,7 +213,7 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const
if (!this->CanCarryCargo()) return 0;
if (mail_capacity != NULL && this->type == VEH_AIRCRAFT && IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
- *mail_capacity = GetVehicleProperty(v, PROP_AIRCRAFT_MAIL_CAPACITY, this->u.air.mail_capacity);
+ *mail_capacity = GetEngineProperty(this->index, PROP_AIRCRAFT_MAIL_CAPACITY, this->u.air.mail_capacity, v);
}
CargoID default_cargo = this->GetDefaultCargoType();
@@ -228,10 +228,10 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const
/* Get capacity according to property resp. CB */
uint capacity;
switch (this->type) {
- case VEH_TRAIN: capacity = GetVehicleProperty(v, PROP_TRAIN_CARGO_CAPACITY, this->u.rail.capacity); break;
- case VEH_ROAD: capacity = GetVehicleProperty(v, PROP_ROADVEH_CARGO_CAPACITY, this->u.road.capacity); break;
- case VEH_SHIP: capacity = GetVehicleProperty(v, PROP_SHIP_CARGO_CAPACITY, this->u.ship.capacity); break;
- case VEH_AIRCRAFT: capacity = GetVehicleProperty(v, PROP_AIRCRAFT_PASSENGER_CAPACITY, this->u.air.passenger_capacity); break;
+ case VEH_TRAIN: capacity = GetEngineProperty(this->index, PROP_TRAIN_CARGO_CAPACITY, this->u.rail.capacity, v); break;
+ case VEH_ROAD: capacity = GetEngineProperty(this->index, PROP_ROADVEH_CARGO_CAPACITY, this->u.road.capacity, v); break;
+ case VEH_SHIP: capacity = GetEngineProperty(this->index, PROP_SHIP_CARGO_CAPACITY, this->u.ship.capacity, v); break;
+ case VEH_AIRCRAFT: capacity = GetEngineProperty(this->index, PROP_AIRCRAFT_PASSENGER_CAPACITY, this->u.air.passenger_capacity, v); break;
default: NOT_REACHED();
}
@@ -240,7 +240,7 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const
if (this->type != VEH_SHIP) {
if (this->type == VEH_AIRCRAFT) {
if (!IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
- capacity += GetVehicleProperty(v, PROP_AIRCRAFT_MAIL_CAPACITY, this->u.air.mail_capacity);
+ capacity += GetEngineProperty(this->index, PROP_AIRCRAFT_MAIL_CAPACITY, this->u.air.mail_capacity, v);
}
if (v->cargo_type == CT_MAIL) return capacity;
} else {
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index f13543f08..69cbe4a56 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -1079,16 +1079,13 @@ uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param
/* Callback 36 handlers */
uint GetVehicleProperty(const Vehicle *v, PropertyID 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;
+ return GetEngineProperty(v->engine_type, property, orig_value, v);
}
-uint GetEngineProperty(EngineID engine, PropertyID property, uint orig_value)
+uint GetEngineProperty(EngineID engine, PropertyID property, uint orig_value, const Vehicle *v)
{
- uint16 callback = GetVehicleCallback(CBID_VEHICLE_MODIFY_PROPERTY, property, 0, engine, NULL);
+ uint16 callback = GetVehicleCallback(CBID_VEHICLE_MODIFY_PROPERTY, property, 0, engine, v);
if (callback != CALLBACK_FAILED) return callback;
return orig_value;
diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h
index 017a7e87b..f63b446a6 100644
--- a/src/newgrf_engine.h
+++ b/src/newgrf_engine.h
@@ -46,7 +46,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, PropertyID property, uint orig_value);
-uint GetEngineProperty(EngineID engine, PropertyID property, uint orig_value);
+uint GetEngineProperty(EngineID engine, PropertyID property, uint orig_value, const Vehicle *v = NULL);
enum VehicleTrigger {
VEHICLE_TRIGGER_NEW_CARGO = 0x01,