2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * upda.c: Give the time of the next update
30 * Known contributors to this file:
35 #include <sys/types.h>
44 * Tell what the update policy is, and when the next update
51 struct mob_acc_globals timestamps;
52 extern int updating_mob;
56 if ((fp = fopen(timestampfil, "r")) == NULL) {
58 if ((fp = fopen(timestampfil, "rb")) == NULL) {
60 logerror("Unable to open timestamp file.");
63 fread(×tamps, sizeof(timestamps), 1, fp);
66 pr("Mobility updating is enabled.\n\n");
68 pr("Mobility updating will come back on around %s",
69 ctime(×tamps.starttime));
70 pr("game time, within 3 minutes, depending on when the server checks.\n\n");
74 if (opt_UPDATESCHED) {
75 time_t now, next, delta;
76 extern int update_time;
78 if (updates_disabled())
79 pr("UPDATES ARE DISABLED!\n");
82 switch (update_policy) {
84 next_update_time(&now, &next, &delta);
85 pr("\nUpdates occur at times specified by the ETU rates.\n\n");
86 pr("The next update is at %19.19s.\n", ctime(&next));
89 next_update_time(&now, &next, &delta);
90 pr("\nUpdates occur at scheduled times.\n\n");
91 pr("The next update is at %19.19s.\n", ctime(&next));
94 next_update_time(&now, &next, &delta);
95 pr("\nBlitz Updates occur every %d minutes. \n\n", blitz_time);
96 pr("The next update is at %19.19s.\n", ctime(&next));
99 pr("There are no regularly scheduled updates.\n");
102 pr("Update policy is inconsistent.\n");
104 pr("The current time is %19.19s.\n\n", ctime(&now));
107 now = update_time - update_window;
108 next_update_time(&now, &next, &delta);
109 pr("The next update window starts at %19.19s.\n",
111 next += update_window;
112 pr("The next update window stops at %19.19s.\n", ctime(&next));
114 if (opt_DEMANDUPDATE) {
115 if (update_demandpolicy != UDDEM_DISABLE) {
116 switch (update_demandpolicy) {
118 next_update_check_time(&now, &next, &delta);
119 pr("Demand updates occur at update CHECK times.\n");
120 pr("The next update check is at %19.19s.\n",
124 pr("Demand updates occur right after the demand is set.\n");
127 pr("Update demand policy is inconsistent.\n");
132 if ((update_policy == UDP_TIMES) ||
133 ((update_demandpolicy == UDDEM_TMCHECK) && opt_DEMANDUPDATE)) {
134 if (*update_times != 0)
135 pr("The update schedule is: %s\n", update_times);
137 if (opt_DEMANDUPDATE) {
138 if (update_demandpolicy != UDDEM_DISABLE) {
139 if (*update_demandtimes != 0)
140 pr("Demand updates are allowed during: %s\n",
142 if (update_wantmin == 0) {
143 pr("Demand updates are disabled by a mininum of 0\n");
145 pr("Demand updates require %d country(s) to want one.\n", update_wantmin);
150 pr("Game days are: %s\n", game_days);
151 if (*game_hours != 0)
152 pr("Game hours are: %s\n", game_hours);
163 upd_time = now + adj_update;
164 secs_per_update = etu_per_update * s_p_etu;
165 delta = secs_per_update - (upd_time % secs_per_update);
166 next_update = now + delta;
167 pr("The next update is at %19.19s.\n", ctime(&next_update));
168 pr("The current time is %19.19s.\n", ctime(&now));
170 pr("Update times are variable, update window is +/- %d minutes %d seconds.\n", update_window / 60, update_window % 60);