2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire 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 3 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, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * setsect.c: Give resources to a country
29 * Known contributors to this file:
32 * Markus Armbruster, 2004-2013
43 * format: setres thing <sect> <#>
52 struct nstr_sect nstr;
56 what = getstarg(player->argp[1],
57 "Give what (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
64 if (!snxtsct(&nstr, player->argp[2]))
66 while (nxtsct(&nstr, §) > 0) {
67 p = getstarg(player->argp[3], "What value : ", buf);
71 if (!check_sect_ok(§))
75 current = sect.sct_min;
77 current = LIMIT_TO(current, 0, 100);
78 resnoise(§, "Iron ore content", sect.sct_min, current);
79 sect.sct_min = (unsigned char)current;
82 current = sect.sct_gmin;
84 current = LIMIT_TO(current, 0, 100);
85 resnoise(§, "Gold content", sect.sct_gmin, current);
86 sect.sct_gmin = (unsigned char)current;
91 current = sect.sct_oil;
93 current = LIMIT_TO(current, 0, 100);
94 resnoise(§, "Oil content", sect.sct_oil, current);
95 sect.sct_oil = (unsigned char)current;
98 if ((amt < 0) || (amt > MAXNOC - 1))
100 pr("Owner of %s changed from %s to %s.\n",
101 xyas(sect.sct_x, sect.sct_y, player->cnum),
102 prnatid(sect.sct_own), prnatid(amt));
103 if (amt == sect.sct_own)
105 if (sect.sct_own && sect.sct_own != player->cnum) {
107 "Sector %s taken from you by an act of %s!\n",
108 xyas(sect.sct_x, sect.sct_y, sect.sct_own),
109 cname(player->cnum));
111 if (amt && amt != player->cnum)
113 "Sector %s given to you by an act of %s!\n",
114 xyas(sect.sct_x, sect.sct_y, amt),
115 cname(player->cnum));
116 sect.sct_own = (natid)amt;
119 if ((amt < 0) || (amt > MAXNOC - 1))
121 pr("Old owner of %s changed from %s to %s.\n",
122 xyas(sect.sct_x, sect.sct_y, player->cnum),
123 prnatid(sect.sct_oldown), prnatid(amt));
124 sect.sct_oldown = (natid)amt;
132 current = sect.sct_effic;
134 current = LIMIT_TO(current, 0, 100);
135 pr("Efficiency in %s changed to %d.\n",
136 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
137 sect.sct_effic = current;
142 current = sect.sct_mines;
144 current = LIMIT_TO(current, 0, MINES_MAX);
145 if (sect.sct_own == sect.sct_oldown)
146 resnoise(§, "Mines", sect.sct_mines, current);
148 pr("Mines of %s changed from %d to %d\n",
149 xyas(sect.sct_x, sect.sct_y, player->cnum),
150 sect.sct_mines, current);
151 sect.sct_mines = current;
154 current = sect.sct_mobil;
156 current = LIMIT_TO(current, -127, 127);
157 pr("Mobility in %s changed to %d.\n",
158 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
159 sect.sct_mobil = current;
167 current = sect.sct_avail;
169 current = LIMIT_TO(current, 0, 9999);
170 pr("Available in %s changed to %d.\n",
171 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
172 sect.sct_avail = (short)current;
175 current = sect.sct_work;
177 current = LIMIT_TO(current, 0, 100);
178 pr("Work in %s changed to %d.\n",
179 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
180 sect.sct_work = (unsigned char)current;
183 current = sect.sct_fertil;
185 current = LIMIT_TO(current, 0, 100);
186 resnoise(§, "Fertility content", sect.sct_fertil, current);
187 sect.sct_fertil = (unsigned char)current;
190 current = sect.sct_uran;
192 current = LIMIT_TO(current, 0, 100);
193 resnoise(§, "Uranium content", sect.sct_uran, current);
194 sect.sct_uran = (unsigned char)current;
206 resbenefit(natid who, int goodness)
208 if (opt_GODNEWS && getnatp(who)->nat_stat != STAT_GOD && goodness)
209 nreport(player->cnum, goodness > 0 ? N_AIDS : N_HURTS, who, 1);
213 resnoise(struct sctstr *sptr, char *name, int old, int new)
215 pr("%s of %s changed from %d to %d\n",
216 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
217 if (sptr->sct_own && sptr->sct_own != player->cnum && new != old)
219 "%s in %s was changed from %d to %d by an act of %s\n",
220 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
221 old, new, cname(player->cnum));
222 resbenefit(sptr->sct_own, new - old);