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 goodness)
230 if (opt_GODNEWS && who && goodness)
231 nreport(player->cnum, goodness > 0 ? N_AIDS : N_HURTS, who, 1);
235 noise(struct sctstr *sptr, char *name, int old, int new)
237 pr("%s of %s changed from %d to %d\n",
238 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
239 if (sptr->sct_own && new != old)
241 "%s in %s was changed from %d to %d by an act of %s\n",
242 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
243 old, new, cname(player->cnum));
244 benefit(sptr->sct_own, new - old);
248 print_sect(struct sctstr *sect)
250 pr("Location <L>: %s\t", xyas(sect->sct_x, sect->sct_y, player->cnum));
251 pr("Distribution sector <D>: %s\n",
252 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum));
253 pr("Designation <s>: %c\tNew designation <S>: %c\n",
254 dchr[sect->sct_type].d_mnem, dchr[sect->sct_newtype].d_mnem);
255 pr("own oo eff mob min gld frt oil urn wrk lty che ctg plg ptime fall avail\n");
256 pr(" o O e m i g f c u w l x X p t F a\n");
257 pr("%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %5d %4d %5d\n",
258 sect->sct_own, sect->sct_oldown, sect->sct_effic, sect->sct_mobil,
259 sect->sct_min, sect->sct_gmin, sect->sct_fertil, sect->sct_oil,
260 sect->sct_uran, sect->sct_work, sect->sct_loyal,
261 sect->sct_che, sect->sct_che_target,
262 sect->sct_pstage, sect->sct_ptime,
263 sect->sct_fallout, sect->sct_avail);
265 pr("Mines <M>: %d\n", sect->sct_mines);
266 pr("Road %% <R>: %d\t", sect->sct_road);
267 pr("Rail %% <r>: %d\t", sect->sct_rail);
268 pr("Defense %% <d>: %d\n", sect->sct_defense);
272 print_nat(struct natstr *np)
276 pr("Country #: %2d\n", np->nat_cnum);
277 pr("Name <n>: %-20s\t", np->nat_cnam);
278 pr("Representative <r>: %-20s\n", np->nat_pnam);
279 pr("BTUs <b>: %3d\t\t\t", np->nat_btu);
280 pr("Reserves <m>: %5d\n", np->nat_reserve);
281 pr("Capital <c>: %s\t\t",
282 xyas(np->nat_xcap, np->nat_ycap, player->cnum));
283 pr("Origin <o>: %3s\n",
284 xyas(np->nat_xorg, np->nat_yorg, player->cnum));
285 pr("Status <s>: 0x%x\t\t\t", np->nat_stat);
286 pr("Seconds Used <u>: %3d\n", np->nat_timeused);
287 pr("Technology <T>: %.2f\t\t", np->nat_level[NAT_TLEV]);
288 pr("Research <R>: %.2f\n", np->nat_level[NAT_RLEV]);
289 pr("Education <E>: %.2f\t\t", np->nat_level[NAT_ELEV]);
290 pr("Happiness <H>: %.2f\n", np->nat_level[NAT_HLEV]);
291 pr("Money <M>: $%6d\n", np->nat_money);
292 pr("Telegrams <t>: %6d\n", np->nat_tgms);
294 pr("Countries contacted: ");
295 for (i = 0; i < MAXNOC; i++) {
296 if (getcontact(np, i))
297 pr("%d(%d) ", i, getcontact(np, i));
304 print_plane(struct plnstr *plane)
306 pr("%s %s\n", prnatid(plane->pln_own), prplane(plane));
307 pr("UID <U>: %d\t\t", plane->pln_uid);
308 pr("Owner <O>: %d\t\t", plane->pln_own);
309 pr("Location <l>: %s\n",
310 xyas(plane->pln_x, plane->pln_y, player->cnum));
311 pr("Efficiency <e>: %d\t", plane->pln_effic);
312 pr("Mobility <m>: %d\n", plane->pln_mobil);
313 pr("Tech <t>: %d\t\t", plane->pln_tech);
314 pr("Wing <w>: %.1s\n", &plane->pln_wing);
315 pr("Range <r>: %d\t\t", plane->pln_range);
316 pr("Flags <f>: %d\n", plane->pln_flags);
317 pr("Ship <s>: %d\t\t", plane->pln_ship);
318 pr("Land Unit <y>: %d\t", plane->pln_land);
322 print_land(struct lndstr *land)
324 pr("%s %s\n", prnatid(land->lnd_own), prland(land));
325 pr("UID <U>: %d\n", land->lnd_uid);
326 pr("Owner <O>: %d\n", land->lnd_own);
327 pr("Location <L>: %s\n", xyas(land->lnd_x, land->lnd_y, player->cnum));
328 pr("Efficiency <e>: %d\t", land->lnd_effic);
329 pr("Mobility <M>: %d\n", land->lnd_mobil);
330 pr("Tech <t>: %d\t\t", land->lnd_tech);
331 pr("Army <a>: %.1s\n", &land->lnd_army);
332 pr("Fortification <F>: %d\t", land->lnd_harden);
333 pr("Land unit <Y>: %d\n", land->lnd_land);
334 pr("Ship <S>: %d\t\t", land->lnd_ship);
335 pr("Retreat percentage <Z>: %d\n", land->lnd_retreat);
336 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
337 land->lnd_rpath, land->lnd_rflags);
338 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
339 pr(" c m u f s g p i d o l h r\n");
340 pr("%3d", land->lnd_item[I_CIVIL]);
341 pr("%4d", land->lnd_item[I_MILIT]);
342 pr("%4d", land->lnd_item[I_UW]);
343 pr("%5d", land->lnd_item[I_FOOD]);
344 pr("%4d", land->lnd_item[I_SHELL]);
345 pr("%4d", land->lnd_item[I_GUN]);
346 pr("%5d", land->lnd_item[I_PETROL]);
347 pr("%5d", land->lnd_item[I_IRON]);
348 pr("%5d", land->lnd_item[I_DUST]);
349 pr("%5d", land->lnd_item[I_OIL]);
350 pr("%5d", land->lnd_item[I_LCM]);
351 pr("%5d", land->lnd_item[I_HCM]);
352 pr("%4d", land->lnd_item[I_RAD]);
357 print_ship(struct shpstr *ship)
359 pr("%s %s\n", prnatid(ship->shp_own), prship(ship));
360 pr("UID <U>: %d\n", ship->shp_uid);
361 pr("Owner <O>: %d\t\t\t", ship->shp_own);
362 pr("Location <L>: %s\n", xyas(ship->shp_x, ship->shp_y, player->cnum));
363 pr("Tech <T>: %d\t\t\t", ship->shp_tech);
364 pr("Efficiency <E>: %d\n", ship->shp_effic);
365 pr("Mobility <M>: %d\t\t", ship->shp_mobil);
366 pr("Fleet <F>: %.1s\n", &ship->shp_fleet);
367 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
368 ship->shp_rpath, ship->shp_rflags);
369 pr("Plague Stage <a>: %d\t\t", ship->shp_pstage);
370 pr("Plague Time <b>: %d\n", ship->shp_ptime);
371 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
372 pr(" c m u f s g p i d o l h r\n");
373 pr("%3d", ship->shp_item[I_CIVIL]);
374 pr("%4d", ship->shp_item[I_MILIT]);
375 pr("%4d", ship->shp_item[I_UW]);
376 pr("%5d", ship->shp_item[I_FOOD]);
377 pr("%4d", ship->shp_item[I_SHELL]);
378 pr("%4d", ship->shp_item[I_GUN]);
379 pr("%5d", ship->shp_item[I_PETROL]);
380 pr("%5d", ship->shp_item[I_IRON]);
381 pr("%5d", ship->shp_item[I_DUST]);
382 pr("%5d", ship->shp_item[I_OIL]);
383 pr("%5d", ship->shp_item[I_LCM]);
384 pr("%5d", ship->shp_item[I_HCM]);
385 pr("%4d", ship->shp_item[I_RAD]);
390 getin(char *buf, char **valp)
397 p = getstarg(NULL, "%c xxxxx -- thing value : ", line);
400 switch (parse(p, buf, argp, NULL, NULL, NULL)) {
411 #if 0 /* not needed right now */
413 warn_deprecated(char key)
415 pr("Key <%c> is deprecated and will go away in a future release\n", key);
420 edit_sect(struct sctstr *sect, char *key, int arg, char *p)
427 if (arg < 0 || arg >= MAXNOC)
429 pr("Owner of %s changed from %s to %s.\n",
430 xyas(sect->sct_x, sect->sct_y, player->cnum),
431 prnatid(sect->sct_own), prnatid(arg));
432 if (arg == sect->sct_own)
436 "Sector %s taken from you by an act of %s!\n",
437 xyas(sect->sct_x, sect->sct_y, sect->sct_own),
438 cname(player->cnum));
440 benefit(sect->sct_own, -1);
444 "Sector %s given to you by an act of %s!\n",
445 xyas(sect->sct_x, sect->sct_y, arg),
446 cname(player->cnum));
451 if (arg < 0 || arg >= MAXNOC)
453 pr("Old owner of %s changed from %s to %s.\n",
454 xyas(sect->sct_x, sect->sct_y, player->cnum),
455 prnatid(sect->sct_oldown), prnatid(arg));
456 sect->sct_oldown = arg;
459 new = LIMIT_TO(arg, 0, 100);
460 noise(sect, "Efficiency", sect->sct_effic, new);
461 sect->sct_effic = new;
464 new = LIMIT_TO(arg, -127, 127);
465 noise(sect, "Mobility", sect->sct_mobil, new);
466 sect->sct_mobil = new;
469 new = LIMIT_TO(arg, 0, 127);
470 noise(sect, "Iron ore content", sect->sct_min, new);
471 sect->sct_min = (unsigned char)new;
474 new = LIMIT_TO(arg, 0, 127);
475 noise(sect, "Gold content", sect->sct_gmin, new);
476 sect->sct_gmin = (unsigned char)new;
479 new = LIMIT_TO(arg, 0, 127);
480 noise(sect, "Fertility", sect->sct_fertil, new);
481 sect->sct_fertil = (unsigned char)new;
484 new = LIMIT_TO(arg, 0, 127);
485 noise(sect, "Oil content", sect->sct_oil, new);
486 sect->sct_oil = (unsigned char)new;
489 new = LIMIT_TO(arg, 0, 127);
490 noise(sect, "Uranium content", sect->sct_uran, new);
491 sect->sct_uran = (unsigned char)new;
494 new = LIMIT_TO(arg, 0, 100);
495 noise(sect, "Workforce percentage", sect->sct_work, new);
496 sect->sct_work = (unsigned char)new;
499 new = LIMIT_TO(arg, 0, 127);
500 pr("Loyalty of %s changed from %d to %d\n",
501 xyas(sect->sct_x, sect->sct_y, player->cnum),
502 sect->sct_loyal, new);
503 sect->sct_loyal = (unsigned char)new;
506 new = LIMIT_TO(arg, 0, CHE_MAX);
507 pr("Guerillas in %s changed from %d to %d\n",
508 xyas(sect->sct_x, sect->sct_y, player->cnum),
513 if (arg < 0 || arg >= MAXNOC)
515 pr("Che target of %s changed from %s to %s.\n",
516 xyas(sect->sct_x, sect->sct_y, player->cnum),
517 prnatid(sect->sct_che_target), prnatid(arg));
518 sect->sct_che_target = arg;
523 new = LIMIT_TO(arg, 0, PLG_EXPOSED);
524 pr("Plague stage of %s changed from %d to %d\n",
525 xyas(sect->sct_x, sect->sct_y, player->cnum),
526 sect->sct_pstage, new);
527 sect->sct_pstage = new;
530 new = LIMIT_TO(arg, 0, 32767);
531 pr("Plague time of %s changed from %d to %d\n",
532 xyas(sect->sct_x, sect->sct_y, player->cnum),
533 sect->sct_ptime, new);
534 sect->sct_ptime = new;
537 new = LIMIT_TO(arg, 0, FALLOUT_MAX);
538 pr("Fallout for sector %s changed from %d to %d\n",
539 xyas(sect->sct_x, sect->sct_y, player->cnum),
540 sect->sct_fallout, new);
541 sect->sct_fallout = new;
544 new = LIMIT_TO(arg, 0, 9999);
545 noise(sect, "Available workforce", sect->sct_avail, new);
546 sect->sct_avail = new;
549 new = LIMIT_TO(arg, 0, MINES_MAX);
550 sect->sct_mines = new;
551 pr("Mines changed to %d\n", new);
554 if (!sarg_xy(p, &newx, &newy))
558 ef_set_uid(EF_SECTOR, §, XYOFFSET(newx, newy));
561 if (!sarg_xy(p, &newx, &newy))
563 pr("Distribution location for sector %s changed from %s to %s\n",
564 xyas(sect->sct_x, sect->sct_y, player->cnum),
565 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
566 xyas(newx, newy, player->cnum));
567 sect->sct_dist_x = newx;
568 sect->sct_dist_y = newy;
571 new = sct_typematch(p);
574 pr("Designation for sector %s changed from %c to %c\n",
575 xyas(sect->sct_x, sect->sct_y, player->cnum),
576 dchr[sect->sct_type].d_mnem, dchr[new].d_mnem);
577 set_coastal(sect, sect->sct_type, new);
578 sect->sct_type = new;
581 new = sct_typematch(p);
584 pr("New designation for sector %s changed from %c to %c\n",
585 xyas(sect->sct_x, sect->sct_y, player->cnum),
586 dchr[sect->sct_newtype].d_mnem, dchr[new].d_mnem);
587 sect->sct_newtype = new;
590 new = LIMIT_TO(arg, 0, 100);
591 noise(sect, "Road percentage", sect->sct_road, new);
592 sect->sct_road = new;
595 new = LIMIT_TO(arg, 0, 100);
596 noise(sect, "Rail percentage", sect->sct_rail, new);
597 sect->sct_rail = new;
600 new = LIMIT_TO(arg, 0, 100);
601 noise(sect, "Defense percentage", sect->sct_defense, new);
602 sect->sct_defense = new;
605 pr("huh? (%s)\n", key);
612 edit_nat(struct natstr *np, char *key, int arg, char *p)
615 natid nat = np->nat_cnum;
616 float farg = (float)atof(p);
620 if (!check_nat_name(p, nat))
622 pr("Country name changed from %s to %s\n", np->nat_cnam, p);
623 strcpy(np->nat_cnam, p);
626 pr("Country representative changed from %s to %s\n",
628 strncpy(np->nat_pnam, p, sizeof(np->nat_pnam) - 1);
631 arg = LIMIT_TO(arg, 0, USHRT_MAX);
635 arg = LIMIT_TO(arg, 0, max_btus);
636 pr("BTU's changed from %d to %d\n", np->nat_btu, arg);
640 arg = LIMIT_TO(arg, 0, INT_MAX);
641 benefit(nat, arg - np->nat_reserve);
642 pr("Military reserves changed from %d to %d\n",
643 np->nat_reserve, arg);
644 if (arg == np->nat_reserve)
647 "Military reserves changed from %d to %d by an act of %s\n",
648 np->nat_reserve, arg, cname(player->cnum));
649 np->nat_reserve = arg;
652 if (!sarg_xy(p, &newx, &newy))
654 pr("Capital coordinates changed from %s to %s\n",
655 xyas(np->nat_xcap, np->nat_ycap, player->cnum),
656 xyas(newx, newy, player->cnum));
661 if (!sarg_xy(p, &newx, &newy))
663 pr("Origin coordinates changed from %s to %s\n",
664 xyas(np->nat_xorg, np->nat_yorg, player->cnum),
665 xyas(newx, newy, player->cnum));
670 np->nat_stat = LIMIT_TO(arg, STAT_UNUSED, STAT_GOD);
673 arg = LIMIT_TO(arg, 0, m_m_p_d * 60);
674 pr("Number of seconds used changed from %d to %d.\n",
675 np->nat_timeused, arg);
676 np->nat_timeused = arg;
679 pr("Money changed from %d to %d\n", np->nat_money, arg);
680 if (arg == np->nat_money)
682 wu(0, nat, "Money changed from %d to %d by an act of %s\n",
683 np->nat_money, arg, cname(player->cnum));
687 farg = MAX(0.0, farg);
688 pr("Tech changed from %.2f to %.2f.\n",
689 np->nat_level[NAT_TLEV], farg);
690 np->nat_level[NAT_TLEV] = farg;
693 farg = MAX(0.0, farg);
694 pr("Research changed from %.2f to %.2f.\n",
695 np->nat_level[NAT_RLEV], farg);
696 np->nat_level[NAT_RLEV] = farg;
699 farg = MAX(0.0, farg);
700 pr("Education changed from %.2f to %.2f.\n",
701 np->nat_level[NAT_ELEV], farg);
702 np->nat_level[NAT_ELEV] = farg;
705 farg = MAX(0.0, farg);
706 pr("Happiness changed from %.2f to %.2f.\n",
707 np->nat_level[NAT_HLEV], farg);
708 np->nat_level[NAT_HLEV] = farg;
711 pr("huh? (%s)\n", key);
719 edit_ship(struct shpstr *ship, char *key, int arg, char *p)
721 struct mchrstr *mcp = &mchr[ship->shp_type];
728 arg = LIMIT_TO(arg, 0, PLG_EXPOSED);
729 ship->shp_pstage = arg;
732 arg = LIMIT_TO(arg, 0, 32767);
733 ship->shp_ptime = arg;
736 strncpy(ship->shp_rpath, p, sizeof(ship->shp_rpath) - 1);
739 ship->shp_rflags = arg;
742 ef_set_uid(EF_SHIP, ship, arg);
745 if (arg < 0 || arg >= MAXNOC)
747 if (arg == ship->shp_own)
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)
830 if (arg == land->lnd_own)
833 wu(0, land->lnd_own, "%s taken from you by an act of %s!\n",
834 prland(land), cname(player->cnum));
836 wu(0, arg, "%s given to you by an act of %s!\n",
837 prland(land), cname(player->cnum));
841 if (!sarg_xy(p, &newx, &newy))
847 land->lnd_effic = LIMIT_TO(arg, LAND_MINEFF, 100);
850 arg = LIMIT_TO(arg, -127, 127);
851 land->lnd_mobil = arg;
854 arg = LIMIT_TO(arg, lcp->l_tech, SHRT_MAX);
855 lnd_set_tech(land, arg);
860 else if (isalpha(p[0]))
861 land->lnd_army = p[0];
863 pr("%c: invalid army\n", p[0]);
868 land->lnd_harden = LIMIT_TO(arg, 0, 127);
871 if (arg < -1 || arg >= ef_nelem(EF_SHIP))
873 if (arg >= 0 && arg != land->lnd_ship)
875 land->lnd_ship = arg;
878 arg = LIMIT_TO(arg, 0, 100);
879 land->lnd_retreat = arg;
882 strncpy(land->lnd_rpath, p, sizeof(land->lnd_rpath) - 1);
885 land->lnd_rflags = arg;
900 ip = item_by_name(key);
901 arg = LIMIT_TO(arg, 0, lchr[land->lnd_type].l_item[ip->i_uid]);
902 land->lnd_item[ip->i_uid] = arg;
905 pr("huh? (%s)\n", key);
912 edit_plane(struct plnstr *plane, char *key, int arg, char *p)
914 struct plchrstr *pcp = &plchr[plane->pln_type];
919 ef_set_uid(EF_PLANE, plane, arg);
922 if (!sarg_xy(p, &newx, &newy))
928 if (arg < 0 || arg >= MAXNOC)
930 if (arg == plane->pln_own)
933 wu(0, plane->pln_own, "%s taken from you by an act of %s!\n",
934 prplane(plane), cname(player->cnum));
936 wu(0, arg, "%s given to you by an act of %s!\n",
937 prplane(plane), cname(player->cnum));
938 plane->pln_own = arg;
941 plane->pln_effic = LIMIT_TO(arg, PLANE_MINEFF, 100);
944 plane->pln_mobil = LIMIT_TO(arg, -127, 127);
947 arg = LIMIT_TO(arg, pcp->pl_tech, SHRT_MAX);
948 pln_set_tech(plane, arg);
953 else if (isalpha(p[0]))
954 plane->pln_wing = p[0];
956 pr("%c: invalid wing\n", p[0]);
961 arg = LIMIT_TO(arg, 0, pl_range(pcp, plane->pln_tech));
962 plane->pln_range = (unsigned char)arg;
965 if (arg < -1 || arg >= ef_nelem(EF_SHIP))
967 if (arg >= 0 && arg != plane->pln_ship)
968 plane->pln_land = -1;
969 plane->pln_ship = arg;
972 if (arg < -1 || arg >= ef_nelem(EF_LAND))
974 if (arg >= 0 && arg != plane->pln_land)
975 plane->pln_ship = -1;
976 plane->pln_land = arg;
979 plane->pln_flags = arg;
982 pr("huh? (%s)\n", key);