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:
44 static void starv_sects(char *range);
45 static void starv_ships(char *range);
46 static void starv_units(char *range);
47 static void sect_hdr(void);
48 static void ship_hdr(void);
49 static void unit_hdr(void);
59 if (opt_NOFOOD) { /* no food - no work! */
60 pr("No food is required in this game\n");
65 if (!player->argp[1]) {
66 do_sects = do_ships = do_units = 1;
67 } else if (*(player->argp[1]) == 's') {
70 range = player->argp[2];
71 } else if (*(player->argp[1]) == 'l') {
74 range = player->argp[2];
77 range = player->argp[1];
79 player->simulation = 1;
87 player->simulation = 0;
92 starv_people(short *vec, int victims)
94 pr(" will starve %d people. %.0f more food needed\n", victims,
95 ceil(food_needed(vec, etu_per_update) - vec[I_FOOD]));
99 starv_sects(char *range)
101 struct nstr_sect nstr;
106 if (!snxtsct(&nstr, range))
108 while (nxtsct(&nstr, §)) {
111 if (sect.sct_type == SCT_SANCT)
115 * Check for starvation. Suppress complaints about tiny
116 * population without food by adding 1f just for the check.
117 * That's okay because growfood() will grow at least that much
120 save = sect.sct_item[I_FOOD];
121 if (sect.sct_item[I_FOOD] == 0)
122 sect.sct_item[I_FOOD] = 1;
123 s = famine_victims(sect.sct_item, etu_per_update);
124 sect.sct_item[I_FOOD] = save;
131 pr("%3d ", sect.sct_own);
132 prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
133 pr(" %c", dchr[sect.sct_type].d_mnem);
134 pr(" %c", sect.sct_own != sect.sct_oldown ? '*' : ' ');
135 if (sect.sct_newtype != sect.sct_type)
136 pr("%c", dchr[sect.sct_newtype].d_mnem);
139 pr("%4d%%", sect.sct_effic);
140 starv_people(sect.sct_item, s);
144 pr("%s: No sector(s)\n", player->argp[1]);
146 pr("%s: No sector(s)\n", "");
149 pr("%d sector%s\n", nsect, splur(nsect));
166 starv_ships(char *range)
173 if (!snxtitem(&ni, EF_SHIP, range))
176 while (nxtitem(&ni, &ship)) {
177 if (!player->owner || !ship.shp_own)
180 s = famine_victims(ship.shp_item, etu_per_update);
186 pr("%3d ", ship.shp_own);
187 pr("%5d ", ship.shp_uid);
188 pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
189 starv_people(ship.shp_item, s);
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(char *range)
221 if (!snxtitem(&ni, EF_LAND, range))
224 while (nxtitem(&ni, &land)) {
225 if (!player->owner || !land.lnd_own)
228 s = famine_victims(land.lnd_item, etu_per_update);
234 pr("%3d ", land.lnd_own);
235 pr("%5d ", land.lnd_uid);
236 pr("%-16.16s ", lchr[(int)land.lnd_type].l_name);
237 starv_people(land.lnd_item, s);
241 pr("%s: No unit(s)\n", range);
243 pr("%s: No unit(s)\n", "");
246 pr("%d unit%s\n", nunit, splur(nunit));
258 pr(" lnd# unit type \n");