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)? ", buf)) == 0)
73 if (!snxtsct(&nstr, player->argp[2]))
75 while (nxtsct(&nstr,§) > 0) {
76 if( !(p = getstarg(player->argp[3], "What value : ", buf)) ||
80 current = sect.sct_min;
86 if (sect.sct_own != 0)
87 resnoise(§,1,"Iron ore content",
88 (int) sect.sct_min, current);
89 sect.sct_min = (u_char) current;
94 if (!snxtsct(&nstr, player->argp[2]))
96 while (nxtsct(&nstr,§) > 0) {
97 if( !(p = getstarg(player->argp[3], "What value : ", buf)) ||
101 current = sect.sct_gmin;
107 if (sect.sct_own != 0)
108 resnoise(§,1,"Gold content",
109 (int) sect.sct_gmin, current);
110 sect.sct_gmin = (u_char) current;
117 if (!snxtsct(&nstr, player->argp[2]))
119 while (nxtsct(&nstr,§) > 0) {
120 if( !(p = getstarg(player->argp[3], "What value : ", buf)) ||
124 current = sect.sct_oil;
130 if (sect.sct_own != 0)
131 resnoise(§,1,"Oil content",
132 (int) sect.sct_oil, current);
133 sect.sct_oil = (u_char) current;
138 if (!snxtsct(&nstr, player->argp[2]))
140 while (nxtsct(&nstr,§) > 0) {
141 if( !(p = getstarg(player->argp[3], "What value : ", buf)) ||
145 if ((amt < 0) || (amt > MAXNOC-1))
147 pr("Owner of %s changed from %s (#%d) to %s (#%d).\n",
148 xyas(sect.sct_x, sect.sct_y, player->cnum),
150 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,
158 wu(player->cnum, amt,
159 "Sector %s gained from deity intervention\n",
160 xyas(sect.sct_x, sect.sct_y,
162 makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x, sect.sct_y);
163 makenotlost(EF_SECTOR, amt, 0, sect.sct_x, sect.sct_y);
165 sect.sct_own = (natid) amt;
170 if (!snxtsct(&nstr, player->argp[2]))
172 while (nxtsct(&nstr,§) > 0) {
173 if( !(p = getstarg(player->argp[3], "What value : ", buf)) ||
177 if ((amt < 0) || (amt > MAXNOC-1))
179 pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
180 xyas(sect.sct_x, sect.sct_y, player->cnum),
181 cname(sect.sct_oldown),
182 sect.sct_oldown, cname(amt), amt);
183 sect.sct_oldown = (natid) amt;
193 if (!snxtsct(&nstr, player->argp[2]))
195 while (nxtsct(&nstr,§) > 0) {
196 if( !(p = getstarg(player->argp[3], "What value : ", buf)) ||
200 current = sect.sct_effic;
206 pr("Efficiency in %s changed to %d.\n",
207 xyas(sect.sct_x, sect.sct_y, player->cnum),
209 sect.sct_effic = (u_char) current;
216 if (!snxtsct(&nstr, player->argp[2]))
218 while (nxtsct(&nstr,§) > 0) {
221 if(!(p = getstarg(player->argp[3], "What value : ", buf)) ||
225 mines=getvar(V_MINE, (s_char *)§,EF_SECTOR);
230 if (sect.sct_own != 0)
231 resnoise(§,1,"Mines",
232 (int) mines, current);
233 putvar(V_MINE,current,(s_char *)§,
239 if (!snxtsct(&nstr, player->argp[2]))
241 while (nxtsct(&nstr,§) > 0) {
242 if(!(p = getstarg(player->argp[3],"What value : ",buf)) ||
246 current = sect.sct_mobil;
252 pr("Mobility in %s changed to %d.\n",
253 xyas(sect.sct_x, sect.sct_y, player->cnum),
255 sect.sct_mobil = (short) current;
265 if (!snxtsct(&nstr, player->argp[2]))
267 while (nxtsct(&nstr,§) > 0) {
268 if( !(p = getstarg(player->argp[3], "What value : ", buf)) ||
272 current = sect.sct_avail;
278 pr("Available in %s changed to %d.\n",
279 xyas(sect.sct_x, sect.sct_y, player->cnum),
281 sect.sct_avail = (short) current;
286 if (!snxtsct(&nstr, player->argp[2]))
288 while (nxtsct(&nstr,§) > 0) {
289 if( !(p = getstarg(player->argp[3], "What value : ", buf)) ||
293 current = sect.sct_work;
299 pr("Work in %s changed to %d.\n",
300 xyas(sect.sct_x, sect.sct_y, player->cnum),
302 sect.sct_work = (u_char) current;
307 if (!snxtsct(&nstr, player->argp[2]))
309 while (nxtsct(&nstr,§) > 0) {
310 if( !(p = getstarg(player->argp[3], "What value : ", buf)) ||
314 current = sect.sct_fertil;
320 if (sect.sct_own != 0)
321 resnoise(§,1,"Fertility content",
322 (int) sect.sct_fertil, current);
323 sect.sct_fertil = (u_char) current;
328 if (!snxtsct(&nstr, player->argp[2]))
330 while (nxtsct(&nstr,§) > 0) {
331 if( !(p = getstarg(player->argp[3], "What value : ", buf)) ||
335 current = sect.sct_uran;
341 if (sect.sct_own != 0)
342 resnoise(§,1,"Uranium content",
343 (int) sect.sct_uran, current);
344 sect.sct_uran = (u_char) current;
356 resbenefit(natid who, int good)
363 nreport(player->cnum, N_AIDS, who, 1);
366 nreport(player->cnum, N_HURTS, who, 1);
371 resnoise(struct sctstr *sptr, int public_amt, s_char *name, int old, int new)
375 pr("%s of %s changed from %d to %d%%\n",
376 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
378 (void) sprintf(p, "changed from %d to %d", old, new);
380 (void) sprintf(p, "%s", old<new ? "increased":"decreased");
383 "%s in %s was %s by an act of %s\n",
384 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
385 p, cname(player->cnum));
386 resbenefit(sptr->sct_own, (old < new));