diff options
author | terkhen <terkhen@openttd.org> | 2010-10-30 14:31:49 +0000 |
---|---|---|
committer | terkhen <terkhen@openttd.org> | 2010-10-30 14:31:49 +0000 |
commit | c87e023d7a4e594eac97e371cbe6ce515402bec1 (patch) | |
tree | e95e729d682f8f6f0a3c444910b5cb6a16dc06d8 | |
parent | 0baf335be3af23144a61a7230686b8811dc953ba (diff) | |
download | openttd-c87e023d7a4e594eac97e371cbe6ce515402bec1.tar.xz |
(svn r21058) -Feature [NewGRF]: Add CB36 support for road vehicle properties 0x13 (Power), 0x14 (Weight) and 0x18 (Tractive effort).
-rw-r--r-- | src/engine.cpp | 6 | ||||
-rw-r--r-- | src/newgrf.cpp | 6 | ||||
-rw-r--r-- | src/newgrf_properties.h | 3 | ||||
-rw-r--r-- | src/roadveh.h | 11 |
4 files changed, 17 insertions, 9 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index e563ac9f5..55358b63f 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -319,7 +319,7 @@ uint Engine::GetPower() const case VEH_TRAIN: return GetEngineProperty(this->index, PROP_TRAIN_POWER, this->u.rail.power); case VEH_ROAD: - return this->u.road.power * 10; + return GetEngineProperty(this->index, PROP_ROADVEH_POWER, this->u.road.power) * 10; default: NOT_REACHED(); } @@ -337,7 +337,7 @@ uint Engine::GetDisplayWeight() const case VEH_TRAIN: return GetEngineProperty(this->index, PROP_TRAIN_WEIGHT, this->u.rail.weight) << (this->u.rail.railveh_type == RAILVEH_MULTIHEAD ? 1 : 0); case VEH_ROAD: - return this->u.road.weight / 4; + return GetEngineProperty(this->index, PROP_ROADVEH_WEIGHT, this->u.road.weight) / 4; default: NOT_REACHED(); } @@ -355,7 +355,7 @@ uint Engine::GetDisplayMaxTractiveEffort() const case VEH_TRAIN: return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_TRAIN_TRACTIVE_EFFORT, this->u.rail.tractive_effort)) / 256; case VEH_ROAD: - return (10 * this->GetDisplayWeight() * this->u.road.tractive_effort) / 256; + return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_ROADVEH_TRACTIVE_EFFORT, this->u.road.tractive_effort)) / 256; default: NOT_REACHED(); } diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 9628fce84..d2db54e3d 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -824,11 +824,11 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop rvi->sfx = buf->ReadByte(); break; - case 0x13: // Power in 10hp + case PROP_ROADVEH_POWER: // Power in units of 10 HP. rvi->power = buf->ReadByte(); break; - case 0x14: // Weight in 1/4 tons + case PROP_ROADVEH_WEIGHT: // Weight in units of 1/4 tons. rvi->weight = buf->ReadByte(); break; @@ -845,7 +845,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop ei->callback_mask = buf->ReadByte(); break; - case 0x18: // Tractive effort + case PROP_ROADVEH_TRACTIVE_EFFORT: // Tractive effort coefficient in 1/256. rvi->tractive_effort = buf->ReadByte(); break; diff --git a/src/newgrf_properties.h b/src/newgrf_properties.h index 2f21352e0..fc46aea2e 100644 --- a/src/newgrf_properties.h +++ b/src/newgrf_properties.h @@ -30,6 +30,9 @@ enum PropertyID { PROP_ROADVEH_RUNNING_COST_FACTOR = 0x09, ///< Yearly runningcost PROP_ROADVEH_CARGO_CAPACITY = 0x0F, ///< Capacity PROP_ROADVEH_COST_FACTOR = 0x11, ///< Purchase cost + PROP_ROADVEH_POWER = 0x13, ///< Power in 10 HP + PROP_ROADVEH_WEIGHT = 0x14, ///< Weight in 1/4 t + PROP_ROADVEH_TRACTIVE_EFFORT = 0x18, ///< Tractive effort coefficient in 1/256 PROP_SHIP_COST_FACTOR = 0x0A, ///< Purchase cost PROP_SHIP_SPEED = 0x0B, ///< Max. speed: 1 unit = 1/3.2 mph = 0.5 km-ish/h diff --git a/src/roadveh.h b/src/roadveh.h index 85db80ccf..8a424dd34 100644 --- a/src/roadveh.h +++ b/src/roadveh.h @@ -17,6 +17,8 @@ #include "cargotype.h" #include "track_func.h" #include "road_type.h" +#include "newgrf_properties.h" +#include "newgrf_engine.h" struct RoadVehicle; @@ -171,7 +173,8 @@ protected: // These functions should not be called outside acceleration code. { /* Power is not added for articulated parts */ if (!this->IsArticulatedPart()) { - return 10 * RoadVehInfo(this->engine_type)->power; // Road vehicle power is in units of 10 HP. + /* Road vehicle power is in units of 10 HP. */ + return 10 * GetVehicleProperty(this, PROP_ROADVEH_POWER, RoadVehInfo(this->engine_type)->power); } return 0; } @@ -195,7 +198,8 @@ protected: // These functions should not be called outside acceleration code. /* Vehicle weight is not added for articulated parts. */ if (!this->IsArticulatedPart()) { - weight += RoadVehInfo(this->engine_type)->weight / 4; // Road vehicle weight is in units of 1/4 t. + /* Road vehicle weight is in units of 1/4 t. */ + weight += GetVehicleProperty(this, PROP_ROADVEH_WEIGHT, RoadVehInfo(this->engine_type)->weight) / 4; } return weight; @@ -207,7 +211,8 @@ protected: // These functions should not be called outside acceleration code. */ FORCEINLINE byte GetTractiveEffort() const { - return RoadVehInfo(this->engine_type)->tractive_effort; + /* The tractive effort coefficient is in units of 1/256. */ + return GetVehicleProperty(this, PROP_ROADVEH_TRACTIVE_EFFORT, RoadVehInfo(this->engine_type)->tractive_effort); } /** |