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;
|
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;
|
uint cur = u->cur_timetable_order_index + 1;
|
||||||
/* Check if we don't go out of bound */
|
/* Check if we don't go out of bound */
|
||||||
if (cur < u->GetNumOrders()) {
|
if (cur < u->GetNumOrders()) {
|
||||||
@@ -1278,10 +1278,12 @@ void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sel_ord < u->cur_timetable_order_index) {
|
if (u->cur_timetable_order_index != INVALID_VEH_ORDER_ID) {
|
||||||
u->cur_timetable_order_index--;
|
if (sel_ord < u->cur_timetable_order_index) {
|
||||||
} else if (sel_ord == u->cur_timetable_order_index) {
|
u->cur_timetable_order_index--;
|
||||||
u->cur_timetable_order_index = INVALID_VEH_ORDER_ID;
|
} 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 */
|
/* Update any possible open window of the vehicle */
|
||||||
|
Reference in New Issue
Block a user