]> git.pond.sub.org Git - empserver/blob - src/lib/subs/show.c
New command show updates:
[empserver] / src / lib / subs / show.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2007, 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  *  show.c: General show routines
29  * 
30  *  Known contributors to this file:
31  *     Julian Onions, 1988
32  *     Jeff Bailey, 1990
33  *     Steve McClure, 1996
34  *     Ron Koenderink, 2005
35  *     Markus Armbruster, 2006-2007
36  */
37
38 #include <config.h>
39
40 #include <math.h>
41 #include "file.h"
42 #include "game.h"
43 #include "item.h"
44 #include "land.h"
45 #include "nat.h"
46 #include "news.h"
47 #include "nuke.h"
48 #include "optlist.h"
49 #include "plane.h"
50 #include "player.h"
51 #include "product.h"
52 #include "prototypes.h"
53 #include "sect.h"
54 #include "server.h"
55 #include "ship.h"
56
57 static char *fmttime2822(time_t);
58
59 struct look_list {
60     union {
61         struct lchrstr *lp;
62         struct plchrstr *pp;
63         struct mchrstr *mp;
64     } l_u;
65     int tech;
66 };
67
68 /*
69  * Change this if there are ever more than 200 ships, plane or land
70  * unit types.
71  */
72 static struct look_list lookup_list[200];
73 static int lookup_list_cnt = 0;
74
75 static void
76 sort_lookup_list(void)
77 {
78     struct natstr *np = getnatp(player->cnum);
79     struct look_list tmp;
80     int i;
81     int j;
82
83     if (!(np->nat_flags & NF_TECHLISTS))
84         return;
85     for (i = 0; i < lookup_list_cnt; i++) {
86         for (j = i; j < lookup_list_cnt; j++) {
87             if (lookup_list[j].tech < lookup_list[i].tech) {
88                 tmp = lookup_list[j];
89                 lookup_list[j] = lookup_list[i];
90                 lookup_list[i] = tmp;
91             }
92         }
93     }
94 }
95
96 static void
97 make_new_list(int tlev, int type)
98 {
99     struct plchrstr *pp;
100     struct lchrstr *lp;
101     struct mchrstr *mp;
102
103     lookup_list_cnt = 0;
104     if (type == EF_PLANE) {
105         for (pp = plchr; pp->pl_name; pp++) {
106             if (pp->pl_tech > tlev)
107                 continue;
108             lookup_list[lookup_list_cnt].l_u.pp = pp;
109             lookup_list[lookup_list_cnt].tech = pp->pl_tech;
110             lookup_list_cnt++;
111         }
112     } else if (type == EF_SHIP) {
113         for (mp = mchr; mp->m_name; mp++) {
114             if (mp->m_tech > tlev)
115                 continue;
116             lookup_list[lookup_list_cnt].l_u.mp = mp;
117             lookup_list[lookup_list_cnt].tech = mp->m_tech;
118             lookup_list_cnt++;
119         }
120     } else if (type == EF_LAND) {
121         for (lp = lchr; lp->l_name; lp++) {
122             if (lp->l_tech > tlev)
123                 continue;
124             lookup_list[lookup_list_cnt].l_u.lp = lp;
125             lookup_list[lookup_list_cnt].tech = lp->l_tech;
126             lookup_list_cnt++;
127         }
128     } else
129         return;
130
131     sort_lookup_list();
132 }
133
134 void
135 show_bridge(int tlev)
136 {
137     if (tlev < buil_bt)
138         return;
139     pr("Bridges require %g tech,", buil_bt);
140     pr(" %d hcm,", buil_bh);
141     pr(" %d workers,\n", 0);
142     pr("%d available workforce, and cost $%g\n",
143        (SCT_BLD_WORK(0, buil_bh) * SCT_MINEFF + 99) / 100,
144        buil_bc);
145 }
146
147 void
148 show_tower(int tlev)
149 {
150     if (tlev < buil_tower_bt)
151         return;
152     pr("Bridge Towers require %g tech,", buil_tower_bt);
153     pr(" %d hcm,", buil_tower_bh);
154     pr(" %d workers,\n", 0);
155     pr("%d available workforce, and cost $%g\n",
156        (SCT_BLD_WORK(0, buil_tower_bh) * SCT_MINEFF + 99) / 100,
157        buil_tower_bc);
158 }
159
160 void
161 show_nuke_stats(int tlev)
162 {
163     show_nuke_capab(tlev);
164 }
165
166 void
167 show_nuke_build(int tlev)
168 {
169     struct nchrstr *np;
170     int avail;
171
172     pr("%13s lcm hcm  oil  rad avail tech res $\n", "");
173
174     for (np = nchr; np->n_name; np++) {
175         avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
176         if (np->n_tech > tlev)
177             continue;
178         pr("%-13.13s %3d %3d %4d %4d %5d %4d %3.0f $%6d\n",
179            np->n_name, np->n_lcm, np->n_hcm, np->n_oil,
180            np->n_rad, avail, np->n_tech,
181            drnuke_const > MIN_DRNUKE_CONST ?
182                 ceil(np->n_tech * drnuke_const) : 0.0,
183            np->n_cost);
184     }
185 }
186
187 void
188 show_nuke_capab(int tlev)
189 {
190     struct nchrstr *np;
191     int i, j;
192     char *p;
193
194     pr("%13s blst dam lbs tech res $%7s abilities\n", "", "");
195
196     for (np = nchr; np->n_name; np++) {
197         if (np->n_tech > tlev)
198             continue;
199         pr("%-13.13s %4d %3d %3d %4d %3.0f $%7d ",
200            np->n_name, np->n_blast, np->n_dam,
201            np->n_weight, np->n_tech,
202            drnuke_const > MIN_DRNUKE_CONST ?
203                 ceil(np->n_tech * drnuke_const) : 0.0,
204            np->n_cost);
205         for (i = j = 0; i < 32; i++) {
206             if (!(np->n_flags & bit(i)))
207                 continue;
208             if (NULL != (p = symbol_by_value(bit(i), nuke_chr_flags))) {
209                 if (j++ > 0)
210                     pr(" ");
211                 pr("%s", p);
212             }
213         }
214         pr("\n");
215     }
216 }
217
218 void
219 show_ship_build(int tlev)
220 {
221     struct mchrstr *mp;
222     int n;
223
224     pr("%25s lcm hcm avail tech $\n", "");
225     make_new_list(tlev, EF_SHIP);
226     for (n = 0; n < lookup_list_cnt; n++) {
227         mp = (struct mchrstr *)lookup_list[n].l_u.mp;
228         /* Can't show trade ships unless it's turned on */
229         if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
230             continue;
231
232         pr("%-25.25s %3d %3d %5d %4d $%d\n",
233            mp->m_name, mp->m_lcm, mp->m_hcm,
234            SHP_BLD_WORK(mp->m_lcm, mp->m_hcm), mp->m_tech, mp->m_cost);
235     }
236 }
237
238 void
239 show_ship_stats(int tlev)
240 {
241     struct mchrstr *mp;
242     int scount;
243     int techdiff;
244
245     pr("%25s      s  v  s  r  f  l  p", "");
246     pr("  h");
247     pr("  x");
248     if (opt_FUEL)
249         pr("  fuel");
250     pr("\n");
251
252     pr("%25s      p  i  p  n  i  n  l", "");
253     pr("  e");
254     pr("  p");
255     if (opt_FUEL)
256         pr("   c/u");
257     pr("\n");
258
259     pr("%25s def  d  s  y  g  r  d  n", "");
260     pr("  l");
261     pr("  l");
262     if (opt_FUEL)
263         pr("      ");
264     pr("\n");
265
266
267     make_new_list(tlev, EF_SHIP);
268     for (scount = 0; scount < lookup_list_cnt; scount++) {
269         mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
270         /* Can't show trade ships unless it's turned on */
271         if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
272             continue;
273
274         techdiff = (int)(tlev - mp->m_tech);
275         pr("%-25.25s %3d %2d %2d %2d %2d %2d ",
276            mp->m_name,
277            (short)SHP_DEF(mp->m_armor, techdiff),
278            (short)SHP_SPD(mp->m_speed, techdiff),
279            (short)SHP_VIS(mp->m_visib, techdiff),
280            mp->m_vrnge,
281            (short)SHP_RNG(mp->m_frnge, techdiff),
282            (short)SHP_FIR(mp->m_glim, techdiff));
283
284         pr("%2d ", mp->m_nland);
285         pr("%2d ", mp->m_nplanes);
286         pr("%2d ", mp->m_nchoppers);
287         pr("%2d ", mp->m_nxlight);
288         if (opt_FUEL)
289             pr("%3d/%1d ", mp->m_fuelc, mp->m_fuelu);
290         pr("\n");
291     }
292 }
293
294 void
295 show_ship_capab(int tlev)
296 {
297     struct mchrstr *mp;
298     i_type i;
299     int j;
300     int scount;
301     int n;
302     char *p;
303
304     pr("%25s cargos & capabilities\n", "");
305
306     make_new_list(tlev, EF_SHIP);
307     for (scount = 0; scount < lookup_list_cnt; scount++) {
308         mp = (struct mchrstr *)lookup_list[scount].l_u.mp;
309         /* Can't show trade ships unless it's turned on */
310         if ((mp->m_flags & M_TRADE) && !opt_TRADESHIPS)
311             continue;
312
313         pr("%-25.25s ", mp->m_name);
314
315         for (i = I_NONE + 1; i <= I_MAX; ++i)
316             if (mp->m_item[i])
317                 pr(" %d%c", mp->m_item[i], ichr[i].i_mnem);
318         pr(" ");
319         for (j = n = 0; j < 32; j++) {
320             if (!(mp->m_flags & bit(j)))
321                 continue;
322             if (NULL != (p = symbol_by_value(bit(j), ship_chr_flags))) {
323                 if (n++ > 0)
324                     pr(" ");
325                 pr("%s", p);
326             }
327         }
328         pr("\n");
329     }
330 }
331
332 void
333 show_plane_stats(int tlev)
334 {
335     struct plchrstr *pp;
336     int pcount;
337
338     pr("%25s acc load att def ran fuel stlth\n", "");
339     make_new_list(tlev, EF_PLANE);
340     for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
341         pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
342         pr("%-25.25s %3d %4d %3d %3d %3d %4d ",
343            pp->pl_name,
344            (int)PLN_ACC(pp->pl_acc, (int)(tlev - pp->pl_tech)),
345            (int)PLN_LOAD(pp->pl_load, (int)(tlev - pp->pl_tech)),
346            (int)PLN_ATTDEF(pp->pl_att, (int)(tlev - pp->pl_tech)),
347            (int)PLN_ATTDEF(pp->pl_def, (int)(tlev - pp->pl_tech)),
348            (int)PLN_RAN(pp->pl_range, (int)(tlev - pp->pl_tech)),
349            pp->pl_fuel);
350         pr("%4d%% ", pp->pl_stealth);
351         pr("\n");
352     }
353 }
354
355 void
356 show_plane_capab(int tlev)
357 {
358     struct plchrstr *pp;
359     int i;
360     int pcount;
361     int n;
362     char *p;
363
364     pr("%25s capabilities\n", "");
365     make_new_list(tlev, EF_PLANE);
366     for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
367         pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
368         pr("%-25.25s  ", pp->pl_name);
369
370         for (i = n = 0; i < 32; i++) {
371             if (!(pp->pl_flags & bit(i)))
372                 continue;
373             if (NULL != (p = symbol_by_value(bit(i), plane_chr_flags))) {
374                 if (n++ > 0)
375                     pr(" ");
376                 pr("%s", p);
377             }
378         }
379         pr("\n");
380     }
381 }
382
383 void
384 show_plane_build(int tlev)
385 {
386     struct plchrstr *pp;
387     int pcount;
388
389     pr("%25s lcm hcm crew avail tech $\n", "");
390     make_new_list(tlev, EF_PLANE);
391     for (pcount = 0; pcount < lookup_list_cnt; pcount++) {
392         pp = (struct plchrstr *)lookup_list[pcount].l_u.pp;
393         pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
394            pp->pl_name, pp->pl_lcm,
395            pp->pl_hcm, pp->pl_crew,
396            PLN_BLD_WORK(pp->pl_lcm, pp->pl_hcm), pp->pl_tech, pp->pl_cost);
397     }
398 }
399
400 void
401 show_land_build(int tlev)
402 {
403     struct lchrstr *lp;
404     int n;
405
406     pr("%25s lcm hcm guns avail tech $\n", "");
407     make_new_list(tlev, EF_LAND);
408     for (n = 0; n < lookup_list_cnt; n++) {
409         lp = (struct lchrstr *)lookup_list[n].l_u.lp;
410         if ((lp->l_flags & L_SPY) && !opt_LANDSPIES)
411             continue;
412         pr("%-25.25s %3d %3d %4d %5d %4d $%d\n",
413            lp->l_name, lp->l_lcm,
414            lp->l_hcm,
415            lp->l_gun,
416            LND_BLD_WORK(lp->l_lcm, lp->l_hcm), lp->l_tech, lp->l_cost);
417     }
418 }
419
420 void
421 show_land_capab(int tlev)
422 {
423     struct lchrstr *lcp;
424     int lcount;
425     i_type i;
426     int j, n;
427     char *p;
428
429     pr("%25s capabilities\n", "");
430
431     make_new_list(tlev, EF_LAND);
432     for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
433         lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
434         if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
435             continue;
436
437         pr("%-25s ", lcp->l_name);
438
439         for (i = I_NONE + 1; i <= I_MAX; ++i)
440             if (lcp->l_item[i])
441                 pr(" %d%c", lcp->l_item[i], ichr[i].i_mnem);
442         pr(" ");
443         for (j = n = 0; j < 32; j++) {
444             if (!(lcp->l_flags & bit(j)))
445                 continue;
446             if (NULL != (p = symbol_by_value(bit(j), land_chr_flags))) {
447                 if (n++ > 0)
448                     pr(" ");
449                 pr("%s", p);
450             }
451         }
452         pr("\n");
453     }
454 }
455
456 void
457 show_land_stats(int tlev)
458 {
459     struct lchrstr *lcp;
460     int lcount;
461     int ourtlev;
462
463     pr("%25s              s  v  s  r  r  a  f  a  a        x  l\n", "");
464     pr("%25s              p  i  p  a  n  c  i  m  a  f  f  p  n\n", "");
465     pr("%25s att def vul  d  s  y  d  g  c  r  m  f  c  u  l  d\n", "");
466
467     make_new_list(tlev, EF_LAND);
468     for (lcount = 0; lcount < lookup_list_cnt; lcount++) {
469         lcp = (struct lchrstr *)lookup_list[lcount].l_u.lp;
470         if ((lcp->l_flags & L_SPY) && !opt_LANDSPIES)
471             continue;
472
473         ourtlev = (int)(tlev - lcp->l_tech);
474         pr("%-25s %1.1f %1.1f %3d ",
475            lcp->l_name,
476            LND_ATTDEF(lcp->l_att, ourtlev),
477            LND_ATTDEF(lcp->l_def, ourtlev),
478            (int)LND_VUL(lcp->l_vul, ourtlev));
479         pr("%2d %2d %2d %2d ",
480            (int)LND_SPD(lcp->l_spd, ourtlev),
481            (int)LND_VIS(lcp->l_vis, ourtlev),
482            (int)LND_SPY(lcp->l_spy, ourtlev),
483            (int)LND_RAD(lcp->l_rad, ourtlev));
484         pr("%2d %2d %2d %2d %2d ",
485            (int)LND_FRG(lcp->l_frg, ourtlev),
486            (int)LND_ACC(lcp->l_acc, ourtlev),
487            (int)LND_DAM(lcp->l_dam, ourtlev),
488            (int)LND_AMM(lcp->l_ammo, ourtlev),
489            (int)LND_AAF(lcp->l_aaf, ourtlev));
490         pr("%2d %2d %2d %2d ",
491            (int)LND_FC(lcp->l_fuelc, ourtlev),
492            (int)LND_FU(lcp->l_fuelu, ourtlev),
493            (int)LND_XPL(lcp->l_nxlight, ourtlev),
494            (int)LND_MXL(lcp->l_nland, ourtlev));
495
496         pr("\n");
497     }
498 }
499
500 void
501 show_sect_build(int foo)
502 {
503     int x, first;
504
505     first = 1;
506     for (x = 0; dchr[x].d_name; x++) {
507         if (dchr[x].d_mnem == 0)
508             continue;
509         if (dchr[x].d_cost < 0)
510             continue;
511         if ((dchr[x].d_cost > 0) || (dchr[x].d_build != 1) ||
512             (dchr[x].d_lcms > 0) || (dchr[x].d_hcms > 0)) {
513             if (first) {
514                 pr("sector type    cost to des    cost for 1%% eff   lcms for 1%%    hcms for 1%%\n");
515                 first = 0;
516             }
517             pr("%-14c %-14d %-17d %-14d %d\n",
518                dchr[x].d_mnem, dchr[x].d_cost, dchr[x].d_build,
519                dchr[x].d_lcms, dchr[x].d_hcms);
520         }
521     }
522
523     first = 1;
524     for (x = 0; intrchr[x].in_name; x++) {
525         if (!intrchr[x].in_enable)
526             continue;
527         if (first)
528             pr("\nInfrastructure building - adding 1 point of efficiency costs:\n"
529                "       type          lcms    hcms    mobility    $$$$\n");
530         pr("%-20s %4d    %4d    %8d    %4d\n",
531            intrchr[x].in_name, intrchr[x].in_lcms, intrchr[x].in_hcms,
532            intrchr[x].in_mcost, intrchr[x].in_dcost);
533         first = 0;
534     }
535 }
536
537 void
538 show_sect_stats(int foo)
539 {
540     int x, first = 1;
541     struct natstr *natp;
542
543     natp = getnatp(player->cnum);
544     for (x = 0; dchr[x].d_name; x++) {
545         if (dchr[x].d_mnem == 0)
546             continue;
547         if (first) {
548             pr("                        mob cost   max   max   --  packing bonus  --   max\n");
549             pr("  sector type            0%% 100%%   off   def   mil  uw civ bar other   pop\n");
550             first = 0;
551         }
552         pr("%c %-21.21s", dchr[x].d_mnem, dchr[x].d_name);
553         if (dchr[x].d_mob0 < 0)
554             pr("  no way ");
555         else
556             pr(" %3.1f  %3.1f", dchr[x].d_mob0, dchr[x].d_mob1);
557         pr("  %5.2f %5.2f   %3d %3d %3d %3d %5d %5d\n",
558            dchr[x].d_ostr, dchr[x].d_dstr,
559            ichr[I_MILIT].i_pkg[dchr[x].d_pkg],
560            ichr[I_UW].i_pkg[dchr[x].d_pkg],
561            ichr[I_CIVIL].i_pkg[dchr[x].d_pkg],
562            ichr[I_BAR].i_pkg[dchr[x].d_pkg],
563            ichr[I_LCM].i_pkg[dchr[x].d_pkg],
564            max_population(natp->nat_level[NAT_RLEV], x, 100));
565     }
566 }
567
568 void
569 show_sect_capab(int foo)
570 {
571     int x, first = 1, i, j;
572     char *tmpstr;
573
574     for (x = 0; dchr[x].d_name; x++) {
575         if (dchr[x].d_mnem == 0 || dchr[x].d_prd < 0)
576             continue;
577         if (first) {
578             pr("                                                 --- level ---          reso \n");
579             pr("  sector type             product use1 use2 use3 level min lag eff%% $$$ dep c\n");
580             first = 0;
581         }
582
583         j = dchr[x].d_prd;
584
585         pr("%c %-23s %-7s ",
586            dchr[x].d_mnem, dchr[x].d_name, pchr[j].p_sname);
587         (void)CANT_HAPPEN(MAXPRCON > 3); /* output has only three columns */
588         for (i = 0; i < 3; i++) {
589             if (i < MAXPRCON
590                 && pchr[j].p_camt[i]
591                 && pchr[j].p_ctype[i] > I_NONE
592                 && pchr[j].p_ctype[i] <= I_MAX) {
593                 pr("%2d %c ", pchr[j].p_camt[i],
594                    ichr[pchr[j].p_ctype[i]].i_name[0]);
595             } else {
596                 pr("     ");
597             }
598         }
599         switch (pchr[j].p_nlndx) {
600         case NAT_TLEV:
601             tmpstr = "tech";
602             break;
603         case NAT_ELEV:
604             tmpstr = "edu";
605             break;
606         case NAT_RLEV:
607             tmpstr = "res";
608             break;
609         case NAT_HLEV:
610             tmpstr = "hap";
611             break;
612         default:
613             tmpstr = " ";
614             break;
615         }
616         pr("%-5s %3d %3d %4d %3d %3d %c",
617            tmpstr,
618            pchr[j].p_nlmin,
619            pchr[j].p_nllag,
620            dchr[x].d_peffic, pchr[j].p_cost, pchr[j].p_nrdep,
621            pchr[j].p_type != I_NONE ? ichr[pchr[j].p_type].i_mnem : ' ');
622
623         pr("\n");
624     }
625 }
626
627 void
628 show_item(int tlev)
629 {
630     struct ichrstr *ip;
631
632     pr("item value sell lbs    packing     melt  item\n");
633     pr("mnem                in rg wh ur bk deno  name\n");
634
635     for (ip = ichr; ip->i_name; ip++) {
636         pr("   %c %5d %4s %3d %2d %2d %2d %2d %2d %4d  %s\n",
637            ip->i_mnem, ip->i_value, ip->i_sell ? "yes" : "no", ip->i_lbs,
638            ip->i_pkg[IPKG], ip->i_pkg[NPKG], ip->i_pkg[WPKG],
639            ip->i_pkg[UPKG], ip->i_pkg[BPKG],
640            ip->i_melt_denom, ip->i_name);
641     }
642 }
643
644 void
645 show_news(int tlev)
646 {
647     int i, j;
648     
649     pr("id category           good will\n");
650     pr("    messsages\n");
651
652     for (i = 1; i < N_MAX_VERB + 1; i++) {
653         if (rpt[i].r_newspage == N_NOTUSED)
654             continue;
655         pr("%-2d %-20.20s %4d\n", rpt[i].r_uid,
656             page_headings[rpt[i].r_newspage].name, rpt[i].r_good_will);
657         for (j = 0; j < NUM_RPTS; j++)
658             pr("    %s\n", rpt[i].r_newstory[j]);
659     }
660 }
661
662 /*
663  * Show update policy and up to N scheduled updates.
664  */
665 void
666 show_updates(int n)
667 {
668     struct gamestr *game = game_tick_tick();
669     int demand = 0;
670     int i;
671
672     pr("%s, Turn %d, ETU %d\n", fmttime2822(time(NULL)),
673        game->game_turn, game->game_tick);
674
675     if (update_time[0]) {
676         if (update_demand == UPD_DEMAND_SCHED) {
677             pr("Demand updates occur according to schedule:\n");
678             demand = 1;
679         } else
680             pr("Updates occur according to schedule:\n");
681         for (i = 0; i < n && update_time[i]; i++)
682             pr("%3d.  %s\n", game->game_turn + i,
683                fmttime2822(update_time[i]));
684         if (update_window) {
685             pr("Updates occur within %d seconds after the scheduled time\n",
686                update_window);
687         }
688     } else
689         pr("There are no updates scheduled.\n");
690
691     if (update_demand == UPD_DEMAND_ASYNC) {
692         pr("Demand updates occur right after the demand is set.\n");
693         if (*update_demandtimes != 0) {
694             pr("Demand updates are allowed during: %s\n",
695                update_demandtimes);
696         }
697         demand = 1;
698     }
699
700     if (demand) {
701         pr("Demand updates require %d country(s) to want one.\n",
702            update_wantmin);
703     }
704
705     if (updates_disabled())
706         pr("\nUPDATES ARE DISABLED!\n");
707 }
708
709 /*
710  * Return T formatted according to RFC 2822.
711  * The return value is statically allocated and overwritten on
712  * subsequent calls.
713  */
714 static char *
715 fmttime2822(time_t t)
716 {
717     static char buf[32];
718     int n = strftime(buf, sizeof(buf), "%a, %d %b %Y %T %z",
719                      localtime(&t));
720     if (CANT_HAPPEN(n == 0))
721         buf[0] = 0;
722     return buf;
723 }