Index: src/train.h =================================================================== --- src/train.h (revisión: 17597) +++ src/train.h (copia de trabajo) @@ -365,4 +365,16 @@ #define FOR_ALL_TRAINS(var) FOR_ALL_VEHICLES_OF_TYPE(Train, var) +/* List of all train properties supported by NewGRF Callback 36 */ +enum TrainProperty { + PROP_TRAIN_SPEED = 0x09, + PROP_TRAIN_POWER = 0x0B, + PROP_TRAIN_RUNNING_COST_FACTOR = 0x0D, + PROP_TRAIN_CARGO_CAPACITY = 0x14, + PROP_TRAIN_WEIGHT = 0x16, + PROP_TRAIN_COST_FACTOR = 0x17, + PROP_TRAIN_TRACTIVE_EFFORT = 0x1F, + PROP_TRAIN_USER_DATA = 0x25, +}; + #endif /* TRAIN_H */ Index: src/ship_cmd.cpp =================================================================== --- src/ship_cmd.cpp (revisión: 17597) +++ src/ship_cmd.cpp (copia de trabajo) @@ -158,7 +158,7 @@ Money Ship::GetRunningCost() const { - return GetVehicleProperty(this, 0x0F, ShipVehInfo(this->engine_type)->running_cost) * _price.ship_running; + return GetVehicleProperty(this, PROP_SHIP_RUNNING_COST_FACTOR, ShipVehInfo(this->engine_type)->running_cost) * _price.ship_running; } void Ship::OnNewDay() @@ -334,7 +334,7 @@ uint spd; byte t; - spd = min(v->cur_speed + 1, GetVehicleProperty(v, 0x0B, v->max_speed)); + spd = min(v->cur_speed + 1, GetVehicleProperty(v, PROP_SHIP_SPEED, v->max_speed)); /* updates statusbar only if speed have changed to save CPU time */ if (spd != v->cur_speed) { @@ -815,7 +815,7 @@ v->InvalidateNewGRFCacheOfChain(); - v->cargo_cap = GetVehicleProperty(v, 0x0D, svi->capacity); + v->cargo_cap = GetVehicleProperty(v, PROP_SHIP_CARGO_CAPACITY, svi->capacity); v->InvalidateNewGRFCacheOfChain(); @@ -942,7 +942,7 @@ } if (capacity == CALLBACK_FAILED) { - capacity = GetVehicleProperty(v, 0x0D, ShipVehInfo(v->engine_type)->capacity); + capacity = GetVehicleProperty(v, PROP_SHIP_CARGO_CAPACITY, ShipVehInfo(v->engine_type)->capacity); } _returned_refit_capacity = capacity; Index: src/roadveh.h =================================================================== --- src/roadveh.h (revisión: 17597) +++ src/roadveh.h (copia de trabajo) @@ -164,4 +164,10 @@ #define FOR_ALL_ROADVEHICLES(var) FOR_ALL_VEHICLES_OF_TYPE(RoadVehicle, var) +/* List of all road vehicle properties supported by NewGRF Callback 36 */ +enum RoadVehicleProperty { + PROP_ROADVEH_CARGO_CAPACITY = 0x0F, + PROP_ROADVEH_COST_FACTOR = 0x11, +}; + #endif /* ROADVEH_H */ Index: src/train_cmd.cpp =================================================================== --- src/train_cmd.cpp (revisión: 17597) +++ src/train_cmd.cpp (copia de trabajo) @@ -107,14 +107,14 @@ const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type); if (engine_has_power) { - uint16 power = GetVehicleProperty(u, 0x0B, rvi_u->power); + uint16 power = GetVehicleProperty(u, PROP_TRAIN_POWER, rvi_u->power); if (power != 0) { /* Halve power for multiheaded parts */ if (u->IsMultiheaded()) power /= 2; total_power += power; /* Tractive effort in (tonnes * 1000 * 10 =) N */ - max_te += (u->tcache.cached_veh_weight * 10000 * GetVehicleProperty(u, 0x1F, rvi_u->tractive_effort)) / 256; + max_te += (u->tcache.cached_veh_weight * 10000 * GetVehicleProperty(u, PROP_TRAIN_TRACTIVE_EFFORT, rvi_u->tractive_effort)) / 256; } } } @@ -151,7 +151,7 @@ /* Vehicle weight is not added for articulated parts. */ if (!u->IsArticulatedPart()) { /* vehicle weight is the sum of the weight of the vehicle and the weight of its cargo */ - vweight += GetVehicleProperty(u, 0x16, RailVehInfo(u->engine_type)->weight); + vweight += GetVehicleProperty(u, PROP_TRAIN_WEIGHT, RailVehInfo(u->engine_type)->weight); } /* powered wagons have extra weight added */ @@ -253,7 +253,7 @@ for (Train *u = v; u != NULL; u = u->Next()) { /* Update user defined data (must be done before other properties) */ - u->tcache.user_def_data = GetVehicleProperty(u, 0x25, u->tcache.user_def_data); + u->tcache.user_def_data = GetVehicleProperty(u, PROP_TRAIN_USER_DATA, u->tcache.user_def_data); v->InvalidateNewGRFCache(); u->InvalidateNewGRFCache(); } @@ -316,14 +316,14 @@ /* max speed is the minimum of the speed limits of all vehicles in the consist */ if ((rvi_u->railveh_type != RAILVEH_WAGON || _settings_game.vehicle.wagon_speed_limits) && !UsesWagonOverride(u)) { - uint16 speed = GetVehicleProperty(u, 0x09, rvi_u->max_speed); + uint16 speed = GetVehicleProperty(u, PROP_TRAIN_SPEED, rvi_u->max_speed); if (speed != 0) max_speed = min(speed, max_speed); } } if (e_u->CanCarryCargo() && u->cargo_type == e_u->GetDefaultCargoType() && u->cargo_subtype == 0) { /* Set cargo capacity if we've not been refitted */ - u->cargo_cap = GetVehicleProperty(u, 0x14, rvi_u->capacity); + u->cargo_cap = GetVehicleProperty(u, PROP_TRAIN_CARGO_CAPACITY, rvi_u->capacity); } /* check the vehicle length (callback) */ @@ -4491,7 +4491,7 @@ do { const RailVehicleInfo *rvi = RailVehInfo(v->engine_type); - byte cost_factor = GetVehicleProperty(v, 0x0D, rvi->running_cost); + byte cost_factor = GetVehicleProperty(v, PROP_TRAIN_RUNNING_COST_FACTOR, rvi->running_cost); if (cost_factor == 0) continue; /* Halve running cost for multiheaded parts */ Index: src/aircraft.h =================================================================== --- src/aircraft.h (revisión: 17597) +++ src/aircraft.h (copia de trabajo) @@ -135,4 +135,11 @@ Station *GetTargetAirportIfValid(const Aircraft *v); +/* List of all aircraft properties supported by NewGRF Callback 36 */ +enum AircraftProperty { + PROP_AIRCRAFT_COST_FACTOR = 0x0B, + PROP_AIRCRAFT_SPEED = 0x0C, + PROP_AIRCRAFT_RUNNING_COST_FACTOR = 0x0E, +}; + #endif /* AIRCRAFT_H */ Index: src/ship.h =================================================================== --- src/ship.h (revisión: 17597) +++ src/ship.h (copia de trabajo) @@ -52,4 +52,12 @@ #define FOR_ALL_SHIPS(var) FOR_ALL_VEHICLES_OF_TYPE(Ship, var) +/* List of all ship properties supported by NewGRF Callback 36 */ +enum ShipProperty { + PROP_SHIP_COST_FACTOR = 0x0A, + PROP_SHIP_SPEED = 0x0B, + PROP_SHIP_CARGO_CAPACITY = 0x0D, + PROP_SHIP_RUNNING_COST_FACTOR = 0x0F, +}; + #endif /* SHIP_H */ Index: src/roadveh_cmd.cpp =================================================================== --- src/roadveh_cmd.cpp (revisión: 17597) +++ src/roadveh_cmd.cpp (copia de trabajo) @@ -288,7 +288,7 @@ for (RoadVehicle *u = v; u != NULL; u = u->Next()) { u->rcache.cached_veh_length = GetRoadVehLength(u); /* Cargo capacity is zero if and only if the vehicle cannot carry anything */ - if (u->cargo_cap != 0) u->cargo_cap = GetVehicleProperty(u, 0x0F, u->cargo_cap); + if (u->cargo_cap != 0) u->cargo_cap = GetVehicleProperty(u, PROP_ROADVEH_CARGO_CAPACITY, u->cargo_cap); v->InvalidateNewGRFCache(); u->InvalidateNewGRFCache(); } @@ -2054,7 +2054,7 @@ * carry twice as much mail/goods as normal cargo, and four times as * many passengers */ - capacity = GetVehicleProperty(v, 0x0F, e->u.road.capacity); + capacity = GetVehicleProperty(v, PROP_ROADVEH_CARGO_CAPACITY, e->u.road.capacity); switch (old_cid) { case CT_PASSENGERS: break; case CT_MAIL: Index: src/engine.cpp =================================================================== --- src/engine.cpp (revisión: 17597) +++ src/engine.cpp (copia de trabajo) @@ -16,6 +16,9 @@ #include "news_func.h" #include "variables.h" #include "aircraft.h" +#include "roadveh.h" +#include "ship.h" +#include "train.h" #include "newgrf.h" #include "newgrf_engine.h" #include "group.h" @@ -172,13 +175,13 @@ if (!this->CanCarryCargo()) return 0; switch (type) { case VEH_TRAIN: - return GetEngineProperty(this->index, 0x14, this->u.rail.capacity) + (this->u.rail.railveh_type == RAILVEH_MULTIHEAD ? this->u.rail.capacity : 0); + return GetEngineProperty(this->index, PROP_TRAIN_CARGO_CAPACITY, this->u.rail.capacity) + (this->u.rail.railveh_type == RAILVEH_MULTIHEAD ? this->u.rail.capacity : 0); case VEH_ROAD: - return GetEngineProperty(this->index, 0x0F, this->u.road.capacity); + return GetEngineProperty(this->index, PROP_ROADVEH_CARGO_CAPACITY, this->u.road.capacity); case VEH_SHIP: - return GetEngineProperty(this->index, 0x0D, this->u.ship.capacity); + return GetEngineProperty(this->index, PROP_SHIP_CARGO_CAPACITY, this->u.ship.capacity); case VEH_AIRCRAFT: return AircraftDefaultCargoCapacity(this->GetDefaultCargoType(), &this->u.air); @@ -194,13 +197,13 @@ return this->u.road.running_cost * GetPriceByIndex(this->u.road.running_cost_class) >> 8; case VEH_TRAIN: - return GetEngineProperty(this->index, 0x0D, this->u.rail.running_cost) * GetPriceByIndex(this->u.rail.running_cost_class) >> 8; + return GetEngineProperty(this->index, PROP_TRAIN_RUNNING_COST_FACTOR, this->u.rail.running_cost) * GetPriceByIndex(this->u.rail.running_cost_class) >> 8; case VEH_SHIP: - return GetEngineProperty(this->index, 0x0F, this->u.ship.running_cost) * _price.ship_running >> 8; + return GetEngineProperty(this->index, PROP_SHIP_RUNNING_COST_FACTOR, this->u.ship.running_cost) * _price.ship_running >> 8; case VEH_AIRCRAFT: - return GetEngineProperty(this->index, 0x0E, this->u.air.running_cost) * _price.aircraft_running >> 8; + return GetEngineProperty(this->index, PROP_AIRCRAFT_RUNNING_COST_FACTOR, this->u.air.running_cost) * _price.aircraft_running >> 8; default: NOT_REACHED(); } @@ -210,19 +213,19 @@ { switch (this->type) { case VEH_ROAD: - return GetEngineProperty(this->index, 0x11, this->u.road.cost_factor) * (_price.roadveh_base >> 3) >> 5; + return GetEngineProperty(this->index, PROP_ROADVEH_COST_FACTOR, this->u.road.cost_factor) * (_price.roadveh_base >> 3) >> 5; case VEH_TRAIN: if (this->u.rail.railveh_type == RAILVEH_WAGON) { - return (GetEngineProperty(this->index, 0x17, this->u.rail.cost_factor) * _price.build_railwagon) >> 8; + return (GetEngineProperty(this->index, PROP_TRAIN_COST_FACTOR, this->u.rail.cost_factor) * _price.build_railwagon) >> 8; } else { - return GetEngineProperty(this->index, 0x17, this->u.rail.cost_factor) * (_price.build_railvehicle >> 3) >> 5; + return GetEngineProperty(this->index, PROP_TRAIN_COST_FACTOR, this->u.rail.cost_factor) * (_price.build_railvehicle >> 3) >> 5; } case VEH_SHIP: - return GetEngineProperty(this->index, 0x0A, this->u.ship.cost_factor) * (_price.ship_base >> 3) >> 5; + return GetEngineProperty(this->index, PROP_SHIP_COST_FACTOR, this->u.ship.cost_factor) * (_price.ship_base >> 3) >> 5; case VEH_AIRCRAFT: - return GetEngineProperty(this->index, 0x0B, this->u.air.cost_factor) * (_price.aircraft_base >> 3) >> 5; + return GetEngineProperty(this->index, PROP_AIRCRAFT_COST_FACTOR, this->u.air.cost_factor) * (_price.aircraft_base >> 3) >> 5; default: NOT_REACHED(); } @@ -236,13 +239,13 @@ { switch (this->type) { case VEH_TRAIN: - return GetEngineProperty(this->index, 0x09, this->u.rail.max_speed); + return GetEngineProperty(this->index, PROP_TRAIN_SPEED, this->u.rail.max_speed); case VEH_ROAD: return this->u.road.max_speed / 2; case VEH_SHIP: - return GetEngineProperty(this->index, 0x0B, this->u.ship.max_speed) / 2; + return GetEngineProperty(this->index, PROP_SHIP_SPEED, this->u.ship.max_speed) / 2; case VEH_AIRCRAFT: return this->u.air.max_speed; @@ -256,7 +259,7 @@ /* Currently only trains have 'power' */ switch (this->type) { case VEH_TRAIN: - return GetEngineProperty(this->index, 0x0B, this->u.rail.power); + return GetEngineProperty(this->index, PROP_TRAIN_POWER, this->u.rail.power); default: NOT_REACHED(); } @@ -272,7 +275,7 @@ /* Currently only trains have 'weight' */ switch (this->type) { case VEH_TRAIN: - return GetEngineProperty(this->index, 0x16, this->u.rail.weight) << (this->u.rail.railveh_type == RAILVEH_MULTIHEAD ? 1 : 0); + return GetEngineProperty(this->index, PROP_TRAIN_WEIGHT, this->u.rail.weight) << (this->u.rail.railveh_type == RAILVEH_MULTIHEAD ? 1 : 0); default: NOT_REACHED(); } @@ -288,7 +291,7 @@ /* Currently only trains have 'tractive effort' */ switch (this->type) { case VEH_TRAIN: - return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, 0x1F, this->u.rail.tractive_effort)) / 256; + return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_TRAIN_TRACTIVE_EFFORT, this->u.rail.tractive_effort)) / 256; default: NOT_REACHED(); } Index: src/aircraft_cmd.cpp =================================================================== --- src/aircraft_cmd.cpp (revisión: 17597) +++ src/aircraft_cmd.cpp (copia de trabajo) @@ -619,7 +619,7 @@ Money Aircraft::GetRunningCost() const { - return GetVehicleProperty(this, 0x0E, AircraftVehInfo(this->engine_type)->running_cost) * _price.aircraft_running; + return GetVehicleProperty(this, PROP_AIRCRAFT_RUNNING_COST_FACTOR, AircraftVehInfo(this->engine_type)->running_cost) * _price.aircraft_running; } void Aircraft::OnNewDay() @@ -753,7 +753,7 @@ void UpdateAircraftCache(Aircraft *v) { - uint max_speed = GetVehicleProperty(v, 0x0C, 0); + uint max_speed = GetVehicleProperty(v, PROP_AIRCRAFT_SPEED, 0); if (max_speed != 0) { /* Convert from original units to (approx) km/h */ max_speed = (max_speed * 129) / 10;