Mercurial > hg > openttd
changeset 5163:969d29b77fee draft
(svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Mon, 27 Nov 2006 23:11:56 +0000 |
parents | a891bf5de037 |
children | a4257de85d3a |
files | lang/english.txt saveload.c settings.c settings_gui.c train.h train_cmd.c train_gui.c variables.h |
diffstat | 8 files changed, 34 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/lang/english.txt +++ b/lang/english.txt @@ -286,8 +286,10 @@ STR_013E_CAPACITIES :{BLACK}Capacities STR_013E_TOTAL_CARGO :{BLACK}Total Cargo STR_013F_CAPACITY :{BLACK}Capacity: {LTBLUE}{CARGO} +STR_CAPACITY_MULT :{BLACK}Capacity: {LTBLUE}{CARGO} (x{NUM}) STR_013F_TOTAL_CAPACITY_TEXT :{BLACK}Total cargo capacity of this train: STR_013F_TOTAL_CAPACITY :{LTBLUE}- {CARGO} ({SHORTCARGO}) +STR_TOTAL_CAPACITY_MULT :{LTBLUE}- {CARGO} ({SHORTCARGO}) (x{NUM}) STR_0140_NEW_GAME :{BLACK}New Game STR_0141_LOAD_GAME :{BLACK}Load Game STR_SINGLE_PLAYER :{BLACK}Single player @@ -1025,6 +1027,7 @@ STR_CONFIG_PATCHES_BRIBE :{LTBLUE}Allow bribing of the local authority: {ORANGE}{STRING1} STR_CONFIG_PATCHES_NONUNIFORM_STATIONS :{LTBLUE}Nonuniform stations: {ORANGE}{STRING1} STR_CONFIG_PATCHES_NEW_PATHFINDING_ALL :{LTBLUE}New global pathfinding (NPF, overrides NTP): {ORANGE}{STRING1} +STR_CONFIG_PATCHES_FREIGHT_TRAINS :{LTBLUE}Weight multiplier for freight to simulate heavy trains: {ORANGE}{STRING} STR_CONFIG_PATCHES_SMALL_AIRPORTS :{LTBLUE}Always allow small airports: {ORANGE}{STRING1} @@ -2498,6 +2501,7 @@ STR_UNKNOWN_DESTINATION :unknown destination STR_8812_EMPTY :{LTBLUE}Empty STR_8813_FROM :{LTBLUE}{CARGO} from {STATION} +STR_FROM_MULT :{LTBLUE}{CARGO} from {STATION} (x{NUM}) STR_8814_TRAIN_IS_WAITING_IN_DEPOT :{WHITE}Train {COMMA} is waiting in depot STR_8815_NEW_VEHICLES :{BLACK}New Vehicles STR_8816 :{BLACK}-
--- a/saveload.c +++ b/saveload.c @@ -30,7 +30,7 @@ #include "variables.h" #include <setjmp.h> -const uint16 SAVEGAME_VERSION = 38; +const uint16 SAVEGAME_VERSION = 39; uint16 _sl_version; /// the major savegame version identifier byte _sl_minor_version; /// the minor savegame version, DO NOT USE!
--- a/settings.c +++ b/settings.c @@ -1322,6 +1322,7 @@ SDT_BOOL(Patches, no_servicing_if_no_breakdowns, 0, 0, false, STR_CONFIG_PATCHES_NOSERVICE, NULL), SDT_BOOL(Patches, wagon_speed_limits, 0, 0, true, STR_CONFIG_PATCHES_WAGONSPEEDLIMITS, NULL), SDT_CONDBOOL(Patches, disable_elrails, 38, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_PATCHES_DISABLE_ELRAILS, SettingsDisableElrail), + SDT_CONDVAR(Patches, freight_trains, SLE_UINT8, 39, SL_MAX_VERSION, 0, 0, 1, 1, 255, 1, STR_CONFIG_PATCHES_FREIGHT_TRAINS, NULL), /***************************************************************************/ /* Station section of the GUI-configure patches window */
--- a/settings_gui.c +++ b/settings_gui.c @@ -647,6 +647,7 @@ "no_servicing_if_no_breakdowns", "wagon_speed_limits", "disable_elrails", + "freight_trains", }; typedef struct PatchEntry { @@ -889,7 +890,7 @@ { WWT_CLOSEBOX, RESIZE_NONE, 10, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_NONE, 10, 11, 369, 0, 13, STR_CONFIG_PATCHES_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS}, { WWT_PANEL, RESIZE_NONE, 10, 0, 369, 14, 41, 0x0, STR_NULL}, -{ WWT_PANEL, RESIZE_NONE, 10, 0, 369, 42, 360, 0x0, STR_NULL}, +{ WWT_PANEL, RESIZE_NONE, 10, 0, 369, 42, 370, 0x0, STR_NULL}, { WWT_TEXTBTN, RESIZE_NONE, 3, 10, 96, 16, 27, STR_CONFIG_PATCHES_GUI, STR_NULL}, { WWT_TEXTBTN, RESIZE_NONE, 3, 97, 183, 16, 27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL}, @@ -901,7 +902,7 @@ }; static const WindowDesc _patches_selection_desc = { - WDP_CENTER, WDP_CENTER, 370, 361, + WDP_CENTER, WDP_CENTER, 370, 371, WC_GAME_OPTIONS,0, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, _patches_selection_widgets,
--- a/train.h +++ b/train.h @@ -222,4 +222,6 @@ int CheckTrainInDepot(const Vehicle *v, bool needs_to_be_stopped); void CcCloneTrain(bool success, TileIndex tile, uint32 p1, uint32 p2); +byte FreightWagonMult(const Vehicle *v); + #endif /* TRAIN_H */
--- a/train_cmd.c +++ b/train_cmd.c @@ -40,6 +40,20 @@ static const byte _vehicle_initial_y_fract[4] = { 8, 4, 8, 10}; static const byte _state_dir_table[4] = { 0x20, 8, 0x10, 4 }; + +/** Return the cargo weight multiplier to use for a rail vehicle + * @param v Vehicle (wagon) to get multiplier for + * @return Cargo weight multiplier + */ +byte FreightWagonMult(const Vehicle *v) +{ + assert(v->type == VEH_Train); + // XXX NewCargos introduces a specific "is freight" flag for this test. + if (v->cargo_type == CT_PASSENGERS || v->cargo_type == CT_MAIL) return 1; + return _patches.freight_trains; +} + + /** * Recalculates the cached weight of a train and its vehicles. Should be called each time the cargo on * the consist changes. @@ -52,7 +66,7 @@ for (u = v; u != NULL; u = u->next) { const RailVehicleInfo *rvi = RailVehInfo(u->engine_type); - uint32 vweight = (_cargoc.weights[u->cargo_type] * u->cargo_count) / 16; + uint32 vweight = (_cargoc.weights[u->cargo_type] * u->cargo_count * FreightWagonMult(u)) / 16; // Vehicle weight is not added for articulated parts. if (!IsArticulatedPart(u)) {
--- a/train_gui.c +++ b/train_gui.c @@ -951,7 +951,8 @@ SetDParam(0, v->cargo_type); SetDParam(1, num); SetDParam(2, v->cargo_source); - str = STR_8813_FROM; + SetDParam(3, _patches.freight_trains); + str = FreightWagonMult(v) > 1 ? STR_FROM_MULT : STR_8813_FROM; } DrawString(x, y, str, 0); } @@ -976,7 +977,8 @@ if (v->cargo_cap != 0) { SetDParam(0, v->cargo_type); SetDParam(1, v->cargo_cap); - DrawString(x, y, STR_013F_CAPACITY, 0); + SetDParam(2, _patches.freight_trains); + DrawString(x, y, FreightWagonMult(v) > 1 ? STR_CAPACITY_MULT : STR_013F_CAPACITY, 0); } } @@ -1113,7 +1115,8 @@ SetDParam(1, act_cargo[i]); // {CARGO} #2 SetDParam(2, i); // {SHORTCARGO} #1 SetDParam(3, max_cargo[i]); // {SHORTCARGO} #2 - DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY, 0); + SetDParam(4, _patches.freight_trains); + DrawString(x, y + 2, FreightWagonMult(v) > 1 ? STR_TOTAL_CAPACITY_MULT : STR_013F_TOTAL_CAPACITY, 0); } } }