Changeset - r24002:6eb7dd997787
[Not reviewed]
master
0 8 0
Niels Martin Hansen - 5 years ago 2019-09-18 18:18:45
nielsm@indvikleren.dk
Feature: Configurable game ending year

Functionally reverts 683b65ee1
8 files changed with 47 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/date.cpp
Show inline comments
 
@@ -24,12 +24,14 @@
 
Year      _cur_year;   ///< Current year, starting at 0
 
Month     _cur_month;  ///< Current month (0..11)
 
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
 
 * @param fract The number of ticks that have passed on this date.
 
 */
 
void SetDate(Date date, DateFract fract)
 
@@ -194,14 +196,14 @@ static void OnNewYear()
 
	TownsYearlyLoop();
 
	InvalidateWindowClassesData(WC_BUILD_STATION);
 
	if (_network_server) NetworkServerYearlyLoop();
 

	
 
	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) {
 
		int days_this_year;
 

	
 
		_cur_year--;
src/date_type.h
Show inline comments
 
@@ -81,12 +81,14 @@ static const Year ORIGINAL_MAX_YEAR  = 2
 

	
 
/** The absolute minimum & maximum years in OTTD */
 
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
 
 * be encoded in a single 32 bits date, about 2^31 / 366 years.
 
 */
 
static const Year MAX_YEAR  = 5000000;
src/lang/english.txt
Show inline comments
 
@@ -1549,12 +1549,16 @@ STR_CONFIG_SETTING_NEWS_MESSAGES_OFF    
 
STR_CONFIG_SETTING_NEWS_MESSAGES_SUMMARY                        :Summary
 
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}
 
STR_CONFIG_SETTING_ALLOW_SHARES_HELPTEXT                        :When enabled, allow buying and selling of company shares. Shares will only be available for companies reaching a certain age
 
STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES                         :Minimum company age to trade shares: {STRING2}
 
STR_CONFIG_SETTING_MIN_YEARS_FOR_SHARES_HELPTEXT                :Set the minimum age of a company for others to be able to buy and sell shares from them.
src/saveload/afterload.cpp
Show inline comments
 
@@ -744,12 +744,21 @@ bool AfterLoadGame()
 
		_settings_game.linkgraph.distribution_pax = DT_MANUAL;
 
		_settings_game.linkgraph.distribution_mail = DT_MANUAL;
 
		_settings_game.linkgraph.distribution_armoured = DT_MANUAL;
 
		_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();
 

	
 
	/* Copy temporary data to Engine pool */
 
	CopyTempEngineData();
src/saveload/saveload.h
Show inline comments
 
@@ -298,12 +298,13 @@ enum SaveLoadVersion : uint16 {
 
	SLV_TREES_WATER_CLASS,                  ///< 213  PR#7405 WaterClass update for tree tiles.
 
	SLV_ROAD_TYPES,                         ///< 214  PR#6811 NewGRF road types.
 

	
 
	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
 
};
 

	
 
/** Save or load result codes. */
 
enum SaveOrLoadResult {
src/settings_gui.cpp
Show inline comments
 
@@ -1695,12 +1695,13 @@ static SettingsContainer &GetSettingsTre
 
			genworld->Add(new SettingEntry("vehicle.road_side"));
 
			genworld->Add(new SettingEntry("economy.larger_towns"));
 
			genworld->Add(new SettingEntry("economy.initial_city_size"));
 
			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));
 
		{
 
			SettingsPage *authorities = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_AUTHORITIES));
 
			{
src/settings_type.h
Show inline comments
 
@@ -275,12 +275,13 @@ struct NetworkSettings {
 
};
 

	
 
/** Settings related to the creation of games. */
 
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
 
	byte   oil_refinery_limit;               ///< distance oil refineries allowed from map edge
 
	byte   snow_line_height;                 ///< the configured snow line height
 
	byte   tgen_smoothness;                  ///< how rough is the terrain from 0-3
src/table/settings.ini
Show inline comments
 
@@ -44,12 +44,14 @@ static bool InvalidateShipPathCache(int3
 

	
 
static bool UpdateClientName(int32 p1);
 
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.
 
 * These include for example the GUI settings and will not be saved with the
 
 * savegame.
 
 * It is also a bit tricky since you would think that service_interval
 
@@ -1399,15 +1401,36 @@ min      = MIN_YEAR
 
max      = MAX_YEAR
 
interval = 1
 
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
 
var      = economy.smooth_economy
 
def      = true
 
str      = STR_CONFIG_SETTING_SMOOTH_ECONOMY
0 comments (0 inline, 0 general)