(svn r21058) -Feature [NewGRF]: Add CB36 support for road vehicle properties 0x13 (Power), 0x14 (Weight) and 0x18 (Tractive effort).

pull/155/head
terkhen 14 years ago
parent bb07520982
commit 867f7b5f7b

@ -319,7 +319,7 @@ uint Engine::GetPower() const
case VEH_TRAIN: case VEH_TRAIN:
return GetEngineProperty(this->index, PROP_TRAIN_POWER, this->u.rail.power); return GetEngineProperty(this->index, PROP_TRAIN_POWER, this->u.rail.power);
case VEH_ROAD: case VEH_ROAD:
return this->u.road.power * 10; return GetEngineProperty(this->index, PROP_ROADVEH_POWER, this->u.road.power) * 10;
default: NOT_REACHED(); default: NOT_REACHED();
} }
@ -337,7 +337,7 @@ uint Engine::GetDisplayWeight() const
case VEH_TRAIN: case VEH_TRAIN:
return GetEngineProperty(this->index, PROP_TRAIN_WEIGHT, 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);
case VEH_ROAD: case VEH_ROAD:
return this->u.road.weight / 4; return GetEngineProperty(this->index, PROP_ROADVEH_WEIGHT, this->u.road.weight) / 4;
default: NOT_REACHED(); default: NOT_REACHED();
} }
@ -355,7 +355,7 @@ uint Engine::GetDisplayMaxTractiveEffort() const
case VEH_TRAIN: case VEH_TRAIN:
return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_TRAIN_TRACTIVE_EFFORT, this->u.rail.tractive_effort)) / 256; return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_TRAIN_TRACTIVE_EFFORT, this->u.rail.tractive_effort)) / 256;
case VEH_ROAD: 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(); default: NOT_REACHED();
} }

@ -824,11 +824,11 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
rvi->sfx = buf->ReadByte(); rvi->sfx = buf->ReadByte();
break; break;
case 0x13: // Power in 10hp case PROP_ROADVEH_POWER: // Power in units of 10 HP.
rvi->power = buf->ReadByte(); rvi->power = buf->ReadByte();
break; break;
case 0x14: // Weight in 1/4 tons case PROP_ROADVEH_WEIGHT: // Weight in units of 1/4 tons.
rvi->weight = buf->ReadByte(); rvi->weight = buf->ReadByte();
break; break;
@ -845,7 +845,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
ei->callback_mask = buf->ReadByte(); ei->callback_mask = buf->ReadByte();
break; break;
case 0x18: // Tractive effort case PROP_ROADVEH_TRACTIVE_EFFORT: // Tractive effort coefficient in 1/256.
rvi->tractive_effort = buf->ReadByte(); rvi->tractive_effort = buf->ReadByte();
break; break;

@ -30,6 +30,9 @@ enum PropertyID {
PROP_ROADVEH_RUNNING_COST_FACTOR = 0x09, ///< Yearly runningcost PROP_ROADVEH_RUNNING_COST_FACTOR = 0x09, ///< Yearly runningcost
PROP_ROADVEH_CARGO_CAPACITY = 0x0F, ///< Capacity PROP_ROADVEH_CARGO_CAPACITY = 0x0F, ///< Capacity
PROP_ROADVEH_COST_FACTOR = 0x11, ///< Purchase cost 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_COST_FACTOR = 0x0A, ///< Purchase cost
PROP_SHIP_SPEED = 0x0B, ///< Max. speed: 1 unit = 1/3.2 mph = 0.5 km-ish/h PROP_SHIP_SPEED = 0x0B, ///< Max. speed: 1 unit = 1/3.2 mph = 0.5 km-ish/h

@ -17,6 +17,8 @@
#include "cargotype.h" #include "cargotype.h"
#include "track_func.h" #include "track_func.h"
#include "road_type.h" #include "road_type.h"
#include "newgrf_properties.h"
#include "newgrf_engine.h"
struct RoadVehicle; struct RoadVehicle;
@ -171,7 +173,8 @@ protected: // These functions should not be called outside acceleration code.
{ {
/* Power is not added for articulated parts */ /* Power is not added for articulated parts */
if (!this->IsArticulatedPart()) { 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; return 0;
} }
@ -195,7 +198,8 @@ protected: // These functions should not be called outside acceleration code.
/* Vehicle weight is not added for articulated parts. */ /* Vehicle weight is not added for articulated parts. */
if (!this->IsArticulatedPart()) { 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; return weight;
@ -207,7 +211,8 @@ protected: // These functions should not be called outside acceleration code.
*/ */
FORCEINLINE byte GetTractiveEffort() const 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);
} }
/** /**

Loading…
Cancel
Save