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>
45 * Tell what the update policy is, and when the next update
52 struct mob_acc_globals timestamps;
53 extern int updating_mob;
54 extern int update_window;
55 extern s_char *timestampfil;
59 if ((fp = fopen(timestampfil, "r")) == NULL) {
61 if ((fp = fopen(timestampfil, "rb")) == NULL) {
63 logerror("Unable to open timestamp file.");
66 fread(×tamps, sizeof(timestamps), 1, fp);
69 pr("Mobility updating is enabled.\n\n");
71 pr("Mobility updating will come back on around %s",
72 ctime(×tamps.starttime));
73 pr("game time, within 3 minutes, depending on when the server checks.\n\n");
77 if (opt_UPDATESCHED) {
78 time_t now, next, delta;
79 extern int update_time;
80 extern int update_policy;
81 extern int update_demandpolicy;
82 extern int update_wantmin;
83 extern int blitz_time;
84 extern s_char *update_times;
85 extern s_char *update_demandtimes;
86 extern s_char *game_days;
87 extern s_char *game_hours;
89 if (updates_disabled())
90 pr("UPDATES ARE DISABLED!\n");
93 switch (update_policy) {
95 next_update_time(&now, &next, &delta);
96 pr("\nUpdates occur at times specified by the ETU rates.\n\n");
97 pr("The next update is at %19.19s.\n", ctime(&next));
100 next_update_time(&now, &next, &delta);
101 pr("\nUpdates occur at scheduled times.\n\n");
102 pr("The next update is at %19.19s.\n", ctime(&next));
105 next_update_time(&now, &next, &delta);
106 pr("\nBlitz Updates occur every %d minutes. \n\n",
108 pr("The next update is at %19.19s.\n",ctime(&next));
111 pr("There are no regularly scheduled updates.\n");
114 pr("Update policy is inconsistent.\n");
116 pr("The current time is %19.19s.\n\n", ctime(&now));
119 now = update_time - update_window;
120 next_update_time(&now, &next, &delta);
121 pr("The next update window starts at %19.19s.\n",ctime(&next));
122 next += update_window;
123 pr("The next update window stops at %19.19s.\n",ctime(&next));
125 if (opt_DEMANDUPDATE) {
126 if (update_demandpolicy != UDDEM_DISABLE) {
127 switch (update_demandpolicy) {
129 next_update_check_time(&now, &next, &delta);
130 pr("Demand updates occur at update CHECK times.\n");
131 pr("The next update check is at %19.19s.\n",
135 pr("Demand updates occur right after the demand is set.\n");
138 pr("Update demand policy is inconsistent.\n");
143 if ((update_policy == UDP_TIMES) ||
144 ((update_demandpolicy == UDDEM_TMCHECK) &&
146 if (*update_times != 0)
147 pr("The update schedule is: %s\n", update_times);
149 if (opt_DEMANDUPDATE) {
150 if (update_demandpolicy != UDDEM_DISABLE) {
151 if (*update_demandtimes != 0)
152 pr("Demand updates are allowed during: %s\n", update_demandtimes);
153 if (update_wantmin == 0) {
154 pr("Demand updates are disabled by a mininum of 0\n");
156 pr("Demand updates require %d country(s) to want one.\n",update_wantmin);
160 if (*game_days != 0) pr("Game days are: %s\n", game_days);
161 if (*game_hours != 0) pr("Game hours are: %s\n", game_hours);
166 extern int etu_per_update;
167 extern int adj_update;
175 upd_time = now + adj_update;
176 secs_per_update = etu_per_update * s_p_etu;
177 delta = secs_per_update - (upd_time % secs_per_update);
178 next_update = now + delta;
179 pr("The next update is at %19.19s.\n",ctime(&next_update));
180 pr("The current time is %19.19s.\n",ctime(&now));
182 pr("Update times are variable, update window is +/- %d minutes %d seconds.\n",
183 update_window / 60, update_window % 60);