2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, 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 the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * setsect.c: Give resources to a country
30 * Known contributors to this file:
52 * format: setres thing <sect> <#>
61 struct nstr_sect nstr;
65 if ((what = getstarg(player->argp[1],
66 "Give What (iron, gold, oil, uranium, fertility, owner, eff., Mob., Work, Avail., oldown, mines)? ",
74 if (!snxtsct(&nstr, player->argp[2]))
76 while (nxtsct(&nstr, §) > 0) {
77 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
81 current = sect.sct_min;
87 if (sect.sct_own != 0)
88 resnoise(§, 1, "Iron ore content",
89 (int)sect.sct_min, current);
90 sect.sct_min = (u_char)current;
95 if (!snxtsct(&nstr, player->argp[2]))
97 while (nxtsct(&nstr, §) > 0) {
98 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
102 current = sect.sct_gmin;
108 if (sect.sct_own != 0)
109 resnoise(§, 1, "Gold content",
110 (int)sect.sct_gmin, current);
111 sect.sct_gmin = (u_char)current;
118 if (!snxtsct(&nstr, player->argp[2]))
120 while (nxtsct(&nstr, §) > 0) {
121 if (!(p = getstarg(player->argp[3], "What value : ", buf))
125 current = sect.sct_oil;
131 if (sect.sct_own != 0)
132 resnoise(§, 1, "Oil content",
133 (int)sect.sct_oil, current);
134 sect.sct_oil = (u_char)current;
139 if (!snxtsct(&nstr, player->argp[2]))
141 while (nxtsct(&nstr, §) > 0) {
142 if (!(p = getstarg(player->argp[3], "What value : ", buf))
146 if ((amt < 0) || (amt > MAXNOC - 1))
148 pr("Owner of %s changed from %s (#%d) to %s (#%d).\n",
149 xyas(sect.sct_x, sect.sct_y, player->cnum),
150 cname(sect.sct_own), sect.sct_own, cname(amt), amt);
152 wu(player->cnum, sect.sct_own,
153 "Sector %s lost to deity intervention\n",
154 xyas(sect.sct_x, sect.sct_y, sect.sct_own));
157 wu(player->cnum, amt,
158 "Sector %s gained from deity intervention\n",
159 xyas(sect.sct_x, sect.sct_y, amt));
160 makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x,
162 makenotlost(EF_SECTOR, amt, 0, sect.sct_x, sect.sct_y);
164 sect.sct_own = (natid)amt;
169 if (!snxtsct(&nstr, player->argp[2]))
171 while (nxtsct(&nstr, §) > 0) {
172 if (!(p = getstarg(player->argp[3], "What value : ", buf))
176 if ((amt < 0) || (amt > MAXNOC - 1))
178 pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
179 xyas(sect.sct_x, sect.sct_y, player->cnum),
180 cname(sect.sct_oldown),
181 sect.sct_oldown, cname(amt), amt);
182 sect.sct_oldown = (natid)amt;
192 if (!snxtsct(&nstr, player->argp[2]))
194 while (nxtsct(&nstr, §) > 0) {
195 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
199 current = sect.sct_effic;
205 pr("Efficiency in %s changed to %d.\n",
206 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
207 sect.sct_effic = (u_char)current;
214 if (!snxtsct(&nstr, player->argp[2]))
216 while (nxtsct(&nstr, §) > 0) {
219 if (!(p = getstarg(player->argp[3], "What value : ", buf))
223 mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
228 if (sect.sct_own != 0)
229 resnoise(§, 1, "Mines", (int)mines, current);
230 putvar(V_MINE, current, (s_char *)§, EF_SECTOR);
235 if (!snxtsct(&nstr, player->argp[2]))
237 while (nxtsct(&nstr, §) > 0) {
238 if (!(p = getstarg(player->argp[3], "What value : ", buf))
242 current = sect.sct_mobil;
248 pr("Mobility in %s changed to %d.\n",
249 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
250 sect.sct_mobil = (short)current;
260 if (!snxtsct(&nstr, player->argp[2]))
262 while (nxtsct(&nstr, §) > 0) {
263 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
267 current = sect.sct_avail;
273 pr("Available in %s changed to %d.\n",
274 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
275 sect.sct_avail = (short)current;
280 if (!snxtsct(&nstr, player->argp[2]))
282 while (nxtsct(&nstr, §) > 0) {
283 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
287 current = sect.sct_work;
293 pr("Work in %s changed to %d.\n",
294 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
295 sect.sct_work = (u_char)current;
300 if (!snxtsct(&nstr, player->argp[2]))
302 while (nxtsct(&nstr, §) > 0) {
303 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
307 current = sect.sct_fertil;
313 if (sect.sct_own != 0)
314 resnoise(§, 1, "Fertility content",
315 (int)sect.sct_fertil, current);
316 sect.sct_fertil = (u_char)current;
321 if (!snxtsct(&nstr, player->argp[2]))
323 while (nxtsct(&nstr, §) > 0) {
324 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
328 current = sect.sct_uran;
334 if (sect.sct_own != 0)
335 resnoise(§, 1, "Uranium content",
336 (int)sect.sct_uran, current);
337 sect.sct_uran = (u_char)current;
349 resbenefit(natid who, int good)
356 nreport(player->cnum, N_AIDS, who, 1);
359 nreport(player->cnum, N_HURTS, who, 1);
364 resnoise(struct sctstr *sptr, int public_amt, s_char *name, int old,
369 pr("%s of %s changed from %d to %d%%\n",
370 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
372 (void)sprintf(p, "changed from %d to %d", old, new);
374 (void)sprintf(p, "%s", old < new ? "increased" : "decreased");
377 "%s in %s was %s by an act of %s\n",
378 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
379 p, cname(player->cnum));
380 resbenefit(sptr->sct_own, (old < new));