diff --git a/docs/newgrf-additions.html b/docs/newgrf-additions.html index e151784e2b..e16030d415 100644 --- a/docs/newgrf-additions.html +++ b/docs/newgrf-additions.html @@ -212,6 +212,14 @@ The property length is 1 byte. 0 is disabled (default). 1 is enabled.

This is indicated by the feature name: action0_railtype_programmable_signals, version 1

+

Enable restricted signal flag for custom signal sprites (mappable property: railtype_enable_restricted_signals)

+

This applies to Action 2/3 - Railtype custom signal sprites.
+ When enabled, bit 24 of variable 18 (extra callback info) is set if the signal is restricted (has a routing restriction program attached).
+ When enabled, the "Show restricted electric signals using default graphics" client setting is not applied.
+ This flag should only be set if the Action 2/3 actually returns a different sprite when bit 24 of variable 18 is set. + The property length is 1 byte. 0 is disabled (default). 1 is enabled. +

+

This is indicated by the feature name: action0_railtype_restricted_signals, version 1


Variational Action 2 - Stations

Track type in purchase list (42)

diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 4b18166d16..a2b519431d 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -4354,6 +4354,11 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, const SB(rti->ctrl_flags, RTCF_PROGSIG, 1, (buf->ReadByte() != 0 ? 1 : 0)); break; + case A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS: + if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break; + SB(rti->ctrl_flags, RTCF_RESTRICTEDSIG, 1, (buf->ReadByte() != 0 ? 1 : 0)); + break; + default: ret = HandleAction0PropertyDefault(buf, prop); break; @@ -8366,6 +8371,7 @@ static const GRFFeatureInfo _grf_feature_list[] = { GRFFeatureInfo("action0_bridge_pillar_flags", 1), GRFFeatureInfo("action5_programmable_signals", 1), GRFFeatureInfo("action0_railtype_programmable_signals", 1), + GRFFeatureInfo("action0_railtype_restricted_signals", 1), GRFFeatureInfo(), }; @@ -8482,6 +8488,7 @@ static const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = { GRFPropertyMapDefinition(GSF_BRIDGES, A0RPI_BRIDGE_MENU_ICON, "bridge_menu_icon"), GRFPropertyMapDefinition(GSF_BRIDGES, A0RPI_BRIDGE_PILLAR_FLAGS, "bridge_pillar_flags"), GRFPropertyMapDefinition(GSF_RAILTYPES, A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS, "railtype_enable_programmable_signals"), + GRFPropertyMapDefinition(GSF_RAILTYPES, A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS, "railtype_enable_restricted_signals"), GRFPropertyMapDefinition(), }; diff --git a/src/newgrf.h b/src/newgrf.h index a293944186..a475c211e0 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -115,6 +115,7 @@ enum Action0RemapPropertyIds { A0RPI_BRIDGE_MENU_ICON, A0RPI_BRIDGE_PILLAR_FLAGS, A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS, + A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS, }; enum GRFPropertyMapFallbackMode { diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp index 9b902c95b4..25c5343fd4 100644 --- a/src/newgrf_railtype.cpp +++ b/src/newgrf_railtype.cpp @@ -124,13 +124,14 @@ SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSp * @param gui Is the sprite being used on the map or in the GUI? * @return The sprite to draw. */ -SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui) +SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui, bool restricted) { if (rti->group[RTSG_SIGNALS] == nullptr) return 0; if (type == SIGTYPE_PROG && !HasBit(rti->ctrl_flags, RTCF_PROGSIG)) return 0; uint32 param1 = gui ? 0x10 : 0x00; uint32 param2 = (type << 16) | (var << 8) | state; + if (restricted && HasBit(rti->ctrl_flags, RTCF_RESTRICTEDSIG)) SetBit(param2, 24); RailTypeResolverObject object(rti, tile, TCX_NORMAL, RTSG_SIGNALS, param1, param2); const SpriteGroup *group = object.Resolve(); diff --git a/src/newgrf_railtype.h b/src/newgrf_railtype.h index adb8ad684e..c9a0c3b8e0 100644 --- a/src/newgrf_railtype.h +++ b/src/newgrf_railtype.h @@ -56,7 +56,7 @@ struct RailTypeResolverObject : public ResolverObject { }; SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context = TCX_NORMAL, uint *num_results = nullptr); -SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui = false); +SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui = false, bool restricted = false); uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile); diff --git a/src/rail.h b/src/rail.h index c0a77cba49..36a8641f58 100644 --- a/src/rail.h +++ b/src/rail.h @@ -44,6 +44,7 @@ DECLARE_ENUM_AS_BIT_SET(RailTypeFlags) /** Railtype control flags. */ enum RailTypeCtrlFlags { RTCF_PROGSIG = 0, ///< Custom signal sprites enabled for programmable pre-signals. + RTCF_RESTRICTEDSIG = 1, ///< Custom signal sprite flag enabled for restricted signals. }; struct SpriteGroup; diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 71d601d756..53c8d172bc 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -2489,7 +2489,7 @@ void DrawSingleSignal(TileIndex tile, const RailtypeInfo *rti, Track track, Sign uint x, y; GetSignalXY(tile, pos, x, y); - SpriteID sprite = GetCustomSignalSprite(rti, tile, type, variant, condition); + SpriteID sprite = GetCustomSignalSprite(rti, tile, type, variant, condition, false, show_restricted); bool is_custom_sprite = (sprite != 0); if (sprite != 0) { sprite += image; @@ -2513,7 +2513,7 @@ void DrawSingleSignal(TileIndex tile, const RailtypeInfo *rti, Track track, Sign is_custom_sprite = origin_slot != _opengfx_grf_file_index && (origin_slot >= _first_user_grf_file_index); } - if (is_custom_sprite && show_restricted && _settings_client.gui.show_restricted_signal_default) { + if (is_custom_sprite && show_restricted && _settings_client.gui.show_restricted_signal_default && !HasBit(rti->ctrl_flags, RTCF_RESTRICTEDSIG)) { /* Use duplicate sprite block, instead of GRF-specified signals */ if (type == SIGTYPE_PROG) { if (variant == SIG_SEMAPHORE) { diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index 8efb837c1c..0c04075d9f 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -629,8 +629,9 @@ class NIHRailType : public NIHelper { HasBit(info->flags, RTF_ALLOW_90DEG) ? 'a' : '-', HasBit(info->flags, RTF_DISALLOW_90DEG) ? 'd' : '-'); print(buffer); - seprintf(buffer, lastof(buffer), " Ctrl flags: %c", - HasBit(info->ctrl_flags, RTCF_PROGSIG) ? 'p' : '-'); + seprintf(buffer, lastof(buffer), " Ctrl flags: %c%c", + HasBit(info->ctrl_flags, RTCF_PROGSIG) ? 'p' : '-', + HasBit(info->ctrl_flags, RTCF_RESTRICTEDSIG) ? 'r' : '-'); print(buffer); };