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:
Peter Nelson
2025-05-23 10:36:28 +01:00
committed by GitHub
parent 7344dfe651
commit 0455627d16
30 changed files with 602 additions and 652 deletions

View File

@@ -248,10 +248,7 @@ CommandCost CmdSellVehicle(DoCommandFlags flags, VehicleID v_id, bool sell_chain
if (!front->IsStoppedInDepot()) return CommandCost(STR_ERROR_TRAIN_MUST_BE_STOPPED_INSIDE_DEPOT + front->type);
/* Can we actually make the order backup, i.e. are there enough orders? */
if (backup_order &&
front->orders != nullptr &&
!front->orders->IsShared() &&
!Order::CanAllocateItem(front->orders->GetNumOrders())) {
if (backup_order && front->orders != nullptr && !front->orders->IsShared()) {
/* Only happens in exceptional cases when there aren't enough orders anyhow.
* Thus it should be safe to just drop the orders in that case. */
backup_order = false;