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