diff options
author | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-09-18 20:18:45 +0200 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-12-28 12:27:39 +0100 |
commit | 2fd871e2af5cb9e239628843fbd40499ee43406a (patch) | |
tree | 25973b79c47ddece4a820807f1fb4694bd85b51b /src | |
parent | 69f9529ba32df396c4353b2d1c752a3f6609069a (diff) | |
download | openttd-2fd871e2af5cb9e239628843fbd40499ee43406a.tar.xz |
Feature: Configurable game ending year
Functionally reverts 683b65ee1
Diffstat (limited to 'src')
-rw-r--r-- | src/date.cpp | 6 | ||||
-rw-r--r-- | src/date_type.h | 2 | ||||
-rw-r--r-- | src/lang/english.txt | 4 | ||||
-rw-r--r-- | src/saveload/afterload.cpp | 9 | ||||
-rw-r--r-- | src/saveload/saveload.h | 1 | ||||
-rw-r--r-- | src/settings_gui.cpp | 1 | ||||
-rw-r--r-- | src/settings_type.h | 1 | ||||
-rw-r--r-- | src/table/settings.ini | 27 |
8 files changed, 47 insertions, 4 deletions
diff --git a/src/date.cpp b/src/date.cpp index c45396efe..be0a7782d 100644 --- a/src/date.cpp +++ b/src/date.cpp @@ -27,6 +27,8 @@ Date _date; ///< Current date in days (day counter) DateFract _date_fract; ///< Fractional part of the day. uint16 _tick_counter; ///< Ever incrementing (and sometimes wrapping) tick counter for setting off various events +int32 _old_ending_year_slv_105; ///< Old ending year for savegames before SLV_105 + /** * Set the date. * @param date New date @@ -197,8 +199,8 @@ static void OnNewYear() if (_cur_year == _settings_client.gui.semaphore_build_before) ResetSignalVariant(); - /* check if we reached end of the game */ - if (_cur_year == ORIGINAL_END_YEAR) { + /* check if we reached end of the game (end of ending year) */ + if (_cur_year == _settings_game.game_creation.ending_year + 1) { ShowEndGameChart(); /* check if we reached the maximum year, decrement dates by a year */ } else if (_cur_year == MAX_YEAR + 1) { diff --git a/src/date_type.h b/src/date_type.h index d05b44008..4cbcfac4e 100644 --- a/src/date_type.h +++ b/src/date_type.h @@ -84,6 +84,8 @@ static const Year MIN_YEAR = 0; /** The default starting year */ static const Year DEF_START_YEAR = 1950; +/** The default scoring end year */ +static const Year DEF_END_YEAR = ORIGINAL_END_YEAR - 1; /** * MAX_YEAR, nicely rounded value of the number of years that can diff --git a/src/lang/english.txt b/src/lang/english.txt index bc89cfee3..1b4069d0f 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1552,6 +1552,10 @@ STR_CONFIG_SETTING_NEWS_MESSAGES_FULL :Full STR_CONFIG_SETTING_COLOURED_NEWS_YEAR :Coloured news appears in: {STRING2} STR_CONFIG_SETTING_COLOURED_NEWS_YEAR_HELPTEXT :Year that the newspaper announcements get printed in colour. Before this year, it uses monochrome black/white STR_CONFIG_SETTING_STARTING_YEAR :Starting year: {STRING2} +STR_CONFIG_SETTING_ENDING_YEAR :Scoring end year: {STRING2} +STR_CONFIG_SETTING_ENDING_YEAR_HELPTEXT :Year the game ends for scoring purposes. At the end of this year, the company's score is recorded and the high-score screen is displayed, but the players can continue playing after that.{}If this is before the starting year, the high-score screen is never displayed. +STR_CONFIG_SETTING_ENDING_YEAR_VALUE :{NUM} +STR_CONFIG_SETTING_ENDING_YEAR_ZERO :Never STR_CONFIG_SETTING_SMOOTH_ECONOMY :Enable smooth economy (more, smaller changes): {STRING2} STR_CONFIG_SETTING_SMOOTH_ECONOMY_HELPTEXT :When enabled, industry production changes more often, and in smaller steps. This setting has usually no effect, if industry types are provided by a NewGRF STR_CONFIG_SETTING_ALLOW_SHARES :Allow buying shares from other companies: {STRING2} diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index dd9fcd534..47d2c7b03 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -747,6 +747,15 @@ bool AfterLoadGame() _settings_game.linkgraph.distribution_default = DT_MANUAL; } + if (IsSavegameVersionBefore(SLV_105)) { + extern int32 _old_ending_year_slv_105; // in date.cpp + _settings_game.game_creation.ending_year = _old_ending_year_slv_105 - 1; + } else if (IsSavegameVersionBefore(SLV_ENDING_YEAR)) { + /* Ending year was a GUI setting before SLV_105, was removed in revision 683b65ee1 (svn r14755). */ + /* This also converts scenarios, both when loading them into the editor, and when starting a new game. */ + _settings_game.game_creation.ending_year = DEF_END_YEAR; + } + /* Load the sprites */ GfxLoadSprites(); LoadStringWidthTable(); diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index beecdc8c4..c06e8fdda 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -301,6 +301,7 @@ enum SaveLoadVersion : uint16 { SLV_SCRIPT_MEMLIMIT, ///< 215 PR#7516 Limit on AI/GS memory consumption. SLV_MULTITILE_DOCKS, ///< 216 PR#7380 Multiple docks per station. SLV_TRADING_AGE, ///< 217 PR#7780 Configurable company trading age. + SLV_ENDING_YEAR, ///< 218 PR#7747 Configurable ending year. SL_MAX_VERSION, ///< Highest possible saveload version }; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 4b7768dfa..187ea2892 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1698,6 +1698,7 @@ static SettingsContainer &GetSettingsTree() genworld->Add(new SettingEntry("economy.town_layout")); genworld->Add(new SettingEntry("difficulty.industry_density")); genworld->Add(new SettingEntry("gui.pause_on_newgame")); + genworld->Add(new SettingEntry("game_creation.ending_year")); } SettingsPage *environment = main->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT)); diff --git a/src/settings_type.h b/src/settings_type.h index 60db6c9f9..0bc5a1a68 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -278,6 +278,7 @@ struct NetworkSettings { struct GameCreationSettings { uint32 generation_seed; ///< noise seed for world generation Year starting_year; ///< starting date + Year ending_year; ///< scoring end date uint8 map_x; ///< X size of map uint8 map_y; ///< Y size of map byte land_generator; ///< the landscape generator diff --git a/src/table/settings.ini b/src/table/settings.ini index 4c3d6ce0d..3e07fcc59 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -47,6 +47,8 @@ static bool UpdateServerPassword(int32 p1); static bool UpdateRconPassword(int32 p1); static bool UpdateClientConfigValues(int32 p1); +extern int32 _old_ending_year_slv_105; + /* End - Callback Functions for the various settings */ /* Some settings do not need to be synchronised when playing in multiplayer. @@ -1402,9 +1404,30 @@ str = STR_CONFIG_SETTING_STARTING_YEAR strval = STR_JUST_INT cat = SC_BASIC -[SDT_NULL] -length = 4 +[SDTG_VAR] +name = ""old_ending_year_slv_105"" +var = _old_ending_year_slv_105 +flags = SLF_NOT_IN_CONFIG +type = SLE_INT32 to = SLV_105 +def = DEF_END_YEAR +min = MIN_YEAR +max = MAX_YEAR + +[SDT_VAR] +base = GameSettings +var = game_creation.ending_year +type = SLE_INT32 +from = SLV_ENDING_YEAR +guiflags = SGF_0ISDISABLED +def = DEF_END_YEAR +min = MIN_YEAR +max = MAX_YEAR +interval = 1 +str = STR_CONFIG_SETTING_ENDING_YEAR +strhelp = STR_CONFIG_SETTING_ENDING_YEAR_HELPTEXT +strval = STR_CONFIG_SETTING_ENDING_YEAR_VALUE +cat = SC_ADVANCED [SDT_BOOL] base = GameSettings |