summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2006-08-16 12:07:24 +0000
committerrubidium <rubidium@openttd.org>2006-08-16 12:07:24 +0000
commitb317c679dd330ca3e353b7c5d1796a237415f67c (patch)
tree81251d3d93f9cd6e4db0874e405a2d254bfe491f
parentff53d076375824ae0290f8f0639278a09a730f12 (diff)
downloadopenttd-b317c679dd330ca3e353b7c5d1796a237415f67c.tar.xz
(svn r5928) -Cleanup: remove ConvertIntDate and use ConvertYMDToDate as ConvertIntDate was only called with Years.
-rw-r--r--date.c36
-rw-r--r--date.h1
-rw-r--r--misc.c4
-rw-r--r--network.c2
4 files changed, 2 insertions, 41 deletions
diff --git a/date.c b/date.c
index b5a11fc6e..def44e6f8 100644
--- a/date.c
+++ b/date.c
@@ -116,42 +116,6 @@ Date ConvertYMDToDate(Year year, Month month, Day day)
return (yr >> 2) * (365 + 365 + 365 + 366) + rem;
}
-/**
- * Convert a date on the form:
- * 1920 - 2090 (MAX_YEAR_END_REAL)
- * 192001 - 209012
- * 19200101 - 20901231
- * or if > 2090 and below 65536, treat it as a daycount.
- * @return -1 if no conversion was possible
- */
-Date ConvertIntDate(uint date)
-{
- Year year;
- Month month = 0;
- Day day = 1;
-
- if (IS_INT_INSIDE(date, 1920, MAX_YEAR + 1)) {
- year = date;
- } else if (IS_INT_INSIDE(date, 192001, 209012 + 1)) {
- month = date % 100 - 1;
- year = date / 100;
- } else if (IS_INT_INSIDE(date, 19200101, 20901231 + 1)) {
- day = date % 100; date /= 100;
- month = date % 100 - 1;
- year = date / 100;
- } else if (IS_INT_INSIDE(date, 2091, 65536)) {
- return date;
- } else {
- return (Date)-1;
- }
-
- /* invalid ranges? */
- if (month >= 12 || !IS_INT_INSIDE(day, 1, 31 + 1)) return (Date)-1;
-
- return ConvertYMDToDate(year, month, day);
-}
-
-
/** Functions used by the IncreaseDate function */
extern void OnNewDay_Train(Vehicle *v);
diff --git a/date.h b/date.h
index cae57aaed..8ca64ece2 100644
--- a/date.h
+++ b/date.h
@@ -32,4 +32,3 @@ extern DateFract _date_fract;
void SetDate(Date date);
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
Date ConvertYMDToDate(Year year, Month month, Day day);
-Date ConvertIntDate(uint date);
diff --git a/misc.c b/misc.c
index 74d620b03..e853fc579 100644
--- a/misc.c
+++ b/misc.c
@@ -124,9 +124,7 @@ void InitializeGame(int mode, uint size_x, uint size_y)
_cur_tileloop_tile = 0;
if ((mode & IG_DATE_RESET) == IG_DATE_RESET) {
- uint starting = ConvertIntDate(_patches.starting_year);
- if (starting == (uint)-1) starting = 10958;
- SetDate(starting);
+ SetDate(ConvertYMDToDate(_patches.starting_year, 0, 1));
}
InitializeEngines();
diff --git a/network.c b/network.c
index 6426686c4..6d68d2ef4 100644
--- a/network.c
+++ b/network.c
@@ -983,7 +983,7 @@ static void NetworkInitGameInfo(void)
_network_game_info.spectators_on = 0;
_network_game_info.game_date = _date;
- _network_game_info.start_date = ConvertIntDate(_patches.starting_year);
+ _network_game_info.start_date = ConvertYMDToDate(_patches.starting_year, 0, 1);
_network_game_info.map_width = MapSizeX();
_network_game_info.map_height = MapSizeY();
_network_game_info.map_set = _opt.landscape;