GRF: Allow railtype custom signal sprites for programmable pre-signals
This commit is contained in:
@@ -205,6 +205,14 @@
|
|||||||
<p>This is indicated by the feature name: <font face="monospace">action0_bridge_pillar_flags</font>, version 1</p>
|
<p>This is indicated by the feature name: <font face="monospace">action0_bridge_pillar_flags</font>, version 1</p>
|
||||||
<h4>More bridges (16 instead of 13)</h4>
|
<h4>More bridges (16 instead of 13)</h4>
|
||||||
<p>This is indicated by the feature name: <font face="monospace">more_bridge_types</font>, version 1</p>
|
<p>This is indicated by the feature name: <font face="monospace">more_bridge_types</font>, version 1</p>
|
||||||
|
<h3><a href="https://newgrf-specs.tt-wiki.net/wiki/Action0/Railtypes">Action 0 - Railtypes</a></h3>
|
||||||
|
<h4>Enable custom signal sprites for programmable pre-signals (mappable property: railtype_enable_programmable_signals)</h4>
|
||||||
|
<p>This enables <a href="https://newgrf-specs.tt-wiki.net/wiki/Action3/Railtypes#Signal_sprites_.280B.29">Action 2/3 - Railtype custom signal sprites</a> for programmable pre-signals.<br />
|
||||||
|
Programmable pre-signals have the signal type value: 06.<br />
|
||||||
|
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>
|
||||||
|
<br />
|
||||||
<h3><a href="https://newgrf-specs.tt-wiki.net/wiki/VariationalAction2/Stations">Variational Action 2 - Stations</a></h3>
|
<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>
|
<h4>Track type in purchase list (42)</h4>
|
||||||
<p>This is indicated by the feature name: <font face="monospace">varaction2_station_var42</font>, version 1</p>
|
<p>This is indicated by the feature name: <font face="monospace">varaction2_station_var42</font>, version 1</p>
|
||||||
|
@@ -4349,6 +4349,11 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, const
|
|||||||
for (int j = buf->ReadByte(); j != 0; j--) buf->ReadDWord();
|
for (int j = buf->ReadByte(); j != 0; j--) buf->ReadDWord();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS:
|
||||||
|
if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break;
|
||||||
|
SB(rti->ctrl_flags, RTCF_PROGSIG, 1, (buf->ReadByte() != 0 ? 1 : 0));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = HandleAction0PropertyDefault(buf, prop);
|
ret = HandleAction0PropertyDefault(buf, prop);
|
||||||
break;
|
break;
|
||||||
@@ -8360,6 +8365,7 @@ static const GRFFeatureInfo _grf_feature_list[] = {
|
|||||||
GRFFeatureInfo("action0_bridge_prop14", 1),
|
GRFFeatureInfo("action0_bridge_prop14", 1),
|
||||||
GRFFeatureInfo("action0_bridge_pillar_flags", 1),
|
GRFFeatureInfo("action0_bridge_pillar_flags", 1),
|
||||||
GRFFeatureInfo("action5_programmable_signals", 1),
|
GRFFeatureInfo("action5_programmable_signals", 1),
|
||||||
|
GRFFeatureInfo("action0_railtype_programmable_signals", 1),
|
||||||
GRFFeatureInfo(),
|
GRFFeatureInfo(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -8475,6 +8481,7 @@ static const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = {
|
|||||||
GRFPropertyMapDefinition(GSF_STATIONS, A0RPI_STATION_DISALLOWED_BRIDGE_PILLARS, "station_disallowed_bridge_pillars"),
|
GRFPropertyMapDefinition(GSF_STATIONS, A0RPI_STATION_DISALLOWED_BRIDGE_PILLARS, "station_disallowed_bridge_pillars"),
|
||||||
GRFPropertyMapDefinition(GSF_BRIDGES, A0RPI_BRIDGE_MENU_ICON, "bridge_menu_icon"),
|
GRFPropertyMapDefinition(GSF_BRIDGES, A0RPI_BRIDGE_MENU_ICON, "bridge_menu_icon"),
|
||||||
GRFPropertyMapDefinition(GSF_BRIDGES, A0RPI_BRIDGE_PILLAR_FLAGS, "bridge_pillar_flags"),
|
GRFPropertyMapDefinition(GSF_BRIDGES, A0RPI_BRIDGE_PILLAR_FLAGS, "bridge_pillar_flags"),
|
||||||
|
GRFPropertyMapDefinition(GSF_RAILTYPES, A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS, "railtype_enable_programmable_signals"),
|
||||||
GRFPropertyMapDefinition(),
|
GRFPropertyMapDefinition(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -114,6 +114,7 @@ enum Action0RemapPropertyIds {
|
|||||||
A0RPI_STATION_DISALLOWED_BRIDGE_PILLARS,
|
A0RPI_STATION_DISALLOWED_BRIDGE_PILLARS,
|
||||||
A0RPI_BRIDGE_MENU_ICON,
|
A0RPI_BRIDGE_MENU_ICON,
|
||||||
A0RPI_BRIDGE_PILLAR_FLAGS,
|
A0RPI_BRIDGE_PILLAR_FLAGS,
|
||||||
|
A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum GRFPropertyMapFallbackMode {
|
enum GRFPropertyMapFallbackMode {
|
||||||
|
@@ -127,6 +127,7 @@ SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSp
|
|||||||
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)
|
||||||
{
|
{
|
||||||
if (rti->group[RTSG_SIGNALS] == nullptr) return 0;
|
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 param1 = gui ? 0x10 : 0x00;
|
||||||
uint32 param2 = (type << 16) | (var << 8) | state;
|
uint32 param2 = (type << 16) | (var << 8) | state;
|
||||||
|
10
src/rail.h
10
src/rail.h
@@ -41,6 +41,11 @@ enum RailTypeFlags {
|
|||||||
};
|
};
|
||||||
DECLARE_ENUM_AS_BIT_SET(RailTypeFlags)
|
DECLARE_ENUM_AS_BIT_SET(RailTypeFlags)
|
||||||
|
|
||||||
|
/** Railtype control flags. */
|
||||||
|
enum RailTypeCtrlFlags {
|
||||||
|
RTCF_PROGSIG = 0, ///< Custom signal sprites enabled for programmable pre-signals.
|
||||||
|
};
|
||||||
|
|
||||||
struct SpriteGroup;
|
struct SpriteGroup;
|
||||||
|
|
||||||
/** Sprite groups for a railtype. */
|
/** Sprite groups for a railtype. */
|
||||||
@@ -208,6 +213,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
RailTypeFlags flags;
|
RailTypeFlags flags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bit mask of rail type control flags
|
||||||
|
*/
|
||||||
|
byte ctrl_flags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cost multiplier for building this rail type
|
* Cost multiplier for building this rail type
|
||||||
*/
|
*/
|
||||||
|
@@ -69,7 +69,7 @@ void ResetRailTypes()
|
|||||||
{0,0,0,0,0,0,0,0,{}},
|
{0,0,0,0,0,0,0,0,{}},
|
||||||
{0,0,0,0,0,0,0,0},
|
{0,0,0,0,0,0,0,0},
|
||||||
{0,0,0,0,0,0},
|
{0,0,0,0,0,0},
|
||||||
0, RAILTYPES_NONE, RAILTYPES_NONE, 0, 0, 0, RTFB_NONE, 0, 0, 0, 0, 0,
|
0, RAILTYPES_NONE, RAILTYPES_NONE, 0, 0, 0, RTFB_NONE, 0, 0, 0, 0, 0, 0,
|
||||||
RailTypeLabelList(), 0, 0, RAILTYPES_NONE, RAILTYPES_NONE, 0,
|
RailTypeLabelList(), 0, 0, RAILTYPES_NONE, RAILTYPES_NONE, 0,
|
||||||
{}, {} };
|
{}, {} };
|
||||||
for (; i < lengthof(_railtypes); i++) _railtypes[i] = empty_railtype;
|
for (; i < lengthof(_railtypes); i++) _railtypes[i] = empty_railtype;
|
||||||
@@ -2489,39 +2489,38 @@ void DrawSingleSignal(TileIndex tile, const RailtypeInfo *rti, Track track, Sign
|
|||||||
uint x, y;
|
uint x, y;
|
||||||
GetSignalXY(tile, pos, x, y);
|
GetSignalXY(tile, pos, x, y);
|
||||||
|
|
||||||
SpriteID sprite;
|
SpriteID sprite = GetCustomSignalSprite(rti, tile, type, variant, condition);
|
||||||
bool is_custom_sprite;
|
bool is_custom_sprite = (sprite != 0);
|
||||||
if (type == SIGTYPE_PROG) {
|
if (sprite != 0) {
|
||||||
|
sprite += image;
|
||||||
|
} else if (type == SIGTYPE_PROG) {
|
||||||
if (variant == SIG_SEMAPHORE) {
|
if (variant == SIG_SEMAPHORE) {
|
||||||
sprite = SPR_PROGSIGNAL_BASE + image * 2 + condition;
|
sprite = SPR_PROGSIGNAL_BASE + image * 2 + condition;
|
||||||
} else {
|
} else {
|
||||||
sprite = SPR_PROGSIGNAL_BASE + 16 + image * 2 + condition;
|
sprite = SPR_PROGSIGNAL_BASE + 16 + image * 2 + condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int _progsig_grf_file_index;
|
extern int _progsig_grf_file_index;
|
||||||
is_custom_sprite = (int) GetOriginFileSlot(sprite) != _progsig_grf_file_index;
|
is_custom_sprite = (int) GetOriginFileSlot(sprite) != _progsig_grf_file_index;
|
||||||
} else {
|
|
||||||
sprite = GetCustomSignalSprite(rti, tile, type, variant, condition);
|
|
||||||
is_custom_sprite = (sprite != 0);
|
|
||||||
if (sprite != 0) {
|
|
||||||
sprite += image;
|
|
||||||
} else {
|
} else {
|
||||||
/* Normal electric signals are stored in a different sprite block than all other signals. */
|
/* Normal electric signals are stored in a different sprite block than all other signals. */
|
||||||
sprite = (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) ? SPR_ORIGINAL_SIGNALS_BASE : SPR_SIGNALS_BASE - 16;
|
sprite = (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) ? SPR_ORIGINAL_SIGNALS_BASE : SPR_SIGNALS_BASE - 16;
|
||||||
sprite += type * 16 + variant * 64 + image * 2 + condition + (IsSignalSpritePBS(type) ? 64 : 0);
|
sprite += type * 16 + variant * 64 + image * 2 + condition + (IsSignalSpritePBS(type) ? 64 : 0);
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_custom_sprite) {
|
|
||||||
int origin_slot = GetOriginFileSlot(sprite);
|
int origin_slot = GetOriginFileSlot(sprite);
|
||||||
extern int _first_user_grf_file_index;
|
extern int _first_user_grf_file_index;
|
||||||
extern int _opengfx_grf_file_index;
|
extern int _opengfx_grf_file_index;
|
||||||
is_custom_sprite = origin_slot != _opengfx_grf_file_index && (origin_slot >= _first_user_grf_file_index);
|
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) {
|
||||||
/* Use duplicate sprite block, instead of GRF-specified signals */
|
/* Use duplicate sprite block, instead of GRF-specified signals */
|
||||||
if (type == SIGTYPE_PROG) {
|
if (type == SIGTYPE_PROG) {
|
||||||
sprite += SPR_DUP_PROGSIGNAL_BASE - SPR_PROGSIGNAL_BASE;
|
if (variant == SIG_SEMAPHORE) {
|
||||||
|
sprite = SPR_DUP_PROGSIGNAL_BASE + image * 2 + condition;
|
||||||
|
} else {
|
||||||
|
sprite = SPR_DUP_PROGSIGNAL_BASE + 16 + image * 2 + condition;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sprite = (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) ? SPR_DUP_ORIGINAL_SIGNALS_BASE : SPR_DUP_SIGNALS_BASE - 16;
|
sprite = (type == SIGTYPE_NORMAL && variant == SIG_ELECTRIC) ? SPR_DUP_ORIGINAL_SIGNALS_BASE : SPR_DUP_SIGNALS_BASE - 16;
|
||||||
sprite += type * 16 + variant * 64 + image * 2 + condition + (IsSignalSpritePBS(type) ? 64 : 0);
|
sprite += type * 16 + variant * 64 + image * 2 + condition + (IsSignalSpritePBS(type) ? 64 : 0);
|
||||||
|
@@ -629,6 +629,9 @@ class NIHRailType : public NIHelper {
|
|||||||
HasBit(info->flags, RTF_ALLOW_90DEG) ? 'a' : '-',
|
HasBit(info->flags, RTF_ALLOW_90DEG) ? 'a' : '-',
|
||||||
HasBit(info->flags, RTF_DISALLOW_90DEG) ? 'd' : '-');
|
HasBit(info->flags, RTF_DISALLOW_90DEG) ? 'd' : '-');
|
||||||
print(buffer);
|
print(buffer);
|
||||||
|
seprintf(buffer, lastof(buffer), " Ctrl flags: %c",
|
||||||
|
HasBit(info->ctrl_flags, RTCF_PROGSIG) ? 'p' : '-');
|
||||||
|
print(buffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
print("Debug Info:");
|
print("Debug Info:");
|
||||||
|
@@ -77,6 +77,9 @@ static const RailtypeInfo _original_railtypes[] = {
|
|||||||
/* flags */
|
/* flags */
|
||||||
RTFB_NONE,
|
RTFB_NONE,
|
||||||
|
|
||||||
|
/* control flags */
|
||||||
|
0,
|
||||||
|
|
||||||
/* cost multiplier */
|
/* cost multiplier */
|
||||||
8,
|
8,
|
||||||
|
|
||||||
@@ -178,6 +181,9 @@ static const RailtypeInfo _original_railtypes[] = {
|
|||||||
/* flags */
|
/* flags */
|
||||||
RTFB_CATENARY,
|
RTFB_CATENARY,
|
||||||
|
|
||||||
|
/* control flags */
|
||||||
|
0,
|
||||||
|
|
||||||
/* cost multiplier */
|
/* cost multiplier */
|
||||||
12,
|
12,
|
||||||
|
|
||||||
@@ -275,6 +281,9 @@ static const RailtypeInfo _original_railtypes[] = {
|
|||||||
/* flags */
|
/* flags */
|
||||||
RTFB_NONE,
|
RTFB_NONE,
|
||||||
|
|
||||||
|
/* control flags */
|
||||||
|
0,
|
||||||
|
|
||||||
/* cost multiplier */
|
/* cost multiplier */
|
||||||
16,
|
16,
|
||||||
|
|
||||||
@@ -372,6 +381,9 @@ static const RailtypeInfo _original_railtypes[] = {
|
|||||||
/* flags */
|
/* flags */
|
||||||
RTFB_NONE,
|
RTFB_NONE,
|
||||||
|
|
||||||
|
/* control flags */
|
||||||
|
0,
|
||||||
|
|
||||||
/* cost multiplier */
|
/* cost multiplier */
|
||||||
24,
|
24,
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user