mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r6355) -Fix: Go to hangar orders for aircraft could get spuriously removed when a road or rail depot got deleted (Darkvater and me)
This bug is probably ages old
This commit is contained in:
parent
1c21c645ae
commit
23168f6309
10
order_cmd.c
10
order_cmd.c
|
@ -968,6 +968,10 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
|
||||||
Order *order;
|
Order *order;
|
||||||
bool need_invalidate;
|
bool need_invalidate;
|
||||||
|
|
||||||
|
/* Aircraft have StationIDs for depot orders and never use DepotIDs
|
||||||
|
* This fact is handled specially below
|
||||||
|
*/
|
||||||
|
|
||||||
/* Go through all vehicles */
|
/* Go through all vehicles */
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
if (v->orders == NULL) continue;
|
if (v->orders == NULL) continue;
|
||||||
|
@ -977,7 +981,8 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
|
||||||
v->last_station_visited = INVALID_STATION;
|
v->last_station_visited = INVALID_STATION;
|
||||||
|
|
||||||
/* Check the current order */
|
/* Check the current order */
|
||||||
if (v->current_order.type == type && v->current_order.dest == destination) {
|
if ((v->type == VEH_Aircraft && v->current_order.type == OT_GOTO_DEPOT ? OT_GOTO_STATION : v->current_order.type) == type &&
|
||||||
|
v->current_order.dest == destination) {
|
||||||
/* Mark the order as DUMMY */
|
/* Mark the order as DUMMY */
|
||||||
v->current_order.type = OT_DUMMY;
|
v->current_order.type = OT_DUMMY;
|
||||||
v->current_order.flags = 0;
|
v->current_order.flags = 0;
|
||||||
|
@ -987,7 +992,8 @@ void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
|
||||||
/* Clear the order from the order-list */
|
/* Clear the order from the order-list */
|
||||||
need_invalidate = false;
|
need_invalidate = false;
|
||||||
FOR_VEHICLE_ORDERS(v, order) {
|
FOR_VEHICLE_ORDERS(v, order) {
|
||||||
if (order->type == type && order->dest == destination) {
|
if ((v->type == VEH_Aircraft && order->type == OT_GOTO_DEPOT ? OT_GOTO_STATION : order->type) == type &&
|
||||||
|
order->dest == destination) {
|
||||||
/* Mark the order as DUMMY */
|
/* Mark the order as DUMMY */
|
||||||
order->type = OT_DUMMY;
|
order->type = OT_DUMMY;
|
||||||
order->flags = 0;
|
order->flags = 0;
|
||||||
|
|
|
@ -2376,7 +2376,6 @@ void DestroyRoadStop(RoadStop* rs)
|
||||||
void DestroyStation(Station *st)
|
void DestroyStation(Station *st)
|
||||||
{
|
{
|
||||||
StationID index;
|
StationID index;
|
||||||
Vehicle *v;
|
|
||||||
|
|
||||||
index = st->index;
|
index = st->index;
|
||||||
|
|
||||||
|
@ -2390,23 +2389,6 @@ void DestroyStation(Station *st)
|
||||||
/* Now delete all orders that go to the station */
|
/* Now delete all orders that go to the station */
|
||||||
RemoveOrderFromAllVehicles(OT_GOTO_STATION, index);
|
RemoveOrderFromAllVehicles(OT_GOTO_STATION, index);
|
||||||
|
|
||||||
//And do the same with aircraft that have the station as a hangar-stop
|
|
||||||
FOR_ALL_VEHICLES(v) {
|
|
||||||
bool invalidate = false;
|
|
||||||
if (v->type == VEH_Aircraft) {
|
|
||||||
Order *order;
|
|
||||||
FOR_VEHICLE_ORDERS(v, order) {
|
|
||||||
if (order->type == OT_GOTO_DEPOT && order->dest == index) {
|
|
||||||
order->type = OT_DUMMY;
|
|
||||||
order->flags = 0;
|
|
||||||
invalidate = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Orders for the vehicle have been changed, invalidate the window
|
|
||||||
if (invalidate) InvalidateWindow(WC_VEHICLE_ORDERS, v->index);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Subsidies need removal as well
|
//Subsidies need removal as well
|
||||||
DeleteSubsidyWithStation(index);
|
DeleteSubsidyWithStation(index);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue