Changeset - r12063:19a5d1ea1b70
[Not reviewed]
master
0 2 0
smatz - 15 years ago 2009-05-31 09:33:12
smatz@openttd.org
(svn r16475) -Codechange: move code invalidating Vehicle::last_station_visited to more logical place
2 files changed with 8 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/order_cmd.cpp
Show inline comments
 
@@ -1449,29 +1449,24 @@ void CheckOrders(const Vehicle *v)
 
void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
 
{
 
	Vehicle *v;
 

	
 
	/* Aircraft have StationIDs for depot orders and never use DepotIDs
 
	 * This fact is handled specially below
 
	 */
 

	
 
	/* Go through all vehicles */
 
	FOR_ALL_VEHICLES(v) {
 
		Order *order;
 

	
 
		/* Forget about this station if this station is removed */
 
		if (v->last_station_visited == destination && type == OT_GOTO_STATION) {
 
			v->last_station_visited = INVALID_STATION;
 
		}
 

	
 
		order = &v->current_order;
 
		if ((v->type == VEH_AIRCRAFT && order->IsType(OT_GOTO_DEPOT) ? OT_GOTO_STATION : order->GetType()) == type &&
 
				v->current_order.GetDestination() == destination) {
 
			order->MakeDummy();
 
			InvalidateWindow(WC_VEHICLE_VIEW, v->index);
 
		}
 

	
 
		/* Clear the order from the order-list */
 
		int id = -1;
 
		FOR_VEHICLE_ORDERS(v, order) {
 
			id++;
 
			if (order->IsType(OT_GOTO_DEPOT) && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue;
src/station.cpp
Show inline comments
 
@@ -66,24 +66,32 @@ Station::~Station()
 
	if (CleaningPool()) return;
 

	
 
	while (!loading_vehicles.empty()) {
 
		loading_vehicles.front()->LeaveStation();
 
	}
 

	
 
	Aircraft *a;
 
	FOR_ALL_AIRCRAFT(a) {
 
		if (!IsNormalAircraft(a)) continue;
 
		if (a->targetairport == this->index) a->targetairport = INVALID_STATION;
 
	}
 

	
 
	Vehicle *v;
 
	FOR_ALL_VEHICLES(v) {
 
		/* Forget about this station if this station is removed */
 
		if (v->last_station_visited == destination && type == OT_GOTO_STATION) {
 
			v->last_station_visited = INVALID_STATION;
 
		}
 
	}
 

	
 
	MarkDirty();
 
	InvalidateWindowData(WC_STATION_LIST, this->owner, 0);
 

	
 
	DeleteWindowById(WC_STATION_VIEW, index);
 
	WindowNumber wno = (index << 16) | VLW_STATION_LIST | this->owner;
 
	DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11));
 
	DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11));
 
	DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11));
 
	DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11));
 

	
 
	/* Now delete all orders that go to the station */
 
	RemoveOrderFromAllVehicles(OT_GOTO_STATION, index);
0 comments (0 inline, 0 general)