2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2008, 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 * setsect.c: Give resources to a country
30 * Known contributors to this file:
44 * format: setres thing <sect> <#>
53 struct nstr_sect nstr;
57 if ((what = getstarg(player->argp[1],
58 "Give What (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
66 if (!snxtsct(&nstr, player->argp[2]))
68 while (nxtsct(&nstr, §) > 0) {
69 if (!(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;
87 if (!snxtsct(&nstr, player->argp[2]))
89 while (nxtsct(&nstr, §) > 0) {
90 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
94 current = sect.sct_gmin;
100 if (sect.sct_own != 0)
101 resnoise(§, 1, "Gold content",
102 (int)sect.sct_gmin, current);
103 sect.sct_gmin = (unsigned char)current;
110 if (!snxtsct(&nstr, player->argp[2]))
112 while (nxtsct(&nstr, §) > 0) {
113 if (!(p = getstarg(player->argp[3], "What value : ", buf))
117 current = sect.sct_oil;
123 if (sect.sct_own != 0)
124 resnoise(§, 1, "Oil content",
125 (int)sect.sct_oil, current);
126 sect.sct_oil = (unsigned char)current;
131 if (!snxtsct(&nstr, player->argp[2]))
133 while (nxtsct(&nstr, §) > 0) {
134 if (!(p = getstarg(player->argp[3], "What value : ", buf))
138 if ((amt < 0) || (amt > MAXNOC - 1))
140 pr("Owner of %s changed from %s (#%d) to %s (#%d).\n",
141 xyas(sect.sct_x, sect.sct_y, player->cnum),
142 cname(sect.sct_own), sect.sct_own, cname(amt), amt);
144 wu(player->cnum, sect.sct_own,
145 "Sector %s lost to deity intervention\n",
146 xyas(sect.sct_x, sect.sct_y, sect.sct_own));
149 wu(player->cnum, amt,
150 "Sector %s gained from deity intervention\n",
151 xyas(sect.sct_x, sect.sct_y, amt));
152 sect.sct_own = (natid)amt;
157 if (!snxtsct(&nstr, player->argp[2]))
159 while (nxtsct(&nstr, §) > 0) {
160 if (!(p = getstarg(player->argp[3], "What value : ", buf))
164 if ((amt < 0) || (amt > MAXNOC - 1))
166 pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
167 xyas(sect.sct_x, sect.sct_y, player->cnum),
168 cname(sect.sct_oldown),
169 sect.sct_oldown, cname(amt), amt);
170 sect.sct_oldown = (natid)amt;
180 if (!snxtsct(&nstr, player->argp[2]))
182 while (nxtsct(&nstr, §) > 0) {
183 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
187 current = sect.sct_effic;
193 pr("Efficiency in %s changed to %d.\n",
194 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
195 sect.sct_effic = (unsigned char)current;
202 if (!snxtsct(&nstr, player->argp[2]))
204 while (nxtsct(&nstr, §) > 0) {
205 if (!(p = getstarg(player->argp[3], "What value : ", buf))
209 current = sect.sct_mines;
213 if (current > MINES_MAX)
215 if (sect.sct_own != 0)
216 resnoise(§, 1, "Mines", sect.sct_mines, current);
217 sect.sct_mines = current;
222 if (!snxtsct(&nstr, player->argp[2]))
224 while (nxtsct(&nstr, §) > 0) {
225 if (!(p = getstarg(player->argp[3], "What value : ", buf))
229 current = sect.sct_mobil;
235 pr("Mobility in %s changed to %d.\n",
236 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
237 sect.sct_mobil = (short)current;
247 if (!snxtsct(&nstr, player->argp[2]))
249 while (nxtsct(&nstr, §) > 0) {
250 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
254 current = sect.sct_avail;
260 pr("Available in %s changed to %d.\n",
261 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
262 sect.sct_avail = (short)current;
267 if (!snxtsct(&nstr, player->argp[2]))
269 while (nxtsct(&nstr, §) > 0) {
270 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
274 current = sect.sct_work;
280 pr("Work in %s changed to %d.\n",
281 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
282 sect.sct_work = (unsigned char)current;
287 if (!snxtsct(&nstr, player->argp[2]))
289 while (nxtsct(&nstr, §) > 0) {
290 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
294 current = sect.sct_fertil;
300 if (sect.sct_own != 0)
301 resnoise(§, 1, "Fertility content",
302 (int)sect.sct_fertil, current);
303 sect.sct_fertil = (unsigned char)current;
308 if (!snxtsct(&nstr, player->argp[2]))
310 while (nxtsct(&nstr, §) > 0) {
311 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
315 current = sect.sct_uran;
321 if (sect.sct_own != 0)
322 resnoise(§, 1, "Uranium content",
323 (int)sect.sct_uran, current);
324 sect.sct_uran = (unsigned char)current;
336 resbenefit(natid who, int good)
343 nreport(player->cnum, N_AIDS, who, 1);
346 nreport(player->cnum, N_HURTS, who, 1);
351 resnoise(struct sctstr *sptr, int public_amt, char *name, int old,
356 pr("%s of %s changed from %d to %d\n",
357 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
359 (void)sprintf(p, "changed from %d to %d", old, new);
361 (void)sprintf(p, "%s", old < new ? "increased" : "decreased");
364 "%s in %s was %s by an act of %s\n",
365 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
366 p, cname(player->cnum));
367 resbenefit(sptr->sct_own, (old < new));