summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2006-08-15 15:18:03 +0000
committerrubidium <rubidium@openttd.org>2006-08-15 15:18:03 +0000
commit0d3ccad29fb035fced3a1a87b7804fde8c4e94b1 (patch)
tree40cc27f619e175b8c9a80e13e6651c33b92144aa
parent8aa76f306db00b81f14b53a736b6e30099258841 (diff)
downloadopenttd-0d3ccad29fb035fced3a1a87b7804fde8c4e94b1.tar.xz
(svn r5916) -Cleanup: use MIN_YEAR/MAX_YEAR for the year boundaries and BASE_YEAR when comparing _cur_year with a 'full' year.
-Cleanup: replace some magic '1920' values with BASE_YEAR.
-rw-r--r--aircraft_gui.c4
-rw-r--r--console_cmds.c2
-rw-r--r--currency.c6
-rw-r--r--date.c8
-rw-r--r--date.h6
-rw-r--r--disaster_cmd.c2
-rw-r--r--economy.c2
-rw-r--r--graph_gui.c2
-rw-r--r--misc_gui.c2
-rw-r--r--network_gui.c2
-rw-r--r--network_server.c4
-rw-r--r--oldloader.c2
-rw-r--r--player_gui.c4
-rw-r--r--roadveh_gui.c4
-rw-r--r--settings.c8
-rw-r--r--settings_gui.c4
-rw-r--r--ship_gui.c4
-rw-r--r--strings.c6
-rw-r--r--train_gui.c4
19 files changed, 38 insertions, 38 deletions
diff --git a/aircraft_gui.c b/aircraft_gui.c
index 7fd25fdb6..4aecb168d 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -66,7 +66,7 @@ void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number)
y += 10;
/* Design date - Life length */
- SetDParam(0, ymd.year + 1920);
+ SetDParam(0, BASE_YEAR + ymd.year);
SetDParam(1, e->lifelength);
DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
y += 10;
@@ -402,7 +402,7 @@ static void AircraftDetailsWndProc(Window *w, WindowEvent *e)
do {
if (v->subtype <= 2) {
SetDParam(0, GetCustomEngineName(v->engine_type));
- SetDParam(1, 1920 + v->build_year);
+ SetDParam(1, BASE_YEAR + v->build_year);
SetDParam(2, v->value);
DrawString(60, y, STR_A011_BUILT_VALUE, 0);
y += 10;
diff --git a/console_cmds.c b/console_cmds.c
index ff3504d8b..d006af5b7 100644
--- a/console_cmds.c
+++ b/console_cmds.c
@@ -1174,7 +1174,7 @@ DEF_CONSOLE_CMD(ConPlayers)
GetString(buffer, STR_00D1_DARK_BLUE + _player_colors[p->index]);
IConsolePrintF(8, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: %d Loan: %d Value: %" OTTD_PRINTF64 "d (T:%d, R:%d, P:%d, S:%d)",
- p->index + 1, buffer, _network_player_info[p->index].company_name, p->inaugurated_year + MAX_YEAR_BEGIN_REAL, p->player_money, p->current_loan, CalculateCompanyValue(p),
+ p->index + 1, buffer, _network_player_info[p->index].company_name, BASE_YEAR + p->inaugurated_year, p->player_money, p->current_loan, CalculateCompanyValue(p),
/* trains */ _network_player_info[p->index].num_vehicle[0],
/* lorry + bus */ _network_player_info[p->index].num_vehicle[1] + _network_player_info[p->index].num_vehicle[2],
/* planes */ _network_player_info[p->index].num_vehicle[3],
diff --git a/currency.c b/currency.c
index 8ade72211..31e461687 100644
--- a/currency.c
+++ b/currency.c
@@ -81,8 +81,8 @@ uint GetMaskOfAllowedCurrencies(void)
for (i = 0; i != lengthof(_currency_specs); i++) {
uint16 to_euro = _currency_specs[i].to_euro;
- if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && _cur_year >= to_euro - MAX_YEAR_BEGIN_REAL) continue;
- if (to_euro == CF_ISEURO && _cur_year < 2000 - MAX_YEAR_BEGIN_REAL) continue;
+ if (to_euro != CF_NOEURO && to_euro != CF_ISEURO && BASE_YEAR + _cur_year >= to_euro) continue;
+ if (to_euro == CF_ISEURO && BASE_YEAR + _cur_year < 2000) continue;
mask |= (1 << i);
}
mask |= (1 << CUSTOM_CURRENCY_ID); // always allow custom currency
@@ -94,7 +94,7 @@ void CheckSwitchToEuro(void)
{
if (_currency_specs[_opt.currency].to_euro != CF_NOEURO &&
_currency_specs[_opt.currency].to_euro != CF_ISEURO &&
- MAX_YEAR_BEGIN_REAL + _cur_year >= _currency_specs[_opt.currency].to_euro) {
+ BASE_YEAR + _cur_year >= _currency_specs[_opt.currency].to_euro) {
_opt.currency = 2; // this is the index of euro above.
AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL, 0, NT_ECONOMY, 0), 0, 0);
}
diff --git a/date.c b/date.c
index dad1aa47b..6305d5f6c 100644
--- a/date.c
+++ b/date.c
@@ -129,7 +129,7 @@ Date ConvertIntDate(uint date)
Month month = 0;
Day day = 1;
- if (IS_INT_INSIDE(date, 1920, MAX_YEAR_END_REAL + 1)) {
+ if (IS_INT_INSIDE(date, 1920, MAX_YEAR + 1)) {
year = date - 1920;
} else if (IS_INT_INSIDE(date, 192001, 209012 + 1)) {
month = date % 100 - 1;
@@ -282,13 +282,13 @@ void IncreaseDate(void)
#endif /* ENABLE_NETWORK */
/* check if we reached end of the game */
- if (_cur_year == _patches.ending_year - MAX_YEAR_BEGIN_REAL) {
+ if (_cur_year == _patches.ending_year - MAX_YEAR) {
ShowEndGameChart();
/* check if we reached the maximum year, decrement dates by a year */
- } else if (_cur_year == (MAX_YEAR_END + 1)) {
+ } else if (BASE_YEAR + _cur_year == MAX_YEAR + 1) {
Vehicle *v;
- _cur_year = MAX_YEAR_END;
+ _cur_year--;
_date -= 365;
FOR_ALL_VEHICLES(v) {
v->date_of_last_service -= 365;
diff --git a/date.h b/date.h
index 96fa2799a..5c486f374 100644
--- a/date.h
+++ b/date.h
@@ -8,9 +8,9 @@
*/
#define DAY_TICKS 74
-#define MAX_YEAR_BEGIN_REAL 1920
-#define MAX_YEAR_END_REAL 2090
-#define MAX_YEAR_END 170
+#define BASE_YEAR 1920
+#define MIN_YEAR 1920
+#define MAX_YEAR 2090
/* Year and Date are defined elsewhere */
typedef uint8 Month;
diff --git a/disaster_cmd.c b/disaster_cmd.c
index 931914695..80d938ccd 100644
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -951,7 +951,7 @@ static DisasterInitProc * const _disaster_initprocs[] = {
Disaster7_Init,
};
-#define MK(a, b) { (a) - MAX_YEAR_BEGIN_REAL, (b) - MAX_YEAR_BEGIN_REAL }
+#define MK(a, b) { (a) - BASE_YEAR, (b) - BASE_YEAR }
static const struct {
byte min;
byte max;
diff --git a/economy.c b/economy.c
index ab3a3efb6..8b8d9034f 100644
--- a/economy.c
+++ b/economy.c
@@ -1482,7 +1482,7 @@ int LoadUnloadVehicle(Vehicle *v)
void PlayersMonthlyLoop(void)
{
PlayersGenStatistics();
- if (_patches.inflation && _cur_year < MAX_YEAR_END)
+ if (_patches.inflation && BASE_YEAR + _cur_year < MAX_YEAR)
AddInflation();
PlayersPayInterest();
// Reset the _current_player flag
diff --git a/graph_gui.c b/graph_gui.c
index 9382d7172..c14bcb2c9 100644
--- a/graph_gui.c
+++ b/graph_gui.c
@@ -151,7 +151,7 @@ static void DrawGraph(const GraphDrawer *gw)
x = gw->left + 44;
y = gw->top + gw->height + 1;
j = gw->month;
- k = gw->year + MAX_YEAR_BEGIN_REAL;
+ k = BASE_YEAR + gw->year;
i = gw->num_on_x_axis;assert(i>0);
do {
SetDParam(2, k);
diff --git a/misc_gui.c b/misc_gui.c
index 8a7c4954e..67fff0289 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -1677,7 +1677,7 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2)
YearMonthDay ymd;
ConvertDayToYMD(&ymd, _date);
- if ((ymd.year == 0 && p2 == -1) || (ymd.year == 170 && p2 == 1)) return _cur_year;
+ if ((BASE_YEAR + ymd.year == MIN_YEAR && p2 == -1) || (BASE_YEAR + ymd.year == MAX_YEAR && p2 == 1)) return _cur_year;
SetDate(ConvertYMDToDay(_cur_year + p2, ymd.month, ymd.day));
EnginesMonthlyLoop();
diff --git a/network_gui.c b/network_gui.c
index dd804e6e3..8289253bc 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -876,7 +876,7 @@ static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
DrawStringTruncated(x, y, STR_NETWORK_COMPANY_NAME, 2, trunc_width);
y += 10;
- SetDParam(0, _network_player_info[nd->company].inaugurated_year + MAX_YEAR_BEGIN_REAL);
+ SetDParam(0, BASE_YEAR + _network_player_info[nd->company].inaugurated_year);
DrawString(x, y, STR_NETWORK_INAUGURATION_YEAR, 2); // inauguration year
y += 10;
diff --git a/network_server.c b/network_server.c
index c607b379a..3a3eca367 100644
--- a/network_server.c
+++ b/network_server.c
@@ -1313,8 +1313,8 @@ extern void SwitchMode(int new_mode);
/* Check if we want to restart the map */
static void NetworkCheckRestartMap(void)
{
- if (_network_restart_game_year != 0 && _cur_year + MAX_YEAR_BEGIN_REAL >= _network_restart_game_year) {
- DEBUG(net, 0)("Auto-restarting map. Year %d reached.", _cur_year + MAX_YEAR_BEGIN_REAL);
+ if (_network_restart_game_year != 0 && BASE_YEAR + _cur_year >= _network_restart_game_year) {
+ DEBUG(net, 0)("Auto-restarting map. Year %d reached.", BASE_YEAR + _cur_year);
_random_seeds[0][0] = Random();
_random_seeds[0][1] = InteractiveRandom();
diff --git a/oldloader.c b/oldloader.c
index 6f634ac92..6bdea4f09 100644
--- a/oldloader.c
+++ b/oldloader.c
@@ -995,7 +995,7 @@ static bool LoadOldPlayer(LoadgameState *ls, int num)
p->money64 = p->player_money = p->current_loan = 100000;
_player_colors[num] = p->player_color;
- p->inaugurated_year = _old_inaugurated_year - MAX_YEAR_BEGIN_REAL;
+ p->inaugurated_year = _old_inaugurated_year - BASE_YEAR;
if (p->location_of_house == 0xFFFF)
p->location_of_house = 0;
diff --git a/player_gui.c b/player_gui.c
index adf4e9fae..10aacb333 100644
--- a/player_gui.c
+++ b/player_gui.c
@@ -47,7 +47,7 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode)
tbl = p->yearly_expenses + 2;
do {
if (year >= p->inaugurated_year) {
- SetDParam(0, year + 1920);
+ SetDParam(0, BASE_YEAR + year);
DrawStringCenterUnderline(x-17, 15, STR_7010, 0);
sum = 0;
for (i = 0; i != 13; i++) {
@@ -537,7 +537,7 @@ static void PlayerCompanyWndProc(Window *w, WindowEvent *e)
w->disabled_state = dis;
DrawWindowWidgets(w);
- SetDParam(0, p->inaugurated_year + 1920);
+ SetDParam(0, BASE_YEAR + p->inaugurated_year);
DrawString(110, 25, STR_7038_INAUGURATED, 0);
DrawPlayerVehiclesAmount(w->window_number);
diff --git a/roadveh_gui.c b/roadveh_gui.c
index 3607a67d1..3acfce898 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -54,7 +54,7 @@ void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number)
y += 10;
/* Design date - Life length */
- SetDParam(0, ymd.year + 1920);
+ SetDParam(0, BASE_YEAR + ymd.year);
SetDParam(1, e->lifelength);
DrawString(x, y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
y += 10;
@@ -216,7 +216,7 @@ static void RoadVehDetailsWndProc(Window *w, WindowEvent *e)
DrawRoadVehImage(v, 3, 57, INVALID_VEHICLE);
SetDParam(0, GetCustomEngineName(v->engine_type));
- SetDParam(1, 1920 + v->build_year);
+ SetDParam(1, BASE_YEAR + v->build_year);
SetDParam(2, v->value);
DrawString(34, 57, STR_9011_BUILT_VALUE, 0);
diff --git a/settings.c b/settings.c
index a07eb1165..15ccf1488 100644
--- a/settings.c
+++ b/settings.c
@@ -1206,7 +1206,7 @@ static const SettingDescGlobVarList _network_settings[] = {
SDTG_BOOL("autoclean_companies", S, 0, _network_autoclean_companies, false, STR_NULL, NULL),
SDTG_VAR("autoclean_unprotected",SLE_UINT8, S, 0, _network_autoclean_unprotected,12, 0, 60, STR_NULL, NULL),
SDTG_VAR("autoclean_protected", SLE_UINT8, S, 0, _network_autoclean_protected, 36, 0, 180, STR_NULL, NULL),
- SDTG_VAR("restart_game_year", SLE_UINT16, S,D0, _network_restart_game_year, 0, MAX_YEAR_BEGIN_REAL, MAX_YEAR_END_REAL, STR_NULL, NULL),
+ SDTG_VAR("restart_game_year", SLE_UINT16, S,D0, _network_restart_game_year, 0, MIN_YEAR, MAX_YEAR, STR_NULL, NULL),
SDTG_END()
};
#endif /* ENABLE_NETWORK */
@@ -1320,9 +1320,9 @@ const SettingDesc _patch_settings[] = {
SDT_BOOL(Patches, same_industry_close, 0, 0, false, STR_CONFIG_PATCHES_SAMEINDCLOSE, NULL),
SDT_BOOL(Patches, bribe, 0, 0, true, STR_CONFIG_PATCHES_BRIBE, NULL),
SDT_VAR(Patches, snow_line_height,SLE_UINT8, 0, 0, 7, 2, 13, STR_CONFIG_PATCHES_SNOWLINE_HEIGHT, NULL),
- SDT_VAR(Patches, colored_news_year,SLE_UINT, 0,NC, 2000, MAX_YEAR_BEGIN_REAL, MAX_YEAR_END_REAL, STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,NULL),
- SDT_VAR(Patches, starting_year, SLE_UINT, 0,NC, 1950, MAX_YEAR_BEGIN_REAL, MAX_YEAR_END_REAL, STR_CONFIG_PATCHES_STARTING_YEAR,NULL),
- SDT_VAR(Patches, ending_year, SLE_UINT,0,NC|NO,2051, MAX_YEAR_BEGIN_REAL, MAX_YEAR_END_REAL, STR_CONFIG_PATCHES_ENDING_YEAR, NULL),
+ SDT_VAR(Patches, colored_news_year,SLE_UINT, 0,NC, 2000, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_COLORED_NEWS_YEAR,NULL),
+ SDT_VAR(Patches, starting_year, SLE_UINT, 0,NC, 1950, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_STARTING_YEAR,NULL),
+ SDT_VAR(Patches, ending_year, SLE_UINT,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, STR_CONFIG_PATCHES_ENDING_YEAR, NULL),
SDT_BOOL(Patches, smooth_economy, 0, 0, true, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, NULL),
SDT_BOOL(Patches, allow_shares, 0, 0, true, STR_CONFIG_PATCHES_ALLOW_SHARES, NULL),
diff --git a/settings_gui.c b/settings_gui.c
index 4a98d28fa..6de19cc76 100644
--- a/settings_gui.c
+++ b/settings_gui.c
@@ -1185,7 +1185,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
WP(w,def_d).data_1 = (1 << (line * 2 + 0));
} else {
_custom_currency.to_euro =
- clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR_END_REAL);
+ clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
WP(w,def_d).data_1 = (1 << (line * 2 + 1));
}
} else { // enter text
@@ -1237,7 +1237,7 @@ static void CustCurrencyWndProc(Window *w, WindowEvent *e)
case 4: /* Year to switch to euro */
val = atoi(b);
- val = clamp(val, 1999, MAX_YEAR_END_REAL);
+ val = clamp(val, 1999, MAX_YEAR);
if (val == 1999) val = 0;
_custom_currency.to_euro = val;
break;
diff --git a/ship_gui.c b/ship_gui.c
index b2ed661ad..49572d7ec 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -54,7 +54,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number)
/* Design date - Life length */
e = GetEngine(engine_number);
ConvertDayToYMD(&ymd, e->intro_date);
- SetDParam(0, ymd.year + 1920);
+ SetDParam(0, BASE_YEAR + ymd.year);
SetDParam(1, e->lifelength);
DrawString(x,y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
y += 10;
@@ -212,7 +212,7 @@ static void ShipDetailsWndProc(Window *w, WindowEvent *e)
DrawShipImage(v, 3, 57, INVALID_VEHICLE);
- SetDParam(1, 1920 + v->build_year);
+ SetDParam(1, BASE_YEAR + v->build_year);
SetDParam(0, GetCustomEngineName(v->engine_type));
SetDParam(2, v->value);
DrawString(74, 57, STR_9816_BUILT_VALUE, 0);
diff --git a/strings.c b/strings.c
index a0d762878..49b730b1e 100644
--- a/strings.c
+++ b/strings.c
@@ -339,7 +339,7 @@ static char *FormatYmdString(char *buff, uint16 number)
for (src = GetStringPtr(STR_0162_JAN + ymd.month); (*buff++ = *src++) != '\0';) {}
buff[-1] = ' ';
- return FormatNoCommaNumber(buff, ymd.year + MAX_YEAR_BEGIN_REAL);
+ return FormatNoCommaNumber(buff, BASE_YEAR + ymd.year);
}
static char *FormatMonthAndYear(char *buff, uint16 number)
@@ -352,7 +352,7 @@ static char *FormatMonthAndYear(char *buff, uint16 number)
for (src = GetStringPtr(STR_MONTH_JAN + ymd.month); (*buff++ = *src++) != '\0';) {}
buff[-1] = ' ';
- return FormatNoCommaNumber(buff, ymd.year + MAX_YEAR_BEGIN_REAL);
+ return FormatNoCommaNumber(buff, BASE_YEAR + ymd.year);
}
static char *FormatTinyDate(char *buff, uint16 number)
@@ -360,7 +360,7 @@ static char *FormatTinyDate(char *buff, uint16 number)
YearMonthDay ymd;
ConvertDayToYMD(&ymd, number);
- buff += sprintf(buff, " %02i-%02i-%04i", ymd.day, ymd.month + 1, ymd.year + MAX_YEAR_BEGIN_REAL);
+ buff += sprintf(buff, " %02i-%02i-%04i", ymd.day, ymd.month + 1, BASE_YEAR + ymd.year);
return buff;
}
diff --git a/train_gui.c b/train_gui.c
index fc1703562..b00d31185 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -73,7 +73,7 @@ void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number)
y += 10;
/* Design date - Life length */
- SetDParam(0, ymd.year + 1920);
+ SetDParam(0, BASE_YEAR + ymd.year);
SetDParam(1, e->lifelength);
DrawString(x,y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
y += 10;
@@ -1115,7 +1115,7 @@ static void TrainDetailsInfoTab(const Vehicle *v, int x, int y)
if (!(rvi->flags & RVI_WAGON)) {
SetDParam(0, GetCustomEngineName(v->engine_type));
- SetDParam(1, v->build_year + 1920);
+ SetDParam(1, BASE_YEAR + v->build_year);
SetDParam(2, v->value);
DrawString(x, y, STR_882C_BUILT_VALUE, 0x10);
} else {