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