Save/restore implicit and TT order indices in VehicleOrderSaver

Fix implicit/TT order indices being unexpectedly changed by
UpdateOrderDest if an order target is unsuitable.
This could assert UpdateVehicleTimetable
This commit is contained in:
Jonathan G Rennison 2021-02-04 21:49:05 +00:00
parent db04bc090e
commit 0cc994c870

View File

@ -3588,6 +3588,8 @@ private:
TileIndex old_dest_tile; TileIndex old_dest_tile;
StationID old_last_station_visited; StationID old_last_station_visited;
VehicleOrderID old_index; VehicleOrderID old_index;
VehicleOrderID old_impl_index;
VehicleOrderID old_tt_index;
bool suppress_implicit_orders; bool suppress_implicit_orders;
public: public:
@ -3597,6 +3599,8 @@ public:
old_dest_tile(_v->dest_tile), old_dest_tile(_v->dest_tile),
old_last_station_visited(_v->last_station_visited), old_last_station_visited(_v->last_station_visited),
old_index(_v->cur_real_order_index), old_index(_v->cur_real_order_index),
old_impl_index(_v->cur_implicit_order_index),
old_tt_index(_v->cur_timetable_order_index),
suppress_implicit_orders(HasBit(_v->gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS)) suppress_implicit_orders(HasBit(_v->gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS))
{ {
} }
@ -3607,6 +3611,8 @@ public:
this->v->dest_tile = this->old_dest_tile; this->v->dest_tile = this->old_dest_tile;
this->v->last_station_visited = this->old_last_station_visited; this->v->last_station_visited = this->old_last_station_visited;
this->v->cur_real_order_index = this->old_index; this->v->cur_real_order_index = this->old_index;
this->v->cur_implicit_order_index = this->old_impl_index;
this->v->cur_timetable_order_index = this->old_tt_index;
SB(this->v->gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS, 1, suppress_implicit_orders ? 1: 0); SB(this->v->gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS, 1, suppress_implicit_orders ? 1: 0);
} }