mirror of https://github.com/OpenTTD/OpenTTD.git
(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:
parent
56988b198d
commit
9853c0dc22
|
@ -373,6 +373,8 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
|||
v->vehicle_flags = 0;
|
||||
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
|
||||
|
||||
v->InvalidateNewGRFCacheOfChain();
|
||||
|
||||
if (v->cargo_type != CT_PASSENGERS) {
|
||||
uint16 callback = CALLBACK_FAILED;
|
||||
|
||||
|
@ -391,6 +393,8 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
|||
u->cargo_cap = 0;
|
||||
}
|
||||
|
||||
v->InvalidateNewGRFCacheOfChain();
|
||||
|
||||
UpdateAircraftCache(v);
|
||||
|
||||
VehicleMove(v, false);
|
||||
|
@ -566,6 +570,7 @@ CommandCost CmdRefitAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
|||
v->cargo_type = new_cid;
|
||||
v->cargo_subtype = new_subtype;
|
||||
v->colourmap = PAL_NONE; // invalidate vehicle colour map
|
||||
v->InvalidateNewGRFCacheOfChain();
|
||||
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
|
||||
|
|
|
@ -122,7 +122,7 @@ CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
|||
/* Company colour data is indirectly cached. */
|
||||
Vehicle *v;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->owner == _current_company) v->vcache.cache_valid = 0;
|
||||
if (v->owner == _current_company) v->InvalidateNewGRFCache();
|
||||
}
|
||||
}
|
||||
return CommandCost();
|
||||
|
|
|
@ -1098,7 +1098,9 @@ void TriggerVehicle(Vehicle *v, VehicleTrigger trigger)
|
|||
VehicleEnteredDepotThisTick(v);
|
||||
}
|
||||
|
||||
v->InvalidateNewGRFCacheOfChain();
|
||||
DoTriggerVehicle(v, trigger, 0, true);
|
||||
v->InvalidateNewGRFCacheOfChain();
|
||||
}
|
||||
|
||||
/* Functions for changing the order of vehicle purchase lists
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -814,8 +814,12 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||
v->vehicle_flags = 0;
|
||||
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
|
||||
|
||||
v->InvalidateNewGRFCacheOfChain();
|
||||
|
||||
v->cargo_cap = GetVehicleProperty(v, 0x0D, svi->capacity);
|
||||
|
||||
v->InvalidateNewGRFCacheOfChain();
|
||||
|
||||
VehicleMove(v, false);
|
||||
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
|
@ -948,6 +952,7 @@ CommandCost CmdRefitShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
|||
v->cargo_type = new_cid;
|
||||
v->cargo_subtype = new_subtype;
|
||||
v->colourmap = PAL_NONE; // invalidate vehicle colour map
|
||||
v->InvalidateNewGRFCacheOfChain();
|
||||
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||
InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
|
||||
|
|
|
@ -241,13 +241,15 @@ void TrainConsistChanged(Train *v, bool same_length)
|
|||
|
||||
/* Set user defined data to its default value */
|
||||
u->tcache.user_def_data = rvi_u->user_def_data;
|
||||
u->vcache.cache_valid = 0;
|
||||
v->InvalidateNewGRFCache();
|
||||
u->InvalidateNewGRFCache();
|
||||
}
|
||||
|
||||
for (Train *u = v; u != NULL; u = u->Next()) {
|
||||
/* Update user defined data (must be done before other properties) */
|
||||
u->tcache.user_def_data = GetVehicleProperty(u, 0x25, u->tcache.user_def_data);
|
||||
u->vcache.cache_valid = 0;
|
||||
v->InvalidateNewGRFCache();
|
||||
u->InvalidateNewGRFCache();
|
||||
}
|
||||
|
||||
for (Train *u = v; u != NULL; u = u->Next()) {
|
||||
|
@ -333,7 +335,8 @@ void TrainConsistChanged(Train *v, bool same_length)
|
|||
if (!same_length) u->tcache.cached_veh_length = veh_len;
|
||||
|
||||
v->tcache.cached_total_length += u->tcache.cached_veh_length;
|
||||
u->vcache.cache_valid = 0;
|
||||
v->InvalidateNewGRFCache();
|
||||
u->InvalidateNewGRFCache();
|
||||
}
|
||||
|
||||
/* store consist weight/max speed in cache */
|
||||
|
|
|
@ -245,6 +245,26 @@ public:
|
|||
*/
|
||||
virtual SpriteID GetImage(Direction direction) const { return 0; }
|
||||
|
||||
/**
|
||||
* Invalidates cached NewGRF variables
|
||||
* @see InvalidateNewGRFCacheOfChain
|
||||
*/
|
||||
FORCEINLINE void InvalidateNewGRFCache()
|
||||
{
|
||||
this->vcache.cache_valid = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates cached NewGRF variables of all vehicles in the chain (after the current vehicle)
|
||||
* @see InvalidateNewGRFCache
|
||||
*/
|
||||
FORCEINLINE void InvalidateNewGRFCacheOfChain()
|
||||
{
|
||||
for (Vehicle *u = this; u != NULL; u = u->Next()) {
|
||||
u->InvalidateNewGRFCache();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the speed in km-ish/h that can be sent into SetDParam for string processing.
|
||||
* @return the vehicle's speed
|
||||
|
|
Loading…
Reference in New Issue