Add signals_style_lookahead_single_signal_only signal style property

This commit is contained in:
Jonathan G Rennison
2022-06-25 01:29:08 +01:00
parent 24e965061c
commit a311f12615
11 changed files with 54 additions and 5 deletions

View File

@@ -508,10 +508,21 @@ item (FEAT_GLOBALVARS) {
Set the look-ahead extra aspects for the most recently defined style (defined using the <span class="code">define_style</span> property).<br /> Set the look-ahead extra aspects for the most recently defined style (defined using the <span class="code">define_style</span> property).<br />
This property only makes a difference when the "limit train lookahead to signal aspect" game setting is enabled.<br /> This property only makes a difference when the "limit train lookahead to signal aspect" game setting is enabled.<br />
This limits the signal aspect which the hypothetical train driver can "read" from the signal without affecting signal aspect propagation to other signals, or variable <span class="code">extra_callback_info2</span>.<br /> This limits the signal aspect which the hypothetical train driver can "read" from the signal without affecting signal aspect propagation to other signals, or variable <span class="code">extra_callback_info2</span>.<br />
Example values could include: 1 for traditional banner repeater signals, or 0 for shunt signals.<br /> Example values could include: 1 for traditional banner repeater signals.<br />
Shunt signals should use <span class="code">style_lookahead_single_signal_only</span> instead.<br />
The value is clamped to be less than or equal to the value set in the <span class="code">extra_aspects</span> property. The value is clamped to be less than or equal to the value set in the <span class="code">extra_aspects</span> property.
</td> </td>
</tr> </tr>
<tr><td>style_lookahead_single_signal_only</td><td>0 or 1</td>
<td>
Set the look-ahead to single signal only mode for the most recently defined style (defined using the <span class="code">define_style</span> property).<br />
This property only makes a difference when the "limit train lookahead to signal aspect" game setting is enabled.<br />
This is similar to <span class="code">style_lookahead_extra_aspects</span> with a value of 0, except the lookahead always ends at the
next signal, even if that signal type sets <span class="code">style_no_aspect_increase</span>.<br />
If enabled, this property overrides <span class="code">style_lookahead_extra_aspects</span>.<br />
This can be used for shunt signals.
</td>
</tr>
<tr><td>style_opposite_side</td><td>0 or 1</td> <tr><td>style_opposite_side</td><td>0 or 1</td>
<td> <td>
Set whether signals should be drawn on the opposite side of the track for the most recently defined style (defined using the <span class="code">define_style</span> property). Set whether signals should be drawn on the opposite side of the track for the most recently defined style (defined using the <span class="code">define_style</span> property).

View File

@@ -475,11 +475,23 @@
<p>This applies to the most recent custom signal style defined using the <a href="#signals_define_style">signals_define_style</a> property.<br /> <p>This applies to the most recent custom signal style defined using the <a href="#signals_define_style">signals_define_style</a> property.<br />
This property only makes a difference when the "limit train lookahead to signal aspect" game setting is enabled.<br /> This property only makes a difference when the "limit train lookahead to signal aspect" game setting is enabled.<br />
This limits the signal aspect which the hypothetical train driver can "read" from the signal without affecting signal aspect propagation to other signals, or variable 0x18.<br /> This limits the signal aspect which the hypothetical train driver can "read" from the signal without affecting signal aspect propagation to other signals, or variable 0x18.<br />
Example values could include: 1 for traditional banner repeater signals, or 0 for shunt signals.</p> Example values could include: 1 for traditional banner repeater signals.<br />
Shunt signals should use <a href="#signals_style_lookahead_single_signal_only#">signals_style_lookahead_single_signal_only</a> instead.</p>
<p>The property length is 1 byte. The value is clamped to be less than or equal to the value set in the <a href="#signals_extra_aspects">signals_extra_aspects</a> property.<br /> <p>The property length is 1 byte. The value is clamped to be less than or equal to the value set in the <a href="#signals_extra_aspects">signals_extra_aspects</a> property.<br />
The Action 0 Id field is not used, the value is ignored. The Action 0 Id field is not used, the value is ignored.
</p> </p>
<p>This is indicated by the feature name: <font face="monospace">action0_signals_style</font>, version 1</p> <p>This is indicated by the feature name: <font face="monospace">action0_signals_style</font>, version 1</p>
<h4 id="signals_style_lookahead_single_signal_only">Set custom signal style train look-ahead to single signal only mode (mappable property: signals_style_lookahead_single_signal_only)</h4>
<p>This applies to the most recent custom signal style defined using the <a href="#signals_define_style">signals_define_style</a> property.<br />
This property only makes a difference when the "limit train lookahead to signal aspect" game setting is enabled.<br />
This is similar to <a href="#signals_style_lookahead_extra_aspects">signals_style_lookahead_extra_aspects</a> with a value of 0, except the lookahead always ends at the
next signal, even if that signal type sets <a href="#signals_style_no_aspect_increase">signals_style_no_aspect_increase</a>.<br />
If enabled, this property overrides <a href="#signals_style_lookahead_extra_aspects">signals_style_lookahead_extra_aspects</a>.<br />
This can be used for shunt signals.</p>
<p>The property length is 1 byte. 0 is disabled (default). 1 is enabled.<br />
The Action 0 Id field is not used, the value is ignored.
</p>
<p>This is indicated by the feature name: <font face="monospace">action0_signals_style</font>, version 1</p>
<h4 id="signals_style_opposite_side">Set custom signal style signal drawn on opposite side (mappable property: signals_style_opposite_side)</h4> <h4 id="signals_style_opposite_side">Set custom signal style signal drawn on opposite side (mappable property: signals_style_opposite_side)</h4>
<p>This applies to the most recent custom signal style defined using the <a href="#signals_define_style">signals_define_style</a> property.<br /> <p>This applies to the most recent custom signal style defined using the <a href="#signals_define_style">signals_define_style</a> property.<br />
When enabled, signals using this style are drawn on the opposite side of the track.</p> When enabled, signals using this style are drawn on the opposite side of the track.</p>

View File

@@ -4253,6 +4253,15 @@ static ChangeInfoResult SignalsChangeInfo(uint id, int numinfo, int prop, const
break; break;
} }
case A0RPI_SIGNALS_STYLE_LOOKAHEAD_SINGLE_SIGNAL_ONLY: {
if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break;
uint8 value = buf->ReadByte();
if (_cur.grffile->current_new_signal_style != nullptr) {
SB(_cur.grffile->current_new_signal_style->style_flags, NSSF_LOOKAHEAD_SINGLE_SIGNAL, 1, (value != 0 ? 1 : 0));
}
break;
}
case A0RPI_SIGNALS_STYLE_SEMAPHORE_ENABLED: { case A0RPI_SIGNALS_STYLE_SEMAPHORE_ENABLED: {
if (MappedPropertyLengthMismatch(buf, 4, mapping_entry)) break; if (MappedPropertyLengthMismatch(buf, 4, mapping_entry)) break;
uint32 mask = buf->ReadDWord(); uint32 mask = buf->ReadDWord();

View File

@@ -97,6 +97,7 @@ extern const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = {
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_NO_ASPECT_INCREASE, "signals_style_no_aspect_increase"), GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_NO_ASPECT_INCREASE, "signals_style_no_aspect_increase"),
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_ALWAYS_RESERVE_THROUGH, "signals_style_always_reserve_through"), GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_ALWAYS_RESERVE_THROUGH, "signals_style_always_reserve_through"),
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_LOOKAHEAD_EXTRA_ASPECTS, "signals_style_lookahead_extra_aspects"), GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_LOOKAHEAD_EXTRA_ASPECTS, "signals_style_lookahead_extra_aspects"),
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_LOOKAHEAD_SINGLE_SIGNAL_ONLY, "signals_style_lookahead_single_signal_only"),
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_SEMAPHORE_ENABLED, "signals_style_semaphore_enabled"), GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_SEMAPHORE_ENABLED, "signals_style_semaphore_enabled"),
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_ELECTRIC_ENABLED, "signals_style_electric_enabled"), GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_ELECTRIC_ENABLED, "signals_style_electric_enabled"),
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_OPPOSITE_SIDE, "signals_style_opposite_side"), GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_OPPOSITE_SIDE, "signals_style_opposite_side"),

View File

@@ -41,6 +41,7 @@ enum Action0RemapPropertyIds {
A0RPI_SIGNALS_STYLE_NO_ASPECT_INCREASE, A0RPI_SIGNALS_STYLE_NO_ASPECT_INCREASE,
A0RPI_SIGNALS_STYLE_ALWAYS_RESERVE_THROUGH, A0RPI_SIGNALS_STYLE_ALWAYS_RESERVE_THROUGH,
A0RPI_SIGNALS_STYLE_LOOKAHEAD_EXTRA_ASPECTS, A0RPI_SIGNALS_STYLE_LOOKAHEAD_EXTRA_ASPECTS,
A0RPI_SIGNALS_STYLE_LOOKAHEAD_SINGLE_SIGNAL_ONLY,
A0RPI_SIGNALS_STYLE_SEMAPHORE_ENABLED, A0RPI_SIGNALS_STYLE_SEMAPHORE_ENABLED,
A0RPI_SIGNALS_STYLE_ELECTRIC_ENABLED, A0RPI_SIGNALS_STYLE_ELECTRIC_ENABLED,
A0RPI_SIGNALS_STYLE_OPPOSITE_SIDE, A0RPI_SIGNALS_STYLE_OPPOSITE_SIDE,

View File

@@ -29,6 +29,7 @@ enum NewSignalStyleFlags {
NSSF_ALWAYS_RESERVE_THROUGH = 1, NSSF_ALWAYS_RESERVE_THROUGH = 1,
NSSF_LOOKAHEAD_ASPECTS_SET = 2, NSSF_LOOKAHEAD_ASPECTS_SET = 2,
NSSF_OPPOSITE_SIDE = 3, NSSF_OPPOSITE_SIDE = 3,
NSSF_LOOKAHEAD_SINGLE_SIGNAL = 4,
}; };
struct NewSignalStyle { struct NewSignalStyle {

View File

@@ -664,6 +664,9 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra
if (HasBit(_non_aspect_inc_style_mask, signal_style)) { if (HasBit(_non_aspect_inc_style_mask, signal_style)) {
SetBit(signal_flags, TRSLAI_NO_ASPECT_INC); SetBit(signal_flags, TRSLAI_NO_ASPECT_INC);
} }
if (HasBit(_next_only_style_mask, signal_style)) {
SetBit(signal_flags, TRSLAI_NEXT_ONLY);
}
lookahead->AddSignal(signal_speed, 0, z, signal_flags); lookahead->AddSignal(signal_speed, 0, z, signal_flags);
lookahead->SetNextExtendPositionIfUnset(); lookahead->SetNextExtendPositionIfUnset();
} }
@@ -1000,8 +1003,10 @@ void SetTrainReservationLookaheadEnd(Train *v)
int32 threshold = v->lookahead->current_position + 24; int32 threshold = v->lookahead->current_position + 24;
uint8 known_signals_ahead = 1; uint8 known_signals_ahead = 1;
bool allow_skip_no_aspect_inc = false;
if (v->IsInDepot()) { if (v->IsInDepot()) {
known_signals_ahead = _extra_aspects + 1; known_signals_ahead = _extra_aspects + 1;
allow_skip_no_aspect_inc = true;
} }
for (const TrainReservationLookAheadItem &item : v->lookahead->items) { for (const TrainReservationLookAheadItem &item : v->lookahead->items) {
if (item.end >= v->lookahead->reservation_end_position) break; if (item.end >= v->lookahead->reservation_end_position) break;
@@ -1010,10 +1015,11 @@ void SetTrainReservationLookaheadEnd(Train *v)
/* Signal is within visual range */ /* Signal is within visual range */
uint8 style = item.data_aux >> 8; uint8 style = item.data_aux >> 8;
uint8 max_aspect = (style == 0) ? _extra_aspects : _new_signal_styles[style - 1].lookahead_extra_aspects; uint8 max_aspect = (style == 0) ? _extra_aspects : _new_signal_styles[style - 1].lookahead_extra_aspects;
max_aspect += (HasBit(item.data_aux, TRSLAI_NO_ASPECT_INC) ? 1 : 2); if (!HasBit(item.data_aux, TRSLAI_NEXT_ONLY)) allow_skip_no_aspect_inc = true;
max_aspect += ((HasBit(item.data_aux, TRSLAI_NO_ASPECT_INC) && allow_skip_no_aspect_inc) ? 1 : 2);
if (max_aspect > known_signals_ahead) known_signals_ahead = max_aspect; if (max_aspect > known_signals_ahead) known_signals_ahead = max_aspect;
} }
if (!HasBit(item.data_aux, TRSLAI_NO_ASPECT_INC)) { if (!HasBit(item.data_aux, TRSLAI_NO_ASPECT_INC) || !allow_skip_no_aspect_inc) {
known_signals_ahead--; known_signals_ahead--;
if (known_signals_ahead == 0) { if (known_signals_ahead == 0) {
if (item.start > v->lookahead->lookahead_end_position) v->lookahead->lookahead_end_position = item.start; if (item.start > v->lookahead->lookahead_end_position) v->lookahead->lookahead_end_position = item.start;

View File

@@ -60,6 +60,7 @@ enum TrainReservationLookAheadItemType : byte {
enum TrainReservationSignalLookAheadItemFlags { enum TrainReservationSignalLookAheadItemFlags {
TRSLAI_NO_ASPECT_INC = 0, ///< This signal does not increase the signal aspect (e.g. banner repeater) TRSLAI_NO_ASPECT_INC = 0, ///< This signal does not increase the signal aspect (e.g. banner repeater)
TRSLAI_NEXT_ONLY = 1, ///< This signal only permits lookahead up to the next physical signal, even if that has TRSLAI_NO_ASPECT_INC (e.g. shunt)
}; };
struct TrainReservationLookAheadItem { struct TrainReservationLookAheadItem {

View File

@@ -31,6 +31,7 @@
uint8 _extra_aspects = 0; uint8 _extra_aspects = 0;
uint64 _aspect_cfg_hash = 0; uint64 _aspect_cfg_hash = 0;
uint16 _non_aspect_inc_style_mask = 0; uint16 _non_aspect_inc_style_mask = 0;
uint16 _next_only_style_mask = 0;
uint16 _always_reserve_through_style_mask = 0; uint16 _always_reserve_through_style_mask = 0;
uint16 _no_tunnel_bridge_style_mask = 0; uint16 _no_tunnel_bridge_style_mask = 0;
uint16 _signal_opposite_side_style_mask = 0; uint16 _signal_opposite_side_style_mask = 0;
@@ -1512,6 +1513,7 @@ static bool DetermineExtraAspectsVariable()
uint8 new_extra_aspects = 0; uint8 new_extra_aspects = 0;
_non_aspect_inc_style_mask = 0; _non_aspect_inc_style_mask = 0;
_next_only_style_mask = 0;
_no_tunnel_bridge_style_mask = 0; _no_tunnel_bridge_style_mask = 0;
_always_reserve_through_style_mask = 0; _always_reserve_through_style_mask = 0;
_signal_opposite_side_style_mask = 0; _signal_opposite_side_style_mask = 0;
@@ -1533,7 +1535,10 @@ static bool DetermineExtraAspectsVariable()
SetBit(_always_reserve_through_style_mask, i + 1); SetBit(_always_reserve_through_style_mask, i + 1);
SetBit(_no_tunnel_bridge_style_mask, i + 1); SetBit(_no_tunnel_bridge_style_mask, i + 1);
} }
if (HasBit(_new_signal_styles[i].style_flags, NSSF_LOOKAHEAD_ASPECTS_SET)) { if (HasBit(_new_signal_styles[i].style_flags, NSSF_LOOKAHEAD_SINGLE_SIGNAL)) {
_new_signal_styles[i].lookahead_extra_aspects = 0;
SetBit(_next_only_style_mask, i + 1);
} else if (HasBit(_new_signal_styles[i].style_flags, NSSF_LOOKAHEAD_ASPECTS_SET)) {
_new_signal_styles[i].lookahead_extra_aspects = std::min<uint8>(_new_signal_styles[i].lookahead_extra_aspects, _new_signal_styles[i].grffile->new_signal_extra_aspects); _new_signal_styles[i].lookahead_extra_aspects = std::min<uint8>(_new_signal_styles[i].lookahead_extra_aspects, _new_signal_styles[i].grffile->new_signal_extra_aspects);
} else { } else {
_new_signal_styles[i].lookahead_extra_aspects = _new_signal_styles[i].grffile->new_signal_extra_aspects; _new_signal_styles[i].lookahead_extra_aspects = _new_signal_styles[i].grffile->new_signal_extra_aspects;

View File

@@ -22,6 +22,7 @@
extern uint8 _extra_aspects; extern uint8 _extra_aspects;
extern uint64 _aspect_cfg_hash; extern uint64 _aspect_cfg_hash;
extern uint16 _non_aspect_inc_style_mask; extern uint16 _non_aspect_inc_style_mask;
extern uint16 _next_only_style_mask;
extern uint16 _always_reserve_through_style_mask; extern uint16 _always_reserve_through_style_mask;
extern uint16 _no_tunnel_bridge_style_mask; extern uint16 _no_tunnel_bridge_style_mask;
extern uint16 _signal_opposite_side_style_mask; extern uint16 _signal_opposite_side_style_mask;

View File

@@ -278,6 +278,7 @@ class NIHVehicle : public NIHelper {
case TRLIT_SIGNAL: case TRLIT_SIGNAL:
b += seprintf(b, lastof(buffer), "signal: target speed: %u, style: %u, flags:", item.data_id, item.data_aux >> 8); b += seprintf(b, lastof(buffer), "signal: target speed: %u, style: %u, flags:", item.data_id, item.data_aux >> 8);
if (HasBit(item.data_aux, TRSLAI_NO_ASPECT_INC)) b += seprintf(b, lastof(buffer), "n"); if (HasBit(item.data_aux, TRSLAI_NO_ASPECT_INC)) b += seprintf(b, lastof(buffer), "n");
if (HasBit(item.data_aux, TRSLAI_NEXT_ONLY)) b += seprintf(b, lastof(buffer), "s");
if (_settings_game.vehicle.realistic_braking_aspect_limited == TRBALM_ON && l.lookahead_end_position == item.start) { if (_settings_game.vehicle.realistic_braking_aspect_limited == TRBALM_ON && l.lookahead_end_position == item.start) {
b += seprintf(b, lastof(buffer), ", lookahead end"); b += seprintf(b, lastof(buffer), ", lookahead end");
print_braking_speed(item.start, 0, item.z_pos); print_braking_speed(item.start, 0, item.z_pos);