00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include <config.h>
00036
00037 #include "commands.h"
00038 #include "lost.h"
00039 #include "news.h"
00040 #include "optlist.h"
00041
00042
00043
00044
00045
00046 int
00047 setsector(void)
00048 {
00049 struct sctstr sect;
00050 char *what;
00051 int amt, current;
00052 char *p;
00053 struct nstr_sect nstr;
00054 char buf[1024];
00055 char char0, char1;
00056
00057 if ((what = getstarg(player->argp[1],
00058 "Give What (iron, gold, oil, uranium, fertility, owner, eff., mob., work, avail., oldown, mines)? ",
00059 buf)) == 0)
00060 return RET_SYN;
00061 char0 = what[0];
00062 char1 = what[1];
00063
00064 switch (char0) {
00065 case 'i':
00066 if (!snxtsct(&nstr, player->argp[2]))
00067 return RET_SYN;
00068 while (nxtsct(&nstr, §) > 0) {
00069 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
00070 (*p == '\0'))
00071 return RET_SYN;
00072 amt = atoi(p);
00073 current = sect.sct_min;
00074 current += amt;
00075 if (current < 0)
00076 current = 0;
00077 if (current > 100)
00078 current = 100;
00079 if (sect.sct_own != 0)
00080 resnoise(§, 1, "Iron ore content",
00081 (int)sect.sct_min, current);
00082 sect.sct_min = (unsigned char)current;
00083 putsect(§);
00084 }
00085 break;
00086 case 'g':
00087 if (!snxtsct(&nstr, player->argp[2]))
00088 return RET_SYN;
00089 while (nxtsct(&nstr, §) > 0) {
00090 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
00091 (*p == '\0'))
00092 return RET_SYN;
00093 amt = atoi(p);
00094 current = sect.sct_gmin;
00095 current += amt;
00096 if (current < 0)
00097 current = 0;
00098 if (current > 100)
00099 current = 100;
00100 if (sect.sct_own != 0)
00101 resnoise(§, 1, "Gold content",
00102 (int)sect.sct_gmin, current);
00103 sect.sct_gmin = (unsigned char)current;
00104 putsect(§);
00105 }
00106 break;
00107 case 'o':
00108 switch (char1) {
00109 case 'i':
00110 if (!snxtsct(&nstr, player->argp[2]))
00111 return RET_SYN;
00112 while (nxtsct(&nstr, §) > 0) {
00113 if (!(p = getstarg(player->argp[3], "What value : ", buf))
00114 || (*p == '\0'))
00115 return RET_SYN;
00116 amt = atoi(p);
00117 current = sect.sct_oil;
00118 current += amt;
00119 if (current < 0)
00120 current = 0;
00121 if (current > 100)
00122 current = 100;
00123 if (sect.sct_own != 0)
00124 resnoise(§, 1, "Oil content",
00125 (int)sect.sct_oil, current);
00126 sect.sct_oil = (unsigned char)current;
00127 putsect(§);
00128 }
00129 break;
00130 case 'w':
00131 if (!snxtsct(&nstr, player->argp[2]))
00132 return RET_SYN;
00133 while (nxtsct(&nstr, §) > 0) {
00134 if (!(p = getstarg(player->argp[3], "What value : ", buf))
00135 || (*p == '\0'))
00136 return RET_SYN;
00137 amt = atoi(p);
00138 if ((amt < 0) || (amt > MAXNOC - 1))
00139 return RET_SYN;
00140 pr("Owner of %s changed from %s (#%d) to %s (#%d).\n",
00141 xyas(sect.sct_x, sect.sct_y, player->cnum),
00142 cname(sect.sct_own), sect.sct_own, cname(amt), amt);
00143 if (sect.sct_own) {
00144 wu(player->cnum, sect.sct_own,
00145 "Sector %s lost to deity intervention\n",
00146 xyas(sect.sct_x, sect.sct_y, sect.sct_own));
00147 }
00148 if (amt)
00149 wu(player->cnum, amt,
00150 "Sector %s gained from deity intervention\n",
00151 xyas(sect.sct_x, sect.sct_y, amt));
00152 makelost(EF_SECTOR, sect.sct_own, 0,
00153 sect.sct_x, sect.sct_y);
00154 makenotlost(EF_SECTOR, amt, 0, sect.sct_x, sect.sct_y);
00155 sect.sct_own = (natid)amt;
00156 putsect(§);
00157 }
00158 break;
00159 case 'l':
00160 if (!snxtsct(&nstr, player->argp[2]))
00161 return RET_SYN;
00162 while (nxtsct(&nstr, §) > 0) {
00163 if (!(p = getstarg(player->argp[3], "What value : ", buf))
00164 || (*p == '\0'))
00165 return RET_SYN;
00166 amt = atoi(p);
00167 if ((amt < 0) || (amt > MAXNOC - 1))
00168 return RET_SYN;
00169 pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
00170 xyas(sect.sct_x, sect.sct_y, player->cnum),
00171 cname(sect.sct_oldown),
00172 sect.sct_oldown, cname(amt), amt);
00173 sect.sct_oldown = (natid)amt;
00174 putsect(§);
00175 }
00176 break;
00177 default:
00178 pr("huh?\n");
00179 return RET_SYN;
00180 }
00181 break;
00182 case 'e':
00183 if (!snxtsct(&nstr, player->argp[2]))
00184 return RET_SYN;
00185 while (nxtsct(&nstr, §) > 0) {
00186 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
00187 (*p == '\0'))
00188 return RET_SYN;
00189 amt = atoi(p);
00190 current = sect.sct_effic;
00191 current += amt;
00192 if (current < 0)
00193 current = 0;
00194 if (current > 100)
00195 current = 100;
00196 pr("Efficiency in %s changed to %d.\n",
00197 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
00198 sect.sct_effic = (unsigned char)current;
00199 putsect(§);
00200 }
00201 break;
00202 case 'm':
00203 switch (char1) {
00204 case 'i':
00205 if (!snxtsct(&nstr, player->argp[2]))
00206 return RET_SYN;
00207 while (nxtsct(&nstr, §) > 0) {
00208 if (!(p = getstarg(player->argp[3], "What value : ", buf))
00209 || (*p == '\0'))
00210 return RET_SYN;
00211 amt = atoi(p);
00212 current = sect.sct_mines;
00213 current += amt;
00214 if (current < 0)
00215 current = 0;
00216 if (current > MINES_MAX)
00217 current = MINES_MAX;
00218 if (sect.sct_own != 0)
00219 resnoise(§, 1, "Mines", sect.sct_mines, current);
00220 sect.sct_mines = current;
00221 putsect(§);
00222 }
00223 break;
00224 case 'o':
00225 if (!snxtsct(&nstr, player->argp[2]))
00226 return RET_SYN;
00227 while (nxtsct(&nstr, §) > 0) {
00228 if (!(p = getstarg(player->argp[3], "What value : ", buf))
00229 || (*p == '\0'))
00230 return RET_SYN;
00231 amt = atoi(p);
00232 current = sect.sct_mobil;
00233 current += amt;
00234 if (current < -127)
00235 current = -127;
00236 if (current > 127)
00237 current = 127;
00238 pr("Mobility in %s changed to %d.\n",
00239 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
00240 sect.sct_mobil = (short)current;
00241 putsect(§);
00242 }
00243 break;
00244 default:
00245 pr("huh?\n");
00246 return RET_SYN;
00247 }
00248 break;
00249 case 'a':
00250 if (!snxtsct(&nstr, player->argp[2]))
00251 return RET_SYN;
00252 while (nxtsct(&nstr, §) > 0) {
00253 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
00254 (*p == '\0'))
00255 return RET_SYN;
00256 amt = atoi(p);
00257 current = sect.sct_avail;
00258 current += amt;
00259 if (current < 0)
00260 current = 0;
00261 if (current > 9999)
00262 current = 9999;
00263 pr("Available in %s changed to %d.\n",
00264 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
00265 sect.sct_avail = (short)current;
00266 putsect(§);
00267 }
00268 break;
00269 case 'w':
00270 if (!snxtsct(&nstr, player->argp[2]))
00271 return RET_SYN;
00272 while (nxtsct(&nstr, §) > 0) {
00273 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
00274 (*p == '\0'))
00275 return RET_SYN;
00276 amt = atoi(p);
00277 current = sect.sct_work;
00278 current += amt;
00279 if (current < 0)
00280 current = 0;
00281 if (current > 100)
00282 current = 100;
00283 pr("Work in %s changed to %d.\n",
00284 xyas(sect.sct_x, sect.sct_y, player->cnum), current);
00285 sect.sct_work = (unsigned char)current;
00286 putsect(§);
00287 }
00288 break;
00289 case 'f':
00290 if (!snxtsct(&nstr, player->argp[2]))
00291 return RET_SYN;
00292 while (nxtsct(&nstr, §) > 0) {
00293 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
00294 (*p == '\0'))
00295 return RET_SYN;
00296 amt = atoi(p);
00297 current = sect.sct_fertil;
00298 current += amt;
00299 if (current < 0)
00300 current = 0;
00301 if (current > 100)
00302 current = 100;
00303 if (sect.sct_own != 0)
00304 resnoise(§, 1, "Fertility content",
00305 (int)sect.sct_fertil, current);
00306 sect.sct_fertil = (unsigned char)current;
00307 putsect(§);
00308 }
00309 break;
00310 case 'u':
00311 if (!snxtsct(&nstr, player->argp[2]))
00312 return RET_SYN;
00313 while (nxtsct(&nstr, §) > 0) {
00314 if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
00315 (*p == '\0'))
00316 return RET_SYN;
00317 amt = atoi(p);
00318 current = sect.sct_uran;
00319 current += amt;
00320 if (current < 0)
00321 current = 0;
00322 if (current > 100)
00323 current = 100;
00324 if (sect.sct_own != 0)
00325 resnoise(§, 1, "Uranium content",
00326 (int)sect.sct_uran, current);
00327 sect.sct_uran = (unsigned char)current;
00328 putsect(§);
00329 }
00330 break;
00331 default:
00332 pr("huh?\n");
00333 return RET_SYN;
00334 }
00335 return RET_OK;
00336 }
00337
00338 static void
00339 resbenefit(natid who, int good)
00340 {
00341 if (!opt_GODNEWS)
00342 return;
00343
00344 if (good) {
00345 if (who)
00346 nreport(player->cnum, N_AIDS, who, 1);
00347 } else {
00348 if (who)
00349 nreport(player->cnum, N_HURTS, who, 1);
00350 }
00351 }
00352
00353 void
00354 resnoise(struct sctstr *sptr, int public_amt, char *name, int old,
00355 int new)
00356 {
00357 char p[100];
00358
00359 pr("%s of %s changed from %d to %d\n",
00360 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
00361 if (public_amt)
00362 (void)sprintf(p, "changed from %d to %d", old, new);
00363 else
00364 (void)sprintf(p, "%s", old < new ? "increased" : "decreased");
00365 if (sptr->sct_own)
00366 wu(0, sptr->sct_own,
00367 "%s in %s was %s by an act of %s\n",
00368 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
00369 p, cname(player->cnum));
00370 resbenefit(sptr->sct_own, (old < new));
00371 }