Changeset - r18607:7724313c61c6
[Not reviewed]
master
0 3 0
rubidium - 13 years ago 2011-12-09 20:48:13
rubidium@openttd.org
(svn r23464) -Fix [FS#4876]: clear the backed up orders of a removed station as well, otherwise one could create orders to a station that was never in the original backupped orders. For example a road vehicle trying to go to a buoy.
3 files changed with 27 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/order_backup.cpp
Show inline comments
 
@@ -17,6 +17,7 @@
 
#include "order_backup.h"
 
#include "vehicle_base.h"
 
#include "window_func.h"
 
#include "station_map.h"
 

	
 
OrderBackupPool _order_backup_pool("BackupOrder");
 
INSTANTIATE_POOL_METHODS(OrderBackup)
 
@@ -257,3 +258,25 @@ CommandCost CmdClearOrderBackup(TileInde
 
		}
 
	}
 
}
 

	
 
/**
 
 * Removes an order from all vehicles. Triggers when, say, a station is removed.
 
 * @param type The type of the order (OT_GOTO_[STATION|DEPOT|WAYPOINT]).
 
 * @param destination The destination. Can be a StationID, DepotID or WaypointID.
 
 */
 
/* static */ void OrderBackup::RemoveOrder(OrderType type, DestinationID destination)
 
{
 
	OrderBackup *ob;
 
	FOR_ALL_ORDER_BACKUPS(ob) {
 
		for (Order *order = ob->orders; order != NULL; order = order->next) {
 
			OrderType ot = order->GetType();
 
			if (ot == OT_GOTO_DEPOT && (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) continue;
 
			if (ot == OT_IMPLICIT || (IsHangarTile(ob->tile) && ot == OT_GOTO_DEPOT)) ot = OT_GOTO_STATION;
 
			if (ot == type && order->GetDestination() == destination) {
 
				/* Remove the order backup! If a station/depot gets removed, we can't/shouldn't restore those broken orders. */
 
				delete ob;
 
				break;
 
			}
 
		}
 
	}
 
}
src/order_backup.h
Show inline comments
 
@@ -67,6 +67,7 @@ public:
 

	
 
	static void ClearGroup(GroupID group);
 
	static void ClearVehicle(const Vehicle *v);
 
	static void RemoveOrder(OrderType type, DestinationID destination);
 
};
 

	
 
/**
src/order_cmd.cpp
Show inline comments
 
@@ -27,6 +27,7 @@
 
#include "station_base.h"
 
#include "waypoint_base.h"
 
#include "company_base.h"
 
#include "order_backup.h"
 

	
 
#include "table/strings.h"
 

	
 
@@ -1705,6 +1706,8 @@ restart:
 
			}
 
		}
 
	}
 

	
 
	OrderBackup::RemoveOrder(type, destination);
 
}
 

	
 
/**
0 comments (0 inline, 0 general)