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 * edit.c: Edit things (sectors, ships, planes, units, nukes, countries)
29 * Known contributors to this file:
32 * Steve McClure, 1998-2000
33 * Ron Koenderink, 2003-2009
34 * Markus Armbruster, 2003-2013
50 static void print_sect(struct sctstr *);
51 static void print_nat(struct natstr *);
52 static void print_plane(struct plnstr *);
53 static void print_land(struct lndstr *);
54 static void print_ship(struct shpstr *);
55 static char *getin(char *, char **);
56 static int edit_sect(struct sctstr *, char *, int, char *);
57 static int edit_nat(struct natstr *, char *, int, char *);
58 static int edit_ship(struct shpstr *, char *, int, char *);
59 static int edit_land(struct lndstr *, char *, int, char *);
60 static int edit_plane(struct plnstr *, char *, int, char *);
80 what = getstarg(player->argp[1],
81 "Edit what (country, land, ship, plane, nuke, unit)? ",
88 if (!(ptr = getstarg(player->argp[2], "Sector : ", buf)))
90 if (!sarg_xy(ptr, &x, &y))
92 if (!getsect(x, y, §))
96 np = natargp(player->argp[2], "Country? ");
101 if ((num = onearg(player->argp[2], "Plane number? ")) < 0)
103 if (!getplane(num, &plane))
107 if ((num = onearg(player->argp[2], "Ship number? ")) < 0)
109 if (!getship(num, &ship))
113 if ((num = onearg(player->argp[2], "Unit number? ")) < 0)
115 if (!getland(num, &land))
119 pr("Not implemented yet.\n");
125 if (!player->argp[3]) {
145 if (player->argp[arg_index]) {
146 if (player->argp[arg_index+1]) {
147 key = player->argp[arg_index++];
148 ptr = player->argp[arg_index++];
152 } else if (arg_index == 3) {
153 key = getin(buf, &ptr);
182 if ((err = edit_nat(np, key, arg, ptr)) != RET_OK)
186 if (!check_sect_ok(§))
188 if ((err = edit_sect(§, key, arg, ptr)) != RET_OK)
194 if (!check_ship_ok(&ship))
196 if ((err = edit_ship(&ship, key, arg, ptr)) != RET_OK)
198 if (!ef_ensure_space(EF_SHIP, ship.shp_uid, 50))
200 if (!putship(ship.shp_uid, &ship))
204 if (!check_land_ok(&land))
206 if ((err = edit_land(&land, key, arg, ptr)) != RET_OK)
208 if (!ef_ensure_space(EF_LAND, land.lnd_uid, 50))
210 if (!putland(land.lnd_uid, &land))
214 if (!check_plane_ok(&plane))
216 if ((err = edit_plane(&plane, key, arg, ptr)) != RET_OK)
218 if (!ef_ensure_space(EF_PLANE, plane.pln_uid, 50))
220 if (!putplane(plane.pln_uid, &plane))
228 benefit(natid who, int good)
235 nreport(player->cnum, N_AIDS, who, 1);
238 nreport(player->cnum, N_HURTS, who, 1);
243 noise(struct sctstr *sptr, char *name, int old, int new)
245 pr("%s of %s changed from %d to %d\n",
246 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
249 "%s in %s was changed from %d to %d by an act of %s\n",
250 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
251 old, new, cname(player->cnum));
252 benefit(sptr->sct_own, old < new);
256 print_sect(struct sctstr *sect)
258 pr("Location <L>: %s\t", xyas(sect->sct_x, sect->sct_y, player->cnum));
259 pr("Distribution sector <D>: %s\n",
260 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum));
261 pr("Designation <s>: %c\tNew designation <S>: %c\n",
262 dchr[sect->sct_type].d_mnem, dchr[sect->sct_newtype].d_mnem);
263 pr("own oo eff mob min gld frt oil urn wrk lty che ctg plg ptime fall avail\n");
264 pr(" o O e m i g f c u w l x X p t F a\n");
265 pr("%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %5d %4d %5d\n",
266 sect->sct_own, sect->sct_oldown, sect->sct_effic, sect->sct_mobil,
267 sect->sct_min, sect->sct_gmin, sect->sct_fertil, sect->sct_oil,
268 sect->sct_uran, sect->sct_work, sect->sct_loyal,
269 sect->sct_che, sect->sct_che_target,
270 sect->sct_pstage, sect->sct_ptime,
271 sect->sct_fallout, sect->sct_avail);
273 pr("Mines <M>: %d\n", sect->sct_mines);
274 pr("Road %% <R>: %d\t", sect->sct_road);
275 pr("Rail %% <r>: %d\t", sect->sct_rail);
276 pr("Defense %% <d>: %d\n", sect->sct_defense);
280 print_nat(struct natstr *np)
284 pr("Country #: %2d\n", np->nat_cnum);
285 pr("Name <n>: %-20s\t", np->nat_cnam);
286 pr("Representative <r>: %-20s\n", np->nat_pnam);
287 pr("BTUs <b>: %3d\t\t\t", np->nat_btu);
288 pr("Reserves <m>: %5d\n", np->nat_reserve);
289 pr("Capital <c>: %s\t\t",
290 xyas(np->nat_xcap, np->nat_ycap, player->cnum));
291 pr("Origin <o>: %3s\n",
292 xyas(np->nat_xorg, np->nat_yorg, player->cnum));
293 pr("Status <s>: 0x%x\t\t\t", np->nat_stat);
294 pr("Seconds Used <u>: %3d\n", np->nat_timeused);
295 pr("Technology <T>: %.2f\t\t", np->nat_level[NAT_TLEV]);
296 pr("Research <R>: %.2f\n", np->nat_level[NAT_RLEV]);
297 pr("Education <E>: %.2f\t\t", np->nat_level[NAT_ELEV]);
298 pr("Happiness <H>: %.2f\n", np->nat_level[NAT_HLEV]);
299 pr("Money <M>: $%6d\n", np->nat_money);
300 pr("Telegrams <t>: %6d\n", np->nat_tgms);
302 pr("Countries contacted: ");
303 for (i = 0; i < MAXNOC; i++) {
304 if (getcontact(np, i))
305 pr("%d(%d) ", i, getcontact(np, i));
312 print_plane(struct plnstr *plane)
314 pr("%s %s\n", prnatid(plane->pln_own), prplane(plane));
315 pr("UID <U>: %d\t\t", plane->pln_uid);
316 pr("Owner <O>: %d\t\t", plane->pln_own);
317 pr("Location <l>: %s\n",
318 xyas(plane->pln_x, plane->pln_y, player->cnum));
319 pr("Efficiency <e>: %d\t", plane->pln_effic);
320 pr("Mobility <m>: %d\n", plane->pln_mobil);
321 pr("Tech <t>: %d\t\t", plane->pln_tech);
322 pr("Wing <w>: %.1s\n", &plane->pln_wing);
323 pr("Range <r>: %d\t\t", plane->pln_range);
324 pr("Flags <f>: %d\n", plane->pln_flags);
325 pr("Ship <s>: %d\t\t", plane->pln_ship);
326 pr("Land Unit <y>: %d\t", plane->pln_land);
330 print_land(struct lndstr *land)
332 pr("%s %s\n", prnatid(land->lnd_own), prland(land));
333 pr("UID <U>: %d\n", land->lnd_uid);
334 pr("Owner <O>: %d\n", land->lnd_own);
335 pr("Location <L>: %s\n", xyas(land->lnd_x, land->lnd_y, player->cnum));
336 pr("Efficiency <e>: %d\t", land->lnd_effic);
337 pr("Mobility <M>: %d\n", land->lnd_mobil);
338 pr("Tech <t>: %d\t\t", land->lnd_tech);
339 pr("Army <a>: %.1s\n", &land->lnd_army);
340 pr("Fortification <F>: %d\t", land->lnd_harden);
341 pr("Land unit <Y>: %d\n", land->lnd_land);
342 pr("Ship <S>: %d\t\t", land->lnd_ship);
343 pr("Retreat percentage <Z>: %d\n", land->lnd_retreat);
344 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
345 land->lnd_rpath, land->lnd_rflags);
346 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
347 pr(" c m u f s g p i d o l h r\n");
348 pr("%3d", land->lnd_item[I_CIVIL]);
349 pr("%4d", land->lnd_item[I_MILIT]);
350 pr("%4d", land->lnd_item[I_UW]);
351 pr("%5d", land->lnd_item[I_FOOD]);
352 pr("%4d", land->lnd_item[I_SHELL]);
353 pr("%4d", land->lnd_item[I_GUN]);
354 pr("%5d", land->lnd_item[I_PETROL]);
355 pr("%5d", land->lnd_item[I_IRON]);
356 pr("%5d", land->lnd_item[I_DUST]);
357 pr("%5d", land->lnd_item[I_OIL]);
358 pr("%5d", land->lnd_item[I_LCM]);
359 pr("%5d", land->lnd_item[I_HCM]);
360 pr("%4d", land->lnd_item[I_RAD]);
365 print_ship(struct shpstr *ship)
367 pr("%s %s\n", prnatid(ship->shp_own), prship(ship));
368 pr("UID <U>: %d\n", ship->shp_uid);
369 pr("Owner <O>: %d\t\t\t", ship->shp_own);
370 pr("Location <L>: %s\n", xyas(ship->shp_x, ship->shp_y, player->cnum));
371 pr("Tech <T>: %d\t\t\t", ship->shp_tech);
372 pr("Efficiency <E>: %d\n", ship->shp_effic);
373 pr("Mobility <M>: %d\t\t", ship->shp_mobil);
374 pr("Fleet <F>: %.1s\n", &ship->shp_fleet);
375 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
376 ship->shp_rpath, ship->shp_rflags);
377 pr("Plague Stage <a>: %d\t\t", ship->shp_pstage);
378 pr("Plague Time <b>: %d\n", ship->shp_ptime);
379 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
380 pr(" c m u f s g p i d o l h r\n");
381 pr("%3d", ship->shp_item[I_CIVIL]);
382 pr("%4d", ship->shp_item[I_MILIT]);
383 pr("%4d", ship->shp_item[I_UW]);
384 pr("%5d", ship->shp_item[I_FOOD]);
385 pr("%4d", ship->shp_item[I_SHELL]);
386 pr("%4d", ship->shp_item[I_GUN]);
387 pr("%5d", ship->shp_item[I_PETROL]);
388 pr("%5d", ship->shp_item[I_IRON]);
389 pr("%5d", ship->shp_item[I_DUST]);
390 pr("%5d", ship->shp_item[I_OIL]);
391 pr("%5d", ship->shp_item[I_LCM]);
392 pr("%5d", ship->shp_item[I_HCM]);
393 pr("%4d", ship->shp_item[I_RAD]);
398 getin(char *buf, char **valp)
405 p = getstarg(NULL, "%c xxxxx -- thing value : ", line);
408 switch (parse(p, buf, argp, NULL, NULL, NULL)) {
419 #if 0 /* not needed right now */
421 warn_deprecated(char key)
423 pr("Key <%c> is deprecated and will go away in a future release\n", key);
428 edit_sect(struct sctstr *sect, char *key, int arg, char *p)
435 if (arg < 0 || arg >= MAXNOC)
437 pr("Owner of %s changed from %s to %s.\n",
438 xyas(sect->sct_x, sect->sct_y, player->cnum),
439 prnatid(sect->sct_own), prnatid(arg));
442 "Sector %s taken from you by an act of %s!\n",
443 xyas(sect->sct_x, sect->sct_y, sect->sct_own),
444 cname(player->cnum));
446 benefit(sect->sct_own, 0);
450 "Sector %s given to you by an act of %s!\n",
451 xyas(sect->sct_x, sect->sct_y, arg),
452 cname(player->cnum));
457 if (arg < 0 || arg >= MAXNOC)
459 pr("Old owner of %s changed from %s to %s.\n",
460 xyas(sect->sct_x, sect->sct_y, player->cnum),
461 prnatid(sect->sct_oldown), prnatid(arg));
462 sect->sct_oldown = arg;
465 new = LIMIT_TO(arg, 0, 100);
466 noise(sect, "Efficiency", sect->sct_effic, new);
467 sect->sct_effic = new;
470 new = LIMIT_TO(arg, -127, 127);
471 noise(sect, "Mobility", sect->sct_mobil, new);
472 sect->sct_mobil = new;
475 new = LIMIT_TO(arg, 0, 127);
476 noise(sect, "Iron ore content", sect->sct_min, new);
477 sect->sct_min = (unsigned char)new;
480 new = LIMIT_TO(arg, 0, 127);
481 noise(sect, "Gold content", sect->sct_gmin, new);
482 sect->sct_gmin = (unsigned char)new;
485 new = LIMIT_TO(arg, 0, 127);
486 noise(sect, "Fertility", sect->sct_fertil, new);
487 sect->sct_fertil = (unsigned char)new;
490 new = LIMIT_TO(arg, 0, 127);
491 noise(sect, "Oil content", sect->sct_oil, new);
492 sect->sct_oil = (unsigned char)new;
495 new = LIMIT_TO(arg, 0, 127);
496 noise(sect, "Uranium content", sect->sct_uran, new);
497 sect->sct_uran = (unsigned char)new;
500 new = LIMIT_TO(arg, 0, 100);
501 noise(sect, "Workforce percentage", sect->sct_work, new);
502 sect->sct_work = (unsigned char)new;
505 new = LIMIT_TO(arg, 0, 127);
506 pr("Loyalty of %s changed from %d to %d\n",
507 xyas(sect->sct_x, sect->sct_y, player->cnum),
508 sect->sct_loyal, new);
509 sect->sct_loyal = (unsigned char)new;
512 new = LIMIT_TO(arg, 0, CHE_MAX);
513 pr("Guerillas in %s changed from %d to %d\n",
514 xyas(sect->sct_x, sect->sct_y, player->cnum),
519 if (arg < 0 || arg >= MAXNOC)
521 pr("Che target of %s changed from %s to %s.\n",
522 xyas(sect->sct_x, sect->sct_y, player->cnum),
523 prnatid(sect->sct_che_target), prnatid(arg));
524 sect->sct_che_target = arg;
529 new = LIMIT_TO(arg, 0, PLG_EXPOSED);
530 pr("Plague stage of %s changed from %d to %d\n",
531 xyas(sect->sct_x, sect->sct_y, player->cnum),
532 sect->sct_pstage, new);
533 sect->sct_pstage = new;
536 new = LIMIT_TO(arg, 0, 32767);
537 pr("Plague time of %s changed from %d to %d\n",
538 xyas(sect->sct_x, sect->sct_y, player->cnum),
539 sect->sct_ptime, new);
540 sect->sct_ptime = new;
543 new = LIMIT_TO(arg, 0, FALLOUT_MAX);
544 pr("Fallout for sector %s changed from %d to %d\n",
545 xyas(sect->sct_x, sect->sct_y, player->cnum),
546 sect->sct_fallout, new);
547 sect->sct_fallout = new;
550 new = LIMIT_TO(arg, 0, 9999);
551 noise(sect, "Available workforce", sect->sct_avail, new);
552 sect->sct_avail = new;
555 new = LIMIT_TO(arg, 0, MINES_MAX);
556 sect->sct_mines = new;
557 pr("Mines changed to %d\n", new);
560 if (!sarg_xy(p, &newx, &newy))
564 ef_set_uid(EF_SECTOR, §, XYOFFSET(newx, newy));
567 if (!sarg_xy(p, &newx, &newy))
569 pr("Distribution location for sector %s changed from %s to %s\n",
570 xyas(sect->sct_x, sect->sct_y, player->cnum),
571 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
572 xyas(newx, newy, player->cnum));
573 sect->sct_dist_x = newx;
574 sect->sct_dist_y = newy;
577 new = sct_typematch(p);
580 pr("Designation for sector %s changed from %c to %c\n",
581 xyas(sect->sct_x, sect->sct_y, player->cnum),
582 dchr[sect->sct_type].d_mnem, dchr[new].d_mnem);
583 set_coastal(sect, sect->sct_type, new);
584 sect->sct_type = new;
587 new = sct_typematch(p);
590 pr("New designation for sector %s changed from %c to %c\n",
591 xyas(sect->sct_x, sect->sct_y, player->cnum),
592 dchr[sect->sct_newtype].d_mnem, dchr[new].d_mnem);
593 sect->sct_newtype = new;
596 new = LIMIT_TO(arg, 0, 100);
597 noise(sect, "Road percentage", sect->sct_road, new);
598 sect->sct_road = new;
601 new = LIMIT_TO(arg, 0, 100);
602 noise(sect, "Rail percentage", sect->sct_rail, new);
603 sect->sct_rail = new;
606 new = LIMIT_TO(arg, 0, 100);
607 noise(sect, "Defense percentage", sect->sct_defense, new);
608 sect->sct_defense = new;
611 pr("huh? (%s)\n", key);
618 edit_nat(struct natstr *np, char *key, int arg, char *p)
621 natid nat = np->nat_cnum;
622 float farg = (float)atof(p);
626 if (!check_nat_name(p, nat))
628 pr("Country name changed from %s to %s\n", np->nat_cnam, p);
629 strcpy(np->nat_cnam, p);
632 pr("Country representative changed from %s to %s\n",
634 strncpy(np->nat_pnam, p, sizeof(np->nat_pnam) - 1);
637 arg = LIMIT_TO(arg, 0, USHRT_MAX);
641 arg = LIMIT_TO(arg, 0, max_btus);
642 pr("BTU's changed from %d to %d\n", np->nat_btu, arg);
646 arg = LIMIT_TO(arg, 0, INT_MAX);
647 benefit(nat, np->nat_reserve < arg);
648 pr("Military reserves changed from %d to %d\n",
649 np->nat_reserve, arg);
651 "Military reserves changed from %d to %d by an act of %s\n",
652 np->nat_reserve, arg, cname(player->cnum));
653 np->nat_reserve = arg;
656 if (!sarg_xy(p, &newx, &newy))
658 pr("Capital coordinates changed from %s to %s\n",
659 xyas(np->nat_xcap, np->nat_ycap, player->cnum),
660 xyas(newx, newy, player->cnum));
665 if (!sarg_xy(p, &newx, &newy))
667 pr("Origin coordinates changed from %s to %s\n",
668 xyas(np->nat_xorg, np->nat_yorg, player->cnum),
669 xyas(newx, newy, player->cnum));
674 np->nat_stat = LIMIT_TO(arg, STAT_UNUSED, STAT_GOD);
677 arg = LIMIT_TO(arg, 0, m_m_p_d * 60);
678 pr("Number of seconds used changed from %d to %d.\n",
679 np->nat_timeused, arg);
680 np->nat_timeused = arg;
683 pr("Money changed from %d to %d\n", np->nat_money, arg);
684 wu(0, nat, "Money changed from %d to %d by an act of %s\n",
685 np->nat_money, arg, cname(player->cnum));
689 farg = MAX(0.0, farg);
690 pr("Tech changed from %.2f to %.2f.\n",
691 np->nat_level[NAT_TLEV], farg);
692 np->nat_level[NAT_TLEV] = farg;
695 farg = MAX(0.0, farg);
696 pr("Research changed from %.2f to %.2f.\n",
697 np->nat_level[NAT_RLEV], farg);
698 np->nat_level[NAT_RLEV] = farg;
701 farg = MAX(0.0, farg);
702 pr("Education changed from %.2f to %.2f.\n",
703 np->nat_level[NAT_ELEV], farg);
704 np->nat_level[NAT_ELEV] = farg;
707 farg = MAX(0.0, farg);
708 pr("Happiness changed from %.2f to %.2f.\n",
709 np->nat_level[NAT_HLEV], farg);
710 np->nat_level[NAT_HLEV] = farg;
713 pr("huh? (%s)\n", key);
721 edit_ship(struct shpstr *ship, char *key, int arg, char *p)
723 struct mchrstr *mcp = &mchr[ship->shp_type];
730 arg = LIMIT_TO(arg, 0, PLG_EXPOSED);
731 ship->shp_pstage = arg;
734 arg = LIMIT_TO(arg, 0, 32767);
735 ship->shp_ptime = arg;
738 strncpy(ship->shp_rpath, p, sizeof(ship->shp_rpath) - 1);
741 ship->shp_rflags = arg;
744 ef_set_uid(EF_SHIP, ship, arg);
747 if (arg < 0 || arg >= MAXNOC)
750 wu(0, ship->shp_own, "%s taken from you by an act of %s!\n",
751 prship(ship), cname(player->cnum));
753 wu(0, arg, "%s given to you by an act of %s!\n",
754 prship(ship), cname(player->cnum));
758 if (!sarg_xy(p, &newx, &newy))
764 arg = LIMIT_TO(arg, mcp->m_tech, SHRT_MAX);
765 shp_set_tech(ship, arg);
768 ship->shp_effic = LIMIT_TO(arg, SHIP_MINEFF, 100);
771 arg = LIMIT_TO(arg, -127, 127);
772 ship->shp_mobil = arg;
777 else if (isalpha(p[0]))
778 ship->shp_fleet = p[0];
780 pr("%c: invalid fleet\n", p[0]);
797 ip = item_by_name(key);
798 arg = LIMIT_TO(arg, 0, mchr[ship->shp_type].m_item[ip->i_uid]);
799 ship->shp_item[ip->i_uid] = arg;
802 pr("huh? (%s)\n", key);
809 edit_land(struct lndstr *land, char *key, int arg, char *p)
811 struct lchrstr *lcp = &lchr[land->lnd_type];
818 if (arg < -1 || arg >= ef_nelem(EF_LAND))
820 if (arg >= 0 && arg != land->lnd_land)
822 land->lnd_land = arg;
825 ef_set_uid(EF_LAND, land, arg);
828 if (arg < 0 || arg >= MAXNOC)
831 wu(0, land->lnd_own, "%s taken from you by an act of %s!\n",
832 prland(land), cname(player->cnum));
834 wu(0, arg, "%s given to you by an act of %s!\n",
835 prland(land), cname(player->cnum));
839 if (!sarg_xy(p, &newx, &newy))
845 land->lnd_effic = LIMIT_TO(arg, LAND_MINEFF, 100);
848 arg = LIMIT_TO(arg, -127, 127);
849 land->lnd_mobil = arg;
852 arg = LIMIT_TO(arg, lcp->l_tech, SHRT_MAX);
853 lnd_set_tech(land, arg);
858 else if (isalpha(p[0]))
859 land->lnd_army = p[0];
861 pr("%c: invalid army\n", p[0]);
866 land->lnd_harden = LIMIT_TO(arg, 0, 127);
869 if (arg < -1 || arg >= ef_nelem(EF_SHIP))
871 if (arg >= 0 && arg != land->lnd_ship)
873 land->lnd_ship = arg;
876 arg = LIMIT_TO(arg, 0, 100);
877 land->lnd_retreat = arg;
880 strncpy(land->lnd_rpath, p, sizeof(land->lnd_rpath) - 1);
883 land->lnd_rflags = arg;
898 ip = item_by_name(key);
899 arg = LIMIT_TO(arg, 0, lchr[land->lnd_type].l_item[ip->i_uid]);
900 land->lnd_item[ip->i_uid] = arg;
903 pr("huh? (%s)\n", key);
910 edit_plane(struct plnstr *plane, char *key, int arg, char *p)
912 struct plchrstr *pcp = &plchr[plane->pln_type];
917 ef_set_uid(EF_PLANE, plane, arg);
920 if (!sarg_xy(p, &newx, &newy))
926 if (arg < 0 || arg >= MAXNOC)
929 wu(0, plane->pln_own, "%s taken from you by an act of %s!\n",
930 prplane(plane), cname(player->cnum));
932 wu(0, arg, "%s given to you by an act of %s!\n",
933 prplane(plane), cname(player->cnum));
934 plane->pln_own = arg;
937 plane->pln_effic = LIMIT_TO(arg, PLANE_MINEFF, 100);
940 plane->pln_mobil = LIMIT_TO(arg, -127, 127);
943 arg = LIMIT_TO(arg, pcp->pl_tech, SHRT_MAX);
944 pln_set_tech(plane, arg);
949 else if (isalpha(p[0]))
950 plane->pln_wing = p[0];
952 pr("%c: invalid wing\n", p[0]);
957 arg = LIMIT_TO(arg, 0, pl_range(pcp, plane->pln_tech));
958 plane->pln_range = (unsigned char)arg;
961 if (arg < -1 || arg >= ef_nelem(EF_SHIP))
963 if (arg >= 0 && arg != plane->pln_ship)
964 plane->pln_land = -1;
965 plane->pln_ship = arg;
968 if (arg < -1 || arg >= ef_nelem(EF_LAND))
970 if (arg >= 0 && arg != plane->pln_land)
971 plane->pln_ship = -1;
972 plane->pln_land = arg;
975 plane->pln_flags = arg;
978 pr("huh? (%s)\n", key);