Codechange: Move ownership of Orders to OrderList. (#13948)
Removes the orders pool, and orders are now stored directly in each OrderList. Iterating orders now no longer needs to traverse a linked-list, all orders in an OrderList are sequential.
This commit is contained in:
@@ -643,16 +643,14 @@ static bool LoadOldOrder(LoadgameState &ls, int num)
|
||||
{
|
||||
if (!LoadChunk(ls, nullptr, order_chunk)) return false;
|
||||
|
||||
Order *o = new (OrderID(num)) Order();
|
||||
o->AssignOrder(UnpackOldOrder(_old_order));
|
||||
OldOrderSaveLoadItem &o = AllocateOldOrder(num);
|
||||
o.order.AssignOrder(UnpackOldOrder(_old_order));
|
||||
|
||||
if (o->IsType(OT_NOTHING)) {
|
||||
delete o;
|
||||
} else {
|
||||
if (!o.order.IsType(OT_NOTHING) && num > 0) {
|
||||
/* Relink the orders to each other (in the orders for one vehicle are behind each other,
|
||||
* with an invalid order (OT_NOTHING) as indication that it is the last order */
|
||||
Order *prev = Order::GetIfValid(num - 1);
|
||||
if (prev != nullptr) prev->next = o;
|
||||
OldOrderSaveLoadItem *prev = GetOldOrder(num + 1 - 1);
|
||||
if (prev != nullptr) prev->next = num + 1; // next is 1-based.
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1364,7 +1362,7 @@ bool LoadOldVehicle(LoadgameState &ls, int num)
|
||||
if (_old_order_ptr != 0 && _old_order_ptr != 0xFFFFFFFF) {
|
||||
uint max = _savegame_type == SGT_TTO ? 3000 : 5000;
|
||||
uint old_id = RemapOrderIndex(_old_order_ptr);
|
||||
if (old_id < max) v->old_orders = Order::Get(old_id); // don't accept orders > max number of orders
|
||||
if (old_id < max) v->old_orders = old_id + 1;
|
||||
}
|
||||
v->current_order.AssignOrder(UnpackOldOrder(_old_order));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user