summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-10-27 20:37:55 +0000
committerfrosch <frosch@openttd.org>2009-10-27 20:37:55 +0000
commit334b809644fd8055b7e45c790f42ffb1ab990878 (patch)
tree1b3f7e9926621a54e4bacbdd77215d467148f5cc /src
parent778f6533ea9932ab79d495b08e625f1ffb6fc23e (diff)
downloadopenttd-334b809644fd8055b7e45c790f42ffb1ab990878.tar.xz
(svn r17894) -Fix: Invalidate cache of vehicle vars 40-43 after testruns of certain commands, that change them temporarily.
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_cmd.cpp2
-rw-r--r--src/roadveh_cmd.cpp6
-rw-r--r--src/ship_cmd.cpp2
-rw-r--r--src/train_cmd.cpp14
4 files changed, 20 insertions, 4 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 6ad01d4c6..f7cfa17f4 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -583,11 +583,11 @@ 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();
SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
}
+ v->InvalidateNewGRFCacheOfChain(); // always invalidate; querycost might have filled it
return cost;
}
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index b092b4c60..74271a1d7 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -2083,7 +2083,11 @@ CommandCost CmdRefitRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
}
}
- if (flags & DC_EXEC) RoadVehUpdateCache(RoadVehicle::Get(p1)->First());
+ if (flags & DC_EXEC) {
+ RoadVehUpdateCache(RoadVehicle::Get(p1)->First());
+ } else {
+ v->InvalidateNewGRFCacheOfChain(); // always invalidate; querycost might have filled it
+ }
_returned_refit_capacity = total_capacity;
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index d6818e46e..0025aabac 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -955,11 +955,11 @@ 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();
SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
}
+ v->InvalidateNewGRFCacheOfChain(); // always invalidate; querycost might have filled it
return cost;
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index f1ae0e3ab..e0e32efd5 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1227,6 +1227,10 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
* than it actually solves (infinite loops and such).
*/
if (dst_head != NULL && !src_in_dst && (flags & DC_AUTOREPLACE) == 0) {
+ /* Forget everything, as everything is going to change */
+ src->InvalidateNewGRFCacheOfChain();
+ dst->InvalidateNewGRFCacheOfChain();
+
/*
* When performing the 'allow wagon attach' callback, we have to check
* that for each and every wagon, not only the first one. This means
@@ -1255,6 +1259,10 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
/* Restore original first_engine data */
next_to_attach->tcache.first_engine = first_engine;
+ /* We do not want to remember any cached variables from the test run */
+ next_to_attach->InvalidateNewGRFCache();
+ dst_head->InvalidateNewGRFCache();
+
if (callback != CALLBACK_FAILED) {
StringID error = STR_NULL;
@@ -2174,7 +2182,11 @@ CommandCost CmdRefitRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
_returned_refit_capacity = num;
/* Update the train's cached variables */
- if (flags & DC_EXEC) TrainConsistChanged(Train::Get(p1)->First(), false);
+ if (flags & DC_EXEC) {
+ TrainConsistChanged(Train::Get(p1)->First(), false);
+ } else {
+ v->InvalidateNewGRFCacheOfChain(); // always invalidate; querycost might have filled it
+ }
return cost;
}