Mercurial > hg > openttd
changeset 17221:edf36d7f3f86 draft
(svn r21960) -Change: show the length of vehicles in tiles, instead of half tiles in the depot
-Fix [FS#4461]: don't count the number of vehicles but the length of vehicles to (configurably) limit train length
author | rubidium <rubidium@openttd.org> |
---|---|
date | Fri, 04 Feb 2011 15:40:35 +0000 |
parents | 026d5463e627 |
children | c3be3dde0adb |
files | src/depot_gui.cpp src/lang/english.txt src/newgrf.cpp src/saveload/saveload.cpp src/settings_gui.cpp src/settings_type.h src/table/settings.h src/train_cmd.cpp |
diffstat | 8 files changed, 14 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -285,8 +285,8 @@ 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; }
--- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1094,7 +1094,7 @@ 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
--- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -6912,7 +6912,7 @@ | (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
--- 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
--- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1451,7 +1451,7 @@ 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"),
--- a/src/settings_type.h +++ b/src/settings_type.h @@ -336,7 +336,7 @@ /** 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
--- a/src/table/settings.h +++ b/src/table/settings.h @@ -393,7 +393,8 @@ 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),
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -944,20 +944,21 @@ /* 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 @@ /* 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 @@ 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(); }