2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2007, 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 if ((what = getstarg(player->argp[1],
58 "Give What (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
66 if (!snxtsct(&nstr, player->argp[2]))
68 while (nxtsct(&nstr, §) > 0) {
69 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
73 current = sect.sct_min;
79 if (sect.sct_own != 0)
80 resnoise(§, 1, "Iron ore content",
81 (int)sect.sct_min, current);
82 sect.sct_min = (unsigned char)current;
87 if (!snxtsct(&nstr, player->argp[2]))
89 while (nxtsct(&nstr, §) > 0) {
90 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
94 current = sect.sct_gmin;
100 if (sect.sct_own != 0)
101 resnoise(§, 1, "Gold content",
102 (int)sect.sct_gmin, current);
103 sect.sct_gmin = (unsigned char)current;
110 if (!snxtsct(&nstr, player->argp[2]))
112 while (nxtsct(&nstr, §) > 0) {
113 if (!(p = getstarg(player->argp[3], "What value : ", buf))
117 current = sect.sct_oil;
123 if (sect.sct_own != 0)
124 resnoise(§, 1, "Oil content",
125 (int)sect.sct_oil, current);
126 sect.sct_oil = (unsigned char)current;
131 if (!snxtsct(&nstr, player->argp[2]))
133 while (nxtsct(&nstr, §) > 0) {
134 if (!(p = getstarg(player->argp[3], "What value : ", buf))
138 if ((amt < 0) || (amt > MAXNOC - 1))
140 pr("Owner of %s changed from %s (#%d) to %s (#%d).\n",
141 xyas(sect.sct_x, sect.sct_y, player->cnum),
142 cname(sect.sct_own), sect.sct_own, cname(amt), amt);
144 wu(player->cnum, sect.sct_own,
145 "Sector %s lost to deity intervention\n",
146 xyas(sect.sct_x, sect.sct_y, sect.sct_own));
149 wu(player->cnum, amt,
150 "Sector %s gained from deity intervention\n",
151 xyas(sect.sct_x, sect.sct_y, amt));
152 makelost(EF_SECTOR, sect.sct_own, 0,
153 sect.sct_x, sect.sct_y);
154 makenotlost(EF_SECTOR, amt, 0, sect.sct_x, sect.sct_y);
155 sect.sct_own = (natid)amt;
160 if (!snxtsct(&nstr, player->argp[2]))
162 while (nxtsct(&nstr, §) > 0) {
163 if (!(p = getstarg(player->argp[3], "What value : ", buf))
167 if ((amt < 0) || (amt > MAXNOC - 1))
169 pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
170 xyas(sect.sct_x, sect.sct_y, player->cnum),
171 cname(sect.sct_oldown),
172 sect.sct_oldown, cname(amt), amt);
173 sect.sct_oldown = (natid)amt;
183 if (!snxtsct(&nstr, player->argp[2]))
185 while (nxtsct(&nstr, §) > 0) {
186 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
190 current = sect.sct_effic;
196 pr("Efficiency in %s changed to %d.\n",
197 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
198 sect.sct_effic = (unsigned char)current;
205 if (!snxtsct(&nstr, player->argp[2]))
207 while (nxtsct(&nstr, §) > 0) {
208 if (!(p = getstarg(player->argp[3], "What value : ", buf))
212 current = sect.sct_mines;
216 if (current > MINES_MAX)
218 if (sect.sct_own != 0)
219 resnoise(§, 1, "Mines", sect.sct_mines, current);
220 sect.sct_mines = current;
225 if (!snxtsct(&nstr, player->argp[2]))
227 while (nxtsct(&nstr, §) > 0) {
228 if (!(p = getstarg(player->argp[3], "What value : ", buf))
232 current = sect.sct_mobil;
238 pr("Mobility in %s changed to %d.\n",
239 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
240 sect.sct_mobil = (short)current;
250 if (!snxtsct(&nstr, player->argp[2]))
252 while (nxtsct(&nstr, §) > 0) {
253 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
257 current = sect.sct_avail;
263 pr("Available in %s changed to %d.\n",
264 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
265 sect.sct_avail = (short)current;
270 if (!snxtsct(&nstr, player->argp[2]))
272 while (nxtsct(&nstr, §) > 0) {
273 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
277 current = sect.sct_work;
283 pr("Work in %s changed to %d.\n",
284 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
285 sect.sct_work = (unsigned char)current;
290 if (!snxtsct(&nstr, player->argp[2]))
292 while (nxtsct(&nstr, §) > 0) {
293 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
297 current = sect.sct_fertil;
303 if (sect.sct_own != 0)
304 resnoise(§, 1, "Fertility content",
305 (int)sect.sct_fertil, current);
306 sect.sct_fertil = (unsigned char)current;
311 if (!snxtsct(&nstr, player->argp[2]))
313 while (nxtsct(&nstr, §) > 0) {
314 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
318 current = sect.sct_uran;
324 if (sect.sct_own != 0)
325 resnoise(§, 1, "Uranium content",
326 (int)sect.sct_uran, current);
327 sect.sct_uran = (unsigned char)current;
339 resbenefit(natid who, int good)
346 nreport(player->cnum, N_AIDS, who, 1);
349 nreport(player->cnum, N_HURTS, who, 1);
354 resnoise(struct sctstr *sptr, int public_amt, char *name, int old,
359 pr("%s of %s changed from %d to %d\n",
360 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
362 (void)sprintf(p, "changed from %d to %d", old, new);
364 (void)sprintf(p, "%s", old < new ? "increased" : "decreased");
367 "%s in %s was %s by an act of %s\n",
368 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
369 p, cname(player->cnum));
370 resbenefit(sptr->sct_own, (old < new));