2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2012, 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 * setsect.c: Give resources to a country
29 * Known contributors to this file:
42 * format: setres thing <sect> <#>
51 struct nstr_sect nstr;
55 what = getstarg(player->argp[1],
56 "Give what (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
63 if (!snxtsct(&nstr, player->argp[2]))
65 while (nxtsct(&nstr, §) > 0) {
66 p = getstarg(player->argp[3], "What value : ", buf);
73 current = sect.sct_min;
79 if (sect.sct_own != 0)
80 resnoise(§, 1, "Iron ore content",
81 (int)sect.sct_min, current);
82 sect.sct_min = (unsigned char)current;
85 current = sect.sct_gmin;
91 if (sect.sct_own != 0)
92 resnoise(§, 1, "Gold content",
93 (int)sect.sct_gmin, current);
94 sect.sct_gmin = (unsigned char)current;
99 current = sect.sct_oil;
105 if (sect.sct_own != 0)
106 resnoise(§, 1, "Oil content",
107 (int)sect.sct_oil, current);
108 sect.sct_oil = (unsigned char)current;
111 if ((amt < 0) || (amt > MAXNOC - 1))
113 pr("Owner of %s changed from %s (#%d) to %s (#%d).\n",
114 xyas(sect.sct_x, sect.sct_y, player->cnum),
115 cname(sect.sct_own), sect.sct_own, cname(amt), amt);
117 wu(player->cnum, sect.sct_own,
118 "Sector %s lost to deity intervention\n",
119 xyas(sect.sct_x, sect.sct_y, sect.sct_own));
122 wu(player->cnum, amt,
123 "Sector %s gained from deity intervention\n",
124 xyas(sect.sct_x, sect.sct_y, amt));
125 sect.sct_own = (natid)amt;
128 if ((amt < 0) || (amt > MAXNOC - 1))
130 pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
131 xyas(sect.sct_x, sect.sct_y, player->cnum),
132 cname(sect.sct_oldown),
133 sect.sct_oldown, cname(amt), amt);
134 sect.sct_oldown = (natid)amt;
142 current = sect.sct_effic;
148 pr("Efficiency in %s changed to %d.\n",
149 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
150 sect.sct_effic = current;
155 current = sect.sct_mines;
159 if (current > MINES_MAX)
161 if (sect.sct_own != 0)
162 resnoise(§, 1, "Mines", sect.sct_mines, current);
163 sect.sct_mines = current;
166 current = sect.sct_mobil;
172 pr("Mobility in %s changed to %d.\n",
173 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
174 sect.sct_mobil = current;
182 current = sect.sct_avail;
188 pr("Available in %s changed to %d.\n",
189 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
190 sect.sct_avail = (short)current;
193 current = sect.sct_work;
199 pr("Work in %s changed to %d.\n",
200 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
201 sect.sct_work = (unsigned char)current;
204 current = sect.sct_fertil;
210 if (sect.sct_own != 0)
211 resnoise(§, 1, "Fertility content",
212 (int)sect.sct_fertil, current);
213 sect.sct_fertil = (unsigned char)current;
216 current = sect.sct_uran;
222 if (sect.sct_own != 0)
223 resnoise(§, 1, "Uranium content",
224 (int)sect.sct_uran, current);
225 sect.sct_uran = (unsigned char)current;
237 resbenefit(natid who, int good)
244 nreport(player->cnum, N_AIDS, who, 1);
247 nreport(player->cnum, N_HURTS, who, 1);
252 resnoise(struct sctstr *sptr, int public_amt, char *name, int old,
257 pr("%s of %s changed from %d to %d\n",
258 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
260 (void)sprintf(p, "changed from %d to %d", old, new);
262 (void)sprintf(p, "%s", old < new ? "increased" : "decreased");
265 "%s in %s was %s by an act of %s\n",
266 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
267 p, cname(player->cnum));
268 resbenefit(sptr->sct_own, (old < new));