Loading

depot_te.patch

  1. diff --git a/src/engine.cpp b/src/engine.cpp
  2. index ac2e8df0e..a416f4a21 100644
  3. --- a/src/engine.cpp
  4. +++ b/src/engine.cpp
  5. @@ -429,14 +429,8 @@ uint Engine::GetDisplayWeight() const
  6.  uint Engine::GetDisplayMaxTractiveEffort() const
  7.  {
  8.     /* Only trains and road vehicles have 'tractive effort'. */
  9. -   switch (this->type) {
  10. -       case VEH_TRAIN:
  11. -           return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_TRAIN_TRACTIVE_EFFORT, this->u.rail.tractive_effort)) / 256;
  12. -       case VEH_ROAD:
  13. -           return (10 * this->GetDisplayWeight() * GetEngineProperty(this->index, PROP_ROADVEH_TRACTIVE_EFFORT, this->u.road.tractive_effort)) / 256;
  14. -
  15. -       default: NOT_REACHED();
  16. -   }
  17. +   assert(this->type == VEH_TRAIN || this->type == VEH_ROAD);
  18. +   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;
  19.  }
  20.  
  21.  /**
  22. diff --git a/src/ground_vehicle.cpp b/src/ground_vehicle.cpp
  23. index f8efd8e1a..6fd8d7710 100644
  24. --- a/src/ground_vehicle.cpp
  25. +++ b/src/ground_vehicle.cpp
  26. @@ -58,7 +58,7 @@ void GroundVehicle<T, Type>::PowerChanged()
  27.  
  28.     this->gcache.cached_air_drag = air_drag + 3 * air_drag * number_of_parts / 20;
  29.  
  30. -   max_te *= 9800; // Tractive effort in (tonnes * 1000 * 9.8 =) N.
  31. +   max_te *= GROUND_ACCELERATION; // Tractive effort in (tonnes * 1000 * 9.8 =) N.
  32.     max_te /= 256;  // Tractive effort is a [0-255] coefficient.
  33.     if (this->gcache.cached_power != total_power || this->gcache.cached_max_te != max_te) {
  34.         /* Stop the vehicle if it has no power. */
  35. diff --git a/src/vehicle_type.h b/src/vehicle_type.h
  36. index 0921b39e3..f3e7d535f 100644
  37. --- a/src/vehicle_type.h
  38. +++ b/src/vehicle_type.h
  39. @@ -17,6 +17,8 @@
  40.  /** The type all our vehicle IDs have. */
  41.  typedef uint32 VehicleID;
  42.  
  43. +static const int GROUND_ACCELERATION = 9800; ///< Acceleration due to gravity, 9.8 m/s^2
  44. +
  45.  /** Available vehicle types. */
  46.  enum VehicleType {
  47.     VEH_BEGIN,

Comments