summaryrefslogtreecommitdiff
path: root/openttd.c
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2006-08-20 18:40:57 +0000
committerrubidium <rubidium@openttd.org>2006-08-20 18:40:57 +0000
commit28a08437075be6495df383ca854f6026965a8b8e (patch)
tree146ad5e3c72a49bcc04fae58e750b972f063d8c2 /openttd.c
parent5e4667624e5093ea2b83bcdf63d836d1a34d46bc (diff)
downloadopenttd-28a08437075be6495df383ca854f6026965a8b8e.tar.xz
(svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
The game date subsystem now allows someone to start in the year 0 and continue up to the year 5 000 000. However, you currently cannot build anything before 1920 as there is no newgrf support for dates before 1920 or after 2090 yet.
Diffstat (limited to 'openttd.c')
-rw-r--r--openttd.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/openttd.c b/openttd.c
index 708bfc317..4a71a589d 100644
--- a/openttd.c
+++ b/openttd.c
@@ -793,7 +793,7 @@ void SwitchMode(int new_mode)
}
}
_generating_world = false;
- _patches_newgame.starting_year = BASE_YEAR + _cur_year;
+ _patches_newgame.starting_year = ORIGINAL_BASE_YEAR + _cur_year;
// delete all stations owned by a player
DeleteAllPlayerStations();
} else {
@@ -1439,5 +1439,29 @@ bool AfterLoadGame(void)
if (!CheckSavegameVersion(27)) AfterLoadStations();
+ /* Time starts at 0 instead of 1920.
+ * Account for this in older games by adding an offset */
+ if (CheckSavegameVersion(31)) {
+ Station *st;
+ Waypoint *wp;
+ Engine *e;
+ Player *player;
+ Industry *i;
+ Vehicle *v;
+
+ _date += DAYS_TILL_ORIGINAL_BASE_YEAR;
+
+ FOR_ALL_STATIONS(st) st->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
+ FOR_ALL_WAYPOINTS(wp) wp->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
+ FOR_ALL_ENGINES(e) e->intro_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
+ FOR_ALL_PLAYERS(player) player->inaugurated_year += ORIGINAL_BASE_YEAR;
+ FOR_ALL_INDUSTRIES(i) i->last_prod_year += ORIGINAL_BASE_YEAR;
+
+ FOR_ALL_VEHICLES(v) {
+ v->date_of_last_service += DAYS_TILL_ORIGINAL_BASE_YEAR;
+ v->build_year += ORIGINAL_BASE_YEAR;
+ }
+ }
+
return true;
}