summaryrefslogtreecommitdiff
path: root/src/ground_vehicle.hpp
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-03-06 12:42:53 +0000
committerterkhen <terkhen@openttd.org>2010-03-06 12:42:53 +0000
commite4a5a556b4d9d6b74f2fcd2330997abb65a68d3b (patch)
tree2ece3e246a052ad62735eb42d0f98c2e5d360717 /src/ground_vehicle.hpp
parentf4281020927f0ee63227d8195a3a1479489f970a (diff)
downloadopenttd-e4a5a556b4d9d6b74f2fcd2330997abb65a68d3b.tar.xz
(svn r19338) -Codechange: Move the acceleration cache to GroundVehicle.
Diffstat (limited to 'src/ground_vehicle.hpp')
-rw-r--r--src/ground_vehicle.hpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/ground_vehicle.hpp b/src/ground_vehicle.hpp
index e852fcee2..200d37830 100644
--- a/src/ground_vehicle.hpp
+++ b/src/ground_vehicle.hpp
@@ -14,11 +14,35 @@
#include "vehicle_base.h"
+/** What is the status of our acceleration? */
+enum AccelStatus {
+ AS_ACCEL, ///< We want to go faster, if possible of course.
+ AS_BRAKE ///< We want to stop.
+};
+
+/**
+ * Cached acceleration values.
+ * All of these values except cached_slope_resistance are set only for the first part of a vehicle.
+ */
+struct AccelerationCache {
+ /* Cached values, recalculated when the cargo on a vehicle changes (in addition to the conditions below) */
+ uint32 cached_weight; ///< Total weight of the consist.
+ uint32 cached_slope_resistance; ///< Resistance caused by weight when this vehicle part is at a slope.
+ uint32 cached_max_te; ///< Maximum tractive effort of consist.
+
+ /* Cached values, recalculated on load and each time a vehicle is added to/removed from the consist. */
+ uint32 cached_power; ///< Total power of the consist.
+ uint32 cached_air_drag; ///< Air drag coefficient of the vehicle.
+ uint16 cached_axle_resistance; ///< Resistance caused by the axles of the vehicle.
+ uint16 cached_max_track_speed; ///< Maximum consist speed limited by track type.
+};
+
/**
* Base class for all vehicles that move through ground.
*/
template <class T, VehicleType Type>
struct GroundVehicle : public SpecializedVehicle<T, Type> {
+ AccelerationCache acc_cache;
/**
* The constructor at SpecializedVehicle must be called.