Changeset - r14393:2a8179560351
[Not reviewed]
master
0 1 0
terkhen - 14 years ago 2010-01-30 10:41:15
terkhen@openttd.org
(svn r18960) -Codechange: Move acceleration-related values to a separated cache.
1 file changed with 20 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/train.h
Show inline comments
 
@@ -56,25 +56,33 @@ bool TryPathReserve(Train *v, bool mark_
 

	
 
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
 
	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 max. speed / acceleration data */
 
	uint16 cached_max_speed;    ///< max speed of the consist. (minimum of the max speed of all vehicles in the consist)
0 comments (0 inline, 0 general)