GRF: Add railtype custom signal sprite restricted flag, and control flag

pull/195/head
Jonathan G Rennison 4 years ago
parent d32672a325
commit b6f583a799

@ -212,6 +212,14 @@
The property length is 1 byte. 0 is disabled (default). 1 is enabled.
</p>
<p>This is indicated by the feature name: <font face="monospace">action0_railtype_programmable_signals</font>, version 1</p>
<h4>Enable restricted signal flag for custom signal sprites (mappable property: railtype_enable_restricted_signals)</h4>
<p>This applies to <a href="https://newgrf-specs.tt-wiki.net/wiki/Action3/Railtypes#Signal_sprites_.280B.29">Action 2/3 - Railtype custom signal sprites</a>.<br />
When enabled, bit 24 of variable 18 (extra callback info) is set if the signal is restricted (has a routing restriction program attached).<br />
When enabled, the "Show restricted electric signals using default graphics" client setting is not applied.<br />
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.
</p>
<p>This is indicated by the feature name: <font face="monospace">action0_railtype_restricted_signals</font>, version 1</p>
<br />
<h3><a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Stations">Variational Action 2 - Stations</a></h3>
<h4>Track type in purchase list (42)</h4>

@ -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(),
};

@ -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 {

@ -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();

@ -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);

@ -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;

@ -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) {

@ -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);
};

Loading…
Cancel
Save