2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, 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 * edit.c: Edit things (sectors, ships, planes, units, nukes, countries)
30 * Known contributors to this file:
33 * Steve McClure, 1998-2000
34 * Ron Koenderink, 2003-2004
58 static void benefit(natid who, int good);
59 static int docountry(s_char op, int arg, s_char *p, float farg, natid nat,
61 static int doland(s_char op, int arg, s_char *p, struct sctstr *sect);
62 static int doplane(s_char op, int arg, s_char *p, struct plnstr *plane);
63 static int doship(s_char op, int arg, s_char *p, struct shpstr *ship);
64 static int dounit(s_char op, int arg, s_char *p, float farg, struct lndstr *land);
65 static int getin(s_char **, s_char **, int *, s_char *);
66 static void noise(struct sctstr *sptr, int public_amt, s_char *name,
68 static void pr_land(struct lndstr *land);
69 static void pr_plane(struct plnstr *plane);
70 static void pr_ship(struct shpstr *ship);
71 static void prnat(natid n);
72 static void prsect(struct sctstr *sect);
94 s_char ewhat; /* saves information from the command line
97 if ((what = getstarg(player->argp[1],
98 "Edit What (country, land, ship, plane, nuke, unit)? ",
104 if (!(ptr = getstarg(player->argp[2], "Sector : ", buf)))
106 if (!sarg_xy(ptr, &x, &y))
108 if (!getsect(x, y, §))
112 if ((num = natarg(player->argp[2], "Country number? ")) < 0)
118 if ((num = onearg(player->argp[2], "Plane number? ")) < 0)
120 if (!getplane(num, &plane))
124 if ((num = onearg(player->argp[2], "Ship number? ")) < 0)
126 if (!getship(num, &ship))
130 if ((num = onearg(player->argp[2], "Unit number? ")) < 0)
132 if (!getland(num, &land))
136 pr("Not implemented yet.\n");
142 if (player->argp[3] == 0) {
164 if (player->argp[arg_index] != 0) {
165 if (player->argp[arg_index+1] != 0) {
166 thing = player->argp[arg_index++];
167 ptr = player->argp[arg_index++];
171 } else if (arg_index == 3) {
172 if ((err = getin(&thing, &ptr, &arg, buf)) != RET_OK) {
199 farg = (float)atof(ptr);
200 if ((err = docountry(thing[0], arg, ptr, farg, nat, np))
205 if ((err = doland(thing[0], arg, ptr, §)) != RET_OK)
211 if ((err = doship(thing[0], arg, ptr, &ship)) != RET_OK)
213 if (!ef_ensure_space(EF_SHIP, ship.shp_uid, 50))
215 if (!putship(ship.shp_uid, &ship))
219 farg = (float)atof(ptr);
220 if ((err = dounit(thing[0], arg, ptr, farg, &land))
223 if (!ef_ensure_space(EF_LAND, land.lnd_uid, 50))
225 if (!putland(land.lnd_uid, &land))
229 if ((err = doplane(thing[0], arg, ptr, &plane))
232 if (!ef_ensure_space(EF_PLANE, plane.pln_uid, 50))
234 if (!putplane(plane.pln_uid, &plane))
247 benefit(natid who, int good)
254 nreport(player->cnum, N_AIDS, who, 1);
257 nreport(player->cnum, N_HURTS, who, 1);
262 noise(struct sctstr *sptr, int public_amt, s_char *name, int old, int new)
266 pr("%s of %s changed from %d to %d\n",
267 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
269 (void)sprintf(p, "changed from %d to %d", old, new);
271 (void)sprintf(p, "%s", (old < new ? "increased" : "decreased"));
273 wu(player->cnum, sptr->sct_own,
274 "%s in %s was %s by an act of %s\n",
275 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
276 p, cname(player->cnum));
277 benefit(sptr->sct_own, (old < new));
281 prsect(struct sctstr *sect)
283 pr("Location <L>: %s\t", xyas(sect->sct_x, sect->sct_y, player->cnum));
284 pr("Distribution sector <D>: %s\n",
285 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum));
286 pr("Designation <s>: %c\t New designation <S>: %c\n",
287 dchr[sect->sct_type].d_mnem, dchr[sect->sct_newtype].d_mnem);
288 pr("own oo eff mob min gld frt oil urn wrk lty che ctg plg ptime fall avail\n");
289 pr(" o O e m i g f c u w l x X p t F a\n");
290 pr("%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %5d %4d %5d\n",
291 sect->sct_own, sect->sct_oldown, sect->sct_effic, sect->sct_mobil,
292 sect->sct_min, sect->sct_gmin, sect->sct_fertil, sect->sct_oil,
293 sect->sct_uran, sect->sct_work, sect->sct_loyal,
294 sect->sct_che, sect->sct_che_target,
295 sect->sct_pstage, sect->sct_ptime,
296 sect->sct_fallout, sect->sct_avail);
298 pr("Mines <M>: %d\t", sect->sct_mines);
299 pr("Coastal <C>: %d\n", sect->sct_coastal);
300 pr("Road %% <R>: %d\t", sect->sct_road);
301 pr("Rail %% <r>: %d\t", sect->sct_rail);
302 pr("Defense %% <d>: %d\n", sect->sct_defense);
312 if ((np = getnatp(n)) == 0)
314 pr("Country #: %2d\n", n);
315 pr("Name <n>: %-20s\t", np->nat_cnam);
316 pr("Connected: %d\n", np->nat_connected);
317 pr("Representative <r>: %-20s\n", np->nat_pnam);
318 pr("BTUs <b>: %3d\t\t\t", np->nat_btu);
319 pr("Reserves <m>: %5ld\n", np->nat_reserve);
320 pr("Capital <c>: %s\t\t",
321 xyas(np->nat_xcap, np->nat_ycap, player->cnum));
322 pr("Origin <o>: %3s\n",
323 xyas(np->nat_xorg, np->nat_yorg, player->cnum));
324 pr("Status <s>: 0x%x\t\t\t", np->nat_stat);
325 pr("Min Used <u>: %3d\n", np->nat_minused);
326 pr("Technology <T>: %.2f\t\t", np->nat_level[NAT_TLEV]);
327 pr("Research <R>: %.2f\n", np->nat_level[NAT_RLEV]);
328 pr("Education <E>: %.2f\t\t", np->nat_level[NAT_ELEV]);
329 pr("Happiness <H>: %.2f\n", np->nat_level[NAT_HLEV]);
330 pr("Money <M>: $%6ld\n", np->nat_money);
331 pr("Telegrams <t>: %6d\n", np->nat_tgms);
332 if (opt_DEMANDUPDATE)
333 pr("Updates missed <U>: %d\n", np->nat_missed);
335 pr("Countries contacted: ");
336 for (i = 0; i < MAXNOC; i++) {
337 if (getcontact(np, i))
338 pr("%d(%d) ", i, getcontact(np, i));
345 pr_plane(struct plnstr *plane)
347 pr("UID <U>: %d\t\t", (int)plane->pln_uid);
348 pr("Owner <O>: %d\t\t", (int)plane->pln_own);
349 pr("Location <l>: %s\n",
350 xyas(plane->pln_x, plane->pln_y, player->cnum));
351 pr("Efficiency <e>: %d\t", (int)plane->pln_effic);
352 pr("Mobility <m>: %d\n", (int)plane->pln_mobil);
353 pr("Tech <t>: %d\t\t", plane->pln_tech);
354 pr("Wing <w>: %c\n", plane->pln_wing);
355 pr("Attack <a>: %d\t\t", plane->pln_att);
356 pr("Defense <d>: %d\n", plane->pln_def);
357 pr("Range <r>: %d\t\t", plane->pln_range);
358 pr("Flags <f>: %d\n", plane->pln_flags);
359 pr("Ship <s>: %d\t\t", plane->pln_ship);
360 pr("Land Unit <y>: %d\t", plane->pln_land);
361 pr("Nuke Type <n>: %d\n", plane->pln_nuketype);
365 pr_land(struct lndstr *land)
367 pr("UID <U>: %d\n", (int)land->lnd_uid);
368 pr("Owner <O>: %d\n", (int)land->lnd_own);
369 pr("Location <L>: %s\n", xyas(land->lnd_x, land->lnd_y, player->cnum));
370 pr("Efficiency <e>: %d\t", (int)land->lnd_effic);
371 pr("Mobility <M>: %d\n", (int)land->lnd_mobil);
372 pr("Tech <t>: %d\t\t", land->lnd_tech);
373 pr("Army <a>: %c\n", land->lnd_army);
374 pr("Fortification <F>: %d\t", land->lnd_harden);
375 pr("Fuel <B>: %d\n", land->lnd_fuel);
376 count_land_planes(land);
377 pr("Xlight planes <X>: %d\n", land->lnd_nxlight);
378 pr("Land unit <Y>: %d\n", land->lnd_land);
379 pr("Ship <S>: %d\t\t", land->lnd_ship);
380 pr("Radius <P>: %d\n", land->lnd_rad_max);
381 pr("Retreat percentage <Z>: %d\n", (int)land->lnd_retreat);
382 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
383 land->lnd_rpath, (int)land->lnd_rflags);
384 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
385 pr(" c m u f s g p i d o l h r\n");
386 pr("%3d", land->lnd_item[I_CIVIL]);
387 pr("%4d", land->lnd_item[I_MILIT]);
388 pr("%4d", land->lnd_item[I_UW]);
389 pr("%5d", land->lnd_item[I_FOOD]);
390 pr("%4d", land->lnd_item[I_SHELL]);
391 pr("%4d", land->lnd_item[I_GUN]);
392 pr("%5d", land->lnd_item[I_PETROL]);
393 pr("%5d", land->lnd_item[I_IRON]);
394 pr("%5d", land->lnd_item[I_DUST]);
395 pr("%5d", land->lnd_item[I_OIL]);
396 pr("%5d", land->lnd_item[I_LCM]);
397 pr("%5d", land->lnd_item[I_HCM]);
398 pr("%4d", land->lnd_item[I_RAD]);
403 pr_ship(struct shpstr *ship)
407 if ((natp = getnatp(ship->shp_own)) == 0)
409 pr("%s (#%d) %s\n", natp->nat_cnam, (int)ship->shp_own, prship(ship));
410 pr("UID <U>: %d\n", (int)ship->shp_uid);
411 pr("Owner <O>: %d\t\t\t", (int)ship->shp_own);
412 pr("Location <L>: %s\n", xyas(ship->shp_x, ship->shp_y, player->cnum));
413 pr("Tech <T>: %d\t\t\t", ship->shp_tech);
414 pr("Efficiency <E>: %d\n", (int)ship->shp_effic);
415 pr("Mobility <M>: %d\t\t", (int)ship->shp_mobil);
416 pr("Fleet <F>: %c\n", ship->shp_fleet);
418 pr("Xlight planes <X>: %d\t\t", (int)ship->shp_nxlight);
419 pr("Planes <P>: %d\n", (int)ship->shp_nplane);
420 pr("Helos <H>: %d\t\t\t", (int)ship->shp_nchoppers);
422 pr("Units <Y>: %d\n", (int)ship->shp_nland);
423 /* could depend on opt_FUEL - but a deity might want to set this
424 up before enabling the option */
425 pr("Fuel <B>: %d\t\t\t", (int)ship->shp_fuel);
426 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
427 ship->shp_rpath, (int)ship->shp_rflags);
428 pr("Plague Stage <a>: %d\t\t",ship->shp_pstage);
429 pr("Plague Time <b>: %d\n", ship->shp_ptime);
430 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
431 pr(" c m u f s g p i d o l h r\n");
432 pr("%3d", ship->shp_item[I_CIVIL]);
433 pr("%4d", ship->shp_item[I_MILIT]);
434 pr("%4d", ship->shp_item[I_UW]);
435 pr("%5d", ship->shp_item[I_FOOD]);
436 pr("%4d", ship->shp_item[I_SHELL]);
437 pr("%4d", ship->shp_item[I_GUN]);
438 pr("%5d", ship->shp_item[I_PETROL]);
439 pr("%5d", ship->shp_item[I_IRON]);
440 pr("%5d", ship->shp_item[I_DUST]);
441 pr("%5d", ship->shp_item[I_OIL]);
442 pr("%5d", ship->shp_item[I_LCM]);
443 pr("%5d", ship->shp_item[I_HCM]);
444 pr("%4d", ship->shp_item[I_RAD]);
449 errcheck(int num, int min, int max)
459 getin(s_char **what, s_char **p, int *arg, s_char *buf)
461 if (!(*what = getstarg(*p, "%c xxxxx -- thing value : ", buf))) {
466 while (**what && isspace(**what))
470 for (*p = *what; **p && !isspace(**p); (*p)++) /* skip non spaces */
472 while (**p && isspace(**p))
481 warn_deprecated(char key)
483 pr("Key <%c> is deprecated and will go away in a future release\n", key);
487 doland(s_char op, int arg, s_char *p, struct sctstr *sect)
489 natid newown, oldown;
497 sect->sct_coastal = (arg ? 1 : 0);
498 pr("Coastal flag of %s changed to %d\n",
499 xyas(sect->sct_x, sect->sct_y, player->cnum),
505 newown = (natid)errcheck(arg, 0, MAXNOC - 1);
506 pr("Owner of %s changed from %s (#%d) to %s (#%d).\n",
507 xyas(sect->sct_x, sect->sct_y, player->cnum),
508 cname(sect->sct_own), sect->sct_own, cname(newown), newown);
510 makelost(EF_SECTOR, sect->sct_own, 0, sect->sct_x,
512 wu(player->cnum, sect->sct_own,
513 "Sector %s lost to deity intervention\n", xyas(sect->sct_x,
518 benefit(sect->sct_own, 0);
519 sect->sct_own = newown;
521 makenotlost(EF_SECTOR, newown, 0, sect->sct_x, sect->sct_y);
522 wu(player->cnum, newown,
523 "Sector %s gained from deity intervention\n",
524 xyas(sect->sct_x, sect->sct_y, sect->sct_own));
531 oldown = (natid)errcheck(arg, 0, MAXNOC - 1);
532 pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
533 xyas(sect->sct_x, sect->sct_y, player->cnum),
534 cname(sect->sct_oldown),
535 sect->sct_oldown, cname(oldown), oldown);
536 sect->sct_oldown = oldown;
539 new = errcheck(arg, 0, 100);
540 noise(sect, 1, "Efficiency", (int)sect->sct_effic, new);
541 sect->sct_effic = (u_char)new;
544 new = errcheck(arg, -127, 255);
545 noise(sect, 1, "Mobility", (int)sect->sct_mobil, new);
546 sect->sct_mobil = new;
549 new = errcheck(arg, 0, 127);
550 noise(sect, 1, "Iron ore content", (int)sect->sct_min, new);
551 sect->sct_min = (u_char)new;
554 new = errcheck(arg, 0, 127);
555 noise(sect, 1, "Gold content", (int)sect->sct_gmin, new);
556 sect->sct_gmin = (u_char)new;
559 new = errcheck(arg, 0, 127);
560 noise(sect, 1, "Fertility", (int)sect->sct_fertil, new);
561 sect->sct_fertil = (u_char)new;
564 new = errcheck(arg, 0, 127);
565 noise(sect, 1, "Oil content", (int)sect->sct_oil, new);
566 sect->sct_oil = (u_char)new;
569 new = errcheck(arg, 0, 127);
570 noise(sect, 1, "Uranium content", (int)sect->sct_uran, new);
571 sect->sct_uran = (u_char)new;
574 new = errcheck(arg, 0, 100);
575 noise(sect, 1, "Workforce percentage", (int)sect->sct_work, new);
576 sect->sct_work = (u_char)new;
579 new = errcheck(arg, 0, 127);
580 pr("Loyalty of %s changed from %d to %d%%\n",
581 xyas(sect->sct_x, sect->sct_y, player->cnum),
582 sect->sct_loyal, new);
583 sect->sct_loyal = (u_char)new;
587 new = errcheck(arg, 0, CHE_MAX);
588 pr("Guerillas in %s changed from %d to %d\n",
589 xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
593 old = sect->sct_che_target;
594 new = errcheck(arg, 0, MAXNOC - 1);
595 pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
596 xyas(sect->sct_x, sect->sct_y, player->cnum),
597 cname(old), old, cname(new), new);
598 sect->sct_che_target = new;
601 old = sect->sct_pstage;
602 new = errcheck(arg, 0, PLG_EXPOSED);
603 pr("Plague stage of %s changed from %d to %d%%\n",
604 xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
605 sect->sct_pstage = new;
608 old = sect->sct_ptime;
609 new = errcheck(arg, 0, 255);
610 pr("Plague time of %s changed from %d to %d%%\n",
611 xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
612 sect->sct_ptime = new;
615 old = sect->sct_fallout;
616 new = errcheck(arg, 0, FALLOUT_MAX);
617 pr("Fallout for sector %s changed from %d to %d\n",
618 xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
619 sect->sct_fallout = new;
622 new = errcheck(arg, 0, 9999);
623 noise(sect, 1, "Available workforce", (int)sect->sct_avail, new);
624 sect->sct_avail = new;
627 new = errcheck(arg, 0, MINES_MAX);
628 sect->sct_mines = new;
629 pr("Mines changed to %d\n", new);
632 if (!sarg_xy(p, &newx, &newy))
638 if (!sarg_xy(p, &newx, &newy))
640 pr("Distribtion Location for sector %s changed from %s to %s\n",
641 xyas(sect->sct_x, sect->sct_y, player->cnum),
642 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
643 xyas(newx, newy, player->cnum));
644 sect->sct_dist_x = newx;
645 sect->sct_dist_y = newy;
648 des = sct_typematch(p);
651 pr("Designation for sector %s changed from %c to %c\n",
652 xyas(sect->sct_x, sect->sct_y, player->cnum),
653 dchr[sect->sct_type].d_mnem, dchr[des].d_mnem);
654 sect->sct_type = des;
657 des = sct_typematch(p);
660 pr("New Designation for sector %s changed from %c to %c\n",
661 xyas(sect->sct_x, sect->sct_y, player->cnum),
662 dchr[sect->sct_newtype].d_mnem, dchr[des].d_mnem);
663 sect->sct_newtype = des;
670 noise(sect, 1, "Road percentage", (int)sect->sct_road, arg);
671 sect->sct_road = arg;
678 noise(sect, 1, "Rail percentage", (int)sect->sct_rail, arg);
679 sect->sct_rail = arg;
686 noise(sect, 1, "Defense percentage", (int)sect->sct_defense, arg);
687 sect->sct_defense = arg;
690 pr("huh? (%c)\n", op);
698 docountry(s_char op, int arg, s_char *p, float farg, natid nat,
704 pr("Country name changed from %s to %s\n", np->nat_cnam, p);
705 strncpy(np->nat_cnam, p, sizeof(np->nat_cnam) - 1);
708 pr("Country representative changed from %s to %s\n",
710 strncpy(np->nat_pnam, p, sizeof(np->nat_pnam) - 1);
716 arg = errcheck(arg, 0, 1024);
717 pr("BTU's changed from %d to %d\n", np->nat_btu, arg);
721 benefit(nat, np->nat_reserve < arg);
722 pr("Military Reserves changed from %ld to %d\n",
723 np->nat_reserve, arg);
724 if (np->nat_stat == STAT_NORM)
725 wu(player->cnum, nat,
726 "Military Reserves changed from %ld to %d by divine intervention.\n",
727 np->nat_reserve, arg);
728 np->nat_reserve = arg;
731 if (!sarg_xy(p, &newx, &newy))
733 pr("Capital coordinates changed from %s to %s\n",
734 xyas(np->nat_xcap, np->nat_ycap, player->cnum),
735 xyas(newx, newy, player->cnum));
740 if (!sarg_xy(p, &newx, &newy))
742 pr("Origin coordinates changed from %s to %s\n",
743 xyas(np->nat_xorg, np->nat_yorg, player->cnum),
744 xyas(newx, newy, player->cnum));
749 np->nat_stat = (s_char)errcheck(arg, 0, STAT_NEW);
752 arg = errcheck(arg, 0, m_m_p_d);
753 pr("Number of minutes used changed from %d to %d.\n",
754 np->nat_minused, arg);
755 np->nat_minused = arg;
758 pr("Money changed from %ld to %d\n", np->nat_money, arg);
759 wu(player->cnum, nat,
760 "Money changed from %ld to %d by divine intervention.\n",
765 pr("Tech changed from %.2f to %.2f.\n",
766 np->nat_level[NAT_TLEV], farg);
767 np->nat_level[NAT_TLEV] = farg;
770 pr("Research changed from %.2f to %.2f.\n",
771 np->nat_level[NAT_RLEV], farg);
772 np->nat_level[NAT_RLEV] = farg;
775 pr("Education changed from %.2f to %.2f.\n",
776 np->nat_level[NAT_ELEV], farg);
777 np->nat_level[NAT_ELEV] = farg;
780 pr("Happiness changed from %.2f to %.2f.\n",
781 np->nat_level[NAT_HLEV], farg);
782 np->nat_level[NAT_HLEV] = farg;
785 np->nat_missed = arg;
788 pr("huh? (%c)\n", op);
797 doship(s_char op, int arg, s_char *p, struct shpstr *ship)
804 ship->shp_pstage = arg;
807 ship->shp_ptime = arg;
810 memcpy(ship->shp_rpath, p, sizeof(ship->shp_rpath));
813 ship->shp_rflags = arg;
816 ship->shp_nchoppers = arg;
819 ship->shp_nxlight = arg;
826 wu(player->cnum, ship->shp_own,
827 "%s taken from you by deity intervention!\n", prship(ship));
828 if (arg && arg < MAXNOC) {
829 wu(player->cnum, (natid)arg,
830 "%s given to you by deity intervention!\n", prship(ship));
831 makelost(EF_SHIP, ship->shp_own, ship->shp_uid, ship->shp_x,
833 ship->shp_own = (natid)arg;
834 makenotlost(EF_SHIP, ship->shp_own, ship->shp_uid, ship->shp_x,
838 makelost(EF_SHIP, ship->shp_own, ship->shp_uid, ship->shp_x,
840 ship->shp_own = (natid)0;
844 if (!sarg_xy(p, &newx, &newy))
851 errcheck(arg, mchr[ship->shp_type].m_tech, SHRT_MAX));
854 ship->shp_effic = errcheck(arg, SHIP_MINEFF, 100);
857 ship->shp_mobil = arg;
860 ship->shp_fuel = errcheck(arg, 0, 255);
864 ship->shp_fleet = ' ';
865 else if (isalpha(p[0]))
866 ship->shp_fleet = p[0];
868 pr("%c: invalid fleet\n", p[0]);
873 ship->shp_nland = errcheck(arg, 0, 100);
876 ship->shp_nplane = errcheck(arg, 0, 100);
879 ship->shp_item[I_CIVIL] = arg;
882 ship->shp_item[I_MILIT] = arg;
885 ship->shp_item[I_UW] = arg;
888 ship->shp_item[I_FOOD] = arg;
891 ship->shp_item[I_SHELL] = arg;
894 ship->shp_item[I_GUN] = arg;
897 ship->shp_item[I_PETROL] = arg;
900 ship->shp_item[I_IRON] = arg;
903 ship->shp_item[I_DUST] = arg;
906 ship->shp_item[I_OIL] = arg;
909 ship->shp_item[I_LCM] = arg;
912 ship->shp_item[I_HCM] = arg;
915 ship->shp_item[I_RAD] = arg;
919 ship->shp_armor = errcheck(arg, 0, SHRT_MAX);
922 pr("huh? (%c)\n", op);
929 dounit(s_char op, int arg, s_char *p, float farg, struct lndstr *land)
936 land->lnd_land = arg;
943 wu(player->cnum, land->lnd_own,
944 "%s taken from you by deity intervention!\n", prland(land));
946 if (arg && arg < MAXNOC) {
947 wu(player->cnum, (natid)arg,
948 "%s given to you by deity intervention!\n", prland(land));
949 makelost(EF_LAND, land->lnd_own, land->lnd_uid, land->lnd_x,
951 land->lnd_own = (natid)arg;
952 makenotlost(EF_LAND, land->lnd_own, land->lnd_uid, land->lnd_x,
955 makelost(EF_LAND, land->lnd_own, land->lnd_uid, land->lnd_x,
958 land->lnd_own = (natid)0;
962 if (!sarg_xy(p, &newx, &newy))
968 land->lnd_effic = errcheck(arg, LAND_MINEFF, 100);
971 land->lnd_mobil = arg;
975 errcheck(arg, lchr[land->lnd_type].l_tech, SHRT_MAX));
979 land->lnd_army = ' ';
980 else if (isalpha(p[0]))
981 land->lnd_army = p[0];
983 pr("%c: invalid army\n", p[0]);
988 land->lnd_harden = errcheck(arg, 0, 255);
991 land->lnd_fuel = errcheck(arg, 0, 255);
994 land->lnd_nxlight = arg;
997 land->lnd_ship = arg;
1000 land->lnd_rad_max = arg;
1003 land->lnd_retreat = arg;
1006 memcpy(land->lnd_rpath, p, sizeof(land->lnd_rpath));
1009 land->lnd_rflags = arg;
1012 land->lnd_item[I_CIVIL] = arg;
1015 land->lnd_item[I_MILIT] = arg;
1018 land->lnd_item[I_UW] = arg;
1021 land->lnd_item[I_FOOD] = arg;
1024 land->lnd_item[I_SHELL] = arg;
1027 land->lnd_item[I_GUN] = arg;
1030 land->lnd_item[I_PETROL] = arg;
1033 land->lnd_item[I_IRON] = arg;
1036 land->lnd_item[I_DUST] = arg;
1039 land->lnd_item[I_OIL] = arg;
1042 land->lnd_item[I_LCM] = arg;
1045 land->lnd_item[I_HCM] = arg;
1048 land->lnd_item[I_RAD] = arg;
1051 warn_deprecated(op);
1052 pr("Attack changed from %1.2f to %1.2f.\n",
1053 land->lnd_att, farg);
1054 land->lnd_att = farg;
1057 warn_deprecated(op);
1058 pr("Defense changed from %1.2f to %1.2f.\n",
1059 land->lnd_def, farg);
1060 land->lnd_def = farg;
1063 pr("huh? (%c)\n", op);
1071 doplane(s_char op, int arg, s_char *p, struct plnstr *plane)
1077 plane->pln_nuketype = arg;
1080 plane->pln_uid = arg;
1083 if (!sarg_xy(p, &newx, &newy))
1085 plane->pln_x = newx;
1086 plane->pln_y = newy;
1090 wu(player->cnum, plane->pln_own,
1091 "%s taken from you by deity intervention!\n",
1093 if (arg && arg < MAXNOC) {
1094 makelost(EF_PLANE, plane->pln_own, plane->pln_uid,
1095 plane->pln_x, plane->pln_y);
1096 plane->pln_own = (natid)arg;
1097 makenotlost(EF_PLANE, plane->pln_own, plane->pln_uid,
1098 plane->pln_x, plane->pln_y);
1099 wu(player->cnum, plane->pln_own,
1100 "%s given to you by deity intervention!\n", prplane(plane));
1102 plane->pln_effic = 0;
1103 makelost(EF_PLANE, plane->pln_own, plane->pln_uid,
1104 plane->pln_x, plane->pln_y);
1105 plane->pln_own = (natid)0;
1109 plane->pln_effic = errcheck(arg, PLANE_MINEFF, 100);
1112 plane->pln_mobil = errcheck(arg, -127, 255);
1116 errcheck(arg, plchr[plane->pln_type].pl_tech, SHRT_MAX));
1120 plane->pln_wing = ' ';
1121 else if (isalpha(p[0]))
1122 plane->pln_wing = p[0];
1124 pr("%c: invalid wing\n", p[0]);
1129 plane->pln_att = (s_char)errcheck(arg, 0, 127);
1132 plane->pln_def = (s_char)arg;
1135 plane->pln_range = (u_char)arg;
1138 plane->pln_ship = arg;
1141 plane->pln_land = arg;
1144 plane->pln_flags = arg;
1147 pr("huh? (%c)\n", op);