diff --git a/src/engine.cpp b/src/engine.cpp index ac2e8df0e..a416f4a21 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -429,14 +429,8 @@ uint Engine::GetDisplayWeight() const uint Engine::GetDisplayMaxTractiveEffort() const { /* Only trains and road vehicles have 'tractive effort'. */ - switch (this->type) { - 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() * GetEngineProperty(this->index, PROP_ROADVEH_TRACTIVE_EFFORT, this->u.road.tractive_effort)) / 256; - - default: NOT_REACHED(); - } + assert(this->type == VEH_TRAIN || this->type == VEH_ROAD); + return (GROUND_ACCELERATION * this->GetDisplayWeight() * GetEngineProperty(this->index, this->type==VEH_TRAIN?PROP_TRAIN_TRACTIVE_EFFORT:PROP_ROADVEH_TRACTIVE_EFFORT, this->u.rail.tractive_effort)) / 256 / 1000; } /** diff --git a/src/ground_vehicle.cpp b/src/ground_vehicle.cpp index f8efd8e1a..6fd8d7710 100644 --- a/src/ground_vehicle.cpp +++ b/src/ground_vehicle.cpp @@ -58,7 +58,7 @@ void GroundVehicle::PowerChanged() this->gcache.cached_air_drag = air_drag + 3 * air_drag * number_of_parts / 20; - max_te *= 9800; // Tractive effort in (tonnes * 1000 * 9.8 =) N. + max_te *= GROUND_ACCELERATION; // Tractive effort in (tonnes * 1000 * 9.8 =) N. max_te /= 256; // Tractive effort is a [0-255] coefficient. if (this->gcache.cached_power != total_power || this->gcache.cached_max_te != max_te) { /* Stop the vehicle if it has no power. */ diff --git a/src/vehicle_type.h b/src/vehicle_type.h index 0921b39e3..f3e7d535f 100644 --- a/src/vehicle_type.h +++ b/src/vehicle_type.h @@ -17,6 +17,8 @@ /** The type all our vehicle IDs have. */ typedef uint32 VehicleID; +static const int GROUND_ACCELERATION = 9800; ///< Acceleration due to gravity, 9.8 m/s^2 + /** Available vehicle types. */ enum VehicleType { VEH_BEGIN,