2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2004, 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:
51 * format: setres thing <sect> <#>
60 struct nstr_sect nstr;
64 if ((what = getstarg(player->argp[1],
65 "Give What (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
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),
149 cname(sect.sct_own), sect.sct_own, cname(amt), amt);
151 wu(player->cnum, sect.sct_own,
152 "Sector %s lost to deity intervention\n",
153 xyas(sect.sct_x, sect.sct_y, sect.sct_own));
156 wu(player->cnum, amt,
157 "Sector %s gained from deity intervention\n",
158 xyas(sect.sct_x, sect.sct_y, amt));
159 makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x,
161 makenotlost(EF_SECTOR, amt, 0, sect.sct_x, sect.sct_y);
163 sect.sct_own = (natid)amt;
168 if (!snxtsct(&nstr, player->argp[2]))
170 while (nxtsct(&nstr, §) > 0) {
171 if (!(p = getstarg(player->argp[3], "What value : ", buf))
175 if ((amt < 0) || (amt > MAXNOC - 1))
177 pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
178 xyas(sect.sct_x, sect.sct_y, player->cnum),
179 cname(sect.sct_oldown),
180 sect.sct_oldown, cname(amt), amt);
181 sect.sct_oldown = (natid)amt;
191 if (!snxtsct(&nstr, player->argp[2]))
193 while (nxtsct(&nstr, §) > 0) {
194 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
198 current = sect.sct_effic;
204 pr("Efficiency in %s changed to %d.\n",
205 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
206 sect.sct_effic = (u_char)current;
213 if (!snxtsct(&nstr, player->argp[2]))
215 while (nxtsct(&nstr, §) > 0) {
216 if (!(p = getstarg(player->argp[3], "What value : ", buf))
220 current = sect.sct_mines;
224 if (current > MINES_MAX)
226 if (sect.sct_own != 0)
227 resnoise(§, 1, "Mines", sect.sct_mines, current);
228 sect.sct_mines = current;
233 if (!snxtsct(&nstr, player->argp[2]))
235 while (nxtsct(&nstr, §) > 0) {
236 if (!(p = getstarg(player->argp[3], "What value : ", buf))
240 current = sect.sct_mobil;
246 pr("Mobility in %s changed to %d.\n",
247 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
248 sect.sct_mobil = (short)current;
258 if (!snxtsct(&nstr, player->argp[2]))
260 while (nxtsct(&nstr, §) > 0) {
261 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
265 current = sect.sct_avail;
271 pr("Available in %s changed to %d.\n",
272 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
273 sect.sct_avail = (short)current;
278 if (!snxtsct(&nstr, player->argp[2]))
280 while (nxtsct(&nstr, §) > 0) {
281 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
285 current = sect.sct_work;
291 pr("Work in %s changed to %d.\n",
292 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
293 sect.sct_work = (u_char)current;
298 if (!snxtsct(&nstr, player->argp[2]))
300 while (nxtsct(&nstr, §) > 0) {
301 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
305 current = sect.sct_fertil;
311 if (sect.sct_own != 0)
312 resnoise(§, 1, "Fertility content",
313 (int)sect.sct_fertil, current);
314 sect.sct_fertil = (u_char)current;
319 if (!snxtsct(&nstr, player->argp[2]))
321 while (nxtsct(&nstr, §) > 0) {
322 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
326 current = sect.sct_uran;
332 if (sect.sct_own != 0)
333 resnoise(§, 1, "Uranium content",
334 (int)sect.sct_uran, current);
335 sect.sct_uran = (u_char)current;
347 resbenefit(natid who, int good)
354 nreport(player->cnum, N_AIDS, who, 1);
357 nreport(player->cnum, N_HURTS, who, 1);
362 resnoise(struct sctstr *sptr, int public_amt, s_char *name, int old,
367 pr("%s of %s changed from %d to %d%%\n",
368 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
370 (void)sprintf(p, "changed from %d to %d", old, new);
372 (void)sprintf(p, "%s", old < new ? "increased" : "decreased");
375 "%s in %s was %s by an act of %s\n",
376 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
377 p, cname(player->cnum));
378 resbenefit(sptr->sct_own, (old < new));