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
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.
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.
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
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.
28 * star.c: Do a starvation report
30 * Known contributors to this file:
50 static void starv_sects(char *range);
51 static void starv_ships(char *range);
52 static void starv_units(char *range);
53 static void sect_hdr(void);
54 static void ship_hdr(void);
55 static void unit_hdr(void);
65 if (opt_NOFOOD) { /* no food - no work! */
66 pr("No food is required in this game\n");
71 if (!player->argp[1]) {
72 do_sects = do_ships = do_units = 1;
73 } else if (*(player->argp[1]) == 's') {
76 range = player->argp[2];
77 } else if (*(player->argp[1]) == 'l') {
80 range = player->argp[2];
83 range = player->argp[1];
85 player->simulation = 1;
93 player->simulation = 0;
98 starv_sects(char *range)
100 struct nstr_sect nstr;
105 if (!snxtsct(&nstr, range))
107 while (nxtsct(&nstr, §)) {
110 if (sect.sct_type == SCT_SANCT)
113 /* This next 2 lines were added to overcompensate for the needy */
114 if (sect.sct_item[I_FOOD])
115 sect.sct_item[I_FOOD]--;
116 s = feed_people(sect.sct_item, etu_per_update, &needed);
123 pr("%3d ", sect.sct_own);
124 prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
125 pr(" %c", dchr[sect.sct_type].d_mnem);
126 pr(" %c", sect.sct_own != sect.sct_oldown ? '*' : ' ');
127 if (sect.sct_newtype != sect.sct_type)
128 pr("%c", dchr[sect.sct_newtype].d_mnem);
131 pr("%4d%%", sect.sct_effic);
132 pr(" will starve %d people. %d more food needed\n", s, needed);
136 pr("%s: No sector(s)\n", player->argp[1]);
138 pr("%s: No sector(s)\n", "");
141 pr("%d sector%s\n", nsect, splur(nsect));
158 starv_ships(char *range)
165 if (!snxtitem(&ni, EF_SHIP, range))
168 while (nxtitem(&ni, &ship)) {
169 if (!player->owner || !ship.shp_own)
172 s = feed_ship(&ship, etu_per_update, &needed, 0);
178 pr("%3d ", ship.shp_own);
179 pr("%5d ", ship.shp_uid);
180 pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
181 pr(" will starve %d people. %d more food needed\n", s, needed);
185 pr("%s: No ship(s)\n", range);
187 pr("%s: No ship(s)\n", "");
190 pr("%d ship%s\n", nship, splur(nship));
202 pr(" shp# ship type \n");
206 starv_units(char *range)
213 if (!snxtitem(&ni, EF_LAND, range))
216 while (nxtitem(&ni, &land)) {
217 if (!player->owner || !land.lnd_own)
220 s = feed_land(&land, etu_per_update, &needed, 0);
226 pr("%3d ", land.lnd_own);
227 pr("%5d ", land.lnd_uid);
228 pr("%-16.16s ", lchr[(int)land.lnd_type].l_name);
229 pr(" will starve %d mil. %d more food needed\n", s, needed);
233 pr("%s: No unit(s)\n", range);
235 pr("%s: No unit(s)\n", "");
238 pr("%d unit%s\n", nunit, splur(nunit));
250 pr(" lnd# unit type \n");