summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/depot_gui.cpp4
-rw-r--r--src/lang/english.txt2
-rw-r--r--src/newgrf.cpp2
-rw-r--r--src/saveload/saveload.cpp3
-rw-r--r--src/settings_gui.cpp2
-rw-r--r--src/settings_type.h2
-rw-r--r--src/table/settings.h3
-rw-r--r--src/train_cmd.cpp9
8 files changed, 14 insertions, 13 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 6d32fd761..d3866af42 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -285,8 +285,8 @@ struct DepotWindow : Window {
DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1,
this->sel, free_wagon ? 0 : this->hscroll->GetPosition(), this->vehicle_over);
- /* Number of wagons relative to a standard length wagon (rounded up) */
- SetDParam(0, CeilDiv(u->gcache.cached_total_length, 8));
+ /* Length of consist in tiles (rounded up) */
+ SetDParam(0, CeilDiv(u->gcache.cached_total_length, TILE_SIZE));
DrawString(rtl ? left + WD_FRAMERECT_LEFT : right - this->count_width, rtl ? left + this->count_width : right - WD_FRAMERECT_RIGHT, y + (this->resize.step_height - FONT_HEIGHT_SMALL) / 2, STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT); // Draw the counter
break;
}
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 215d699f1..56ced0b68 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1094,7 +1094,7 @@ STR_CONFIG_SETTING_BUILDONSLOPES :{LTBLUE}Allow b
STR_CONFIG_SETTING_AUTOSLOPE :{LTBLUE}Allow landscaping under buildings, tracks, etc. (autoslope): {ORANGE}{STRING1}
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 and tunnels: {ORANGE}{STRING1}
-STR_CONFIG_SETTING_MAMMOTHTRAINS :{LTBLUE}Enable building very long trains: {ORANGE}{STRING1}
+STR_CONFIG_SETTING_TRAIN_LENGTH :{LTBLUE}Maximum length of trains: {ORANGE}{STRING1} tile{P 0:1 "" s}
STR_CONFIG_SETTING_SMOKE_AMOUNT :{LTBLUE}Amount of vehicle smoke/sparks: {ORANGE}{STRING1}
STR_CONFIG_SETTING_SMOKE_AMOUNT_NONE :None
STR_CONFIG_SETTING_SMOKE_AMOUNT_ORIGINAL :Original
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index ed1d08d1b..21df87951 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -6912,7 +6912,7 @@ static void InitializeGRFSpecial()
| (1 << 0x1E); // generalfixes
_ttdpatch_flags[1] = ((_settings_game.economy.station_noise_level ? 1 : 0) << 0x07) // moreairports - based on units of noise
- | ((_settings_game.vehicle.mammoth_trains ? 1 : 0) << 0x08) // mammothtrains
+ | ((_settings_game.vehicle.max_train_length > 5 ? 1 : 0) << 0x08) // mammothtrains
| (1 << 0x09) // trainrefit
| (0 << 0x0B) // subsidiaries
| ((_settings_game.order.gradual_loading ? 1 : 0) << 0x0C) // gradualloading
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 552b008ab..ec85aedaf 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -223,8 +223,9 @@
* 156 21728
* 157 21862
* 158 21933
+ * 159 21960
*/
-extern const uint16 SAVEGAME_VERSION = 158; ///< Current savegame version of OpenTTD.
+extern const uint16 SAVEGAME_VERSION = 159; ///< 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 f89614e0a..d2367d33a 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1451,7 +1451,7 @@ static SettingsPage _settings_vehicles_servicing_page = {_settings_vehicles_serv
static SettingEntry _settings_vehicles_trains[] = {
SettingEntry("vehicle.train_acceleration_model"),
SettingEntry("vehicle.train_slope_steepness"),
- SettingEntry("vehicle.mammoth_trains"),
+ SettingEntry("vehicle.max_train_length"),
SettingEntry("vehicle.wagon_speed_limits"),
SettingEntry("vehicle.disable_elrails"),
SettingEntry("vehicle.freight_trains"),
diff --git a/src/settings_type.h b/src/settings_type.h
index cf89662f5..6a1ad7fb3 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -336,7 +336,7 @@ struct OrderSettings {
/** Settings related to vehicles. */
struct VehicleSettings {
- bool mammoth_trains; ///< allow very long trains
+ uint8 max_train_length; ///< maximum length for 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
diff --git a/src/table/settings.h b/src/table/settings.h
index 07ff7ca8e..5f87f74ae 100644
--- a/src/table/settings.h
+++ b/src/table/settings.h
@@ -393,7 +393,8 @@ const SettingDesc _settings[] = {
SDT_CONDVAR(GameSettings, vehicle.train_slope_steepness, SLE_UINT8,133, SL_MAX_VERSION, 0, 0, 3, 0, 10, 1, STR_CONFIG_SETTING_TRAIN_SLOPE_STEEPNESS, TrainSlopeSteepnessChanged),
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.max_train_length, SLE_UINT8,159, SL_MAX_VERSION, 0,NN, 7, 1, 64, 1, STR_CONFIG_SETTING_TRAIN_LENGTH, NULL),
+ SDT_CONDNULL( 1, 0, 158), // vehicle.mammoth_trains
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_CONDNULL( 1, 0, 158), // order.gotodepot
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 58f19b6bf..139a7faa8 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -944,20 +944,21 @@ static CommandCost CheckTrainAttachment(Train *t)
/* The maximum length for a train. For each part we decrease this by one
* and if the result is negative the train is simply too long. */
- int allowed_len = _settings_game.vehicle.mammoth_trains ? 100 : 10;
+ int allowed_len = _settings_game.vehicle.max_train_length * TILE_SIZE - t->gcache.cached_veh_length;
Train *head = t;
Train *prev = t;
/* Break the prev -> t link so it always holds within the loop. */
t = t->Next();
- allowed_len--;
prev->SetNext(NULL);
/* Make sure the cache is cleared. */
head->InvalidateNewGRFCache();
while (t != NULL) {
+ allowed_len -= t->gcache.cached_veh_length;
+
Train *next = t->Next();
/* Unlink the to-be-added piece; it is already unlinked from the previous
@@ -966,8 +967,6 @@ static CommandCost CheckTrainAttachment(Train *t)
/* Don't check callback for articulated or rear dual headed parts */
if (!t->IsArticulatedPart() && !t->IsRearDualheaded()) {
- allowed_len--; // We do not count articulated parts and rear heads either.
-
/* Back up and clear the first_engine data to avoid using wagon override group */
EngineID first_engine = t->gcache.first_engine;
t->gcache.first_engine = INVALID_ENGINE;
@@ -1002,7 +1001,7 @@ static CommandCost CheckTrainAttachment(Train *t)
t = next;
}
- if (allowed_len <= 0) return_cmd_error(STR_ERROR_TRAIN_TOO_LONG);
+ if (allowed_len < 0) return_cmd_error(STR_ERROR_TRAIN_TOO_LONG);
return CommandCost();
}