mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Add VehicleOrderSaver::Restore()
parent
7e7d943526
commit
a4052ca348
|
@ -2449,6 +2449,7 @@ private:
|
|||
StationID old_last_station_visited;
|
||||
VehicleOrderID index;
|
||||
bool suppress_implicit_orders;
|
||||
bool restored;
|
||||
|
||||
public:
|
||||
VehicleOrderSaver(Train *_v) :
|
||||
|
@ -2457,16 +2458,29 @@ public:
|
|||
old_dest_tile(_v->dest_tile),
|
||||
old_last_station_visited(_v->last_station_visited),
|
||||
index(_v->cur_real_order_index),
|
||||
suppress_implicit_orders(HasBit(_v->gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS))
|
||||
suppress_implicit_orders(HasBit(_v->gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS)),
|
||||
restored(false)
|
||||
{
|
||||
}
|
||||
|
||||
~VehicleOrderSaver()
|
||||
/**
|
||||
* Restore the saved order to the vehicle.
|
||||
*/
|
||||
void Restore()
|
||||
{
|
||||
this->v->current_order = this->old_order;
|
||||
this->v->dest_tile = this->old_dest_tile;
|
||||
this->v->last_station_visited = this->old_last_station_visited;
|
||||
SB(this->v->gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS, 1, suppress_implicit_orders ? 1: 0);
|
||||
this->restored = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the saved order to the vehicle, if Restore() has not already been called.
|
||||
*/
|
||||
~VehicleOrderSaver()
|
||||
{
|
||||
if (!this->restored) this->Restore();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue