Fix handling of current timetable order index when deleting/inserting orders

pull/30/merge
Jonathan G Rennison 7 years ago
parent c4897f92df
commit 9a5986fa70

@ -1129,7 +1129,7 @@ void InsertOrder(Vehicle *v, Order *new_o, VehicleOrderID sel_ord)
u->cur_implicit_order_index = cur;
}
}
if (sel_ord <= u->cur_timetable_order_index) {
if (u->cur_timetable_order_index != INVALID_VEH_ORDER_ID && sel_ord <= u->cur_timetable_order_index) {
uint cur = u->cur_timetable_order_index + 1;
/* Check if we don't go out of bound */
if (cur < u->GetNumOrders()) {
@ -1278,10 +1278,12 @@ void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
}
}
if (sel_ord < u->cur_timetable_order_index) {
u->cur_timetable_order_index--;
} else if (sel_ord == u->cur_timetable_order_index) {
u->cur_timetable_order_index = INVALID_VEH_ORDER_ID;
if (u->cur_timetable_order_index != INVALID_VEH_ORDER_ID) {
if (sel_ord < u->cur_timetable_order_index) {
u->cur_timetable_order_index--;
} else if (sel_ord == u->cur_timetable_order_index) {
u->cur_timetable_order_index = INVALID_VEH_ORDER_ID;
}
}
/* Update any possible open window of the vehicle */

Loading…
Cancel
Save