summaryrefslogtreecommitdiff
path: root/src/train.h
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-03-06 12:27:23 +0000
committerterkhen <terkhen@openttd.org>2010-03-06 12:27:23 +0000
commitb5714c3597fc87219e3fa144ad181bfec707763d (patch)
tree10090e62415675601d795cf5eb2a740571c1b618 /src/train.h
parentd4b748e27e9a09ae407ba605453c46071a626e1b (diff)
downloadopenttd-b5714c3597fc87219e3fa144ad181bfec707763d.tar.xz
(svn r19336) -Codechange: Move rail speed limit to its own function.
Diffstat (limited to 'src/train.h')
-rw-r--r--src/train.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/train.h b/src/train.h
index aadb48981..70eed6854 100644
--- a/src/train.h
+++ b/src/train.h
@@ -70,6 +70,7 @@ struct AccelerationCache {
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; ///< Max consist speed limited by track type
};
/** Variables that are cached to improve performance and such */
@@ -86,7 +87,6 @@ struct TrainCache : public AccelerationCache {
/* cached max. speed / acceleration data */
uint16 cached_max_speed; ///< max speed of the consist. (minimum of the max speed of all vehicles in the consist)
- uint16 cached_max_rail_speed; ///< max consist speed limited by rail type
int cached_max_curve_speed; ///< max consist speed limited by curves
/**
@@ -512,6 +512,24 @@ protected: // These functions should not be called outside acceleration code.
{
return 20 * _settings_game.vehicle.train_slope_steepness; // 1% slope * slope steepness
}
+
+ /**
+ * Gets the maximum speed of the vehicle, ignoring the limitations of the kind of track the vehicle is on.
+ * @return Maximum speed of the vehicle.
+ */
+ FORCEINLINE uint16 GetInitialMaxSpeed() const
+ {
+ return this->tcache.cached_max_speed;
+ }
+
+ /**
+ * Gets the maximum speed allowed by the track for this vehicle.
+ * @return Maximum speed allowed.
+ */
+ FORCEINLINE uint16 GetMaxTrackSpeed() const
+ {
+ return GetRailTypeInfo(GetRailType(this->tile))->max_speed;
+ }
};
#define FOR_ALL_TRAINS(var) FOR_ALL_VEHICLES_OF_TYPE(Train, var)