summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt4
-rw-r--r--src/saveload/saveload.cpp3
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/settings_type.h1
-rw-r--r--src/table/settings.h1
-rw-r--r--src/train_cmd.cpp45
6 files changed, 47 insertions, 8 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index ef6aed235..35965578a 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1084,6 +1084,10 @@ STR_CONFIG_SETTING_AUTOSLOPE :{LTBLUE}Allow t
STR_CONFIG_SETTING_CATCHMENT :{LTBLUE}Allow more realistically sized catchment areas: {ORANGE}{STRING1}
STR_CONFIG_SETTING_EXTRADYNAMITE :{LTBLUE}Allow removal of more town-owned roads, bridges, etc: {ORANGE}{STRING1}
STR_CONFIG_SETTING_MAMMOTHTRAINS :{LTBLUE}Enable building very long trains: {ORANGE}{STRING1}
+STR_CONFIG_SETTING_SMOKE_AMOUNT :{LTBLUE}Amount of locomotive smoke/sparks: {ORANGE}{STRING1}
+STR_CONFIG_SETTING_SMOKE_AMOUNT_NONE :None
+STR_CONFIG_SETTING_SMOKE_AMOUNT_ORIGINAL :Original
+STR_CONFIG_SETTING_SMOKE_AMOUNT_REALISTIC :Realistic
STR_CONFIG_SETTING_TRAIN_ACCELERATION_MODEL :{LTBLUE}Train acceleration model: {ORANGE}{STRING1}
STR_CONFIG_SETTING_TRAIN_ACCELERATION_MODEL_ORIGINAL :Original
STR_CONFIG_SETTING_TRAIN_ACCELERATION_MODEL_REALISTIC :Realistic
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index c57cf597b..48c07b63e 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -208,8 +208,9 @@
* 142 20003
* 143 20048
* 144 20334
+ * 145 20376
*/
-extern const uint16 SAVEGAME_VERSION = 144; ///< current savegame version of OpenTTD
+extern const uint16 SAVEGAME_VERSION = 145; ///< current savegame version of OpenTTD
SavegameType _savegame_type; ///< type of savegame we are loading
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 5491506d7..de83a435d 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1441,6 +1441,7 @@ static SettingEntry _settings_vehicles_trains[] = {
SettingEntry("vehicle.train_acceleration_model"),
SettingEntry("vehicle.train_slope_steepness"),
SettingEntry("vehicle.mammoth_trains"),
+ SettingEntry("vehicle.smoke_amount"),
SettingEntry("gui.lost_train_warn"),
SettingEntry("vehicle.wagon_speed_limits"),
SettingEntry("vehicle.disable_elrails"),
diff --git a/src/settings_type.h b/src/settings_type.h
index 8e3b61db8..f5a9a85d4 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -313,6 +313,7 @@ struct OrderSettings {
/** Settings related to vehicles. */
struct VehicleSettings {
bool mammoth_trains; ///< allow very long trains
+ uint8 smoke_amount; ///< amount of smoke/sparks locomotives produce
uint8 train_acceleration_model; ///< realistic acceleration for trains
uint8 roadveh_acceleration_model; ///< realistic acceleration for road vehicles
uint8 train_slope_steepness; ///< Steepness of hills for trains when using realistic acceleration
diff --git a/src/table/settings.h b/src/table/settings.h
index 8533f8f25..86ef0c23b 100644
--- a/src/table/settings.h
+++ b/src/table/settings.h
@@ -382,6 +382,7 @@ const SettingDesc _settings[] = {
SDT_CONDVAR(GameSettings, vehicle.roadveh_slope_steepness, SLE_UINT8,139, SL_MAX_VERSION, 0, 0, 7, 0, 10, 1, STR_CONFIG_SETTING_ROAD_VEHICLE_SLOPE_STEEPNESS, RoadVehSlopeSteepnessChanged),
SDT_BOOL(GameSettings, pf.forbid_90_deg, 0, 0, false, STR_CONFIG_SETTING_FORBID_90_DEG, NULL),
SDT_BOOL(GameSettings, vehicle.mammoth_trains, 0,NN, true, STR_CONFIG_SETTING_MAMMOTHTRAINS, NULL),
+ SDT_CONDVAR(GameSettings, vehicle.smoke_amount, SLE_UINT8,145, SL_MAX_VERSION, 0,MS, 1, 0, 2, 0, STR_CONFIG_SETTING_SMOKE_AMOUNT, NULL),
SDT_BOOL(GameSettings, order.gotodepot, 0, 0, true, STR_CONFIG_SETTING_GOTODEPOT, NULL),
SDT_BOOL(GameSettings, pf.roadveh_queue, 0, 0, true, STR_CONFIG_SETTING_ROAD_VEHICLE_QUEUEING, NULL),
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index bac4e78d2..8d75bfcde 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2034,7 +2034,17 @@ static void HandleLocomotiveSmokeCloud(const Train *v)
{
bool sound = false;
- if ((v->vehstatus & VS_TRAIN_SLOWING) || v->cur_speed < 2) {
+ /* Do not show any locomotive smoke/sparks when smoke_amount is set to none (0) or train is:
+ * slowing down or stopped (by the player) or
+ * it is ordered to reverse direction (by player) so it is slowing down to do it or
+ * its current speed is less than 2 km-ish/h or
+ * it is entering station with an order to stop there and its speed is equal to maximum station entering speed. */
+ if (_settings_game.vehicle.smoke_amount == 0 ||
+ v->vehstatus & (VS_TRAIN_SLOWING | VS_STOPPED) ||
+ HasBit(v->flags, VRF_REVERSING) ||
+ v->cur_speed < 2 ||
+ (IsRailStationTile(v->tile) && v->IsFrontEngine() && v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile)) &&
+ v->cur_speed >= v->Train::GetCurrentMaxSpeed())) {
return;
}
@@ -2076,24 +2086,45 @@ static void HandleLocomotiveSmokeCloud(const Train *v)
switch (effect_type) {
case 0:
- /* steam smoke. */
- if (GB(v->tick_counter, 0, 4) == 0) {
+ /* Steam smoke - amount is gradually falling until train reaches its maximum speed, after that it's normal.
+ * Details: while train's current speed is gradually increasing, steam plumes' density decreases by one third each
+ * third of its maximum speed spectrum. Steam emission finally normalises at very close to train's maximum speed.
+ * REGULATION:
+ * - instead of 1, 4 / 2^smoke_amount (max. 2) is used to provide sufficient regulation to steam puffs' amount. */
+ if (GB(v->tick_counter, 0, ((4 >> _settings_game.vehicle.smoke_amount) + ((u->cur_speed * 3) / u->tcache.cached_max_speed))) == 0) {
CreateEffectVehicleRel(v, x, y, 10, EV_STEAM_SMOKE);
sound = true;
}
break;
case 1:
- /* diesel smoke */
- if (u->cur_speed <= 40 && Chance16(15, 128)) {
+ /* Diesel smoke - thicker when train is starting, gradually subsiding till locomotive reaches its maximum speed
+ * when it stops.
+ * Details: Train's (max.) speed spectrum is divided into 32 parts. When max. speed is reached, chance for smoke
+ * emission erodes by 32 (1/4). Power and train's weight come in handy too to either increase smoke emission in
+ * 6 steps (1000HP each) if the power is low or decrease smoke emission in 6 steps (512 tonnes each) if the train
+ * isn't overweight. Power and weight contributions are expressed in a way that neither extreme power, nor
+ * extreme weight can ruin the balance (e.g. FreightWagonMultiplier) in the formula. When the train reaches
+ * maximum speed no diesel_smoke is emitted as train has enough traction to keep locomotive running optimally.
+ * REGULATION:
+ * - up to which speed a diesel train is emitting smoke (with reduced/small setting only until 1/2 of max_speed),
+ * - in Chance16 - the last value is 512 / 2^smoke_amount (max. smoke when 128 = smoke_amount of 2). */
+ if (u->cur_speed < (u->tcache.cached_max_speed >> (2 >> _settings_game.vehicle.smoke_amount)) &&
+ Chance16((64 - ((u->cur_speed << 5) / u->tcache.cached_max_speed) + (32 >> (u->acc_cache.cached_power >> 10)) - (32 >> (u->acc_cache.cached_weight >> 9))), (512 >> _settings_game.vehicle.smoke_amount))) {
CreateEffectVehicleRel(v, 0, 0, 10, EV_DIESEL_SMOKE);
sound = true;
}
break;
case 2:
- /* blue spark */
- if (GB(v->tick_counter, 0, 2) == 0 && Chance16(1, 45)) {
+ /* Electric train's spark - more often occurs when train is departing (more load)
+ * Details: Electric locomotives are usually at least twice as powerful as their diesel counterparts, so spark
+ * emissions are kept simple. Only when starting, creating huge force are sparks more likely to happen, but when
+ * reaching its max. speed, quarter by quarter of it, chance decreases untill the usuall 2,22% at train's top speed.
+ * REGULATION:
+ * - in Chance16 the last value is 360 / 2^smoke_amount (max. sparks when 90 = smoke_amount of 2). */
+ if (GB(v->tick_counter, 0, 2) == 0 &&
+ Chance16((6 - ((u->cur_speed << 2) / u->tcache.cached_max_speed)), (360 >> _settings_game.vehicle.smoke_amount))) {
CreateEffectVehicleRel(v, 0, 0, 10, EV_ELECTRIC_SPARK);
sound = true;
}