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 if (sect.sct_own != 0)
79 resnoise(§, "Iron ore content", sect.sct_min, current);
80 sect.sct_min = (unsigned char)current;
83 current = sect.sct_gmin;
85 current = LIMIT_TO(current, 0, 100);
86 if (sect.sct_own != 0)
87 resnoise(§, "Gold content", sect.sct_gmin, current);
88 sect.sct_gmin = (unsigned char)current;
93 current = sect.sct_oil;
95 current = LIMIT_TO(current, 0, 100);
96 if (sect.sct_own != 0)
97 resnoise(§, "Oil content", sect.sct_oil, current);
98 sect.sct_oil = (unsigned char)current;
101 if ((amt < 0) || (amt > MAXNOC - 1))
103 pr("Owner of %s changed from %s to %s.\n",
104 xyas(sect.sct_x, sect.sct_y, player->cnum),
105 prnatid(sect.sct_own), prnatid(amt));
108 "Sector %s taken from you by an act of %s!\n",
109 xyas(sect.sct_x, sect.sct_y, sect.sct_own),
110 cname(player->cnum));
114 "Sector %s given to you by an act of %s!\n",
115 xyas(sect.sct_x, sect.sct_y, amt),
116 cname(player->cnum));
117 sect.sct_own = (natid)amt;
120 if ((amt < 0) || (amt > MAXNOC - 1))
122 pr("Old owner of %s changed from %s to %s.\n",
123 xyas(sect.sct_x, sect.sct_y, player->cnum),
124 prnatid(sect.sct_oldown), prnatid(amt));
125 sect.sct_oldown = (natid)amt;
133 current = sect.sct_effic;
135 current = LIMIT_TO(current, 0, 100);
136 pr("Efficiency in %s changed to %d.\n",
137 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
138 sect.sct_effic = current;
143 current = sect.sct_mines;
145 current = LIMIT_TO(current, 0, MINES_MAX);
146 if (sect.sct_own != 0 && sect.sct_own == sect.sct_oldown)
147 resnoise(§, "Mines", sect.sct_mines, current);
148 sect.sct_mines = current;
151 current = sect.sct_mobil;
153 current = LIMIT_TO(current, -127, 127);
154 pr("Mobility in %s changed to %d.\n",
155 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
156 sect.sct_mobil = current;
164 current = sect.sct_avail;
166 current = LIMIT_TO(current, 0, 9999);
167 pr("Available in %s changed to %d.\n",
168 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
169 sect.sct_avail = (short)current;
172 current = sect.sct_work;
174 current = LIMIT_TO(current, 0, 100);
175 pr("Work in %s changed to %d.\n",
176 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
177 sect.sct_work = (unsigned char)current;
180 current = sect.sct_fertil;
182 current = LIMIT_TO(current, 0, 100);
183 if (sect.sct_own != 0)
184 resnoise(§, "Fertility content", sect.sct_fertil, current);
185 sect.sct_fertil = (unsigned char)current;
188 current = sect.sct_uran;
190 current = LIMIT_TO(current, 0, 100);
191 if (sect.sct_own != 0)
192 resnoise(§, "Uranium content", sect.sct_uran, current);
193 sect.sct_uran = (unsigned char)current;
205 resbenefit(natid who, int good)
212 nreport(player->cnum, N_AIDS, who, 1);
215 nreport(player->cnum, N_HURTS, who, 1);
220 resnoise(struct sctstr *sptr, char *name, int old, int new)
222 pr("%s of %s changed from %d to %d\n",
223 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
226 "%s in %s was changed from %d to %d by an act of %s\n",
227 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
228 old, new, cname(player->cnum));
229 resbenefit(sptr->sct_own, (old < new));