2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2009, 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 what = getstarg(player->argp[1],
58 "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 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 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 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 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 sect.sct_own = (natid)amt;
158 if (!snxtsct(&nstr, player->argp[2]))
160 while (nxtsct(&nstr, §) > 0) {
161 p = getstarg(player->argp[3], "What value : ", buf);
165 if ((amt < 0) || (amt > MAXNOC - 1))
167 pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
168 xyas(sect.sct_x, sect.sct_y, player->cnum),
169 cname(sect.sct_oldown),
170 sect.sct_oldown, cname(amt), amt);
171 sect.sct_oldown = (natid)amt;
181 if (!snxtsct(&nstr, player->argp[2]))
183 while (nxtsct(&nstr, §) > 0) {
184 p = getstarg(player->argp[3], "What value : ", buf);
188 current = sect.sct_effic;
194 pr("Efficiency in %s changed to %d.\n",
195 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
196 sect.sct_effic = current;
203 if (!snxtsct(&nstr, player->argp[2]))
205 while (nxtsct(&nstr, §) > 0) {
206 p = getstarg(player->argp[3], "What value : ", buf);
210 current = sect.sct_mines;
214 if (current > MINES_MAX)
216 if (sect.sct_own != 0)
217 resnoise(§, 1, "Mines", sect.sct_mines, current);
218 sect.sct_mines = current;
223 if (!snxtsct(&nstr, player->argp[2]))
225 while (nxtsct(&nstr, §) > 0) {
226 p = getstarg(player->argp[3], "What value : ", buf);
230 current = sect.sct_mobil;
236 pr("Mobility in %s changed to %d.\n",
237 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
238 sect.sct_mobil = current;
248 if (!snxtsct(&nstr, player->argp[2]))
250 while (nxtsct(&nstr, §) > 0) {
251 p = getstarg(player->argp[3], "What value : ", buf);
255 current = sect.sct_avail;
261 pr("Available in %s changed to %d.\n",
262 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
263 sect.sct_avail = (short)current;
268 if (!snxtsct(&nstr, player->argp[2]))
270 while (nxtsct(&nstr, §) > 0) {
271 p = getstarg(player->argp[3], "What value : ", buf);
275 current = sect.sct_work;
281 pr("Work in %s changed to %d.\n",
282 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
283 sect.sct_work = (unsigned char)current;
288 if (!snxtsct(&nstr, player->argp[2]))
290 while (nxtsct(&nstr, §) > 0) {
291 p = getstarg(player->argp[3], "What value : ", buf);
295 current = sect.sct_fertil;
301 if (sect.sct_own != 0)
302 resnoise(§, 1, "Fertility content",
303 (int)sect.sct_fertil, current);
304 sect.sct_fertil = (unsigned char)current;
309 if (!snxtsct(&nstr, player->argp[2]))
311 while (nxtsct(&nstr, §) > 0) {
312 p = getstarg(player->argp[3], "What value : ", buf);
316 current = sect.sct_uran;
322 if (sect.sct_own != 0)
323 resnoise(§, 1, "Uranium content",
324 (int)sect.sct_uran, current);
325 sect.sct_uran = (unsigned char)current;
337 resbenefit(natid who, int good)
344 nreport(player->cnum, N_AIDS, who, 1);
347 nreport(player->cnum, N_HURTS, who, 1);
352 resnoise(struct sctstr *sptr, int public_amt, char *name, int old,
357 pr("%s of %s changed from %d to %d\n",
358 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
360 (void)sprintf(p, "changed from %d to %d", old, new);
362 (void)sprintf(p, "%s", old < new ? "increased" : "decreased");
365 "%s in %s was %s by an act of %s\n",
366 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
367 p, cname(player->cnum));
368 resbenefit(sptr->sct_own, (old < new));