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