]> git.pond.sub.org Git - empserver/blob - src/lib/commands/sinf.c
4.0.2 made land unit mobility costs differ significantly from normal
[empserver] / src / lib / commands / sinf.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2006, 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  *  sinf.c: Do an infrastructure report
29  * 
30  *  Known contributors to this file:
31  *     Steve McClure, 1996
32  */
33
34 #include <config.h>
35
36 #include "misc.h"
37 #include "player.h"
38 #include "xy.h"
39 #include "sect.h"
40 #include "nsc.h"
41 #include "nat.h"
42 #include "optlist.h"
43 #include "path.h"
44 #include "commands.h"
45 #include "combat.h"
46
47 int
48 sinfra(void)
49 {
50     struct sctstr sect;
51     int nsect;
52     struct nstr_sect nstr;
53
54     if (!snxtsct(&nstr, player->argp[1]))
55         return RET_SYN;
56     prdate();
57     nsect = 0;
58     while (nxtsct(&nstr, &sect)) {
59         if (!player->owner)
60             continue;
61         if (nsect++ == 0) {
62             if (player->god)
63                 pr("    ");
64             pr("                      road        rail       defense\n");
65             if (player->god)
66                 pr("own ");
67             pr("  sect        eff   eff mcost   eff mcost   eff  fact\n");
68         }
69         if (player->god)
70             pr("%3d ", sect.sct_own);
71         prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
72         pr(" %c", dchr[sect.sct_type].d_mnem);
73         if (sect.sct_newtype != sect.sct_type)
74             pr("%c", dchr[sect.sct_newtype].d_mnem);
75         else
76             pr(" ");
77         pr("%4d%% ", sect.sct_effic);
78         pr("%4d%% ", sect.sct_road);
79         pr("%4.3f ", sector_mcost(&sect, MOB_MOVE));
80         pr("%4d%% ", sect.sct_rail);
81         pr("%4.3f ", sector_mcost(&sect, MOB_RAIL));
82         pr("%4d%% ", SCT_DEFENSE(&sect));
83         pr("%5.2f\n", sector_strength(&sect));
84     }
85     if (nsect == 0) {
86         if (player->argp[1])
87             pr("%s: No sector(s)\n", player->argp[1]);
88         else
89             pr("%s: No sector(s)\n", "");
90         return RET_FAIL;
91     } else
92         pr("%d sector%s\n", nsect, splur(nsect));
93     return 0;
94 }