]> git.pond.sub.org Git - empserver/blob - src/lib/commands/cuto.c
32b2f04ab97490586940b2825b819fbb577367e8
[empserver] / src / lib / commands / cuto.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2020, 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  *  cuto.c: Do a delivery cutoff level report
28  *
29  *  Known contributors to this file:
30  *     David Muir Sharnoff, 1987
31  */
32
33 #include <config.h>
34
35 #include "commands.h"
36 #include "path.h"
37
38 int
39 cuto(void)
40 {
41     struct sctstr sect;
42     int nsect;
43     int n;
44     struct nstr_sect nstr;
45     char dirstr[12];
46
47     if (!snxtsct(&nstr, player->argp[1]))
48         return RET_SYN;
49     prdate();
50     (void)strcpy(dirstr, ".      $");
51     for (n = 1; n <= 6; n++)
52         dirstr[n] = dirch[n];
53     nsect = 0;
54     while (nxtsct(&nstr, &sect)) {
55         if (!player->owner)
56             continue;
57         if (nsect++ == 0) {
58             pr("DELIVERY CUTOFF LEVELS\n");
59             if (player->god)
60                 pr("own");
61             pr("   sect   cmufsgpidbolhr civ mil  uw food sh gun pet irn dst bar oil lcm hcm rad\n");
62         }
63         if (player->god)
64             pr("%3d", sect.sct_own);
65         prxy("%3d,%-3d", nstr.x, nstr.y); /* FIXME too narrow */
66         pr(" %c ", dchr[sect.sct_type].d_mnem);
67         pr("%c", dirstr[sect.sct_del[I_CIVIL] & 0x7]);
68         pr("%c", dirstr[sect.sct_del[I_MILIT] & 0x7]);
69         pr("%c", dirstr[sect.sct_del[I_UW] & 0x7]);
70         pr("%c", dirstr[sect.sct_del[I_FOOD] & 0x7]);
71         pr("%c", dirstr[sect.sct_del[I_SHELL] & 0x7]);
72         pr("%c", dirstr[sect.sct_del[I_GUN] & 0x7]);
73         pr("%c", dirstr[sect.sct_del[I_PETROL] & 0x7]);
74         pr("%c", dirstr[sect.sct_del[I_IRON] & 0x7]);
75         pr("%c", dirstr[sect.sct_del[I_DUST] & 0x7]);
76         pr("%c", dirstr[sect.sct_del[I_BAR] & 0x7]);
77         pr("%c", dirstr[sect.sct_del[I_OIL] & 0x7]);
78         pr("%c", dirstr[sect.sct_del[I_LCM] & 0x7]);
79         pr("%c", dirstr[sect.sct_del[I_HCM] & 0x7]);
80         pr("%c", dirstr[sect.sct_del[I_RAD] & 0x7]);
81         pr("%4d", sect.sct_del[I_CIVIL] & ~0x7);
82         pr("%4d", sect.sct_del[I_MILIT] & ~0x7);
83         pr("%4d", sect.sct_del[I_UW] & ~0x7);
84         pr("%4d", sect.sct_del[I_FOOD] & ~0x7);
85         pr("%4d", sect.sct_del[I_SHELL] & ~0x7);
86         pr("%4d", sect.sct_del[I_GUN] & ~0x7);
87         pr("%4d", sect.sct_del[I_PETROL] & ~0x7);
88         pr("%4d", sect.sct_del[I_IRON] & ~0x7);
89         pr("%4d", sect.sct_del[I_DUST] & ~0x7);
90         pr("%4d", sect.sct_del[I_BAR] & ~0x7);
91         pr("%4d", sect.sct_del[I_OIL] & ~0x7);
92         pr("%4d", sect.sct_del[I_LCM] & ~0x7);
93         pr("%4d", sect.sct_del[I_HCM] & ~0x7);
94         pr("%4d", sect.sct_del[I_RAD] & ~0x7);
95         pr("\n");
96     }
97     if (nsect == 0) {
98         if (player->argp[1])
99             pr("%s: No sector(s)\n", player->argp[1]);
100         else
101             pr("%s: No sector(s)\n", "");
102         return RET_FAIL;
103     } else
104         pr("%d sector%s\n", nsect, splur(nsect));
105     return RET_OK;
106 }