diff options
-rw-r--r-- | projects/openttd_vs80.vcproj | 4 | ||||
-rw-r--r-- | projects/openttd_vs90.vcproj | 4 | ||||
-rw-r--r-- | source.list | 1 | ||||
-rw-r--r-- | src/aircraft_cmd.cpp | 4 | ||||
-rw-r--r-- | src/engine.cpp | 32 | ||||
-rw-r--r-- | src/newgrf.cpp | 34 | ||||
-rw-r--r-- | src/newgrf_engine.cpp | 4 | ||||
-rw-r--r-- | src/newgrf_engine.h | 5 | ||||
-rw-r--r-- | src/newgrf_properties.h | 43 | ||||
-rw-r--r-- | src/rail_cmd.cpp | 2 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 4 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 8 | ||||
-rw-r--r-- | src/train_cmd.cpp | 14 |
13 files changed, 106 insertions, 53 deletions
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj index e2ffffde7..cc42e9e96 100644 --- a/projects/openttd_vs80.vcproj +++ b/projects/openttd_vs80.vcproj @@ -1208,6 +1208,10 @@ > </File> <File + RelativePath=".\..\src\newgrf_properties.h" + > + </File> + <File RelativePath=".\..\src\newgrf_sound.h" > </File> diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj index 8d4f8304e..c58155b4b 100644 --- a/projects/openttd_vs90.vcproj +++ b/projects/openttd_vs90.vcproj @@ -1205,6 +1205,10 @@ > </File> <File + RelativePath=".\..\src\newgrf_properties.h" + > + </File> + <File RelativePath=".\..\src\newgrf_sound.h" > </File> diff --git a/source.list b/source.list index 777d78330..62159f8c6 100644 --- a/source.list +++ b/source.list @@ -207,6 +207,7 @@ newgrf_generic.h newgrf_house.h newgrf_industries.h newgrf_industrytiles.h +newgrf_properties.h newgrf_sound.h newgrf_spritegroup.h newgrf_station.h diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index b979ac8cf..3defb067e 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -619,7 +619,7 @@ static void CheckIfAircraftNeedsService(Aircraft *v) 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 @@ static void PlayAircraftSound(const Vehicle *v) 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; diff --git a/src/engine.cpp b/src/engine.cpp index 8d0983380..c7f6b440b 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -172,13 +172,13 @@ uint Engine::GetDisplayDefaultCapacity() const 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 +194,13 @@ Money Engine::GetRunningCost() const 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 +210,19 @@ Money Engine::GetCost() const { 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 +236,13 @@ uint Engine::GetDisplayMaxSpeed() const { 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 +256,7 @@ uint Engine::GetPower() const /* 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 +272,7 @@ uint Engine::GetDisplayWeight() const /* 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 +288,7 @@ uint Engine::GetDisplayMaxTractiveEffort() const /* 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(); } diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 58773ec7b..2a46c1a13 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -506,14 +506,14 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop rvi->ai_passenger_only = grf_load_byte(&buf); break; - case 0x09: { // Speed (1 unit is 1 kmh) + case PROP_TRAIN_SPEED: { // 0x09 Speed (1 unit is 1 km-ish/h) uint16 speed = grf_load_word(&buf); if (speed == 0xFFFF) speed = 0; rvi->max_speed = speed; } break; - case 0x0B: // Power + case PROP_TRAIN_POWER: // 0x0B Power rvi->power = grf_load_word(&buf); /* Set engine / wagon state based on power */ @@ -526,7 +526,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop } break; - case 0x0D: // Running cost factor + case PROP_TRAIN_RUNNING_COST_FACTOR: // 0x0D Running cost factor rvi->running_cost = grf_load_byte(&buf); break; @@ -567,7 +567,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop } } break; - case 0x14: // Cargo capacity + case PROP_TRAIN_CARGO_CAPACITY: // 0x14 Cargo capacity rvi->capacity = grf_load_byte(&buf); break; @@ -585,11 +585,11 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop } } break; - case 0x16: // Weight + case PROP_TRAIN_WEIGHT: // 0x16 Weight SB(rvi->weight, 0, 8, grf_load_byte(&buf)); break; - case 0x17: // Cost factor + case PROP_TRAIN_COST_FACTOR: // 0x17 Cost factor rvi->cost_factor = grf_load_byte(&buf); break; @@ -653,7 +653,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop ei->callback_mask = grf_load_byte(&buf); break; - case 0x1F: // Tractive effort coefficient + case PROP_TRAIN_TRACTIVE_EFFORT: // 0x1F Tractive effort coefficient rvi->tractive_effort = grf_load_byte(&buf); break; @@ -686,7 +686,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop } } break; - case 0x25: // User-defined bit mask to set when checking veh. var. 42 + case PROP_TRAIN_USER_DATA: // 0x25 User-defined bit mask to set when checking veh. var. 42 rvi->user_def_data = grf_load_byte(&buf); break; @@ -769,7 +769,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop rvi->image_index = spriteid; } break; - case 0x0F: // Cargo capacity + case PROP_ROADVEH_CARGO_CAPACITY: // 0x0F Cargo capacity rvi->capacity = grf_load_byte(&buf); break; @@ -786,7 +786,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop } } break; - case 0x11: // Cost factor + case PROP_ROADVEH_COST_FACTOR: // 0x11 Cost factor rvi->cost_factor = grf_load_byte(&buf); break; @@ -887,11 +887,11 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop svi->refittable = (grf_load_byte(&buf) != 0); break; - case 0x0A: // Cost factor + case PROP_SHIP_COST_FACTOR: // 0x0A Cost factor svi->cost_factor = grf_load_byte(&buf); break; - case 0x0B: // Speed (1 unit is 0.5 kmh) + case PROP_SHIP_SPEED: // 0x0B Speed (1 unit is 0.5 km-ish/h) svi->max_speed = grf_load_byte(&buf); break; @@ -908,11 +908,11 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop } } break; - case 0x0D: // Cargo capacity + case PROP_SHIP_CARGO_CAPACITY: // 0x0D Cargo capacity svi->capacity = grf_load_word(&buf); break; - case 0x0F: // Running cost factor + case PROP_SHIP_RUNNING_COST_FACTOR: // 0x0F Running cost factor svi->running_cost = grf_load_byte(&buf); break; @@ -1008,11 +1008,11 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int SB(avi->subtype, 1, 1, (grf_load_byte(&buf) != 0 ? 1 : 0)); // AIR_FAST break; - case 0x0B: // Cost factor + case PROP_AIRCRAFT_COST_FACTOR: // 0x0B Cost factor avi->cost_factor = grf_load_byte(&buf); break; - case 0x0C: // Speed (1 unit is 8 mph, we translate to 1 unit is 1 km/h) + case PROP_AIRCRAFT_SPEED: // 0x0C Speed (1 unit is 8 mph, we translate to 1 unit is 1 km/h) avi->max_speed = (grf_load_byte(&buf) * 129) / 10; break; @@ -1020,7 +1020,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int avi->acceleration = (grf_load_byte(&buf) * 129) / 10; break; - case 0x0E: // Running cost factor + case PROP_AIRCRAFT_RUNNING_COST_FACTOR: // 0x0E Running cost factor avi->running_cost = grf_load_byte(&buf); break; diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index e85449548..4a566fe30 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -1026,7 +1026,7 @@ uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param /* Callback 36 handlers */ -uint GetVehicleProperty(const Vehicle *v, uint8 property, uint orig_value) +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; @@ -1035,7 +1035,7 @@ uint GetVehicleProperty(const Vehicle *v, uint8 property, uint orig_value) } -uint GetEngineProperty(EngineID engine, uint8 property, uint orig_value) +uint GetEngineProperty(EngineID engine, PropertyID property, uint orig_value) { uint16 callback = GetVehicleCallback(CBID_VEHICLE_MODIFY_PROPERTY, property, 0, engine, NULL); if (callback != CALLBACK_FAILED) return callback; diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h index aef412b63..e62150ab6 100644 --- a/src/newgrf_engine.h +++ b/src/newgrf_engine.h @@ -14,6 +14,7 @@ #include "direction_type.h" #include "newgrf_callbacks.h" +#include "newgrf_properties.h" enum { TRAININFO_DEFAULT_VEHICLE_WIDTH = 29, @@ -45,8 +46,8 @@ 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); +uint GetVehicleProperty(const Vehicle *v, PropertyID property, uint orig_value); +uint GetEngineProperty(EngineID engine, PropertyID property, uint orig_value); enum VehicleTrigger { VEHICLE_TRIGGER_NEW_CARGO = 0x01, diff --git a/src/newgrf_properties.h b/src/newgrf_properties.h new file mode 100644 index 000000000..7786faf89 --- /dev/null +++ b/src/newgrf_properties.h @@ -0,0 +1,43 @@ +/* $Id$ */ + +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + */ + +/** @file newgrf_properties.h Properties of NewGRF Action 0. */ + +#ifndef NEWGRF_PROPERTIES_H +#define NEWGRF_PROPERTIES_H + +/** + * List of NewGRF properties used in Action 0 or Callback 0x36 (CBID_VEHICLE_MODIFY_PROPERTY). + * Names are formatted as PROP_<CLASS>_<NAME> + * @todo Currently the list only contains properties which are used more than once in the code. I.e. they are available for callback 0x36. + */ +enum PropertyID { + PROP_TRAIN_SPEED = 0x09, ///< Max. speed: 1 unit = 1/1.6 mph = 1 km-ish/h + PROP_TRAIN_POWER = 0x0B, ///< Power in hp (if dualheaded: sum of both vehicles) + PROP_TRAIN_RUNNING_COST_FACTOR = 0x0D, ///< Yearly runningcost (if dualheaded: sum of both vehicles) + PROP_TRAIN_CARGO_CAPACITY = 0x14, ///< Capacity (if dualheaded: for each single vehicle) + PROP_TRAIN_WEIGHT = 0x16, ///< Weight in t (if dualheaded: for each single vehicle) + PROP_TRAIN_COST_FACTOR = 0x17, ///< Purchase cost (if dualheaded: sum of both vehicles) + PROP_TRAIN_TRACTIVE_EFFORT = 0x1F, ///< Tractive effort coefficient in 1/256 + PROP_TRAIN_USER_DATA = 0x25, ///< User defined data for vehicle variable 0x42 + + PROP_ROADVEH_CARGO_CAPACITY = 0x0F, ///< Capacity + PROP_ROADVEH_COST_FACTOR = 0x11, ///< Purchase cost + + PROP_SHIP_COST_FACTOR = 0x0A, ///< Purchase cost + PROP_SHIP_SPEED = 0x0B, ///< Max. speed: 1 unit = 1/3.2 mph = 0.5 km-ish/h + PROP_SHIP_CARGO_CAPACITY = 0x0D, ///< Capacity + PROP_SHIP_RUNNING_COST_FACTOR = 0x0F, ///< Yearly runningcost + + PROP_AIRCRAFT_COST_FACTOR = 0x0B, ///< Purchase cost + PROP_AIRCRAFT_SPEED = 0x0C, ///< Max. speed: 1 unit = 8 mph = 12.8 km-ish/h + PROP_AIRCRAFT_RUNNING_COST_FACTOR = 0x0E, ///< Yearly runningcost +}; + +#endif /* NEWGRF_PROPERTIES_H */ diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 393b3c841..c32fc76b1 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1268,7 +1268,7 @@ Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data) if (t->IsArticulatedPart()) return NULL; const RailVehicleInfo *rvi = RailVehInfo(t->engine_type); - if (GetVehicleProperty(t, 0x0B, rvi->power) != 0) TrainPowerChanged(t->First()); + if (GetVehicleProperty(t, PROP_TRAIN_POWER, rvi->power) != 0) TrainPowerChanged(t->First()); return NULL; } diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index b1a9e3006..c0b511917 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -288,7 +288,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint 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 @@ CommandCost CmdRefitRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint * 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: diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 5aeebffee..cbfcb8d34 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -158,7 +158,7 @@ static void CheckIfShipNeedsService(Vehicle *v) 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 @@ static bool ShipAccelerate(Vehicle *v) 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 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 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 @@ CommandCost CmdRefitShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } 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; diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 78f19a17c..684a789b3 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -107,14 +107,14 @@ void TrainPowerChanged(Train *v) 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 @@ static void TrainCargoChanged(Train *v) /* 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 @@ void TrainConsistChanged(Train *v, bool same_length) 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 @@ void TrainConsistChanged(Train *v, bool same_length) /* 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 @@ Money Train::GetRunningCost() const 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 */ |