Add signal style flag for no aspect increase behaviour (banner repeater)

pull/400/head
Jonathan G Rennison 2 years ago
parent 6e4c4b35e7
commit 7ae06124ae

@ -460,6 +460,12 @@ item (FEAT_GLOBALVARS) {
This property should be used if using the define_style property, as otherwise the style will have no name. This property should be used if using the define_style property, as otherwise the style will have no name.
</td> </td>
</tr> </tr>
<tr><td>style_no_aspect_increase</td><td>0 or 1</td>
<td>
Set whether the most recently defined style (defined using the define_style property) does not increase
the signal aspect with respect to the signals either side (i.e. function like a banner repeater).
</td>
</tr>
<tr><td>no_default_style</td><td>0 or 1</td> <tr><td>no_default_style</td><td>0 or 1</td>
<td> <td>
When enabled, custom signal graphics from this GRF are only used for custom signal styles, not the default style When enabled, custom signal graphics from this GRF are only used for custom signal styles, not the default style

@ -431,6 +431,13 @@
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_no_aspect_increase">Set custom signal style no aspect increase mode (mappable property: signals_style_no_aspect_increase)</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 />
When enabled, signals using this style do not increase the signal aspect with respect to the signals either side (i.e. function like a banner repeater).</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_no_default_style">Set whether custom signal sprites should not be used for the default signal style (mappable property: signals_no_default_style)</h4> <h4 id="signals_no_default_style">Set whether custom signal sprites should not be used for the default signal style (mappable property: signals_no_default_style)</h4>
<p>This applies to <a href="#a3signals_custom_signal_sprites">Action 2/3 Signals (Feature 0E) custom signal sprites</a> for this GRF.<br /> <p>This applies to <a href="#a3signals_custom_signal_sprites">Action 2/3 Signals (Feature 0E) custom signal sprites</a> for this GRF.<br />
When enabled, this GRF is not used for the default signal style, it is only used for custom signal styles defined with <a href="#signals_define_style">signals_define_style</a>.</p> When enabled, this GRF is not used for the default signal style, it is only used for custom signal styles defined with <a href="#signals_define_style">signals_define_style</a>.</p>

@ -6266,6 +6266,7 @@ STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM :{WHITE}Can't re
STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE :{WHITE}Can't convert signals here... STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE :{WHITE}Can't convert signals here...
STR_ERROR_THERE_IS_NO_RAILROAD_TRACK :{WHITE}... there is no railway track STR_ERROR_THERE_IS_NO_RAILROAD_TRACK :{WHITE}... there is no railway track
STR_ERROR_THERE_ARE_NO_SIGNALS :{WHITE}... there are no signals STR_ERROR_THERE_ARE_NO_SIGNALS :{WHITE}... there are no signals
STR_ERROR_UNSUITABLE_SIGNAL_TYPE :{WHITE}... unsuitable signal type
STR_ERROR_CAN_T_CONVERT_RAIL :{WHITE}Can't convert rail type here... STR_ERROR_CAN_T_CONVERT_RAIL :{WHITE}Can't convert rail type here...

@ -99,6 +99,7 @@ void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settin
_extra_station_names_used = 0; _extra_station_names_used = 0;
_extra_station_names_probability = 0; _extra_station_names_probability = 0;
_extra_aspects = 0; _extra_aspects = 0;
_aspect_cfg_hash = 0;
_loadgame_DBGL_data.clear(); _loadgame_DBGL_data.clear();
if (reset_settings) MakeNewgameSettingsLive(); if (reset_settings) MakeNewgameSettingsLive();

@ -4225,6 +4225,15 @@ static ChangeInfoResult SignalsChangeInfo(uint id, int numinfo, int prop, const
break; break;
} }
case A0RPI_SIGNALS_STYLE_NO_ASPECT_INCREASE: {
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_NO_ASPECT_INC, 1, (value != 0 ? 1 : 0));
}
break;
}
default: default:
ret = HandleAction0PropertyDefault(buf, prop); ret = HandleAction0PropertyDefault(buf, prop);
break; break;

@ -94,6 +94,7 @@ extern const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = {
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_NO_DEFAULT_STYLE, "signals_no_default_style"), GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_NO_DEFAULT_STYLE, "signals_no_default_style"),
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_DEFINE_STYLE, "signals_define_style"), GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_DEFINE_STYLE, "signals_define_style"),
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_NAME, "signals_style_name"), GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_NAME, "signals_style_name"),
GRFPropertyMapDefinition(GSF_SIGNALS, A0RPI_SIGNALS_STYLE_NO_ASPECT_INCREASE, "signals_style_no_aspect_increase"),
GRFPropertyMapDefinition(GSF_OBJECTS, A0RPI_OBJECT_USE_LAND_GROUND, "object_use_land_ground"), GRFPropertyMapDefinition(GSF_OBJECTS, A0RPI_OBJECT_USE_LAND_GROUND, "object_use_land_ground"),
GRFPropertyMapDefinition(GSF_OBJECTS, A0RPI_OBJECT_EDGE_FOUNDATION_MODE, "object_edge_foundation_mode"), GRFPropertyMapDefinition(GSF_OBJECTS, A0RPI_OBJECT_EDGE_FOUNDATION_MODE, "object_edge_foundation_mode"),
GRFPropertyMapDefinition(GSF_OBJECTS, A0RPI_OBJECT_FLOOD_RESISTANT, "object_flood_resistant"), GRFPropertyMapDefinition(GSF_OBJECTS, A0RPI_OBJECT_FLOOD_RESISTANT, "object_flood_resistant"),

@ -38,6 +38,7 @@ enum Action0RemapPropertyIds {
A0RPI_SIGNALS_NO_DEFAULT_STYLE, A0RPI_SIGNALS_NO_DEFAULT_STYLE,
A0RPI_SIGNALS_DEFINE_STYLE, A0RPI_SIGNALS_DEFINE_STYLE,
A0RPI_SIGNALS_STYLE_NAME, A0RPI_SIGNALS_STYLE_NAME,
A0RPI_SIGNALS_STYLE_NO_ASPECT_INCREASE,
A0RPI_OBJECT_USE_LAND_GROUND, A0RPI_OBJECT_USE_LAND_GROUND,
A0RPI_OBJECT_EDGE_FOUNDATION_MODE, A0RPI_OBJECT_EDGE_FOUNDATION_MODE,
A0RPI_OBJECT_FLOOD_RESISTANT, A0RPI_OBJECT_FLOOD_RESISTANT,

@ -24,10 +24,15 @@ enum {
MAX_NEW_SIGNAL_STYLES = 15, MAX_NEW_SIGNAL_STYLES = 15,
}; };
enum NewSignalStyleFlags {
NSSF_NO_ASPECT_INC = 0,
};
struct NewSignalStyle { struct NewSignalStyle {
const GRFFile *grffile; const GRFFile *grffile;
StringID name = 0; StringID name;
uint8 grf_local_id; uint8 grf_local_id;
uint8 style_flags;
PalSpriteID signals[SIGTYPE_END][2][2]; PalSpriteID signals[SIGTYPE_END][2][2];
}; };

@ -476,6 +476,7 @@ static void ShutdownGame()
_extra_station_names_used = 0; _extra_station_names_used = 0;
_extra_station_names_probability = 0; _extra_station_names_probability = 0;
_extra_aspects = 0; _extra_aspects = 0;
_aspect_cfg_hash = 0;
_loadgame_DBGL_data.clear(); _loadgame_DBGL_data.clear();
_loadgame_DBGC_data.clear(); _loadgame_DBGC_data.clear();
} }

@ -1517,7 +1517,10 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
bool p2_active = p2_signal_in || p2_signal_out; bool p2_active = p2_signal_in || p2_signal_out;
if (!IsTunnelBridgeWithSignalSimulation(tile)) { // toggle signal zero costs. if (!IsTunnelBridgeWithSignalSimulation(tile)) { // toggle signal zero costs.
if (convert_signal) return_cmd_error(STR_ERROR_THERE_ARE_NO_SIGNALS); if (convert_signal) return_cmd_error(STR_ERROR_THERE_ARE_NO_SIGNALS);
if (!(p2_signal_in && p2_signal_out)) cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_SIGNALS] * ((GetTunnelBridgeLength(tile, tile_exit) + 4) >> 2) * (bidirectional ? 2 : 1)); // minimal 1 if (!(p2_signal_in && p2_signal_out)) {
cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_SIGNALS] * ((GetTunnelBridgeLength(tile, tile_exit) + 4) >> 2) * (bidirectional ? 2 : 1)); // minimal 1
if (HasBit(_no_tunnel_bridge_style_mask, signal_style)) return_cmd_error(STR_ERROR_UNSUITABLE_SIGNAL_TYPE);
}
} else { } else {
if (HasBit(p1, 17)) return CommandCost(); if (HasBit(p1, 17)) return CommandCost();
bool is_bidi = IsTunnelBridgeSignalSimulationBidirectional(tile); bool is_bidi = IsTunnelBridgeSignalSimulationBidirectional(tile);
@ -1526,6 +1529,7 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (convert_signal) { if (convert_signal) {
will_be_bidi = bidirectional && !ctrl_pressed; will_be_bidi = bidirectional && !ctrl_pressed;
change_style = (signal_style != GetTunnelBridgeSignalStyle(tile)); change_style = (signal_style != GetTunnelBridgeSignalStyle(tile));
if (HasBit(_no_tunnel_bridge_style_mask, signal_style)) return_cmd_error(STR_ERROR_UNSUITABLE_SIGNAL_TYPE);
} else if (ctrl_pressed) { } else if (ctrl_pressed) {
will_be_bidi = false; will_be_bidi = false;
} }

@ -3670,6 +3670,7 @@ bool AfterLoadGame()
} }
/* force aspect re-calculation */ /* force aspect re-calculation */
_extra_aspects = 0; _extra_aspects = 0;
_aspect_cfg_hash = 0;
} }
if (SlXvIsFeatureMissing(XSLFI_CUSTOM_BRIDGE_HEADS)) { if (SlXvIsFeatureMissing(XSLFI_CUSTOM_BRIDGE_HEADS)) {

@ -151,7 +151,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_ANIMATED_TILE_EXTRA, XSCF_NULL, 1, 1, "animated_tile_extra", nullptr, nullptr, nullptr }, { XSLFI_ANIMATED_TILE_EXTRA, XSCF_NULL, 1, 1, "animated_tile_extra", nullptr, nullptr, nullptr },
{ XSLFI_NEWGRF_INFO_EXTRA, XSCF_NULL, 1, 1, "newgrf_info_extra", nullptr, nullptr, nullptr }, { XSLFI_NEWGRF_INFO_EXTRA, XSCF_NULL, 1, 1, "newgrf_info_extra", nullptr, nullptr, nullptr },
{ XSLFI_INDUSTRY_CARGO_ADJ, XSCF_IGNORABLE_UNKNOWN, 1, 1, "industry_cargo_adj", nullptr, nullptr, nullptr }, { XSLFI_INDUSTRY_CARGO_ADJ, XSCF_IGNORABLE_UNKNOWN, 1, 1, "industry_cargo_adj", nullptr, nullptr, nullptr },
{ XSLFI_REALISTIC_TRAIN_BRAKING,XSCF_NULL, 6, 6, "realistic_train_braking", nullptr, nullptr, "VLKA" }, { XSLFI_REALISTIC_TRAIN_BRAKING,XSCF_NULL, 7, 7, "realistic_train_braking", nullptr, nullptr, "VLKA" },
{ XSLFI_INFLATION_FIXED_DATES, XSCF_IGNORABLE_ALL, 1, 1, "inflation_fixed_dates", nullptr, nullptr, nullptr }, { XSLFI_INFLATION_FIXED_DATES, XSCF_IGNORABLE_ALL, 1, 1, "inflation_fixed_dates", nullptr, nullptr, nullptr },
{ XSLFI_WATER_FLOODING, XSCF_NULL, 2, 2, "water_flooding", nullptr, nullptr, nullptr }, { XSLFI_WATER_FLOODING, XSCF_NULL, 2, 2, "water_flooding", nullptr, nullptr, nullptr },
{ XSLFI_MORE_HOUSES, XSCF_NULL, 2, 2, "more_houses", nullptr, nullptr, nullptr }, { XSLFI_MORE_HOUSES, XSCF_NULL, 2, 2, "more_houses", nullptr, nullptr, nullptr },

@ -28,6 +28,7 @@ extern TileIndex _cur_tileloop_tile;
extern uint16 _disaster_delay; extern uint16 _disaster_delay;
extern byte _trees_tick_ctr; extern byte _trees_tick_ctr;
extern uint8 _extra_aspects; extern uint8 _extra_aspects;
extern uint64 _aspect_cfg_hash;
/* Keep track of current game position */ /* Keep track of current game position */
int _saved_scrollpos_x; int _saved_scrollpos_x;
@ -97,7 +98,8 @@ static const SaveLoad _date_desc[] = {
SLEG_CONDVAR(_pause_mode, SLE_UINT8, SLV_4, SL_MAX_VERSION), SLEG_CONDVAR(_pause_mode, SLE_UINT8, SLV_4, SL_MAX_VERSION),
SLEG_CONDVAR_X(_game_events_overall, SLE_UINT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GAME_EVENTS)), SLEG_CONDVAR_X(_game_events_overall, SLE_UINT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GAME_EVENTS)),
SLEG_CONDVAR_X(_road_layout_change_counter, SLE_UINT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_ROAD_LAYOUT_CHANGE_CTR)), SLEG_CONDVAR_X(_road_layout_change_counter, SLE_UINT32, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_ROAD_LAYOUT_CHANGE_CTR)),
SLEG_CONDVAR_X(_extra_aspects, SLE_UINT8, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_REALISTIC_TRAIN_BRAKING, 4)), SLE_CONDNULL_X(1, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_REALISTIC_TRAIN_BRAKING, 4, 6)), // _extra_aspects
SLEG_CONDVAR_X(_aspect_cfg_hash, SLE_UINT64, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_REALISTIC_TRAIN_BRAKING, 7)),
SLE_CONDNULL(4, SLV_11, SLV_120), SLE_CONDNULL(4, SLV_11, SLV_120),
}; };
@ -126,7 +128,8 @@ static const SaveLoad _date_check_desc[] = {
SLE_CONDNULL(1, SLV_4, SL_MAX_VERSION), // _pause_mode SLE_CONDNULL(1, SLV_4, SL_MAX_VERSION), // _pause_mode
SLE_CONDNULL_X(4, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GAME_EVENTS)), // _game_events_overall SLE_CONDNULL_X(4, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_GAME_EVENTS)), // _game_events_overall
SLE_CONDNULL_X(4, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_ROAD_LAYOUT_CHANGE_CTR)), // _road_layout_change_counter SLE_CONDNULL_X(4, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_ROAD_LAYOUT_CHANGE_CTR)), // _road_layout_change_counter
SLE_CONDNULL_X(1, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_REALISTIC_TRAIN_BRAKING, 4)), // _extra_aspects SLE_CONDNULL_X(1, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_REALISTIC_TRAIN_BRAKING, 4, 6)), // _extra_aspects
SLE_CONDNULL_X(8, SL_MIN_VERSION, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_REALISTIC_TRAIN_BRAKING, 7)), // _aspect_cfg_hash
SLE_CONDNULL(4, SLV_11, SLV_120), SLE_CONDNULL(4, SLV_11, SLV_120),
}; };

@ -23,10 +23,15 @@
#include "tunnelbridge.h" #include "tunnelbridge.h"
#include "bridge_signal_map.h" #include "bridge_signal_map.h"
#include "newgrf_newsignals.h" #include "newgrf_newsignals.h"
#include "core/checksum_func.hpp"
#include "core/hash_func.hpp"
#include "safeguards.h" #include "safeguards.h"
uint8 _extra_aspects = 0; uint8 _extra_aspects = 0;
uint64 _aspect_cfg_hash = 0;
uint16 _non_aspect_inc_style_mask = 0;
uint16 _no_tunnel_bridge_style_mask = 0;
bool _signal_sprite_oversized = false; bool _signal_sprite_oversized = false;
/// List of signals dependent upon this one /// List of signals dependent upon this one
@ -614,7 +619,9 @@ uint8 GetForwardAspectFollowingTrack(TileIndex tile, Trackdir trackdir)
if (HasSignalOnTrack(tile, track)) { // now check whole track, not trackdir if (HasSignalOnTrack(tile, track)) { // now check whole track, not trackdir
if (HasSignalOnTrackdir(tile, trackdir)) { if (HasSignalOnTrackdir(tile, trackdir)) {
if (GetSignalStateByTrackdir(tile, trackdir) == SIGNAL_STATE_RED) return 0; if (GetSignalStateByTrackdir(tile, trackdir) == SIGNAL_STATE_RED) return 0;
return GetSignalAspect(tile, track); uint8 aspect = GetSignalAspect(tile, track);
AdjustSignalAspectIfNonIncStyle(tile, track, aspect);
return aspect;
} else if (IsOnewaySignal(tile, track)) { } else if (IsOnewaySignal(tile, track)) {
return 0; // one-way signal facing the wrong way return 0; // one-way signal facing the wrong way
} }
@ -666,7 +673,7 @@ uint8 GetForwardAspectFollowingTrack(TileIndex tile, Trackdir trackdir)
trackdir = TrackEnterdirToTrackdir(track, ReverseDiagDir(enterdir)); trackdir = TrackEnterdirToTrackdir(track, ReverseDiagDir(enterdir));
if (IsTunnelBridgeWithSignalSimulation(tile) && HasTrack(GetAcrossTunnelBridgeTrackBits(tile), track)) { if (IsTunnelBridgeWithSignalSimulation(tile) && HasTrack(GetAcrossTunnelBridgeTrackBits(tile), track)) {
return GetSignalAspectGeneric(tile, trackdir); return GetSignalAspectGeneric(tile, trackdir, false);
} }
if (TrackdirEntersTunnelBridge(tile, trackdir)) { if (TrackdirEntersTunnelBridge(tile, trackdir)) {
@ -694,7 +701,7 @@ static uint8 GetForwardAspect(const SigInfo &info, TileIndex tile, Trackdir trac
if (info.flags & SF_JUNCTION) { if (info.flags & SF_JUNCTION) {
return GetForwardAspectFollowingTrack(tile, trackdir); return GetForwardAspectFollowingTrack(tile, trackdir);
} else { } else {
return (info.out_signal_tile != INVALID_TILE) ? GetSignalAspectGeneric(info.out_signal_tile, info.out_signal_trackdir) : 0; return (info.out_signal_tile != INVALID_TILE) ? GetSignalAspectGeneric(info.out_signal_tile, info.out_signal_trackdir, true) : 0;
} }
} }
@ -828,7 +835,7 @@ static void UpdateSignalsAroundSegment(SigInfo info)
if (newstate == SIGNAL_STATE_GREEN) { if (newstate == SIGNAL_STATE_GREEN) {
aspect = 1; aspect = 1;
if (info.out_signal_tile != INVALID_TILE) { if (info.out_signal_tile != INVALID_TILE) {
aspect = std::min<uint8>(GetSignalAspectGeneric(info.out_signal_tile, info.out_signal_trackdir) + 1, _extra_aspects + 1); aspect = std::min<uint8>(GetSignalAspectGeneric(info.out_signal_tile, info.out_signal_trackdir, true) + 1, _extra_aspects + 1);
} }
} else { } else {
aspect = 0; aspect = 0;
@ -1220,12 +1227,14 @@ void CheckRemoveSignal(TileIndex tile, Track track)
} }
} }
uint8 GetSignalAspectGeneric(TileIndex tile, Trackdir trackdir) uint8 GetSignalAspectGeneric(TileIndex tile, Trackdir trackdir, bool check_non_inc_style)
{ {
switch (GetTileType(tile)) { switch (GetTileType(tile)) {
case MP_RAILWAY: case MP_RAILWAY:
if (HasSignalOnTrackdir(tile, trackdir) && GetSignalStateByTrackdir(tile, trackdir) == SIGNAL_STATE_GREEN) { if (HasSignalOnTrackdir(tile, trackdir) && GetSignalStateByTrackdir(tile, trackdir) == SIGNAL_STATE_GREEN) {
return GetSignalAspect(tile, TrackdirToTrack(trackdir)); uint8 aspect = GetSignalAspect(tile, TrackdirToTrack(trackdir));
if (check_non_inc_style) AdjustSignalAspectIfNonIncStyle(tile, TrackdirToTrack(trackdir), aspect);
return aspect;
} }
break; break;
@ -1245,6 +1254,11 @@ uint8 GetSignalAspectGeneric(TileIndex tile, Trackdir trackdir)
return 0; return 0;
} }
void AdjustSignalAspectIfNonIncStyleIntl(TileIndex tile, Track track, uint8 &aspect)
{
if (IsTileType(tile, MP_RAILWAY) && HasBit(_non_aspect_inc_style_mask, GetSignalStyle(tile, track))) aspect--;
}
static void RefreshBridgeOnExitAspectChange(TileIndex entrance, TileIndex exit) static void RefreshBridgeOnExitAspectChange(TileIndex entrance, TileIndex exit)
{ {
const uint simulated_wormhole_signals = GetTunnelBridgeSignalSimulationSpacing(entrance); const uint simulated_wormhole_signals = GetTunnelBridgeSignalSimulationSpacing(entrance);
@ -1263,6 +1277,8 @@ static void RefreshBridgeOnExitAspectChange(TileIndex entrance, TileIndex exit)
void PropagateAspectChange(TileIndex tile, Trackdir trackdir, uint8 aspect) void PropagateAspectChange(TileIndex tile, Trackdir trackdir, uint8 aspect)
{ {
AdjustSignalAspectIfNonIncStyle(tile, TrackdirToTrack(trackdir), aspect);
aspect = std::min<uint8>(aspect + 1, _extra_aspects + 1); aspect = std::min<uint8>(aspect + 1, _extra_aspects + 1);
Owner owner = GetTileOwner(tile); Owner owner = GetTileOwner(tile);
DiagDirection exitdir = TrackdirToExitdir(ReverseTrackdir(trackdir)); DiagDirection exitdir = TrackdirToExitdir(ReverseTrackdir(trackdir));
@ -1310,6 +1326,7 @@ void PropagateAspectChange(TileIndex tile, Trackdir trackdir, uint8 aspect)
if (GetSignalAspect(tile, track) == aspect) return; // aspect already correct if (GetSignalAspect(tile, track) == aspect) return; // aspect already correct
SetSignalAspect(tile, track, aspect); SetSignalAspect(tile, track, aspect);
MarkSingleSignalDirty(tile, reversedir); MarkSingleSignalDirty(tile, reversedir);
AdjustSignalAspectIfNonIncStyle(tile, TrackdirToTrack(trackdir), aspect);
aspect = std::min<uint8>(aspect + 1, _extra_aspects + 1); aspect = std::min<uint8>(aspect + 1, _extra_aspects + 1);
} else if (IsOnewaySignal(tile, track)) { } else if (IsOnewaySignal(tile, track)) {
return; // one-way signal facing the wrong way return; // one-way signal facing the wrong way
@ -1479,10 +1496,14 @@ void UpdateAllSignalAspects()
} }
} }
static uint8 DetermineExtraAspectsVariable() static bool DetermineExtraAspectsVariable()
{ {
bool changed = false;
uint8 new_extra_aspects = 0; uint8 new_extra_aspects = 0;
_non_aspect_inc_style_mask = 0;
_no_tunnel_bridge_style_mask = 0;
if (_settings_game.vehicle.train_braking_model == TBM_REALISTIC) { if (_settings_game.vehicle.train_braking_model == TBM_REALISTIC) {
for (RailType r = RAILTYPE_BEGIN; r != RAILTYPE_END; r++) { for (RailType r = RAILTYPE_BEGIN; r != RAILTYPE_END; r++) {
const RailtypeInfo *rti = GetRailTypeInfo(r); const RailtypeInfo *rti = GetRailTypeInfo(r);
@ -1491,17 +1512,33 @@ static uint8 DetermineExtraAspectsVariable()
for (const GRFFile *grf : _new_signals_grfs) { for (const GRFFile *grf : _new_signals_grfs) {
new_extra_aspects = std::max<uint8>(new_extra_aspects, grf->new_signal_extra_aspects); new_extra_aspects = std::max<uint8>(new_extra_aspects, grf->new_signal_extra_aspects);
} }
for (uint i = 0; i < _num_new_signal_styles; i++) {
if (HasBit(_new_signal_styles[i].style_flags, NSSF_NO_ASPECT_INC)) {
SetBit(_non_aspect_inc_style_mask, i + 1);
SetBit(_no_tunnel_bridge_style_mask, i + 1);
}
}
}
_extra_aspects = new_extra_aspects;
SimpleChecksum64 checksum;
checksum.Update(SimpleHash32(_extra_aspects));
checksum.Update(SimpleHash32(_non_aspect_inc_style_mask));
if (checksum.state != _aspect_cfg_hash) {
_aspect_cfg_hash = checksum.state;
changed = true;
} }
return new_extra_aspects; return changed;
} }
void UpdateExtraAspectsVariable() void UpdateExtraAspectsVariable()
{ {
uint8 new_extra_aspects = DetermineExtraAspectsVariable(); bool changed = DetermineExtraAspectsVariable();
if (new_extra_aspects != _extra_aspects) { if (changed) {
_extra_aspects = new_extra_aspects;
if (_extra_aspects > 0) UpdateAllSignalAspects(); if (_extra_aspects > 0) UpdateAllSignalAspects();
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
@ -1509,5 +1546,5 @@ void UpdateExtraAspectsVariable()
void InitialiseExtraAspectsVariable() void InitialiseExtraAspectsVariable()
{ {
_extra_aspects = DetermineExtraAspectsVariable(); DetermineExtraAspectsVariable();
} }

@ -20,6 +20,9 @@
#include "vehicle_type.h" #include "vehicle_type.h"
extern uint8 _extra_aspects; extern uint8 _extra_aspects;
extern uint64 _aspect_cfg_hash;
extern uint16 _non_aspect_inc_style_mask;
extern uint16 _no_tunnel_bridge_style_mask;
extern bool _signal_sprite_oversized; extern bool _signal_sprite_oversized;
/** /**
@ -170,7 +173,7 @@ void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner);
void UpdateSignalsInBuffer(); void UpdateSignalsInBuffer();
void UpdateSignalsInBufferIfOwnerNotAddable(Owner owner); void UpdateSignalsInBufferIfOwnerNotAddable(Owner owner);
uint8 GetForwardAspectFollowingTrack(TileIndex tile, Trackdir trackdir); uint8 GetForwardAspectFollowingTrack(TileIndex tile, Trackdir trackdir);
uint8 GetSignalAspectGeneric(TileIndex tile, Trackdir trackdir); uint8 GetSignalAspectGeneric(TileIndex tile, Trackdir trackdir, bool check_non_inc_style);
void PropagateAspectChange(TileIndex tile, Trackdir trackdir, uint8 aspect); void PropagateAspectChange(TileIndex tile, Trackdir trackdir, uint8 aspect);
void UpdateAspectDeferred(TileIndex tile, Trackdir trackdir); void UpdateAspectDeferred(TileIndex tile, Trackdir trackdir);
void FlushDeferredAspectUpdates(); void FlushDeferredAspectUpdates();
@ -178,6 +181,12 @@ void UpdateAllSignalAspects();
void UpdateExtraAspectsVariable(); void UpdateExtraAspectsVariable();
void InitialiseExtraAspectsVariable(); void InitialiseExtraAspectsVariable();
inline void AdjustSignalAspectIfNonIncStyle(TileIndex tile, Track track, uint8 &aspect)
{
extern void AdjustSignalAspectIfNonIncStyleIntl(TileIndex tile, Track track, uint8 &aspect);
if (aspect > 0 && _non_aspect_inc_style_mask != 0) AdjustSignalAspectIfNonIncStyleIntl(tile, track, aspect);
}
inline uint8 GetForwardAspectFollowingTrackAndIncrement(TileIndex tile, Trackdir trackdir) inline uint8 GetForwardAspectFollowingTrackAndIncrement(TileIndex tile, Trackdir trackdir)
{ {
return std::min<uint8>(GetForwardAspectFollowingTrack(tile, trackdir) + 1, _extra_aspects + 1); return std::min<uint8>(GetForwardAspectFollowingTrack(tile, trackdir) + 1, _extra_aspects + 1);

Loading…
Cancel
Save