summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index ce3ab61d2..1d4b9774f 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -169,6 +169,8 @@ void RoadVehUpdateCache(RoadVehicle *v)
v->InvalidateNewGRFCacheOfChain();
+ v->rcache.cached_total_length = 0;
+
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
/* Check the v->first cache. */
assert(u->First() == v);
@@ -178,6 +180,7 @@ void RoadVehUpdateCache(RoadVehicle *v)
/* Update the length of the vehicle. */
u->rcache.cached_veh_length = GetRoadVehLength(u);
+ v->rcache.cached_total_length += u->rcache.cached_veh_length;
/* Invalidate the vehicle colour map */
u->colourmap = PAL_NONE;