Add a release slot at front of train slot action.
Distinguish from release slot at back. Fix slot release and acquire at front when passing PBS from back.
This commit is contained in:
@@ -2461,10 +2461,12 @@ STR_TRACE_RESTRICT_DIRECTION_NW :north-west
|
||||
STR_TRACE_RESTRICT_SLOT_OP :Slot operation
|
||||
STR_TRACE_RESTRICT_SLOT_ACQUIRE_WAIT :Acquire or wait
|
||||
STR_TRACE_RESTRICT_SLOT_TRY_ACQUIRE :Try to acquire
|
||||
STR_TRACE_RESTRICT_SLOT_RELEASE :Release
|
||||
STR_TRACE_RESTRICT_SLOT_RELEASE_FRONT :Release (front)
|
||||
STR_TRACE_RESTRICT_SLOT_RELEASE_BACK :Release (back)
|
||||
STR_TRACE_RESTRICT_SLOT_ACQUIRE_WAIT_ITEM :Acquire slot: {STRING1}{BLACK}{STRING}, or wait at PBS signal
|
||||
STR_TRACE_RESTRICT_SLOT_TRY_ACQUIRE_ITEM :Try to acquire slot: {STRING1}{BLACK}{STRING}, or continue anyway
|
||||
STR_TRACE_RESTRICT_SLOT_RELEASE_ITEM :Release slot: {STRING1}
|
||||
STR_TRACE_RESTRICT_SLOT_RELEASE_FRONT_ITEM :Release slot: {STRING1}{BLACK}{STRING} (front of train)
|
||||
STR_TRACE_RESTRICT_SLOT_RELEASE_BACK_ITEM :Release slot: {STRING1}{BLACK}{STRING} (back of train)
|
||||
STR_TRACE_RESTRICT_SLOT_NAME :{TRSLOT}
|
||||
STR_TRACE_RESTRICT_SLOT_LIST_HEADER :{BLACK}Slot{CONSUME_ARG}{P "" s}: {LTBLUE}
|
||||
STR_TRACE_RESTRICT_SLOT_LIST_SEPARATOR :{BLACK}, {LTBLUE}
|
||||
|
@@ -471,8 +471,12 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
||||
if (input.permitted_slot_operations & TRPISP_ACQUIRE) slot->Occupy(v->index);
|
||||
break;
|
||||
|
||||
case TRSCOF_RELEASE:
|
||||
if (input.permitted_slot_operations & TRPISP_RELEASE) slot->Vacate(v->index);
|
||||
case TRSCOF_RELEASE_BACK:
|
||||
if (input.permitted_slot_operations & TRPISP_RELEASE_BACK) slot->Vacate(v->index);
|
||||
break;
|
||||
|
||||
case TRSCOF_RELEASE_FRONT:
|
||||
if (input.permitted_slot_operations & TRPISP_RELEASE_FRONT) slot->Vacate(v->index);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -606,8 +610,12 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
|
||||
actions_used_flags |= TRPAUF_SLOT_ACQUIRE;
|
||||
break;
|
||||
|
||||
case TRSCOF_RELEASE:
|
||||
actions_used_flags |= TRPAUF_SLOT_RELEASE;
|
||||
case TRSCOF_RELEASE_BACK:
|
||||
actions_used_flags |= TRPAUF_SLOT_RELEASE_BACK;
|
||||
break;
|
||||
|
||||
case TRSCOF_RELEASE_FRONT:
|
||||
actions_used_flags |= TRPAUF_SLOT_RELEASE_FRONT;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -227,7 +227,8 @@ enum TraceRestrictPathfinderPenaltyAuxField {
|
||||
enum TraceRestrictSlotCondOpField {
|
||||
TRSCOF_ACQUIRE_WAIT = 0, ///< acquire a slot, or wait at the current signal
|
||||
TRSCOF_ACQUIRE_TRY = 1, ///< try to acquire a slot, or carry on otherwise
|
||||
TRSCOF_RELEASE = 2, ///< release a slot
|
||||
TRSCOF_RELEASE_BACK = 2, ///< release a slot (back of train)
|
||||
TRSCOF_RELEASE_FRONT = 3, ///< release a slot (front of train)
|
||||
/* space up to 8 */
|
||||
};
|
||||
|
||||
@@ -262,7 +263,8 @@ enum TraceRestrictProgramActionsUsedFlags {
|
||||
TRPAUF_LONG_RESERVE = 1 << 2, ///< Long reserve action is present
|
||||
TRPAUF_WAIT_AT_PBS = 1 << 3, ///< Wait at PBS signal action is present
|
||||
TRPAUF_SLOT_ACQUIRE = 1 << 4, ///< Slot acquire action is present
|
||||
TRPAUF_SLOT_RELEASE = 1 << 5, ///< Slot release action is present
|
||||
TRPAUF_SLOT_RELEASE_BACK = 1 << 5, ///< Slot release (back) action is present
|
||||
TRPAUF_SLOT_RELEASE_FRONT = 1 << 6, ///< Slot release (front) action is present
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(TraceRestrictProgramActionsUsedFlags)
|
||||
|
||||
@@ -271,7 +273,8 @@ DECLARE_ENUM_AS_BIT_SET(TraceRestrictProgramActionsUsedFlags)
|
||||
*/
|
||||
enum TraceRestrictProgramInputSlotPermissions {
|
||||
TRPISP_ACQUIRE = 1 << 0, ///< Slot acquire is permitted
|
||||
TRPISP_RELEASE = 1 << 1, ///< Slot release is permitted
|
||||
TRPISP_RELEASE_BACK = 1 << 1, ///< Slot release (back) is permitted
|
||||
TRPISP_RELEASE_FRONT = 1 << 2, ///< Slot release (front) is permitted
|
||||
};
|
||||
DECLARE_ENUM_AS_BIT_SET(TraceRestrictProgramInputSlotPermissions)
|
||||
|
||||
|
@@ -482,13 +482,15 @@ static const TraceRestrictDropDownListSet _cargo_cond_ops = {
|
||||
static const StringID _slot_op_cond_ops_str[] = {
|
||||
STR_TRACE_RESTRICT_SLOT_ACQUIRE_WAIT,
|
||||
STR_TRACE_RESTRICT_SLOT_TRY_ACQUIRE,
|
||||
STR_TRACE_RESTRICT_SLOT_RELEASE,
|
||||
STR_TRACE_RESTRICT_SLOT_RELEASE_FRONT,
|
||||
STR_TRACE_RESTRICT_SLOT_RELEASE_BACK,
|
||||
INVALID_STRING_ID,
|
||||
};
|
||||
static const uint _slot_op_cond_ops_val[] = {
|
||||
TRSCOF_ACQUIRE_WAIT,
|
||||
TRSCOF_ACQUIRE_TRY,
|
||||
TRSCOF_RELEASE,
|
||||
TRSCOF_RELEASE_FRONT,
|
||||
TRSCOF_RELEASE_BACK,
|
||||
};
|
||||
/** cargo conditional operators dropdown list set */
|
||||
static const TraceRestrictDropDownListSet _slot_op_cond_ops = {
|
||||
@@ -1006,8 +1008,12 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric
|
||||
instruction_string = STR_TRACE_RESTRICT_SLOT_TRY_ACQUIRE_ITEM;
|
||||
break;
|
||||
|
||||
case TRSCOF_RELEASE:
|
||||
instruction_string = STR_TRACE_RESTRICT_SLOT_RELEASE_ITEM;
|
||||
case TRSCOF_RELEASE_BACK:
|
||||
instruction_string = STR_TRACE_RESTRICT_SLOT_RELEASE_BACK_ITEM;
|
||||
break;
|
||||
|
||||
case TRSCOF_RELEASE_FRONT:
|
||||
instruction_string = STR_TRACE_RESTRICT_SLOT_RELEASE_FRONT_ITEM;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -3326,12 +3326,12 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
|
||||
|
||||
if (IsPlainRailTile(gp.new_tile) && HasSignals(gp.new_tile) && IsRestrictedSignal(gp.new_tile)) {
|
||||
const Trackdir dir = FindFirstTrackdir(trackdirbits);
|
||||
if (HasSignalOnTrackdir(gp.new_tile, dir)) {
|
||||
if (HasSignalOnTrack(gp.new_tile, TrackdirToTrack(dir))) {
|
||||
const TraceRestrictProgram *prog = GetExistingTraceRestrictProgram(gp.new_tile, TrackdirToTrack(dir));
|
||||
if (prog && prog->actions_used_flags & TRPAUF_SLOT_ACQUIRE) {
|
||||
if (prog && prog->actions_used_flags & (TRPAUF_SLOT_ACQUIRE | TRPAUF_SLOT_RELEASE_FRONT)) {
|
||||
TraceRestrictProgramResult out;
|
||||
TraceRestrictProgramInput input(gp.new_tile, dir, NULL, NULL);
|
||||
input.permitted_slot_operations = TRPISP_ACQUIRE;
|
||||
input.permitted_slot_operations = TRPISP_ACQUIRE | TRPISP_RELEASE_FRONT;
|
||||
prog->Execute(v, input, out);
|
||||
}
|
||||
}
|
||||
@@ -3530,10 +3530,10 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
|
||||
const Track track = TrackdirToTrack(rev_trackdir);
|
||||
if (HasSignalOnTrack(gp.old_tile, track)) {
|
||||
const TraceRestrictProgram *prog = GetExistingTraceRestrictProgram(gp.old_tile, track);
|
||||
if (prog && prog->actions_used_flags & TRPAUF_SLOT_RELEASE) {
|
||||
if (prog && prog->actions_used_flags & TRPAUF_SLOT_RELEASE_BACK) {
|
||||
TraceRestrictProgramResult out;
|
||||
TraceRestrictProgramInput input(gp.old_tile, ReverseTrackdir(rev_trackdir), NULL, NULL);
|
||||
input.permitted_slot_operations = TRPISP_RELEASE;
|
||||
input.permitted_slot_operations = TRPISP_RELEASE_BACK;
|
||||
prog->Execute(first, input, out);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user