Update order destination refcount in RemoveVehicleOrdersIf

This commit is contained in:
Jonathan G Rennison
2019-08-27 17:14:49 +01:00
parent d9c112cc9e
commit ce130bc181
2 changed files with 15 additions and 11 deletions

View File

@@ -16,6 +16,18 @@
#include "order_func.h"
#include "vehicle_base.h"
void UpdateOrderDestinationRefcount(const Order *order, VehicleType type, Owner owner, int delta);
inline void RegisterOrderDestination(const Order *order, VehicleType type, Owner owner)
{
if (_order_destination_refcount_map_valid) UpdateOrderDestinationRefcount(order, type, owner, 1);
}
inline void UnregisterOrderDestination(const Order *order, VehicleType type, Owner owner)
{
if (_order_destination_refcount_map_valid) UpdateOrderDestinationRefcount(order, type, owner, -1);
}
/**
* Removes all orders from a vehicle for which order_predicate returns true.
* Handles timetable updating, removing implicit orders correctly, etc.
@@ -41,6 +53,8 @@ restart:
break;
}
UnregisterOrderDestination(order, v->type, v->owner);
/* Clear wait time */
if (!order->IsType(OT_CONDITIONAL)) v->orders.list->UpdateTotalDuration(-order->GetWaitTime());
if (order->IsWaitTimetabled()) {