Fix tracerestrict train is loading status condition when predicting orders
This commit is contained in:
@@ -482,9 +482,12 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
|||||||
has_status = v->current_order.IsType(OT_GOTO_DEPOT);
|
has_status = v->current_order.IsType(OT_GOTO_DEPOT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TRTSVF_LOADING:
|
case TRTSVF_LOADING: {
|
||||||
has_status = v->current_order.IsType(OT_LOADING) || v->current_order.IsType(OT_LOADING_ADVANCE);
|
extern const Order *_choose_train_track_saved_current_order;
|
||||||
|
const Order *o = (_choose_train_track_saved_current_order != nullptr) ? _choose_train_track_saved_current_order : &(v->current_order);
|
||||||
|
has_status = o->IsType(OT_LOADING) || o->IsType(OT_LOADING_ADVANCE);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case TRTSVF_WAITING:
|
case TRTSVF_WAITING:
|
||||||
has_status = v->current_order.IsType(OT_WAITING);
|
has_status = v->current_order.IsType(OT_WAITING);
|
||||||
|
@@ -3597,6 +3597,8 @@ static bool TryReserveSafeTrack(const Train *v, TileIndex tile, Trackdir td, boo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Order *_choose_train_track_saved_current_order = nullptr;
|
||||||
|
|
||||||
/** This class will save the current order of a vehicle and restore it on destruction. */
|
/** This class will save the current order of a vehicle and restore it on destruction. */
|
||||||
class VehicleOrderSaver {
|
class VehicleOrderSaver {
|
||||||
private:
|
private:
|
||||||
@@ -3608,6 +3610,7 @@ private:
|
|||||||
VehicleOrderID old_impl_index;
|
VehicleOrderID old_impl_index;
|
||||||
VehicleOrderID old_tt_index;
|
VehicleOrderID old_tt_index;
|
||||||
bool suppress_implicit_orders;
|
bool suppress_implicit_orders;
|
||||||
|
bool clear_saved_order_ptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VehicleOrderSaver(Train *_v) :
|
VehicleOrderSaver(Train *_v) :
|
||||||
@@ -3620,6 +3623,12 @@ public:
|
|||||||
old_tt_index(_v->cur_timetable_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))
|
||||||
{
|
{
|
||||||
|
if (_choose_train_track_saved_current_order == nullptr) {
|
||||||
|
_choose_train_track_saved_current_order = &(this->old_order);
|
||||||
|
this->clear_saved_order_ptr = true;
|
||||||
|
} else {
|
||||||
|
this->clear_saved_order_ptr = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~VehicleOrderSaver()
|
~VehicleOrderSaver()
|
||||||
@@ -3631,6 +3640,7 @@ public:
|
|||||||
this->v->cur_implicit_order_index = this->old_impl_index;
|
this->v->cur_implicit_order_index = this->old_impl_index;
|
||||||
this->v->cur_timetable_order_index = this->old_tt_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);
|
||||||
|
if (this->clear_saved_order_ptr) _choose_train_track_saved_current_order = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user