summaryrefslogtreecommitdiff
path: root/src/train.h
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/train.h
parentf4281020927f0ee63227d8195a3a1479489f970a (diff)
downloadopenttd-e4a5a556b4d9d6b74f2fcd2330997abb65a68d3b.tar.xz
(svn r19338) -Codechange: Move the acceleration cache to GroundVehicle.
Diffstat (limited to 'src/train.h')
-rw-r--r--src/train.h29
1 files changed, 3 insertions, 26 deletions
diff --git a/src/train.h b/src/train.h
index 89d9ce63c..bbb8ab3e9 100644
--- a/src/train.h
+++ b/src/train.h
@@ -56,25 +56,8 @@ 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
- uint16 cached_max_track_speed; ///< Max consist speed limited by track type
-};
-
/** Variables that are cached to improve performance and such */
-struct TrainCache : public AccelerationCache {
+struct TrainCache {
/* Cached wagon override spritegroup */
const struct SpriteGroup *cached_override;
@@ -102,12 +85,6 @@ struct TrainCache : public AccelerationCache {
EngineID first_engine; ///< cached EngineID of the front vehicle. INVALID_ENGINE for the front vehicle itself.
};
-/** What is the status of our acceleration? */
-enum AccelStatus {
- AS_ACCEL, ///< We want to go faster, if possible ofcourse
- AS_BRAKE ///< We want to stop
-};
-
/**
* 'Train' is either a loco or a wagon.
*/
@@ -486,9 +463,9 @@ protected: // These functions should not be called outside acceleration code.
for (const Train *u = this; u != NULL; u = u->Next()) {
if (HasBit(u->flags, VRF_GOINGUP)) {
- incl += u->tcache.cached_slope_resistance;
+ incl += u->acc_cache.cached_slope_resistance;
} else if (HasBit(u->flags, VRF_GOINGDOWN)) {
- incl -= u->tcache.cached_slope_resistance;
+ incl -= u->acc_cache.cached_slope_resistance;
}
}