]> git.pond.sub.org Git - empserver/blob - src/lib/commands/reso.c
Do not include var.h where no longer needed. Clean up register keywords in these...
[empserver] / src / lib / commands / reso.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2004, 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  *  reso.c: Display natural resources
29  * 
30  *  Known contributors to this file:
31  *     Dave Pare, 1989
32  */
33
34 #include "misc.h"
35 #include "player.h"
36 #include "xy.h"
37 #include "sect.h"
38 #include "nsc.h"
39 #include "nat.h"
40 #include "path.h"
41 #include "file.h"
42 #include "commands.h"
43
44 static void reso_hdr(void);
45
46 int
47 reso(void)
48 {
49     struct sctstr sect;
50     int nsect;
51     struct nstr_sect nstr;
52
53     if (!snxtsct(&nstr, player->argp[1]))
54         return RET_SYN;
55     prdate();
56     nsect = 0;
57     while (nxtsct(&nstr, &sect)) {
58         if (!player->owner)
59             continue;
60         if (nsect++ == 0)
61             reso_hdr();
62         if (player->god)
63             pr("%3d ", sect.sct_own);
64         prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
65         pr(" %c", dchr[sect.sct_type].d_mnem);
66         if (sect.sct_newtype != sect.sct_type)
67             pr("%c", dchr[sect.sct_newtype].d_mnem);
68         else
69             pr(" ");
70         pr("%4d%%", sect.sct_effic);
71         pr(" %4d", sect.sct_min);
72         pr("%5d", sect.sct_gmin);
73         pr("%5d", sect.sct_fertil);
74         pr("%4d", sect.sct_oil);
75         pr("%5d", sect.sct_uran);
76 /*              pr("%5d", sect.sct_elev);*/
77         if (!player->god && sect.sct_terr)
78             pr("%4d", sect.sct_terr);
79         pr("\n");
80     }
81     if (nsect == 0) {
82         if (player->argp[1])
83             pr("%s: No sector(s)\n", player->argp[1]);
84         else
85             pr("%s: No sector(s)\n", "");
86         return RET_FAIL;
87     } else
88         pr("%d sector%s\n", nsect, splur(nsect));
89     return 0;
90 }
91
92 static void
93 reso_hdr(void)
94 {
95     if (player->god)
96         pr("    ");
97     pr("RESOURCE\n");
98     if (player->god)
99         pr("own ");
100     pr("  sect        eff  min gold fert oil uran ");
101     if (!player->god)
102         pr("ter");
103     pr("\n");
104 }