Update order destination refcount in RemoveVehicleOrdersIf
This commit is contained in:
@@ -80,23 +80,13 @@ void ClearOrderDestinationRefcountMap()
|
|||||||
_order_destination_refcount_map_valid = false;
|
_order_destination_refcount_map_valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateOrderDestinationRefcount(const Order *order, VehicleType type, Owner owner, int delta)
|
void UpdateOrderDestinationRefcount(const Order *order, VehicleType type, Owner owner, int delta)
|
||||||
{
|
{
|
||||||
if (order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT) || order->IsType(OT_IMPLICIT)) {
|
if (order->IsType(OT_GOTO_STATION) || order->IsType(OT_GOTO_WAYPOINT) || order->IsType(OT_IMPLICIT)) {
|
||||||
_order_destination_refcount_map[OrderDestinationRefcountMapKey(order->GetDestination(), owner, order->GetType(), type)] += delta;
|
_order_destination_refcount_map[OrderDestinationRefcountMapKey(order->GetDestination(), owner, order->GetType(), type)] += 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Clean everything up. */
|
/** Clean everything up. */
|
||||||
Order::~Order()
|
Order::~Order()
|
||||||
{
|
{
|
||||||
|
@@ -16,6 +16,18 @@
|
|||||||
#include "order_func.h"
|
#include "order_func.h"
|
||||||
#include "vehicle_base.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.
|
* Removes all orders from a vehicle for which order_predicate returns true.
|
||||||
* Handles timetable updating, removing implicit orders correctly, etc.
|
* Handles timetable updating, removing implicit orders correctly, etc.
|
||||||
@@ -41,6 +53,8 @@ restart:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnregisterOrderDestination(order, v->type, v->owner);
|
||||||
|
|
||||||
/* Clear wait time */
|
/* Clear wait time */
|
||||||
if (!order->IsType(OT_CONDITIONAL)) v->orders.list->UpdateTotalDuration(-order->GetWaitTime());
|
if (!order->IsType(OT_CONDITIONAL)) v->orders.list->UpdateTotalDuration(-order->GetWaitTime());
|
||||||
if (order->IsWaitTimetabled()) {
|
if (order->IsWaitTimetabled()) {
|
||||||
|
Reference in New Issue
Block a user