Fix handling of current timetable order index when deleting/inserting orders
This commit is contained in:
@@ -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,11 +1278,13 @@ void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
|
||||
}
|
||||
}
|
||||
|
||||
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 */
|
||||
InvalidateVehicleOrder(u, sel_ord | (INVALID_VEH_ORDER_ID << 8));
|
||||
|
Reference in New Issue
Block a user