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", blitz_time);
107 pr("The next update is at %19.19s.\n", ctime(&next));
110 pr("There are no regularly scheduled updates.\n");
113 pr("Update policy is inconsistent.\n");
115 pr("The current time is %19.19s.\n\n", ctime(&now));
118 now = update_time - update_window;
119 next_update_time(&now, &next, &delta);
120 pr("The next update window starts at %19.19s.\n",
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) && opt_DEMANDUPDATE)) {
145 if (*update_times != 0)
146 pr("The update schedule is: %s\n", update_times);
148 if (opt_DEMANDUPDATE) {
149 if (update_demandpolicy != UDDEM_DISABLE) {
150 if (*update_demandtimes != 0)
151 pr("Demand updates are allowed during: %s\n",
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);
161 pr("Game days are: %s\n", game_days);
162 if (*game_hours != 0)
163 pr("Game hours are: %s\n", game_hours);
168 extern int etu_per_update;
169 extern int adj_update;
177 upd_time = now + adj_update;
178 secs_per_update = etu_per_update * s_p_etu;
179 delta = secs_per_update - (upd_time % secs_per_update);
180 next_update = now + delta;
181 pr("The next update is at %19.19s.\n", ctime(&next_update));
182 pr("The current time is %19.19s.\n", ctime(&now));
184 pr("Update times are variable, update window is +/- %d minutes %d seconds.\n", update_window / 60, update_window % 60);