Changeset - r970:a6f7afe85299
[Not reviewed]
master
0 10 0
darkvater - 19 years ago 2005-01-10 14:43:00
darkvater@openttd.org
(svn r1465) -Fix: [1099101] starting year patch goes out of range. Clamped year between 1920-2090 as wel as adding defines for it.
10 files changed with 22 insertions and 19 deletions:
0 comments (0 inline, 0 general)
economy.c
Show inline comments
 
@@ -26,8 +26,8 @@ uint GetMaskOfAllowedCurrencies(void)
 
	for (i = 0; i != lengthof(_currency_specs); i++) {
 
		uint16 to_euro = _currency_specs[i].to_euro;
 
		if (i == 23) mask |= (1 << 23); // always allow custom currency
 
		if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= (to_euro-1920)) continue;
 
		if (_cur_year < (2000-1920) && (to_euro == CF_ISEURO)) continue;
 
		if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= (to_euro-MAX_YEAR_BEGIN_REAL)) continue;
 
		if (_cur_year < (2000-MAX_YEAR_BEGIN_REAL) && (to_euro == CF_ISEURO)) continue;
 
		mask |= (1 << i);
 
	}
 
	return mask;
 
@@ -37,7 +37,7 @@ void CheckSwitchToEuro(void)
 
{
 
	if (_currency_specs[_opt.currency].to_euro != CF_NOEURO &&
 
			_currency_specs[_opt.currency].to_euro != CF_ISEURO &&
 
			_cur_year >= (_currency_specs[_opt.currency].to_euro-1920)) {
 
			_cur_year >= (_currency_specs[_opt.currency].to_euro-MAX_YEAR_BEGIN_REAL)) {
 
		_opt.currency = 2; // this is the index of euro above.
 
		AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL,0,NT_ECONOMY,0), 0, 0);
 
	}
graph_gui.c
Show inline comments
 
@@ -142,7 +142,7 @@ static void DrawGraph(GraphDrawer *gw)
 
		x = gw->left + 44;
 
		y = gw->top + gw->height + 1;
 
		j = gw->month;
 
		k = gw->year + 1920;
 
		k = gw->year + MAX_YEAR_BEGIN_REAL;
 
		i = gw->num_on_x_axis;assert(i>0);
 
		do {
 
			SetDParam(2, k);
main_gui.c
Show inline comments
 
@@ -25,7 +25,7 @@
 

	
 

	
 
/* Min/Max date for scenario editor */
 
static const uint MinDate = 0;     // 1920-01-01
 
static const uint MinDate = 0;     // 1920-01-01 (MAX_YEAR_BEGIN_REAL)
 
static const uint MaxDate = 29220; // 2000-01-01
 

	
 
extern void DoTestSave();
misc.c
Show inline comments
 
@@ -443,7 +443,7 @@ uint ConvertYMDToDay(uint year, uint mon
 
}
 

	
 
// convert a date on the form
 
// 1920 - 2090
 
// 1920 - 2090 (MAX_YEAR_END_REAL)
 
// 192001 - 209012
 
// 19200101 - 20901231
 
// or if > 2090 and below 65536, treat it as a daycount
 
@@ -452,7 +452,7 @@ uint ConvertIntDate(uint date)
 
{
 
	uint year, month = 0, day = 1;
 

	
 
	if (IS_INT_INSIDE(date, 1920, 2090 + 1)) {
 
	if (IS_INT_INSIDE(date, 1920, MAX_YEAR_END_REAL + 1)) {
 
		year = date - 1920;
 
	} else if (IS_INT_INSIDE(date, 192001, 209012+1)) {
 
		month = date % 100 - 1;
 
@@ -700,10 +700,10 @@ void IncreaseDate()
 
		NetworkServerYearlyLoop();
 
#endif /* ENABLE_NETWORK */
 

	
 
	/* check if we reached 2090, that's the maximum year. */
 
	if (_cur_year == 171) {
 
	/* check if we reached 2090 (MAX_YEAR_END_REAL), that's the maximum year. */
 
	if (_cur_year == (MAX_YEAR_END + 1)) {
 
		Vehicle *v;
 
		_cur_year = 170;
 
		_cur_year = MAX_YEAR_END;
 
		_date = 62093;
 
		FOR_ALL_VEHICLES(v) {
 
			v->date_of_last_service -= 365; // 1 year is 365 days long
network_gui.c
Show inline comments
 
@@ -746,7 +746,7 @@ static void NetworkLobbyWindowWndProc(Wi
 
			DeleteName(str);
 
			y += 10;
 

	
 
			SetDParam(0, _network_player_info[_selected_company_item].inaugurated_year + 1920);
 
			SetDParam(0, _network_player_info[_selected_company_item].inaugurated_year + MAX_YEAR_BEGIN_REAL);
 
			DrawString(x, y, STR_NETWORK_INAUGURATION_YEAR, 2); // inauguration year
 
			y += 10;
 

	
network_server.c
Show inline comments
 
@@ -1281,10 +1281,10 @@ extern void SwitchMode(int new_mode);
 
/* Check if we want to restart the map */
 
static void NetworkCheckRestartMap()
 
{
 
	if (_network_restart_game_date != 0 && _cur_year + 1920 >= _network_restart_game_date) {
 
	if (_network_restart_game_date != 0 && _cur_year + MAX_YEAR_BEGIN_REAL >= _network_restart_game_date) {
 
		_docommand_recursive = 0;
 

	
 
		DEBUG(net, 0)("Auto-restarting map. Year %d reached.", _cur_year + 1920);
 
		DEBUG(net, 0)("Auto-restarting map. Year %d reached.", _cur_year + MAX_YEAR_BEGIN_REAL);
 

	
 
		_random_seeds[0][0] = Random();
 
		_random_seeds[0][1] = InteractiveRandom();
oldloader.c
Show inline comments
 
@@ -941,7 +941,7 @@ static void FixPlayer(Player *n, OldPlay
 

	
 
		FixEconomy(&n->cur_economy, &o->economy[0]);
 
		for(i=0; i!=24; i++) FixEconomy(&n->old_economy[i], &o->economy[i+1]);
 
		n->inaugurated_year = o->inaugurated_date - 1920;
 
		n->inaugurated_year = o->inaugurated_date - MAX_YEAR_BEGIN_REAL;
 
		n->last_build_coordinate = o->last_build_coordinate;
 
		n->num_valid_stat_ent = o->num_valid_stat_ent;
 

	
settings_gui.c
Show inline comments
 
@@ -682,7 +682,7 @@ static const PatchEntry _patches_economy
 
	{PE_UINT8,	0, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT,	"snow_line_height", &_patches.snow_line_height,					2, 13,  1, NULL},
 

	
 
	{PE_INT32,	PF_NOCOMMA, STR_CONFIG_PATCHES_COLORED_NEWS_DATE, "colored_new_data", &_patches.colored_news_date, 1900, 2200, 5, NULL},
 
	{PE_INT32,	PF_NOCOMMA, STR_CONFIG_PATCHES_STARTING_DATE, "starting_date", &_patches.starting_date,	 1920,2100, 1, NULL},
 
	{PE_INT32,	PF_NOCOMMA, STR_CONFIG_PATCHES_STARTING_DATE, "starting_date", &_patches.starting_date,	 1920, MAX_YEAR_END_REAL, 1, NULL},
 

	
 
	{PE_BOOL,		0, STR_CONFIG_PATCHES_SMOOTH_ECONOMY,		"smooth_economy", &_patches.smooth_economy,						0,  0,  0, NULL},
 
	{PE_BOOL,		0, STR_CONFIG_PATCHES_ALLOW_SHARES,			"allow_shares", &_patches.allow_shares,						0,  0,  0, NULL},
 
@@ -1403,7 +1403,7 @@ static void CustCurrencyWndProc(Window *
 
					} else {
 
						if(_currency_specs[23].to_euro == 0) _currency_specs[23].to_euro = 2000;
 
						else _currency_specs[23].to_euro++;
 
						_currency_specs[23].to_euro = min(2090, _currency_specs[23].to_euro);
 
						_currency_specs[23].to_euro = min(MAX_YEAR_END_REAL, _currency_specs[23].to_euro);
 
						WP(w,def_d).data_1 = (1 << (line * 2 + 1));
 
					}
 
				} else { // enter text
 
@@ -1452,7 +1452,7 @@ static void CustCurrencyWndProc(Window *
 
				break;
 
				case 4:
 
					val = atoi(b);
 
					val = clamp(val, 1999, 2090);
 
					val = clamp(val, 1999, MAX_YEAR_END_REAL);
 
					if (val == 1999) val = 0;
 
					_currency_specs[23].to_euro = val;
 
				break;
strings.c
Show inline comments
 
@@ -243,7 +243,7 @@ static byte *FormatYmdString(byte *buff,
 
	memcpy(buff, GetStringPtr(STR_0162_JAN + ymd.month), 4);
 
	buff[3] = ' ';
 

	
 
	return FormatNoCommaNumber(buff+4, ymd.year + 1920);
 
	return FormatNoCommaNumber(buff+4, ymd.year + MAX_YEAR_BEGIN_REAL);
 
}
 

	
 
static byte *FormatMonthAndYear(byte *buff, uint16 number)
 
@@ -256,7 +256,7 @@ static byte *FormatMonthAndYear(byte *bu
 
	for(src = GetStringPtr(STR_MONTH_JAN + ymd.month); (*buff++=*src++) != 0;) {}
 
	buff[-1] = ' ';
 

	
 
	return FormatNoCommaNumber(buff, ymd.year + 1920);
 
	return FormatNoCommaNumber(buff, ymd.year + MAX_YEAR_BEGIN_REAL);
 
}
 

	
 
uint GetCurrentCurrencyRate() {
ttd.h
Show inline comments
 
@@ -42,6 +42,9 @@ typedef struct YearMonthDay {
 
* * 1 day is thus about 2 seconds (74*27 = 1998) on a machine that can run OpenTTD normally
 
*/
 
#define DAY_TICKS 74
 
#define MAX_YEAR_BEGIN_REAL 1920
 
#define MAX_YEAR_END_REAL 2090
 
#define MAX_YEAR_END 170
 

	
 
#include "macros.h"
 

	
0 comments (0 inline, 0 general)