Changeset - r13375:8a0b26bf86dc
[Not reviewed]
master
0 4 0
frosch - 15 years ago 2009-10-27 20:37:55
frosch@openttd.org
(svn r17894) -Fix: Invalidate cache of vehicle vars 40-43 after testruns of certain commands, that change them temporarily.
4 files changed with 20 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -583,11 +583,11 @@ CommandCost CmdRefitAircraft(TileIndex t
 
		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;
 
}
src/roadveh_cmd.cpp
Show inline comments
 
@@ -2083,7 +2083,11 @@ CommandCost CmdRefitRoadVeh(TileIndex ti
 
		}
 
	}
 

	
 
	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;
 

	
src/ship_cmd.cpp
Show inline comments
 
@@ -955,11 +955,11 @@ CommandCost CmdRefitShip(TileIndex tile,
 
		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;
 

	
src/train_cmd.cpp
Show inline comments
 
@@ -1227,6 +1227,10 @@ CommandCost CmdMoveRailVehicle(TileIndex
 
	 * 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
 
				/* 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(TileInde
 
	_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;
 
}
0 comments (0 inline, 0 general)