Add NewGRF railtype flag to disable realistic braking for vehs of that type
See: #242
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user