Add NewGRF railtype flag to disable realistic braking for vehs of that type

See: #242
pull/251/head
Jonathan G Rennison 3 years ago
parent ba2e6087b2
commit 6a62b94263

@ -40,6 +40,11 @@
This flag must only be set if a different sprite is returned when bit 24 of <span class="code">extra_callback_info2</span> is set.
</td>
</tr>
<tr><td>disable_realistic_braking</td><td>0 or 1</td>
<td>
When this property is set realistic braking is disabled for trains of this railtype even when realistic braking is otherwise in effect.
</td>
</tr>
</table>
<h3><a href="https://newgrf-specs.tt-wiki.net/wiki/NML:Roadtypes#Roadtype_properties">Roadtype properties</a></h3>
<table>

@ -231,6 +231,12 @@
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>
<h4>Disable use of realistic braking with this rail type (mappable property: railtype_disable_realistic_braking)</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 this property is set realistic braking is disabled for trains of this railtype even when realistic braking is otherwise in effect.<br />
The property length is 1 byte. 0 is realistic braking is not disabled for this railtype. 1 is disable realistic braking for this railtype.
</p>
<p>This is indicated by the feature name: <font face="monospace">action0_railtype_disable_realistic_braking</font>, version 1</p>
<br />
<h3><a href="https://newgrf-specs.tt-wiki.net/wiki/Action0/Roadtypes">Action 0 - Roadtypes</a> and <a href="https://newgrf-specs.tt-wiki.net/wiki/Action0/Tramtypes">Action 0 - Tramtypes</a></h3>
<h4>Extra road/tram type flags (mappable property: roadtype_extra_flags)</h4>

@ -2468,7 +2468,7 @@ DEF_CONSOLE_CMD(ConDumpRailTypes)
grfid = grf->grfid;
grfs.insert(std::pair<uint32, const GRFFile *>(grfid, grf));
}
IConsolePrintF(CC_DEFAULT, " %02u %c%c%c%c, Flags: %c%c%c%c%c%c, Ctrl Flags: %c%c, GRF: %08X, %s",
IConsolePrintF(CC_DEFAULT, " %02u %c%c%c%c, Flags: %c%c%c%c%c%c, Ctrl Flags: %c%c%c, GRF: %08X, %s",
(uint) rt,
rti->label >> 24, rti->label >> 16, rti->label >> 8, rti->label,
HasBit(rti->flags, RTF_CATENARY) ? 'c' : '-',
@ -2479,6 +2479,7 @@ DEF_CONSOLE_CMD(ConDumpRailTypes)
HasBit(rti->flags, RTF_DISALLOW_90DEG) ? 'd' : '-',
HasBit(rti->ctrl_flags, RTCF_PROGSIG) ? 'p' : '-',
HasBit(rti->ctrl_flags, RTCF_RESTRICTEDSIG) ? 'r' : '-',
HasBit(rti->ctrl_flags, RTCF_NOREALISTICBRAKING) ? 'b' : '-',
BSWAP32(grfid),
GetStringPtr(rti->strings.name)
);

@ -4377,6 +4377,11 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, const
SB(rti->ctrl_flags, RTCF_RESTRICTEDSIG, 1, (buf->ReadByte() != 0 ? 1 : 0));
break;
case A0RPI_RAILTYPE_DISABLE_REALISTIC_BRAKING:
if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break;
SB(rti->ctrl_flags, RTCF_NOREALISTICBRAKING, 1, (buf->ReadByte() != 0 ? 1 : 0));
break;
default:
ret = HandleAction0PropertyDefault(buf, prop);
break;
@ -4459,6 +4464,7 @@ static ChangeInfoResult RailTypeReserveInfo(uint id, int numinfo, int prop, cons
case A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS:
case A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS:
case A0RPI_RAILTYPE_DISABLE_REALISTIC_BRAKING:
buf->Skip(buf->ReadExtendedByte());
break;
@ -8403,6 +8409,7 @@ static const GRFFeatureInfo _grf_feature_list[] = {
GRFFeatureInfo("action5_programmable_signals", 1),
GRFFeatureInfo("action0_railtype_programmable_signals", 1),
GRFFeatureInfo("action0_railtype_restricted_signals", 1),
GRFFeatureInfo("action0_railtype_disable_realistic_braking", 1),
GRFFeatureInfo("action0_roadtype_extra_flags", 1),
GRFFeatureInfo(),
};
@ -8522,6 +8529,7 @@ static const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = {
GRFPropertyMapDefinition(GSF_BRIDGES, A0RPI_BRIDGE_AVAILABILITY_FLAGS, "bridge_availability_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(GSF_RAILTYPES, A0RPI_RAILTYPE_DISABLE_REALISTIC_BRAKING, "railtype_disable_realistic_braking"),
GRFPropertyMapDefinition(GSF_ROADTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"),
GRFPropertyMapDefinition(GSF_TRAMTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"),
GRFPropertyMapDefinition(),

@ -117,6 +117,7 @@ enum Action0RemapPropertyIds {
A0RPI_BRIDGE_AVAILABILITY_FLAGS,
A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS,
A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS,
A0RPI_RAILTYPE_DISABLE_REALISTIC_BRAKING,
A0RPI_ROADTYPE_EXTRA_FLAGS,
};

@ -43,8 +43,9 @@ 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.
RTCF_PROGSIG = 0, ///< Custom signal sprites enabled for programmable pre-signals.
RTCF_RESTRICTEDSIG = 1, ///< Custom signal sprite flag enabled for restricted signals.
RTCF_NOREALISTICBRAKING = 2, ///< Realistic braking disabled for this track type
};
struct SpriteGroup;

@ -838,9 +838,10 @@ 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%c",
seprintf(buffer, lastof(buffer), " Ctrl flags: %c%c%c",
HasBit(info->ctrl_flags, RTCF_PROGSIG) ? 'p' : '-',
HasBit(info->ctrl_flags, RTCF_RESTRICTEDSIG) ? 'r' : '-');
HasBit(info->ctrl_flags, RTCF_RESTRICTEDSIG) ? 'r' : '-',
HasBit(info->ctrl_flags, RTCF_NOREALISTICBRAKING) ? 'b' : '-');
print(buffer);
seprintf(buffer, lastof(buffer), " Powered: 0x" OTTD_PRINTFHEX64, info->powered_railtypes);
print(buffer);

@ -1073,7 +1073,7 @@ void Train::UpdateAcceleration()
assert(weight != 0);
this->acceleration = Clamp(power / weight * 4, 1, 255);
if (_settings_game.vehicle.train_braking_model == TBM_REALISTIC) {
if (_settings_game.vehicle.train_braking_model == TBM_REALISTIC && !HasBit(GetRailTypeInfo(this->railtype)->ctrl_flags, RTCF_NOREALISTICBRAKING)) {
this->tcache.cached_tflags |= TCF_RL_BRAKING;
switch (_settings_game.vehicle.train_acceleration_model) {
default: NOT_REACHED();

Loading…
Cancel
Save