(svn r18960) -Codechange: Move acceleration-related values to a separated cache.

This commit is contained in:
terkhen 2010-01-30 10:41:15 +00:00
parent 9e4a62d1ee
commit 72f4bd818c

View File

@ -56,26 +56,34 @@ bool TryPathReserve(Train *v, bool mark_as_stuck = false, bool first_tile_okay =
int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, int *station_ahead, int *station_length);
/**
* 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 train changes (in addition to the conditions above) */
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; ///< max 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
};
/** Variables that are cached to improve performance and such */
struct TrainCache {
struct TrainCache : public AccelerationCache {
/* Cached wagon override spritegroup */
const struct SpriteGroup *cached_override;
uint16 last_speed; // NOSAVE: only used in UI
/* 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.
uint16 cached_axle_resistance; ///< Resistance caused by the axles of the vehicle
uint32 cached_air_drag; ///< Air drag coefficient of the vehicle
uint16 cached_total_length; ///< Length of the whole train, valid only for first engine.
uint8 cached_veh_length; ///< length of this vehicle in units of 1/8 of normal length, cached because this can be set by a callback
bool cached_tilt; ///< train can tilt; feature provides a bonus in curves
/* cached values, recalculated when the cargo on a train changes (in addition to the conditions above) */
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; ///< max tractive effort of consist
/* 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)
int cached_max_curve_speed; ///< max consist speed limited by curves