Add NewGRF railtype flag to disable realistic braking for vehs of that type
See: #242
This commit is contained in:
@@ -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.
|
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>
|
</td>
|
||||||
</tr>
|
</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>
|
</table>
|
||||||
<h3><a href="https://newgrf-specs.tt-wiki.net/wiki/NML:Roadtypes#Roadtype_properties">Roadtype properties</a></h3>
|
<h3><a href="https://newgrf-specs.tt-wiki.net/wiki/NML:Roadtypes#Roadtype_properties">Roadtype properties</a></h3>
|
||||||
<table>
|
<table>
|
||||||
|
@@ -231,6 +231,12 @@
|
|||||||
The property length is 1 byte. 0 is disabled (default). 1 is enabled.
|
The property length is 1 byte. 0 is disabled (default). 1 is enabled.
|
||||||
</p>
|
</p>
|
||||||
<p>This is indicated by the feature name: <font face="monospace">action0_railtype_restricted_signals</font>, version 1</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 />
|
<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>
|
<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>
|
<h4>Extra road/tram type flags (mappable property: roadtype_extra_flags)</h4>
|
||||||
|
@@ -2468,7 +2468,7 @@ DEF_CONSOLE_CMD(ConDumpRailTypes)
|
|||||||
grfid = grf->grfid;
|
grfid = grf->grfid;
|
||||||
grfs.insert(std::pair<uint32, const GRFFile *>(grfid, grf));
|
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,
|
(uint) rt,
|
||||||
rti->label >> 24, rti->label >> 16, rti->label >> 8, rti->label,
|
rti->label >> 24, rti->label >> 16, rti->label >> 8, rti->label,
|
||||||
HasBit(rti->flags, RTF_CATENARY) ? 'c' : '-',
|
HasBit(rti->flags, RTF_CATENARY) ? 'c' : '-',
|
||||||
@@ -2479,6 +2479,7 @@ DEF_CONSOLE_CMD(ConDumpRailTypes)
|
|||||||
HasBit(rti->flags, RTF_DISALLOW_90DEG) ? 'd' : '-',
|
HasBit(rti->flags, RTF_DISALLOW_90DEG) ? 'd' : '-',
|
||||||
HasBit(rti->ctrl_flags, RTCF_PROGSIG) ? 'p' : '-',
|
HasBit(rti->ctrl_flags, RTCF_PROGSIG) ? 'p' : '-',
|
||||||
HasBit(rti->ctrl_flags, RTCF_RESTRICTEDSIG) ? 'r' : '-',
|
HasBit(rti->ctrl_flags, RTCF_RESTRICTEDSIG) ? 'r' : '-',
|
||||||
|
HasBit(rti->ctrl_flags, RTCF_NOREALISTICBRAKING) ? 'b' : '-',
|
||||||
BSWAP32(grfid),
|
BSWAP32(grfid),
|
||||||
GetStringPtr(rti->strings.name)
|
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));
|
SB(rti->ctrl_flags, RTCF_RESTRICTEDSIG, 1, (buf->ReadByte() != 0 ? 1 : 0));
|
||||||
break;
|
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:
|
default:
|
||||||
ret = HandleAction0PropertyDefault(buf, prop);
|
ret = HandleAction0PropertyDefault(buf, prop);
|
||||||
break;
|
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_PROGRAMMABLE_SIGNALS:
|
||||||
case A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS:
|
case A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS:
|
||||||
|
case A0RPI_RAILTYPE_DISABLE_REALISTIC_BRAKING:
|
||||||
buf->Skip(buf->ReadExtendedByte());
|
buf->Skip(buf->ReadExtendedByte());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -8403,6 +8409,7 @@ static const GRFFeatureInfo _grf_feature_list[] = {
|
|||||||
GRFFeatureInfo("action5_programmable_signals", 1),
|
GRFFeatureInfo("action5_programmable_signals", 1),
|
||||||
GRFFeatureInfo("action0_railtype_programmable_signals", 1),
|
GRFFeatureInfo("action0_railtype_programmable_signals", 1),
|
||||||
GRFFeatureInfo("action0_railtype_restricted_signals", 1),
|
GRFFeatureInfo("action0_railtype_restricted_signals", 1),
|
||||||
|
GRFFeatureInfo("action0_railtype_disable_realistic_braking", 1),
|
||||||
GRFFeatureInfo("action0_roadtype_extra_flags", 1),
|
GRFFeatureInfo("action0_roadtype_extra_flags", 1),
|
||||||
GRFFeatureInfo(),
|
GRFFeatureInfo(),
|
||||||
};
|
};
|
||||||
@@ -8522,6 +8529,7 @@ static const GRFPropertyMapDefinition _grf_action0_remappable_properties[] = {
|
|||||||
GRFPropertyMapDefinition(GSF_BRIDGES, A0RPI_BRIDGE_AVAILABILITY_FLAGS, "bridge_availability_flags"),
|
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_PROGRAMMABLE_SIGNALS, "railtype_enable_programmable_signals"),
|
||||||
GRFPropertyMapDefinition(GSF_RAILTYPES, A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS, "railtype_enable_restricted_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_ROADTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"),
|
||||||
GRFPropertyMapDefinition(GSF_TRAMTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"),
|
GRFPropertyMapDefinition(GSF_TRAMTYPES, A0RPI_ROADTYPE_EXTRA_FLAGS, "roadtype_extra_flags"),
|
||||||
GRFPropertyMapDefinition(),
|
GRFPropertyMapDefinition(),
|
||||||
|
@@ -117,6 +117,7 @@ enum Action0RemapPropertyIds {
|
|||||||
A0RPI_BRIDGE_AVAILABILITY_FLAGS,
|
A0RPI_BRIDGE_AVAILABILITY_FLAGS,
|
||||||
A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS,
|
A0RPI_RAILTYPE_ENABLE_PROGRAMMABLE_SIGNALS,
|
||||||
A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS,
|
A0RPI_RAILTYPE_ENABLE_RESTRICTED_SIGNALS,
|
||||||
|
A0RPI_RAILTYPE_DISABLE_REALISTIC_BRAKING,
|
||||||
A0RPI_ROADTYPE_EXTRA_FLAGS,
|
A0RPI_ROADTYPE_EXTRA_FLAGS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -43,8 +43,9 @@ DECLARE_ENUM_AS_BIT_SET(RailTypeFlags)
|
|||||||
|
|
||||||
/** Railtype control flags. */
|
/** Railtype control flags. */
|
||||||
enum RailTypeCtrlFlags {
|
enum RailTypeCtrlFlags {
|
||||||
RTCF_PROGSIG = 0, ///< Custom signal sprites enabled for programmable pre-signals.
|
RTCF_PROGSIG = 0, ///< Custom signal sprites enabled for programmable pre-signals.
|
||||||
RTCF_RESTRICTEDSIG = 1, ///< Custom signal sprite flag enabled for restricted signals.
|
RTCF_RESTRICTEDSIG = 1, ///< Custom signal sprite flag enabled for restricted signals.
|
||||||
|
RTCF_NOREALISTICBRAKING = 2, ///< Realistic braking disabled for this track type
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SpriteGroup;
|
struct SpriteGroup;
|
||||||
|
@@ -838,9 +838,10 @@ 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%c",
|
seprintf(buffer, lastof(buffer), " Ctrl flags: %c%c%c",
|
||||||
HasBit(info->ctrl_flags, RTCF_PROGSIG) ? 'p' : '-',
|
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);
|
print(buffer);
|
||||||
seprintf(buffer, lastof(buffer), " Powered: 0x" OTTD_PRINTFHEX64, info->powered_railtypes);
|
seprintf(buffer, lastof(buffer), " Powered: 0x" OTTD_PRINTFHEX64, info->powered_railtypes);
|
||||||
print(buffer);
|
print(buffer);
|
||||||
|
@@ -1073,7 +1073,7 @@ void Train::UpdateAcceleration()
|
|||||||
assert(weight != 0);
|
assert(weight != 0);
|
||||||
this->acceleration = Clamp(power / weight * 4, 1, 255);
|
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;
|
this->tcache.cached_tflags |= TCF_RL_BRAKING;
|
||||||
switch (_settings_game.vehicle.train_acceleration_model) {
|
switch (_settings_game.vehicle.train_acceleration_model) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
|
Reference in New Issue
Block a user