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
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, 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) {
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 if ((err = dounit(thing[0], arg, ptr, &land))
222 if (!ef_ensure_space(EF_LAND, land.lnd_uid, 50))
224 if (!putland(land.lnd_uid, &land))
228 if ((err = doplane(thing[0], arg, ptr, &plane))
231 if (!ef_ensure_space(EF_PLANE, plane.pln_uid, 50))
233 if (!putplane(plane.pln_uid, &plane))
246 benefit(natid who, int good)
253 nreport(player->cnum, N_AIDS, who, 1);
256 nreport(player->cnum, N_HURTS, who, 1);
261 noise(struct sctstr *sptr, int public_amt, s_char *name, int old, int new)
265 pr("%s of %s changed from %d to %d\n",
266 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
268 (void)sprintf(p, "changed from %d to %d", old, new);
270 (void)sprintf(p, "%s", (old < new ? "increased" : "decreased"));
272 wu(player->cnum, sptr->sct_own,
273 "%s in %s was %s by an act of %s\n",
274 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
275 p, cname(player->cnum));
276 benefit(sptr->sct_own, (old < new));
280 prsect(struct sctstr *sect)
282 pr("Location <L>: %s\t", xyas(sect->sct_x, sect->sct_y, player->cnum));
283 pr("Distribution sector <D>: %s\n",
284 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum));
285 pr("Designation <s>: %c\t New designation <S>: %c\n",
286 dchr[sect->sct_type].d_mnem, dchr[sect->sct_newtype].d_mnem);
287 pr("own oo eff mob min gld frt oil urn wrk lty che plg ptime fall avail\n");
288 pr(" o O e m i g f c u w l x p t F a\n");
289 pr("%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %4d %3d %5d %4d %5d\n",
290 sect->sct_own, sect->sct_oldown, sect->sct_effic, sect->sct_mobil,
291 sect->sct_min, sect->sct_gmin, sect->sct_fertil, sect->sct_oil,
292 sect->sct_uran, sect->sct_work, sect->sct_loyal,
293 sect->sct_che, sect->sct_pstage, sect->sct_ptime,
294 sect->sct_fallout, sect->sct_avail);
296 pr("Mines <M>: %d\t", sect->sct_mines);
297 pr("Coastal <C>: %d\n", sect->sct_coastal);
298 pr("Road %% <R>: %d\t", sect->sct_road);
299 pr("Rail %% <r>: %d\t", sect->sct_rail);
300 pr("Defense %% <d>: %d\n", sect->sct_defense);
310 if ((np = getnatp(n)) == 0)
312 pr("Country #: %2d\n", n);
313 pr("Name <n>: %-20s\t", np->nat_cnam);
314 pr("Connected: %d\n", np->nat_connected);
315 pr("Representative <r>: %-20s\n", np->nat_pnam);
316 pr("BTUs <b>: %3d\t\t\t", np->nat_btu);
317 pr("Reserves <m>: %5d\n", np->nat_reserve);
318 pr("Capital <c>: %s\t\t",
319 xyas(np->nat_xcap, np->nat_ycap, player->cnum));
320 pr("Origin <o>: %3s\n",
321 xyas(np->nat_xorg, np->nat_yorg, player->cnum));
322 pr("Status <s>: 0x%x\t\t\t", np->nat_stat);
323 pr("Min Used <u>: %3d\n", np->nat_minused);
324 pr("Technology <T>: %.2f\t\t", np->nat_level[NAT_TLEV]);
325 pr("Research <R>: %.2f\n", np->nat_level[NAT_RLEV]);
326 pr("Education <E>: %.2f\t\t", np->nat_level[NAT_ELEV]);
327 pr("Happiness <H>: %.2f\n", np->nat_level[NAT_HLEV]);
328 pr("Money <M>: $%6d\n", np->nat_money);
329 pr("Telegrams <t>: %6d\n", np->nat_tgms);
330 if (opt_DEMANDUPDATE)
331 pr("Updates missed <U>: %d\n", np->nat_missed);
333 pr("Countries contacted: ");
334 for (i = 0; i < MAXNOC; i++) {
335 if (getcontact(np, i))
336 pr("%d(%d) ", i, getcontact(np, i));
343 pr_plane(struct plnstr *plane)
345 pr("UID <U>: %d\t\t", (int)plane->pln_uid);
346 pr("Owner <O>: %d\t\t", (int)plane->pln_own);
347 pr("Location <l>: %s\n",
348 xyas(plane->pln_x, plane->pln_y, player->cnum));
349 pr("Efficiency <e>: %d\t", (int)plane->pln_effic);
350 pr("Mobility <m>: %d\n", (int)plane->pln_mobil);
351 pr("Tech <t>: %d\t\t", plane->pln_tech);
352 pr("Wing <w>: %c\n", plane->pln_wing);
353 pr("Attack <a>: %d\t\t", plane->pln_att);
354 pr("Defense <d>: %d\n", plane->pln_def);
355 pr("Range <r>: %d\t\t", plane->pln_range);
356 pr("Flags <f>: %d\n", plane->pln_flags);
357 pr("Ship <s>: %d\t\t", plane->pln_ship);
358 pr("Land Unit <y>: %d\t", plane->pln_land);
359 pr("Nuke Type <n>: %d\n", plane->pln_nuketype);
363 pr_land(struct lndstr *land)
368 lcp = &lchr[(int)land->lnd_type];
369 pr("UID <U>: %d\n", (int)land->lnd_uid);
370 pr("Owner <O>: %d\n", (int)land->lnd_own);
371 pr("Location <L>: %s\n", xyas(land->lnd_x, land->lnd_y, player->cnum));
372 pr("Efficiency <e>: %d\t", (int)land->lnd_effic);
373 pr("Mobility <M>: %d\n", (int)land->lnd_mobil);
374 pr("Tech <t>: %d\t\t", land->lnd_tech);
375 pr("Army <a>: %c\n", land->lnd_army);
376 pr("Attack: %f\t", lcp->l_att);
377 pr("Defense: %f\n", lcp->l_def);
378 pr("Fortification <F>: %d\t", land->lnd_harden);
379 pr("Fuel <B>: %d\n", land->lnd_fuel);
380 count_land_planes(land);
381 pr("Xlight planes <X>: %d\n", land->lnd_nxlight);
382 pr("Land unit <Y>: %d\n", land->lnd_land);
383 pr("Ship <S>: %d\t\t", land->lnd_ship);
384 pr("Radius <P>: %d\n", land->lnd_rad_max);
385 pr("Retreat percentage <Z>: %d\n", (int)land->lnd_retreat);
386 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
387 land->lnd_rpath, (int)land->lnd_rflags);
388 getvec(VT_ITEM, vec, (s_char *)land, EF_LAND);
389 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
390 pr(" c m u f s g p i d o l h r\n");
391 pr("%3d", vec[I_CIVIL]);
392 pr("%4d", vec[I_MILIT]);
393 pr("%4d", vec[I_UW]);
394 pr("%5d", vec[I_FOOD]);
395 pr("%4d", vec[I_SHELL]);
396 pr("%4d", vec[I_GUN]);
397 pr("%5d", vec[I_PETROL]);
398 pr("%5d", vec[I_IRON]);
399 pr("%5d", vec[I_DUST]);
400 pr("%5d", vec[I_OIL]);
401 pr("%5d", vec[I_LCM]);
402 pr("%5d", vec[I_HCM]);
403 pr("%4d", vec[I_RAD]);
408 pr_ship(struct shpstr *ship)
413 if ((natp = getnatp(ship->shp_own)) == 0)
415 pr("%s (#%d) %s\n", natp->nat_cnam, (int)ship->shp_own, prship(ship));
416 pr("UID <U>: %d\n", (int)ship->shp_uid);
417 pr("Owner <O>: %d\t\t\t", (int)ship->shp_own);
418 pr("Location <L>: %s\n", xyas(ship->shp_x, ship->shp_y, player->cnum));
419 pr("Tech <T>: %d\t\t\t", ship->shp_tech);
420 pr("Efficiency <E>: %d\n", (int)ship->shp_effic);
421 pr("Mobility <M>: %d\t\t\t", (int)ship->shp_mobil);
422 pr("Fleet <F>: %c\n", ship->shp_fleet);
424 pr("Helos <H>: %d\n", (int)ship->shp_nchoppers);
425 pr("Xlight planes <X>: %d\n", (int)ship->shp_nxlight);
426 pr("Planes <P>: %d\n", (int)ship->shp_nplane);
428 pr("Units <Y>: %d\n", (int)ship->shp_nland);
429 /* could depend on opt_FUEL - but a deity might want to set this
430 up before enabling the option */
431 pr("Fuel <B>: %d\n", (int)ship->shp_fuel);
432 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
433 ship->shp_rpath, (int)ship->shp_rflags);
434 getvec(VT_ITEM, vec, (s_char *)ship, EF_SHIP);
435 pr("Plague Stage <a>: %d\n", ship->shp_pstage);
436 pr("Plague Time <b>: %d\n", ship->shp_ptime);
437 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
438 pr(" c m u f s g p i d o l h r\n");
439 pr("%3d", vec[I_CIVIL]);
440 pr("%4d", vec[I_MILIT]);
441 pr("%4d", vec[I_UW]);
442 pr("%5d", vec[I_FOOD]);
443 pr("%4d", vec[I_SHELL]);
444 pr("%4d", vec[I_GUN]);
445 pr("%5d", vec[I_PETROL]);
446 pr("%5d", vec[I_IRON]);
447 pr("%5d", vec[I_DUST]);
448 pr("%5d", vec[I_OIL]);
449 pr("%5d", vec[I_LCM]);
450 pr("%5d", vec[I_HCM]);
451 pr("%4d", vec[I_RAD]);
456 errcheck(int num, int min, int max)
466 getin(s_char **what, s_char **p, int *arg, s_char *buf)
468 if (!(*what = getstarg(*p, "%c xxxxx -- thing value : ", buf))) {
473 while (**what && isspace(**what))
477 for (*p = *what; **p && !isspace(**p); (*p)++) /* skip non spaces */
479 while (**p && isspace(**p))
489 doland(s_char op, int arg, s_char *p, struct sctstr *sect)
491 natid newown, oldown;
499 sect->sct_coastal = (arg ? 1 : 0);
500 pr("Coastal flag of %s changed to %d\n",
501 xyas(sect->sct_x, sect->sct_y, player->cnum),
507 newown = (natid)errcheck(arg, 0, MAXNOC - 1);
508 pr("Owner of %s changed from %s (#%d) to %s (#%d).\n",
509 xyas(sect->sct_x, sect->sct_y, player->cnum),
510 cname(sect->sct_own), sect->sct_own, cname(newown), newown);
512 makelost(EF_SECTOR, sect->sct_own, 0, sect->sct_x,
514 wu(player->cnum, sect->sct_own,
515 "Sector %s lost to deity intervention\n", xyas(sect->sct_x,
520 benefit(sect->sct_own, 0);
521 sect->sct_own = newown;
523 makenotlost(EF_SECTOR, newown, 0, sect->sct_x, sect->sct_y);
524 wu(player->cnum, newown,
525 "Sector %s gained from deity intervention\n",
526 xyas(sect->sct_x, sect->sct_y, sect->sct_own));
533 oldown = (natid)errcheck(arg, 0, MAXNOC - 1);
534 pr("Old owner of %s changed from %s (#%d) to %s (#%d).\n",
535 xyas(sect->sct_x, sect->sct_y, player->cnum),
536 cname(sect->sct_oldown),
537 sect->sct_oldown, cname(oldown), oldown);
538 sect->sct_oldown = oldown;
541 new = errcheck(arg, 0, 100);
542 noise(sect, 1, "Efficiency", (int)sect->sct_effic, new);
543 sect->sct_effic = (u_char)new;
546 new = errcheck(arg, -127, 255);
547 noise(sect, 1, "Mobility", (int)sect->sct_mobil, new);
548 sect->sct_mobil = new;
551 new = errcheck(arg, 0, 127);
552 noise(sect, 1, "Iron ore content", (int)sect->sct_min, new);
553 sect->sct_min = (u_char)new;
556 new = errcheck(arg, 0, 127);
557 noise(sect, 1, "Gold content", (int)sect->sct_gmin, new);
558 sect->sct_gmin = (u_char)new;
561 new = errcheck(arg, 0, 127);
562 noise(sect, 1, "Fertility", (int)sect->sct_fertil, new);
563 sect->sct_fertil = (u_char)new;
566 new = errcheck(arg, 0, 127);
567 noise(sect, 1, "Oil content", (int)sect->sct_oil, new);
568 sect->sct_oil = (u_char)new;
571 new = errcheck(arg, 0, 127);
572 noise(sect, 1, "Uranium content", (int)sect->sct_uran, new);
573 sect->sct_uran = (u_char)new;
576 new = errcheck(arg, 0, 100);
577 noise(sect, 1, "Workforce percentage", (int)sect->sct_work, new);
578 sect->sct_work = (u_char)new;
581 new = errcheck(arg, 0, 127);
582 pr("Loyalty of %s changed from %d to %d%%\n",
583 xyas(sect->sct_x, sect->sct_y, player->cnum),
584 sect->sct_loyal, new);
585 sect->sct_loyal = (u_char)new;
589 new = errcheck(arg, 0, 65536);
590 pr("Guerillas in %s changed from %d to %d%\n",
591 xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
595 old = sect->sct_pstage;
596 new = errcheck(arg, 0, PLG_EXPOSED);
597 pr("Plague stage of %s changed from %d to %d%\n",
598 xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
599 sect->sct_pstage = new;
602 old = sect->sct_ptime;
603 new = errcheck(arg, 0, 255);
604 pr("Plague time of %s changed from %d to %d%\n",
605 xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
606 sect->sct_ptime = new;
609 old = sect->sct_fallout;
610 new = errcheck(arg, 0, 9999);
611 pr("Fallout for sector %s changed from %d to %d\n",
612 xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
613 sect->sct_fallout = new;
616 new = errcheck(arg, 0, 9999);
617 noise(sect, 1, "Available workforce", (int)sect->sct_avail, new);
618 sect->sct_avail = new;
621 sect->sct_mines = arg;
622 pr("Mines changed to %d\n", arg);
625 if (!sarg_xy(p, &newx, &newy))
631 if (!sarg_xy(p, &newx, &newy))
633 pr("Distribtion Location for sector %s changed from %s to %s\n",
634 xyas(sect->sct_x, sect->sct_y, player->cnum),
635 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
636 xyas(newx, newy, player->cnum));
637 sect->sct_dist_x = newx;
638 sect->sct_dist_y = newy;
641 des = sct_typematch(p);
644 pr("Designation for sector %s changed from %c to %c\n",
645 xyas(sect->sct_x, sect->sct_y, player->cnum),
646 dchr[sect->sct_type].d_mnem, dchr[des].d_mnem);
647 sect->sct_type = des;
650 des = sct_typematch(p);
653 pr("New Designation for sector %s changed from %c to %c\n",
654 xyas(sect->sct_x, sect->sct_y, player->cnum),
655 dchr[sect->sct_newtype].d_mnem, dchr[des].d_mnem);
656 sect->sct_newtype = des;
663 noise(sect, 1, "Road percentage", (int)sect->sct_road, arg);
664 sect->sct_road = arg;
671 noise(sect, 1, "Rail percentage", (int)sect->sct_rail, arg);
672 sect->sct_rail = arg;
679 noise(sect, 1, "Defense percentage", (int)sect->sct_defense, arg);
680 sect->sct_defense = arg;
683 pr("huh? (%c)\n", op);
691 docountry(s_char op, int arg, s_char *p, float farg, natid nat,
697 pr("Country name changed from %s to %s\n", np->nat_cnam, p);
698 strncpy(np->nat_cnam, p, sizeof(np->nat_cnam) - 1);
701 pr("Country representative changed from %s to %s\n",
703 strncpy(np->nat_pnam, p, sizeof(np->nat_pnam) - 1);
709 arg = errcheck(arg, 0, 1024);
710 pr("BTU's changed from %d to %d\n", np->nat_btu, arg);
714 benefit(nat, np->nat_reserve < arg);
715 pr("Military Reserves changed from %d to %d\n",
716 np->nat_reserve, arg);
717 if (np->nat_stat == STAT_NORM)
718 wu(player->cnum, nat,
719 "Military Reserves changed from %d to %d by divine intervention.\n",
720 np->nat_reserve, arg);
721 np->nat_reserve = arg;
724 if (!sarg_xy(p, &newx, &newy))
726 pr("Capital coordinates changed from %s to %s\n",
727 xyas(np->nat_xcap, np->nat_ycap, player->cnum),
728 xyas(newx, newy, player->cnum));
733 if (!sarg_xy(p, &newx, &newy))
735 pr("Origin coordinates changed from %s to %s\n",
736 xyas(np->nat_xorg, np->nat_yorg, player->cnum),
737 xyas(newx, newy, player->cnum));
742 np->nat_stat = (s_char)errcheck(arg, 0, STAT_NEW);
745 arg = errcheck(arg, 0, m_m_p_d);
746 pr("Number of minutes used changed from %d to %d.\n",
747 np->nat_minused, arg);
748 np->nat_minused = arg;
751 pr("Money changed from %d to %d\n", np->nat_money, arg);
752 wu(player->cnum, nat,
753 "Money changed from %d to %d by divine intervention.\n",
758 pr("Tech changed from %.2f to %.2f.\n",
759 np->nat_level[NAT_TLEV], farg);
760 np->nat_level[NAT_TLEV] = farg;
763 pr("Research changed from %.2f to %.2f.\n",
764 np->nat_level[NAT_RLEV], farg);
765 np->nat_level[NAT_RLEV] = farg;
768 pr("Education changed from %.2f to %.2f.\n",
769 np->nat_level[NAT_ELEV], farg);
770 np->nat_level[NAT_ELEV] = farg;
773 pr("Happiness changed from %.2f to %.2f.\n",
774 np->nat_level[NAT_HLEV], farg);
775 np->nat_level[NAT_HLEV] = farg;
778 np->nat_missed = arg;
781 pr("huh? (%c)\n", op);
790 doship(s_char op, int arg, s_char *p, struct shpstr *ship)
797 ship->shp_pstage = arg;
800 ship->shp_ptime = arg;
803 memcpy(ship->shp_rpath, p, sizeof(ship->shp_rpath));
806 ship->shp_rflags = arg;
809 ship->shp_nchoppers = arg;
812 ship->shp_nxlight = arg;
819 wu(player->cnum, ship->shp_own,
820 "%s taken from you by deity intervention!\n", prship(ship));
821 if (arg && arg < MAXNOC) {
822 wu(player->cnum, (natid)arg,
823 "%s given to you by deity intervention!\n", prship(ship));
824 makelost(EF_SHIP, ship->shp_own, ship->shp_uid, ship->shp_x,
826 ship->shp_own = (natid)arg;
827 makenotlost(EF_SHIP, ship->shp_own, ship->shp_uid, ship->shp_x,
831 makelost(EF_SHIP, ship->shp_own, ship->shp_uid, ship->shp_x,
833 ship->shp_own = (natid)0;
837 if (!sarg_xy(p, &newx, &newy))
843 ship->shp_tech = arg;
846 ship->shp_effic = errcheck(arg, 0, 100);
849 makelost(EF_SHIP, ship->shp_own, ship->shp_uid, ship->shp_x,
851 ship->shp_own = (natid)0;
855 ship->shp_mobil = arg;
858 ship->shp_fuel = errcheck(arg, 0, 255);
862 ship->shp_fleet = ' ';
863 else if (isalpha(p[0]))
864 ship->shp_fleet = p[0];
866 pr("%c: invalid fleet\n", p[0]);
871 ship->shp_nland = errcheck(arg, 0, 100);
874 ship->shp_nplane = errcheck(arg, 0, 100);
877 ship->shp_item[I_CIVIL] = arg;
880 ship->shp_item[I_MILIT] = arg;
883 ship->shp_item[I_UW] = arg;
886 ship->shp_item[I_FOOD] = arg;
889 ship->shp_item[I_SHELL] = arg;
892 ship->shp_item[I_GUN] = arg;
895 ship->shp_item[I_PETROL] = arg;
898 ship->shp_item[I_IRON] = arg;
901 ship->shp_item[I_DUST] = arg;
904 ship->shp_item[I_OIL] = arg;
907 ship->shp_item[I_LCM] = arg;
910 ship->shp_item[I_HCM] = arg;
913 ship->shp_item[I_RAD] = arg;
916 pr("huh? (%c)\n", op);
923 dounit(s_char op, int arg, s_char *p, struct lndstr *land)
930 land->lnd_land = arg;
937 wu(player->cnum, land->lnd_own,
938 "%s taken from you by deity intervention!\n", prland(land));
940 if (arg && arg < MAXNOC) {
941 wu(player->cnum, (natid)arg,
942 "%s given to you by deity intervention!\n", prland(land));
943 makelost(EF_LAND, land->lnd_own, land->lnd_uid, land->lnd_x,
945 land->lnd_own = (natid)arg;
946 makenotlost(EF_LAND, land->lnd_own, land->lnd_uid, land->lnd_x,
949 makelost(EF_LAND, land->lnd_own, land->lnd_uid, land->lnd_x,
952 land->lnd_own = (natid)0;
956 if (!sarg_xy(p, &newx, &newy))
962 land->lnd_effic = errcheck(arg, 0, 100);
964 makelost(EF_LAND, land->lnd_own, land->lnd_uid, land->lnd_x,
967 land->lnd_own = (natid)0;
971 land->lnd_mobil = arg;
974 land->lnd_tech = arg;
978 land->lnd_army = ' ';
979 else if (isalpha(p[0]))
980 land->lnd_army = p[0];
982 pr("%c: invalid army\n", p[0]);
987 land->lnd_harden = errcheck(arg, 0, 255);
990 land->lnd_fuel = errcheck(arg, 0, 255);
993 land->lnd_nxlight = arg;
996 land->lnd_ship = arg;
999 land->lnd_rad_max = arg;
1002 land->lnd_retreat = arg;
1005 memcpy(land->lnd_rpath, p, sizeof(land->lnd_rpath));
1008 land->lnd_rflags = arg;
1011 land->lnd_item[I_CIVIL] = arg;
1014 land->lnd_item[I_MILIT] = arg;
1017 land->lnd_item[I_UW] = arg;
1020 land->lnd_item[I_FOOD] = arg;
1023 land->lnd_item[I_SHELL] = arg;
1026 land->lnd_item[I_GUN] = arg;
1029 land->lnd_item[I_PETROL] = arg;
1032 land->lnd_item[I_IRON] = arg;
1035 land->lnd_item[I_DUST] = arg;
1038 land->lnd_item[I_OIL] = arg;
1041 land->lnd_item[I_LCM] = arg;
1044 land->lnd_item[I_HCM] = arg;
1047 land->lnd_item[I_RAD] = arg;
1050 pr("huh? (%c)\n", op);
1058 doplane(s_char op, int arg, s_char *p, struct plnstr *plane)
1064 plane->pln_nuketype = arg;
1067 plane->pln_uid = arg;
1070 if (!sarg_xy(p, &newx, &newy))
1072 plane->pln_x = newx;
1073 plane->pln_y = newy;
1077 wu(player->cnum, plane->pln_own,
1078 "%s taken from you by deity intervention!\n",
1080 if (arg && arg < MAXNOC) {
1081 makelost(EF_PLANE, plane->pln_own, plane->pln_uid,
1082 plane->pln_x, plane->pln_y);
1083 plane->pln_own = (natid)arg;
1084 makenotlost(EF_PLANE, plane->pln_own, plane->pln_uid,
1085 plane->pln_x, plane->pln_y);
1086 wu(player->cnum, plane->pln_own,
1087 "%s given to you by deity intervention!\n", prplane(plane));
1089 plane->pln_effic = 0;
1090 makelost(EF_PLANE, plane->pln_own, plane->pln_uid,
1091 plane->pln_x, plane->pln_y);
1092 plane->pln_own = (natid)0;
1096 plane->pln_effic = errcheck(arg, 0, 100);
1098 plane->pln_effic = 0;
1099 makelost(EF_PLANE, plane->pln_own, plane->pln_uid,
1100 plane->pln_x, plane->pln_y);
1101 plane->pln_own = (natid)0;
1105 plane->pln_mobil = errcheck(arg, -127, 255);
1108 plane->pln_tech = arg;
1112 plane->pln_wing = ' ';
1113 else if (isalpha(p[0]))
1114 plane->pln_wing = p[0];
1116 pr("%c: invalid wing\n", p[0]);
1121 plane->pln_att = (s_char)errcheck(arg, 0, 127);
1124 plane->pln_def = (s_char)arg;
1127 plane->pln_range = (u_char)arg;
1130 plane->pln_ship = arg;
1133 plane->pln_land = arg;
1136 plane->pln_flags = arg;
1139 pr("huh? (%c)\n", op);