MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / onOrderDelete

Function onOrderDelete

src/OpenLoco/src/Ui/Windows/Vehicle.cpp:2885–2911  ·  view source on GitHub ↗

0x004B4F6D

Source from the content-addressed store, hash-verified

2883
2884 // 0x004B4F6D
2885 static void onOrderDelete(Vehicles::VehicleHead* const head, const int16_t orderId)
2886 {
2887 // No deletable orders
2888 if (head->sizeOfOrderTable <= 1)
2889 {
2890 return;
2891 }
2892
2893 // orderId can be -1 at this point for none selected
2894 auto i = 0;
2895 const Vehicles::Order* last = nullptr;
2896 for (const auto& order : getOrderTable(head))
2897 {
2898 if (i == orderId)
2899 {
2900 orderDeleteCommand(head, order.getOffset());
2901 return;
2902 }
2903 last = &order;
2904 i++;
2905 }
2906 // No order selected so delete the last one
2907 if (last != nullptr)
2908 {
2909 orderDeleteCommand(head, last->getOffset());
2910 }
2911 }
2912
2913 // 0x004B4C14
2914 static bool orderUpCommand(Vehicles::VehicleHead* const head, const uint32_t orderOffset)

Callers 1

onMouseUpFunction · 0.85

Calls 3

getOrderTableFunction · 0.85
orderDeleteCommandFunction · 0.85
getOffsetMethod · 0.80

Tested by

no test coverage detected