]> git.pond.sub.org Git - empserver/blob - src/lib/commands/upda.c
8c6076b789a6e8a7e90aa6d2125dce756aec0e7f
[empserver] / src / lib / commands / upda.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                Ken Stevens, Steve McClure, Markus Armbruster
5  *
6  *  Empire 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 3 of the License, or
9  *  (at your option) any later version.
10  *
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.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  *  ---
20  *
21  *  See files README, COPYING and CREDITS in the root of the source
22  *  tree for related information and legal notices.  It is expected
23  *  that future projects/authors will amend these files as needed.
24  *
25  *  ---
26  *
27  *  upda.c: Give the time of the next update
28  *
29  *  Known contributors to this file:
30  *     Markus Armbruster, 2007-2010
31  */
32
33 #include <config.h>
34
35 #include "commands.h"
36 #include "game.h"
37 #include "optlist.h"
38 #include "server.h"
39
40 /*
41  * Tell what the update policy is, and when the next update
42  * is likely to be.
43  */
44 int
45 upda(void)
46 {
47     time_t now, next, stop;
48
49     if (updates_disabled())
50         pr("UPDATES ARE DISABLED!\n");
51
52     (void)time(&now);
53     next = update_time[0];
54     if (next) {
55         pr("\nUpdates occur at times specified by the ETU rates.\n\n");
56         pr("The next update is at %19.19s.\n", ctime(&next));
57     } else {
58         pr("There are no regularly scheduled updates.\n");
59     }
60     pr("The current time is   %19.19s.\n\n", ctime(&now));
61
62     if (next && update_window) {
63         pr("The next update window starts at %19.19s.\n", ctime(&next));
64         stop = next + update_window;
65         pr("The next update window stops at %19.19s.\n", ctime(&stop));
66     }
67
68     switch (update_demand) {
69     case UPD_DEMAND_NONE:
70     default:
71         break;
72     case UPD_DEMAND_SCHED:
73         pr("Demand updates occur at update CHECK times.\n");
74         if (next) {
75             pr("The next update check is at %19.19s.\n", ctime(&next));
76         }
77         pr("Demand updates require %d country(s) to want one.\n",
78            update_wantmin);
79         break;
80     case UPD_DEMAND_ASYNC:
81         pr("Demand updates occur right after the demand is set.\n");
82         if (*update_demandtimes != 0) {
83             pr("Demand updates are allowed during: %s\n",
84                update_demandtimes);
85         }
86         pr("Demand updates require %d country(s) to want one.\n",
87            update_wantmin);
88     }
89
90     if (*game_days != 0)
91         pr("Game days are: %s\n", game_days);
92     if (*game_hours != 0)
93         pr("Game hours are: %s\n", game_hours);
94
95     pr("\nThis command is obsolete and will go away in a future version.\n"
96        "Please use \"show updates\".\n");
97     return 0;
98 }