2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2015, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire 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 3 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, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * star.c: Do a starvation report
29 * Known contributors to this file:
42 static void starv_sects(char *range);
43 static void starv_ships(char *range);
44 static void starv_units(char *range);
45 static void sect_hdr(void);
46 static void ship_hdr(void);
47 static void unit_hdr(void);
57 if (opt_NOFOOD) { /* no food - no work! */
58 pr("No food is required in this game\n");
63 if (!player->argp[1]) {
64 do_sects = do_ships = do_units = 1;
65 } else if (*(player->argp[1]) == 's') {
68 range = player->argp[2];
69 } else if (*(player->argp[1]) == 'l') {
72 range = player->argp[2];
75 range = player->argp[1];
77 player->simulation = 1;
85 player->simulation = 0;
90 starv_people(short *vec, int victims)
92 pr(" will starve %d people. %.0f more food needed\n", victims,
93 ceil(food_needed(vec, etu_per_update) - vec[I_FOOD]));
97 starv_sects(char *range)
99 struct nstr_sect nstr;
104 if (!snxtsct(&nstr, range))
106 while (nxtsct(&nstr, §)) {
109 if (sect.sct_type == SCT_SANCT)
113 * Check for starvation. Suppress complaints about tiny
114 * population without food by adding 1f just for the check.
115 * That's okay because growfood() will grow at least that much
118 save = sect.sct_item[I_FOOD];
119 if (sect.sct_item[I_FOOD] == 0)
120 sect.sct_item[I_FOOD] = 1;
121 s = famine_victims(sect.sct_item, etu_per_update);
122 sect.sct_item[I_FOOD] = save;
129 pr("%3d ", sect.sct_own);
130 prxy("%4d,%-4d", nstr.x, nstr.y);
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 starv_people(sect.sct_item, s);
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(char *range)
171 if (!snxtitem(&ni, EF_SHIP, range, NULL))
174 while (nxtitem(&ni, &ship)) {
175 if (!player->owner || !ship.shp_own)
178 s = famine_victims(ship.shp_item, etu_per_update);
184 pr("%3d ", ship.shp_own);
185 pr("%5d ", ship.shp_uid);
186 pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
187 starv_people(ship.shp_item, s);
191 pr("%s: No ship(s)\n", range);
193 pr("%s: No ship(s)\n", "");
196 pr("%d ship%s\n", nship, splur(nship));
208 pr(" shp# ship type\n");
212 starv_units(char *range)
219 if (!snxtitem(&ni, EF_LAND, range, NULL))
222 while (nxtitem(&ni, &land)) {
223 if (!player->owner || !land.lnd_own)
226 s = famine_victims(land.lnd_item, etu_per_update);
232 pr("%3d ", land.lnd_own);
233 pr("%5d ", land.lnd_uid);
234 pr("%-16.16s ", lchr[(int)land.lnd_type].l_name);
235 starv_people(land.lnd_item, s);
239 pr("%s: No unit(s)\n", range);
241 pr("%s: No unit(s)\n", "");
244 pr("%d unit%s\n", nunit, splur(nunit));
256 pr(" lnd# unit type\n");