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:
45 * format: setres thing <sect> <#>
54 struct nstr_sect nstr;
58 if ((what = getstarg(player->argp[1],
59 "Give What (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
67 if (!snxtsct(&nstr, player->argp[2]))
69 while (nxtsct(&nstr, §) > 0) {
70 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
74 current = sect.sct_min;
80 if (sect.sct_own != 0)
81 resnoise(§, 1, "Iron ore content",
82 (int)sect.sct_min, current);
83 sect.sct_min = (unsigned char)current;
88 if (!snxtsct(&nstr, player->argp[2]))
90 while (nxtsct(&nstr, §) > 0) {
91 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
95 current = sect.sct_gmin;
101 if (sect.sct_own != 0)
102 resnoise(§, 1, "Gold content",
103 (int)sect.sct_gmin, current);
104 sect.sct_gmin = (unsigned char)current;
111 if (!snxtsct(&nstr, player->argp[2]))
113 while (nxtsct(&nstr, §) > 0) {
114 if (!(p = getstarg(player->argp[3], "What value : ", buf))
118 current = sect.sct_oil;
124 if (sect.sct_own != 0)
125 resnoise(§, 1, "Oil content",
126 (int)sect.sct_oil, current);
127 sect.sct_oil = (unsigned char)current;
132 if (!snxtsct(&nstr, player->argp[2]))
134 while (nxtsct(&nstr, §) > 0) {
135 if (!(p = getstarg(player->argp[3], "What value : ", buf))
139 if ((amt < 0) || (amt > MAXNOC - 1))
141 pr("Owner of %s changed from %s (#%d) to %s (#%d).\n",
142 xyas(sect.sct_x, sect.sct_y, player->cnum),
143 cname(sect.sct_own), sect.sct_own, cname(amt), amt);
145 wu(player->cnum, sect.sct_own,
146 "Sector %s lost to deity intervention\n",
147 xyas(sect.sct_x, sect.sct_y, sect.sct_own));
150 wu(player->cnum, amt,
151 "Sector %s gained from deity intervention\n",
152 xyas(sect.sct_x, sect.sct_y, amt));
153 makelost(EF_SECTOR, sect.sct_own, 0,
154 sect.sct_x, sect.sct_y);
155 makenotlost(EF_SECTOR, amt, 0, sect.sct_x, sect.sct_y);
156 sect.sct_own = (natid)amt;
161 if (!snxtsct(&nstr, player->argp[2]))
163 while (nxtsct(&nstr, §) > 0) {
164 if (!(p = getstarg(player->argp[3], "What value : ", buf))
168 if ((amt < 0) || (amt > MAXNOC - 1))
170 pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
171 xyas(sect.sct_x, sect.sct_y, player->cnum),
172 cname(sect.sct_oldown),
173 sect.sct_oldown, cname(amt), amt);
174 sect.sct_oldown = (natid)amt;
184 if (!snxtsct(&nstr, player->argp[2]))
186 while (nxtsct(&nstr, §) > 0) {
187 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
191 current = sect.sct_effic;
197 pr("Efficiency in %s changed to %d.\n",
198 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
199 sect.sct_effic = (unsigned char)current;
206 if (!snxtsct(&nstr, player->argp[2]))
208 while (nxtsct(&nstr, §) > 0) {
209 if (!(p = getstarg(player->argp[3], "What value : ", buf))
213 current = sect.sct_mines;
217 if (current > MINES_MAX)
219 if (sect.sct_own != 0)
220 resnoise(§, 1, "Mines", sect.sct_mines, current);
221 sect.sct_mines = current;
226 if (!snxtsct(&nstr, player->argp[2]))
228 while (nxtsct(&nstr, §) > 0) {
229 if (!(p = getstarg(player->argp[3], "What value : ", buf))
233 current = sect.sct_mobil;
239 pr("Mobility in %s changed to %d.\n",
240 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
241 sect.sct_mobil = (short)current;
251 if (!snxtsct(&nstr, player->argp[2]))
253 while (nxtsct(&nstr, §) > 0) {
254 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
258 current = sect.sct_avail;
264 pr("Available in %s changed to %d.\n",
265 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
266 sect.sct_avail = (short)current;
271 if (!snxtsct(&nstr, player->argp[2]))
273 while (nxtsct(&nstr, §) > 0) {
274 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
278 current = sect.sct_work;
284 pr("Work in %s changed to %d.\n",
285 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
286 sect.sct_work = (unsigned char)current;
291 if (!snxtsct(&nstr, player->argp[2]))
293 while (nxtsct(&nstr, §) > 0) {
294 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
298 current = sect.sct_fertil;
304 if (sect.sct_own != 0)
305 resnoise(§, 1, "Fertility content",
306 (int)sect.sct_fertil, current);
307 sect.sct_fertil = (unsigned char)current;
312 if (!snxtsct(&nstr, player->argp[2]))
314 while (nxtsct(&nstr, §) > 0) {
315 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
319 current = sect.sct_uran;
325 if (sect.sct_own != 0)
326 resnoise(§, 1, "Uranium content",
327 (int)sect.sct_uran, current);
328 sect.sct_uran = (unsigned char)current;
340 resbenefit(natid who, int good)
347 nreport(player->cnum, N_AIDS, who, 1);
350 nreport(player->cnum, N_HURTS, who, 1);
355 resnoise(struct sctstr *sptr, int public_amt, char *name, int old,
360 pr("%s of %s changed from %d to %d%%\n",
361 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
363 (void)sprintf(p, "changed from %d to %d", old, new);
365 (void)sprintf(p, "%s", old < new ? "increased" : "decreased");
368 "%s in %s was %s by an act of %s\n",
369 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
370 p, cname(player->cnum));
371 resbenefit(sptr->sct_own, (old < new));