diff --git a/src/lang/extra/english.txt b/src/lang/extra/english.txt index 42ef2cb98b..a9d45b86f5 100644 --- a/src/lang/extra/english.txt +++ b/src/lang/extra/english.txt @@ -952,6 +952,7 @@ STR_TRACE_RESTRICT_SLOT_ACQUIRE_WAIT :Acquire or wait STR_TRACE_RESTRICT_SLOT_TRY_ACQUIRE :Try to acquire STR_TRACE_RESTRICT_SLOT_RELEASE_FRONT :Release (front) STR_TRACE_RESTRICT_SLOT_RELEASE_BACK :Release (back) +STR_TRACE_RESTRICT_SLOT_RELEASE_ON_RESERVE :Release (on reserve) STR_TRACE_RESTRICT_SLOT_PBS_RES_END_ACQUIRE_WAIT :PBS end: Acquire or wait STR_TRACE_RESTRICT_SLOT_PBS_RES_END_TRY_ACQUIRE :PBS end: Try to acquire STR_TRACE_RESTRICT_SLOT_PBS_RES_END_RELEASE :PBS end: Release @@ -959,6 +960,7 @@ STR_TRACE_RESTRICT_SLOT_ACQUIRE_WAIT_ITEM :Acquire slot: { STR_TRACE_RESTRICT_SLOT_TRY_ACQUIRE_ITEM :Try to acquire slot: {STRING1}{BLACK}{STRING}, or continue anyway 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_RELEASE_ON_RESERVE_ITEM :Release slot: {STRING1}{BLACK}{STRING} (on PBS reserve) STR_TRACE_RESTRICT_SLOT_PBS_RES_END_ACQUIRE_WAIT_ITEM :PBS reservation ending here: Acquire slot: {STRING1}{BLACK}{STRING}, or wait at start STR_TRACE_RESTRICT_SLOT_PBS_RES_END_TRY_ACQUIRE_ITEM :PBS reservation ending here: Acquire slot: {STRING1}{BLACK}{STRING}, or continue anyway STR_TRACE_RESTRICT_SLOT_PBS_RES_END_RELEASE_ITEM :PBS reservation ending here: Release slot: {STRING1}{BLACK}{STRING} diff --git a/src/tracerestrict.cpp b/src/tracerestrict.cpp index 704632bd76..2b8e05100f 100644 --- a/src/tracerestrict.cpp +++ b/src/tracerestrict.cpp @@ -744,6 +744,14 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp } break; + case TRSCOF_RELEASE_ON_RESERVE: + if (input.permitted_slot_operations & TRPISP_ACQUIRE) { + slot->Vacate(v->index); + } else if (input.permitted_slot_operations & TRPISP_ACQUIRE_TEMP_STATE) { + slot->VacateUsingTemporaryState(v->index, input.slot_temporary_state); + } + break; + case TRSCOF_RELEASE_BACK: if (input.permitted_slot_operations & TRPISP_RELEASE_BACK) slot->Vacate(v->index); break; @@ -1357,6 +1365,10 @@ CommandCost TraceRestrictProgram::Validate(const std::vector actions_used_flags |= TRPAUF_SLOT_ACQUIRE; break; + case TRSCOF_RELEASE_ON_RESERVE: + actions_used_flags |= TRPAUF_SLOT_ACQUIRE; + break; + case TRSCOF_RELEASE_BACK: actions_used_flags |= TRPAUF_SLOT_RELEASE_BACK; break; diff --git a/src/tracerestrict.h b/src/tracerestrict.h index 66dd7f4a46..a080e0ed38 100644 --- a/src/tracerestrict.h +++ b/src/tracerestrict.h @@ -387,6 +387,7 @@ enum TraceRestrictSlotSubtypeField { TRSCOF_PBS_RES_END_ACQ_WAIT = 4, ///< PBS reservations ending at this signal: acquire a slot, or wait TRSCOF_PBS_RES_END_ACQ_TRY = 5, ///< PBS reservations ending at this signal: acquire a slot, or carry on otherwise TRSCOF_PBS_RES_END_RELEASE = 6, ///< PBS reservations ending at this signal: release a slot + TRSCOF_RELEASE_ON_RESERVE = 7, ///< release a slot (on reserve) /* space up to 31 */ }; @@ -459,7 +460,7 @@ enum TraceRestrictProgramActionsUsedFlags { TRPAUF_RESERVE_THROUGH = 1 << 1, ///< Reserve through action is present 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_ACQUIRE = 1 << 4, ///< Slot acquire and/or release (on reserve) actions are 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 TRPAUF_PBS_RES_END_WAIT = 1 << 7, ///< PBS reservations ending at this signal wait action is present @@ -482,7 +483,7 @@ DECLARE_ENUM_AS_BIT_SET(TraceRestrictProgramActionsUsedFlags) * Enumeration for TraceRestrictProgramInput::permitted_slot_operations */ enum TraceRestrictProgramInputSlotPermissions : uint8_t { - TRPISP_ACQUIRE = 1 << 0, ///< Slot acquire is permitted + TRPISP_ACQUIRE = 1 << 0, ///< Slot acquire and release (on reserve) are permitted TRPISP_RELEASE_BACK = 1 << 1, ///< Slot release (back) is permitted TRPISP_RELEASE_FRONT = 1 << 2, ///< Slot release (front) is permitted TRPISP_PBS_RES_END_ACQUIRE = 1 << 3, ///< Slot acquire/release (PBS reservations ending at this signal) is permitted diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index 513203a675..fc20e9e761 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -815,6 +815,7 @@ static const StringID _slot_op_subtypes_str[] = { STR_TRACE_RESTRICT_SLOT_TRY_ACQUIRE, STR_TRACE_RESTRICT_SLOT_RELEASE_FRONT, STR_TRACE_RESTRICT_SLOT_RELEASE_BACK, + STR_TRACE_RESTRICT_SLOT_RELEASE_ON_RESERVE, STR_TRACE_RESTRICT_SLOT_PBS_RES_END_ACQUIRE_WAIT, STR_TRACE_RESTRICT_SLOT_PBS_RES_END_TRY_ACQUIRE, STR_TRACE_RESTRICT_SLOT_PBS_RES_END_RELEASE, @@ -825,6 +826,7 @@ static const uint _slot_op_subtypes_val[] = { TRSCOF_ACQUIRE_TRY, TRSCOF_RELEASE_FRONT, TRSCOF_RELEASE_BACK, + TRSCOF_RELEASE_ON_RESERVE, TRSCOF_PBS_RES_END_ACQ_WAIT, TRSCOF_PBS_RES_END_ACQ_TRY, TRSCOF_PBS_RES_END_RELEASE, @@ -1603,6 +1605,10 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric instruction_string = STR_TRACE_RESTRICT_SLOT_RELEASE_FRONT_ITEM; break; + case TRSCOF_RELEASE_ON_RESERVE: + instruction_string = STR_TRACE_RESTRICT_SLOT_RELEASE_ON_RESERVE_ITEM; + break; + case TRSCOF_PBS_RES_END_ACQ_WAIT: instruction_string = STR_TRACE_RESTRICT_SLOT_PBS_RES_END_ACQUIRE_WAIT_ITEM; break;