mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
Tracrestrict: Rename various constants for reverse behind signal
This commit is contained in:
parent
ff89547280
commit
c286210902
@ -113,7 +113,7 @@ uint GetNewSignalsRestrictedSignalsInfo(const TraceRestrictProgram *prog, TileIn
|
||||
if (prog != nullptr) {
|
||||
result |= 1;
|
||||
if ((prog->actions_used_flags & TRPAUF_RESERVE_THROUGH_ALWAYS) && !IsTileType(tile, MP_TUNNELBRIDGE)) result |= 2;
|
||||
if ((prog->actions_used_flags & TRPAUF_REVERSE) && !IsTileType(tile, MP_TUNNELBRIDGE)) result |= 4;
|
||||
if ((prog->actions_used_flags & TRPAUF_REVERSE_BEHIND) && !IsTileType(tile, MP_TUNNELBRIDGE)) result |= 4;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ private:
|
||||
flags_to_check |= TRPAUF_NO_PBS_BACK_PENALTY;
|
||||
}
|
||||
if (GetSignalType(tile, TrackdirToTrack(trackdir)) == SIGTYPE_PBS && !HasSignalOnTrackdir(tile, trackdir)) {
|
||||
flags_to_check |= TRPAUF_REVERSE;
|
||||
flags_to_check |= TRPAUF_REVERSE_BEHIND;
|
||||
}
|
||||
if (prog != nullptr && prog->actions_used_flags & flags_to_check) {
|
||||
prog->Execute(Yapf().GetVehicle(), TraceRestrictProgramInput(tile, trackdir, &TraceRestrictPreviousSignalCallback, &n), out);
|
||||
@ -312,7 +312,7 @@ private:
|
||||
n.m_segment->m_end_segment_reason |= ESRB_DEAD_END;
|
||||
return true;
|
||||
}
|
||||
if (out.flags & TRPRF_REVERSE && flags_to_check & TRPAUF_REVERSE && !n.flags_u.flags_s.m_reverse_pending) {
|
||||
if (out.flags & TRPRF_REVERSE_BEHIND && flags_to_check & TRPAUF_REVERSE_BEHIND && !n.flags_u.flags_s.m_reverse_pending) {
|
||||
n.flags_u.flags_s.m_reverse_pending = true;
|
||||
n.m_segment->m_end_segment_reason |= ESRB_REVERSE;
|
||||
}
|
||||
|
@ -645,7 +645,7 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra
|
||||
au_flags = TRPAUF_SPEED_RESTRICTION;
|
||||
} else {
|
||||
/* Passing through a signal from the rear side */
|
||||
au_flags = TRPAUF_SPEED_RESTRICTION | TRPAUF_REVERSE;
|
||||
au_flags = TRPAUF_SPEED_RESTRICTION | TRPAUF_REVERSE_BEHIND;
|
||||
}
|
||||
uint16_t speed_restriction = lookahead->speed_restriction;
|
||||
if (v != nullptr) {
|
||||
@ -654,7 +654,7 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra
|
||||
TraceRestrictProgramResult out;
|
||||
TraceRestrictProgramInput input(tile, trackdir, nullptr, nullptr);
|
||||
prog->Execute(v, input, out);
|
||||
if (out.flags & TRPRF_REVERSE && au_flags & TRPAUF_REVERSE) {
|
||||
if (out.flags & TRPRF_REVERSE_BEHIND && au_flags & TRPAUF_REVERSE_BEHIND) {
|
||||
lookahead->AddReverse(z);
|
||||
}
|
||||
if (out.flags & TRPRF_SPEED_RESTRICTION_SET) {
|
||||
@ -666,7 +666,7 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(au_flags & TRPAUF_REVERSE)) {
|
||||
if (!(au_flags & TRPAUF_REVERSE_BEHIND)) {
|
||||
/* Passing through a signal from the front side */
|
||||
uint16_t signal_speed = GetRailTypeInfo(rt)->max_speed;
|
||||
if (signal_speed == 0 || (speed_restriction != 0 && speed_restriction < signal_speed)) signal_speed = speed_restriction;
|
||||
|
@ -2268,7 +2268,7 @@ class NIHTraceRestrict : public NIHelper {
|
||||
CA(SLOT_RELEASE_FRONT)
|
||||
CA(PBS_RES_END_WAIT)
|
||||
CA(PBS_RES_END_SLOT)
|
||||
CA(REVERSE)
|
||||
CA(REVERSE_BEHIND)
|
||||
CA(SPEED_RESTRICTION)
|
||||
CA(TRAIN_NOT_STUCK)
|
||||
CA(CHANGE_COUNTER)
|
||||
|
@ -797,12 +797,13 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp
|
||||
|
||||
case TRIT_REVERSE:
|
||||
switch (static_cast<TraceRestrictReverseValueField>(GetTraceRestrictValue(item))) {
|
||||
case TRRVF_REVERSE:
|
||||
out.flags |= TRPRF_REVERSE;
|
||||
case TRRVF_REVERSE_BEHIND:
|
||||
out.flags |= TRPRF_REVERSE_BEHIND;
|
||||
break;
|
||||
|
||||
case TRRVF_CANCEL_REVERSE:
|
||||
out.flags &= ~TRPRF_REVERSE;
|
||||
case TRRVF_CANCEL_REVERSE_BEHIND:
|
||||
out.flags &= ~TRPRF_REVERSE_BEHIND;
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1401,12 +1402,12 @@ CommandCost TraceRestrictProgram::Validate(const std::vector<TraceRestrictItem>
|
||||
|
||||
case TRIT_REVERSE:
|
||||
switch (static_cast<TraceRestrictReverseValueField>(GetTraceRestrictValue(item))) {
|
||||
case TRRVF_REVERSE:
|
||||
actions_used_flags |= TRPAUF_REVERSE;
|
||||
case TRRVF_REVERSE_BEHIND:
|
||||
actions_used_flags |= TRPAUF_REVERSE_BEHIND;
|
||||
break;
|
||||
|
||||
case TRRVF_CANCEL_REVERSE:
|
||||
if (condstack.empty()) actions_used_flags &= ~TRPAUF_REVERSE;
|
||||
case TRRVF_CANCEL_REVERSE_BEHIND:
|
||||
if (condstack.empty()) actions_used_flags &= ~TRPAUF_REVERSE_BEHIND;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1749,7 +1750,7 @@ void TraceRestrictCheckRefreshSignals(const TraceRestrictProgram *prog, size_t o
|
||||
|
||||
if (IsHeadless()) return;
|
||||
|
||||
if (!((old_actions_used_flags ^ prog->actions_used_flags) & (TRPAUF_RESERVE_THROUGH_ALWAYS | TRPAUF_REVERSE))) return;
|
||||
if (!((old_actions_used_flags ^ prog->actions_used_flags) & (TRPAUF_RESERVE_THROUGH_ALWAYS | TRPAUF_REVERSE_BEHIND))) return;
|
||||
|
||||
if (old_size == 0 && prog->refcount == 1) return; // Program is new, no need to refresh again
|
||||
|
||||
|
@ -310,8 +310,8 @@ enum TraceRestrictWaitAtPbsValueField : uint8_t {
|
||||
* TraceRestrictItem value field, for TRIT_REVERSE
|
||||
*/
|
||||
enum TraceRestrictReverseValueField : uint8_t {
|
||||
TRRVF_REVERSE = 0, ///< Reverse
|
||||
TRRVF_CANCEL_REVERSE = 1, ///< Cancel reverse
|
||||
TRRVF_REVERSE_BEHIND = 0, ///< Reverse behind signal
|
||||
TRRVF_CANCEL_REVERSE_BEHIND = 1, ///< Cancel reverse behind signal
|
||||
};
|
||||
|
||||
/**
|
||||
@ -440,7 +440,7 @@ enum TraceRestrictProgramResultFlags : uint16_t {
|
||||
TRPRF_LONG_RESERVE = 1 << 2, ///< Long reserve is set
|
||||
TRPRF_WAIT_AT_PBS = 1 << 3, ///< Wait at PBS signal is set
|
||||
TRPRF_PBS_RES_END_WAIT = 1 << 4, ///< PBS reservations ending at this signal wait is set
|
||||
TRPRF_REVERSE = 1 << 5, ///< Reverse behind signal
|
||||
TRPRF_REVERSE_BEHIND = 1 << 5, ///< Reverse behind signal
|
||||
TRPRF_SPEED_RESTRICTION_SET = 1 << 6, ///< Speed restriction field set
|
||||
TRPRF_TRAIN_NOT_STUCK = 1 << 7, ///< Train is not stuck
|
||||
TRPRF_NO_PBS_BACK_PENALTY = 1 << 8, ///< Do not apply PBS back penalty
|
||||
@ -465,7 +465,7 @@ enum TraceRestrictProgramActionsUsedFlags : uint32_t {
|
||||
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
|
||||
TRPAUF_PBS_RES_END_SLOT = 1 << 8, ///< PBS reservations ending at this signal slot action is present
|
||||
TRPAUF_REVERSE = 1 << 9, ///< Reverse behind signal
|
||||
TRPAUF_REVERSE_BEHIND = 1 << 9, ///< Reverse behind signal
|
||||
TRPAUF_SPEED_RESTRICTION = 1 << 10, ///< Speed restriction
|
||||
TRPAUF_TRAIN_NOT_STUCK = 1 << 11, ///< Train is not stuck
|
||||
TRPAUF_CHANGE_COUNTER = 1 << 12, ///< Change counter value is present
|
||||
|
@ -337,8 +337,8 @@ static const StringID _reverse_value_str[] = {
|
||||
STR_TRACE_RESTRICT_REVERSE_SIG_CANCEL,
|
||||
};
|
||||
static const uint _reverse_value_val[] = {
|
||||
TRRVF_REVERSE,
|
||||
TRRVF_CANCEL_REVERSE,
|
||||
TRRVF_REVERSE_BEHIND,
|
||||
TRRVF_CANCEL_REVERSE_BEHIND,
|
||||
};
|
||||
|
||||
/** value drop down list for reverse types strings and values */
|
||||
@ -1606,11 +1606,11 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric
|
||||
|
||||
case TRIT_REVERSE:
|
||||
switch (static_cast<TraceRestrictReverseValueField>(GetTraceRestrictValue(item))) {
|
||||
case TRRVF_REVERSE:
|
||||
case TRRVF_REVERSE_BEHIND:
|
||||
instruction_string = STR_TRACE_RESTRICT_REVERSE_SIG;
|
||||
break;
|
||||
|
||||
case TRRVF_CANCEL_REVERSE:
|
||||
case TRRVF_CANCEL_REVERSE_BEHIND:
|
||||
instruction_string = STR_TRACE_RESTRICT_REVERSE_SIG_CANCEL;
|
||||
break;
|
||||
|
||||
|
@ -5753,10 +5753,10 @@ 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 (HasSignalOnTrack(gp.new_tile, TrackdirToTrack(dir))) {
|
||||
TrainControllerTraceRestrictFrontEvaluation(gp.new_tile, dir, v, TRPAUF_REVERSE, [&]() -> bool {
|
||||
TrainControllerTraceRestrictFrontEvaluation(gp.new_tile, dir, v, TRPAUF_REVERSE_BEHIND, [&]() -> bool {
|
||||
return !IsPbsSignal(GetSignalType(gp.new_tile, TrackdirToTrack(dir)));
|
||||
}, [&](const TraceRestrictProgramResult &out) {
|
||||
if (out.flags & TRPRF_REVERSE && GetSignalType(gp.new_tile, TrackdirToTrack(dir)) == SIGTYPE_PBS &&
|
||||
if (out.flags & TRPRF_REVERSE_BEHIND && GetSignalType(gp.new_tile, TrackdirToTrack(dir)) == SIGTYPE_PBS &&
|
||||
!HasSignalOnTrackdir(gp.new_tile, dir)) {
|
||||
v->reverse_distance = v->gcache.cached_total_length + (IsDiagonalTrack(TrackdirToTrack(dir)) ? 16 : 8);
|
||||
SetWindowDirty(WC_VEHICLE_VIEW, v->index);
|
||||
|
Loading…
Reference in New Issue
Block a user