2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2021, 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 * improve.c: Improve the infrastructure of a sector
29 * Known contributors to this file:
30 * Steve McClure, 1996-2000
31 * Markus Armbruster, 2004-2016
42 struct sctintrins *incp;
45 struct nstr_sect nstr;
56 p = getstarg(player->argp[1],
57 "Improve what ('road', 'rail' or 'defense')? ",
61 if (!strncmp(p, "ro", 2))
63 else if (!strncmp(p, "ra", 2))
65 else if (!strncmp(p, "de", 2)) {
70 incp = &intrchr[type];
71 if (!incp->in_enable) {
72 pr("%s improvement is disabled.\n", incp->in_name);
76 if (!snxtsct(&nstr, player->argp[2]))
80 while (nxtsct(&nstr, §)) {
84 value = sect.sct_road;
85 else if (type == INT_RAIL)
86 value = sect.sct_rail;
87 else /* type == INT_DEF */
88 value = sect.sct_defense;
89 sprintf(prompt, "Sector %s has a %s of %d%%. Improve how much? ",
90 xyas(sect.sct_x, sect.sct_y, player->cnum),
91 incp->in_name, value);
92 p = getstarg(player->argp[3], prompt, buf);
95 if (!check_sect_ok(§))
106 lim = (sect. sct_mobil - 1) * 100 / incp->in_bmobil;
108 pr("Not enough mobility in %s\n",
109 xyas(sect.sct_x, sect.sct_y, player->cnum));
115 for (i = I_NONE + 1; i <= I_MAX; i++) {
116 if (!incp->in_mat[i])
118 lim = sect.sct_item[i] * 100 / incp->in_mat[i];
120 pr("Not enough %s in %s\n",
122 xyas(sect.sct_x, sect.sct_y, player->cnum));
130 natp = getnatp(player->cnum);
131 lim = (natp->nat_money - player->dolcost) * 100 / incp->in_cost;
133 pr("Not enough money left to improve %s by %d%%\n",
134 xyas(sect.sct_x, sect.sct_y, player->cnum), maxup);
140 for (i = I_NONE + 1; i <= I_MAX; i++)
141 sect.sct_item[i] -= roundavg(maxup * incp->in_mat[i] / 100.0);
142 sect.sct_mobil -= roundavg(maxup * incp->in_bmobil / 100.0);
143 player->dolcost += maxup * incp->in_cost / 100.0;
146 if (CANT_HAPPEN(value > 100))
148 pr("Sector %s %s increased from %d%% to %d%%\n",
149 xyas(sect.sct_x, sect.sct_y, player->cnum),
150 incp->in_name, ovalue, value);
151 if (type == INT_ROAD)
152 sect.sct_road = value;
153 else if (type == INT_RAIL)
154 sect.sct_rail = value;
155 else if (type == INT_DEF)
156 sect.sct_defense = value;
162 pr("%s: No sector(s)\n", player->argp[1]);
164 pr("%s: No sector(s)\n", "");
167 pr("%d sector%s\n", nsect, splur(nsect));