Skip to content

Commit

Permalink
Add setting to also limit acceleration when using realistic braking
Browse files Browse the repository at this point in the history
  • Loading branch information
JGRennison committed Aug 8, 2023
1 parent 3840a37 commit 8a14d8c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ground_vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ GroundVehicleAcceleration GroundVehicle<T, Type>::GetAcceleration()
extern std::vector<Train *> _tick_train_too_heavy_cache;
_tick_train_too_heavy_cache.push_back(Train::From(this));
}

if (Train::From(this)->UsingRealisticBraking() && _settings_game.vehicle.limit_train_acceleration) {
accel = std::min(accel, 250);
}
}

return { accel, braking_accel };
Expand Down
3 changes: 3 additions & 0 deletions src/lang/extra/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ STR_CONFIG_SETTING_TRAIN_BRAKING_MODEL_HELPTEXT :Select the phys
STR_CONFIG_SETTING_REALISTIC_BRAKING_ASPECT_LIMITED :Realistic train braking is aspect limited: {STRING2}
STR_CONFIG_SETTING_REALISTIC_BRAKING_ASPECT_LIMITED_HELPTEXT :In the realistic train braking model, limit the look-ahead of trains to the aspect of signals (i.e. do not allow reserving and looking ahead an unlimited number of signals).{}This requires a NewGRF which provides multi-aspect signals.{}{}This is an expert setting which will likely increase gameplay difficulty and will require additional thought about signal types and placement.

STR_CONFIG_SETTING_LIMIT_TRAIN_ACCELERATION :Limit train acceleration: {STRING2}
STR_CONFIG_SETTING_LIMIT_TRAIN_ACCELERATION_HELPTEXT :When using the realistic train train braking model, also limit the maximum acceleration of trains. This is to prevent passengers from spilling their drinks due to some train types otherwise accelerating excessively quickly.

STR_CONFIG_SETTING_THROUGH_LOAD_SPEED_LIMIT :Train through load maximum speed: {STRING2}
STR_CONFIG_SETTING_THROUGH_LOAD_SPEED_LIMIT_HELPTEXT :The maximum permitted speed for trains when through loading at a station

Expand Down
1 change: 1 addition & 0 deletions src/settings_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2236,6 +2236,7 @@ static SettingsContainer &GetSettingsTree()
physics->Add(new SettingEntry("vehicle.train_acceleration_model"));
physics->Add(new SettingEntry("vehicle.train_braking_model"));
physics->Add(new ConditionallyHiddenSettingEntry("vehicle.realistic_braking_aspect_limited", []() -> bool { return GetGameSettings().vehicle.train_braking_model != TBM_REALISTIC; }));
physics->Add(new ConditionallyHiddenSettingEntry("vehicle.limit_train_acceleration", []() -> bool { return GetGameSettings().vehicle.train_braking_model != TBM_REALISTIC; }));
physics->Add(new SettingEntry("vehicle.train_slope_steepness"));
physics->Add(new SettingEntry("vehicle.wagon_speed_limits"));
physics->Add(new SettingEntry("vehicle.train_speed_adaptation"));
Expand Down
1 change: 1 addition & 0 deletions src/settings_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ struct VehicleSettings {
uint8 train_acceleration_model; ///< realistic acceleration for trains
uint8 train_braking_model; ///< braking model for trains
uint8 realistic_braking_aspect_limited; ///< realistic braking lookahead is aspect limited
bool limit_train_acceleration; ///< when using realistic braking, also limit train acceleration
uint8 roadveh_acceleration_model; ///< realistic acceleration for road vehicles
uint8 train_slope_steepness; ///< Steepness of hills for trains when using realistic acceleration
uint8 roadveh_slope_steepness; ///< Steepness of hills for road vehicles when using realistic acceleration
Expand Down
8 changes: 8 additions & 0 deletions src/table/settings/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,14 @@ strhelp = STR_CONFIG_SETTING_REALISTIC_BRAKING_ASPECT_LIMITED_HELPTEXT
cat = SC_EXPERT
patxname = ""realistic_braking.vehicle.realistic_braking_aspect_limited""

[SDT_BOOL]
var = vehicle.limit_train_acceleration
def = false
str = STR_CONFIG_SETTING_LIMIT_TRAIN_ACCELERATION
strhelp = STR_CONFIG_SETTING_LIMIT_TRAIN_ACCELERATION_HELPTEXT
cat = SC_EXPERT
patxname = ""realistic_braking.vehicle.limit_train_acceleration""

[SDT_VAR]
var = vehicle.roadveh_acceleration_model
type = SLE_UINT8
Expand Down

0 comments on commit 8a14d8c

Please sign in to comment.