2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2006, 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:
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) {
217 if (!(p = getstarg(player->argp[3], "What value : ", buf))
221 current = sect.sct_mines;
225 if (current > MINES_MAX)
227 if (sect.sct_own != 0)
228 resnoise(§, 1, "Mines", sect.sct_mines, current);
229 sect.sct_mines = current;
234 if (!snxtsct(&nstr, player->argp[2]))
236 while (nxtsct(&nstr, §) > 0) {
237 if (!(p = getstarg(player->argp[3], "What value : ", buf))
241 current = sect.sct_mobil;
247 pr("Mobility in %s changed to %d.\n",
248 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
249 sect.sct_mobil = (short)current;
259 if (!snxtsct(&nstr, player->argp[2]))
261 while (nxtsct(&nstr, §) > 0) {
262 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
266 current = sect.sct_avail;
272 pr("Available in %s changed to %d.\n",
273 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
274 sect.sct_avail = (short)current;
279 if (!snxtsct(&nstr, player->argp[2]))
281 while (nxtsct(&nstr, §) > 0) {
282 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
286 current = sect.sct_work;
292 pr("Work in %s changed to %d.\n",
293 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
294 sect.sct_work = (u_char)current;
299 if (!snxtsct(&nstr, player->argp[2]))
301 while (nxtsct(&nstr, §) > 0) {
302 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
306 current = sect.sct_fertil;
312 if (sect.sct_own != 0)
313 resnoise(§, 1, "Fertility content",
314 (int)sect.sct_fertil, current);
315 sect.sct_fertil = (u_char)current;
320 if (!snxtsct(&nstr, player->argp[2]))
322 while (nxtsct(&nstr, §) > 0) {
323 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
327 current = sect.sct_uran;
333 if (sect.sct_own != 0)
334 resnoise(§, 1, "Uranium content",
335 (int)sect.sct_uran, current);
336 sect.sct_uran = (u_char)current;
348 resbenefit(natid who, int good)
355 nreport(player->cnum, N_AIDS, who, 1);
358 nreport(player->cnum, N_HURTS, who, 1);
363 resnoise(struct sctstr *sptr, int public_amt, s_char *name, int old,
368 pr("%s of %s changed from %d to %d%%\n",
369 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
371 (void)sprintf(p, "changed from %d to %d", old, new);
373 (void)sprintf(p, "%s", old < new ? "increased" : "decreased");
376 "%s in %s was %s by an act of %s\n",
377 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
378 p, cname(player->cnum));
379 resbenefit(sptr->sct_own, (old < new));