summaryrefslogtreecommitdiff
path: root/network_server.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-12-23 17:37:26 +0000
committertruelight <truelight@openttd.org>2004-12-23 17:37:26 +0000
commitc9645885d085706aab46c593fab1fd2c1d560c17 (patch)
tree58714b88a827433fe0f108fda19afc593185fdea /network_server.c
parent3672ae111857e7dffff55737a50d06f5d44114a5 (diff)
downloadopenttd-c9645885d085706aab46c593fab1fd2c1d560c17.tar.xz
(svn r1252) -Add: [Network] With 'set restart_game_date' you can set the date for in
which year the server must restart hisself. (0 = disabled, default value)
Diffstat (limited to 'network_server.c')
-rw-r--r--network_server.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/network_server.c b/network_server.c
index 91ff13e1c..9e54bfd34 100644
--- a/network_server.c
+++ b/network_server.c
@@ -1259,6 +1259,23 @@ void NetworkUpdateClientInfo(uint16 client_index)
}
}
+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) {
+ _docommand_recursive = 0;
+
+ DEBUG(net, 0)("Auto-restarting map. Year %d reached.", _cur_year + 1920);
+
+ _random_seeds[0][0] = Random();
+ _random_seeds[0][1] = InteractiveRandom();
+
+ SwitchMode(SM_NEWGAME);
+ }
+}
+
/* Check if the server has autoclean_companies activated
Two things happen:
1) If a company is not protected, it is closed after 1 year (for example)
@@ -1477,6 +1494,11 @@ void NetworkServer_Tick(void)
NetworkUDPAdvertise();
}
+void NetworkServerYearlyLoop(void)
+{
+ NetworkCheckRestartMap();
+}
+
void NetworkServerMonthlyLoop(void)
{
NetworkAutoCleanCompanies();