@@ -13,12 +13,13 @@
#include "command_func.h"
#include "core/pool_func.hpp"
#include "network/network.h"
#include "network/network_func.h"
#include "order_backup.h"
#include "vehicle_base.h"
#include "window_func.h"
OrderBackupPool _order_backup_pool("BackupOrder");
INSTANTIATE_POOL_METHODS(OrderBackup)
/** Free everything that is allocated. */
OrderBackup::~OrderBackup()
@@ -81,12 +82,14 @@ void OrderBackup::DoRestore(Vehicle *v)
/* If we had shared orders, recover that */
if (this->clone != NULL) {
DoCommand(0, v->index | CO_SHARE << 30, this->clone->index, DC_EXEC, CMD_CLONE_ORDER);
} else if (this->orders != NULL && OrderList::CanAllocateItem()) {
v->orders.list = new OrderList(this->orders, v);
this->orders = NULL;
/* Make sure buoys/oil rigs are updated in the station list. */
InvalidateWindowClassesData(WC_STATION_LIST, 0);
}
uint num_orders = v->GetNumOrders();
if (num_orders != 0) {
v->cur_real_order_index = v->cur_implicit_order_index = this->orderindex % num_orders;
v->UpdateRealOrderIndex();
@@ -48,13 +48,13 @@ public:
Order *next; ///< Pointer to next order. If NULL, end of list
uint16 wait_time; ///< How long in ticks to wait at the destination.
uint16 travel_time; ///< How long in ticks the journey to this destination should take.
Order() : refit_cargo(CT_NO_REFIT) {}
~Order() {}
~Order();
Order(uint32 packed);
/**
* Check whether this order is of the given type.
* @param type the type to check against.
@@ -38,12 +38,25 @@ assert_compile(sizeof(DestinationID) >=
OrderPool _order_pool("Order");
INSTANTIATE_POOL_METHODS(Order)
OrderListPool _orderlist_pool("OrderList");
INSTANTIATE_POOL_METHODS(OrderList)
/** Clean everything up. */
Order::~Order()
{
if (CleaningPool()) return;
/* We can visit oil rigs and buoys that are not our own. They will be shown in
* the list of stations. So, we need to invalidate that window if needed. */
if (this->IsType(OT_GOTO_STATION) || this->IsType(OT_GOTO_WAYPOINT)) {
BaseStation *bs = BaseStation::GetIfValid(this->GetDestination());
if (bs != NULL && bs->owner == OWNER_NONE) InvalidateWindowClassesData(WC_STATION_LIST, 0);
* 'Free' the order
* @note ONLY use on "current_order" vehicle orders!
*/
void Order::Free()
@@ -364,12 +377,20 @@ void OrderList::InsertOrderAt(Order *new
order->next = new_order;
++this->num_orders;
if (!new_order->IsType(OT_IMPLICIT)) ++this->num_manual_orders;
this->timetable_duration += new_order->wait_time + new_order->travel_time;
if (new_order->IsType(OT_GOTO_STATION) || new_order->IsType(OT_GOTO_WAYPOINT)) {
BaseStation *bs = BaseStation::Get(new_order->GetDestination());
if (bs->owner == OWNER_NONE) InvalidateWindowClassesData(WC_STATION_LIST, 0);
* Remove an order from the order list and delete it.
* @param index is the position of the order which is to be deleted.
@@ -96,14 +96,18 @@ Station::~Station()
/* Clear the persistent storage. */
delete this->airport.psa;
InvalidateWindowData(WC_STATION_LIST, this->owner, 0);
if (this->owner == OWNER_NONE) {
/* Invalidate all in case of oil rigs. */
} else {
DeleteWindowById(WC_STATION_VIEW, index);
/* Now delete all orders that go to the station */
RemoveOrderFromAllVehicles(OT_GOTO_STATION, this->index);
Status change: