(svn r16480) -Fix (r15617): Invalidate newgrf variable caches of more vehicles in more places. Esp. they were only invalidated for trains.

This commit is contained in:
frosch
2009-05-31 12:03:14 +00:00
parent 749c976e47
commit 6e06b592ad
7 changed files with 44 additions and 4 deletions

View File

@@ -137,6 +137,8 @@ void RoadVehUpdateCache(RoadVehicle *v)
assert(v->type == VEH_ROAD);
assert(IsRoadVehFront(v));
v->InvalidateNewGRFCacheOfChain();
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
/* Check the v->first cache. */
assert(u->First() == v);
@@ -252,12 +254,15 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
v->cargo_cap = rvi->capacity;
AddArticulatedParts(v, VEH_ROAD);
v->InvalidateNewGRFCacheOfChain();
/* Call various callbacks after the whole consist has been constructed */
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
u->rcache.cached_veh_length = GetRoadVehLength(u);
/* Cargo capacity is zero if and only if the vehicle cannot carry anything */
if (u->cargo_cap != 0) u->cargo_cap = GetVehicleProperty(u, 0x0F, u->cargo_cap);
v->InvalidateNewGRFCache();
u->InvalidateNewGRFCache();
}
VehicleMove(v, false);