Skip to content

Fix vehicle orders not being deleted correctly when deallocating a station#3393

Merged
duncanspumpkin merged 5 commits intoOpenLoco:masterfrom
LeeSpork:Fix-station-deallocation-order-removal
Nov 10, 2025
Merged

Fix vehicle orders not being deleted correctly when deallocating a station#3393
duncanspumpkin merged 5 commits intoOpenLoco:masterfrom
LeeSpork:Fix-station-deallocation-order-removal

Conversation

@LeeSpork
Copy link
Copy Markdown
Contributor

@LeeSpork LeeSpork commented Nov 9, 2025

Fixes #3313

@AaronVanGeffen AaronVanGeffen changed the title Fix vehicle orders not being deleted correctly when dealocating a station Fix vehicle orders not being deleted correctly when deallocating a station Nov 9, 2025
Co-authored-by: Aaron van Geffen <aaron@aaronweb.net>
&& i < head->orderTableOffset + head->sizeOfOrderTable)
{
deleteOrder(head, i);
deleteOrder(head, i - head->orderTableOffset);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look correct to me. deleteOrder gets passed the vehicle head, so it should account for the order table offset already.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One would think, but it looks like it actually adds it

// Move orders in the order table, effectively removing the order
shiftOrdersLeft(head->orderTableOffset + orderOffset, removeOrderSize);
// Bookkeeping: change order table size
orderTableLength() -= removeOrderSize;
// Compensate other vehicles to use new table offsets
reoffsetVehicleOrderTables(head->orderTableOffset + orderOffset + 1, -removeOrderSize);

Copy link
Copy Markdown
Member

@AaronVanGeffen AaronVanGeffen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reminds me how much I hate the order table data structure with their variable item lengths. Gah 😄

Copy link
Copy Markdown
Contributor

@duncanspumpkin duncanspumpkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good. The assembly here was comparing the values back to front so I accidentally inverted things. (i've got no excuse for the delete order mistake though. Doh)

@AaronVanGeffen AaronVanGeffen added this to the v25.11+ milestone Nov 10, 2025
@duncanspumpkin duncanspumpkin merged commit 8af9806 into OpenLoco:master Nov 10, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vehicle orders are deleted incorrectly when deallocating a station

3 participants