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
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 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.
28 * star.c: Do a starvation report
30 * Known contributors to this file:
51 extern int etu_per_update;
52 static void starv_sects(s_char *range);
53 static void starv_ships(s_char *range);
54 static void starv_units(s_char *range);
55 static void sect_hdr(void);
56 static void ship_hdr(void);
57 static void unit_hdr(void);
62 struct nstr_sect nstr;
68 if (opt_NOFOOD) { /* no food - no work! */
69 pr("No food is required in this game\n");
74 if (!player->argp[1]) {
75 do_sects = do_ships = do_units = 1;
76 } else if (*(player->argp[1]) == 's') {
79 strcpy(range, player->argp[2]);
80 } else if (*(player->argp[1]) == 'l') {
83 strcpy(range, player->argp[2]);
85 if (!snxtsct(&nstr, player->argp[1]))
88 strcpy(range, player->argp[1]);
90 player->simulation = 1;
98 player->simulation = 0;
103 starv_sects(s_char *range)
105 struct nstr_sect nstr;
108 int vec[I_MAX + 1], s, needed;
110 if (!snxtsct(&nstr, range))
112 while (nxtsct(&nstr, §)) {
115 if (sect.sct_type == SCT_SANCT)
118 getvec(VT_ITEM, vec, (s_char *)§, EF_SECTOR);
119 /* This next 2 lines were added to overcompensate for the needy */
122 s = feed_people(vec, etu_per_update, &needed);
129 pr("%3d ", sect.sct_own);
130 prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
131 pr(" %c", dchr[sect.sct_type].d_mnem);
132 pr(" %c", (sect.sct_own != sect.sct_oldown ? '*' : ' '));
133 if (sect.sct_newtype != sect.sct_type)
134 pr("%c", dchr[sect.sct_newtype].d_mnem);
137 pr("%4d%%", sect.sct_effic);
138 pr(" will starve %d people. %d more food needed\n", s, needed);
142 pr("%s: No sector(s)\n", player->argp[1]);
144 pr("%s: No sector(s)\n", "");
147 pr("%d sector%s\n", nsect, splur(nsect));
164 starv_ships(s_char *range)
169 int vec[I_MAX + 1], s, needed;
171 if (!snxtitem(&ni, EF_SHIP, range))
174 while (nxtitem(&ni, (s_char *)&ship)) {
175 if (!player->owner || !ship.shp_own)
178 getvec(VT_ITEM, vec, (s_char *)&ship, EF_SHIP);
179 s = feed_ship(&ship, vec, etu_per_update, &needed, 0);
186 pr("%3d ", ship.shp_own);
187 pr("%5d ", ship.shp_uid);
188 pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
189 pr(" will starve %d people. %d more food needed\n", s, needed);
193 pr("%s: No ship(s)\n", range);
195 pr("%s: No ship(s)\n", "");
198 pr("%d ship%s\n", nship, splur(nship));
210 pr(" shp# ship type \n");
214 starv_units(s_char *range)
219 int vec[I_MAX + 1], s, needed;
221 if (!snxtitem(&ni, EF_LAND, range))
224 while (nxtitem(&ni, (s_char *)&land)) {
225 if (!player->owner || !land.lnd_own)
228 getvec(VT_ITEM, vec, (s_char *)&land, EF_LAND);
229 s = feed_land(&land, vec, etu_per_update, &needed, 0);
236 pr("%3d ", land.lnd_own);
237 pr("%5d ", land.lnd_uid);
238 pr("%-16.16s ", lchr[(int)land.lnd_type].l_name);
239 pr(" will starve %d mil. %d more food needed\n", s, needed);
243 pr("%s: No unit(s)\n", range);
245 pr("%s: No unit(s)\n", "");
248 pr("%d unit%s\n", nunit, splur(nunit));
260 pr(" lnd# unit type \n");