summaryrefslogtreecommitdiff
path: root/vehicle.h
diff options
context:
space:
mode:
authorhackykid <hackykid@openttd.org>2005-06-05 15:37:00 +0000
committerhackykid <hackykid@openttd.org>2005-06-05 15:37:00 +0000
commiteb173099e92b0004fb9fd23253d9500481079a52 (patch)
tree6e71df41bc09c11b7f906d7ef2ea613673f6e33c /vehicle.h
parent9ac03e71816b2d9227e4705f7ec5166bfdd710eb (diff)
downloadopenttd-eb173099e92b0004fb9fd23253d9500481079a52.tar.xz
(svn r2411) - Codechange: Have trains cache stuff like consist power/weight/max speed instead of recalculating it each time.
- Fix: Station ratings now depends on the max speed of a consist, without being affected by other speed limits from realistic acceleration.
Diffstat (limited to 'vehicle.h')
-rw-r--r--vehicle.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/vehicle.h b/vehicle.h
index a760cbf2b..96a4d22df 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -50,8 +50,12 @@ typedef struct VehicleRail {
uint16 crash_anim_pos;
uint16 days_since_order_progr;
- uint16 cached_weight; // cached power and weight for the vehicle.
- uint32 cached_power; // no need to save those, they are recomputed on load.
+ // cached values, recalculated on load and each time a vehicle is added to/removed from the consist.
+ uint16 cached_max_speed; // max speed of the consist. (minimum of the max speed of all vehicles in the consist)
+ uint32 cached_power; // total power of the consist.
+ // cached values, recalculated when the cargo on a train changes (in addition to the conditions above)
+ uint16 cached_weight; // total weight of the consist.
+ uint16 cached_veh_weight; // weight of the vehicle.
// NOSAVE: for wagon override - id of the first engine in train
// 0xffff == not in train
@@ -307,6 +311,7 @@ UnitID GetFreeUnitNumber(byte type);
int LoadUnloadVehicle(Vehicle *v);
+void TrainConsistChanged(Vehicle *v);
void UpdateTrainAcceleration(Vehicle *v);
int32 GetTrainRunningCost(const Vehicle *v);