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
51 static void print_sect(struct sctstr *);
52 static void print_nat(struct natstr *);
53 static void print_plane(struct plnstr *);
54 static void print_land(struct lndstr *);
55 static void print_ship(struct shpstr *);
56 static char *getin(char *, char **);
57 static int edit_sect(struct sctstr *, char *, int, char *);
58 static int edit_nat(struct natstr *, char *, int, char *);
59 static int edit_ship(struct shpstr *, char *, int, char *);
60 static int edit_land(struct lndstr *, char *, int, char *);
61 static int edit_plane(struct plnstr *, char *, int, char *);
81 what = getstarg(player->argp[1],
82 "Edit what (country, land, ship, plane, nuke, unit)? ",
89 if (!(ptr = getstarg(player->argp[2], "Sector : ", buf)))
91 if (!sarg_xy(ptr, &x, &y))
93 if (!getsect(x, y, §))
97 np = natargp(player->argp[2], "Country? ");
102 if ((num = onearg(player->argp[2], "Plane number? ")) < 0)
104 if (!getplane(num, &plane))
108 if ((num = onearg(player->argp[2], "Ship number? ")) < 0)
110 if (!getship(num, &ship))
114 if ((num = onearg(player->argp[2], "Unit number? ")) < 0)
116 if (!getland(num, &land))
120 pr("Not implemented yet.\n");
126 if (!player->argp[3]) {
146 if (player->argp[arg_index]) {
147 if (player->argp[arg_index+1]) {
148 key = player->argp[arg_index++];
149 ptr = player->argp[arg_index++];
153 } else if (arg_index == 3) {
154 key = getin(buf, &ptr);
183 if ((err = edit_nat(np, key, arg, ptr)) != RET_OK)
187 if (!check_sect_ok(§))
189 if ((err = edit_sect(§, key, arg, ptr)) != RET_OK)
195 if (!check_ship_ok(&ship))
197 if ((err = edit_ship(&ship, key, arg, ptr)) != RET_OK)
199 if (!ef_ensure_space(EF_SHIP, ship.shp_uid, 50))
201 if (!putship(ship.shp_uid, &ship))
205 if (!check_land_ok(&land))
207 if ((err = edit_land(&land, key, arg, ptr)) != RET_OK)
209 if (!ef_ensure_space(EF_LAND, land.lnd_uid, 50))
211 if (!putland(land.lnd_uid, &land))
215 if (!check_plane_ok(&plane))
217 if ((err = edit_plane(&plane, key, arg, ptr)) != RET_OK)
219 if (!ef_ensure_space(EF_PLANE, plane.pln_uid, 50))
221 if (!putplane(plane.pln_uid, &plane))
229 benefit(natid who, int goodness)
231 if (opt_GODNEWS && getnatp(who)->nat_stat != STAT_GOD && goodness)
232 nreport(player->cnum, goodness > 0 ? N_AIDS : N_HURTS, who, 1);
236 noise(struct sctstr *sptr, char *name, int old, int new)
238 pr("%s of %s changed from %d to %d\n",
239 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
240 if (sptr->sct_own && sptr->sct_own != player->cnum && new != old)
242 "%s in %s was changed from %d to %d by an act of %s\n",
243 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
244 old, new, cname(player->cnum));
245 benefit(sptr->sct_own, new - old);
249 print_sect(struct sctstr *sect)
251 pr("Location <L>: %s\t", xyas(sect->sct_x, sect->sct_y, player->cnum));
252 pr("Distribution sector <D>: %s\n",
253 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum));
254 pr("Designation <s>: %c\tNew designation <S>: %c\n",
255 dchr[sect->sct_type].d_mnem, dchr[sect->sct_newtype].d_mnem);
256 pr("own oo eff mob min gld frt oil urn wrk lty che ctg plg ptime fall avail\n");
257 pr(" o O e m i g f c u w l x X p t F a\n");
258 pr("%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %5d %4d %5d\n",
259 sect->sct_own, sect->sct_oldown, sect->sct_effic, sect->sct_mobil,
260 sect->sct_min, sect->sct_gmin, sect->sct_fertil, sect->sct_oil,
261 sect->sct_uran, sect->sct_work, sect->sct_loyal,
262 sect->sct_che, sect->sct_che_target,
263 sect->sct_pstage, sect->sct_ptime,
264 sect->sct_fallout, sect->sct_avail);
266 pr("Mines <M>: %d\n", sect->sct_mines);
267 pr("Road %% <R>: %d\t", sect->sct_road);
268 pr("Rail %% <r>: %d\t", sect->sct_rail);
269 pr("Defense %% <d>: %d\n", sect->sct_defense);
273 print_nat(struct natstr *np)
277 pr("Country #: %2d\n", np->nat_cnum);
278 pr("Name <n>: %-20s\t", np->nat_cnam);
279 pr("Representative <r>: %-20s\n", np->nat_pnam);
280 pr("BTUs <b>: %3d\t\t\t", np->nat_btu);
281 pr("Reserves <m>: %5d\n", np->nat_reserve);
282 pr("Capital <c>: %s\t\t",
283 xyas(np->nat_xcap, np->nat_ycap, player->cnum));
284 pr("Origin <o>: %3s\n",
285 xyas(np->nat_xorg, np->nat_yorg, player->cnum));
286 pr("Status <s>: 0x%x\t\t\t", np->nat_stat);
287 pr("Seconds Used <u>: %3d\n", np->nat_timeused);
288 pr("Technology <T>: %.2f\t\t", np->nat_level[NAT_TLEV]);
289 pr("Research <R>: %.2f\n", np->nat_level[NAT_RLEV]);
290 pr("Education <E>: %.2f\t\t", np->nat_level[NAT_ELEV]);
291 pr("Happiness <H>: %.2f\n", np->nat_level[NAT_HLEV]);
292 pr("Money <M>: $%6d\n", np->nat_money);
293 pr("Telegrams <t>: %6d\n", np->nat_tgms);
295 pr("Countries contacted: ");
296 for (i = 0; i < MAXNOC; i++) {
297 if (getcontact(np, i))
298 pr("%d(%d) ", i, getcontact(np, i));
305 print_plane(struct plnstr *plane)
307 pr("%s %s\n", prnatid(plane->pln_own), prplane(plane));
308 pr("UID <U>: %d\t\t", plane->pln_uid);
309 pr("Owner <O>: %d\t\t", plane->pln_own);
310 pr("Location <l>: %s\n",
311 xyas(plane->pln_x, plane->pln_y, player->cnum));
312 pr("Efficiency <e>: %d\t", plane->pln_effic);
313 pr("Mobility <m>: %d\n", plane->pln_mobil);
314 pr("Tech <t>: %d\t\t", plane->pln_tech);
315 pr("Wing <w>: %.1s\n", &plane->pln_wing);
316 pr("Range <r>: %d\t\t", plane->pln_range);
317 pr("Flags <f>: %d\n", plane->pln_flags);
318 pr("Ship <s>: %d\t\t", plane->pln_ship);
319 pr("Land Unit <y>: %d\t", plane->pln_land);
323 print_land(struct lndstr *land)
325 pr("%s %s\n", prnatid(land->lnd_own), prland(land));
326 pr("UID <U>: %d\n", land->lnd_uid);
327 pr("Owner <O>: %d\n", land->lnd_own);
328 pr("Location <L>: %s\n", xyas(land->lnd_x, land->lnd_y, player->cnum));
329 pr("Efficiency <e>: %d\t", land->lnd_effic);
330 pr("Mobility <M>: %d\n", land->lnd_mobil);
331 pr("Tech <t>: %d\t\t", land->lnd_tech);
332 pr("Army <a>: %.1s\n", &land->lnd_army);
333 pr("Fortification <F>: %d\t", land->lnd_harden);
334 pr("Land unit <Y>: %d\n", land->lnd_land);
335 pr("Ship <S>: %d\t\t", land->lnd_ship);
336 pr("Retreat percentage <Z>: %d\n", land->lnd_retreat);
337 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
338 land->lnd_rpath, land->lnd_rflags);
339 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
340 pr(" c m u f s g p i d o l h r\n");
341 pr("%3d", land->lnd_item[I_CIVIL]);
342 pr("%4d", land->lnd_item[I_MILIT]);
343 pr("%4d", land->lnd_item[I_UW]);
344 pr("%5d", land->lnd_item[I_FOOD]);
345 pr("%4d", land->lnd_item[I_SHELL]);
346 pr("%4d", land->lnd_item[I_GUN]);
347 pr("%5d", land->lnd_item[I_PETROL]);
348 pr("%5d", land->lnd_item[I_IRON]);
349 pr("%5d", land->lnd_item[I_DUST]);
350 pr("%5d", land->lnd_item[I_OIL]);
351 pr("%5d", land->lnd_item[I_LCM]);
352 pr("%5d", land->lnd_item[I_HCM]);
353 pr("%4d", land->lnd_item[I_RAD]);
358 print_ship(struct shpstr *ship)
360 pr("%s %s\n", prnatid(ship->shp_own), prship(ship));
361 pr("UID <U>: %d\n", ship->shp_uid);
362 pr("Owner <O>: %d\t\t\t", ship->shp_own);
363 pr("Location <L>: %s\n", xyas(ship->shp_x, ship->shp_y, player->cnum));
364 pr("Tech <T>: %d\t\t\t", ship->shp_tech);
365 pr("Efficiency <E>: %d\n", ship->shp_effic);
366 pr("Mobility <M>: %d\t\t", ship->shp_mobil);
367 pr("Fleet <F>: %.1s\n", &ship->shp_fleet);
368 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
369 ship->shp_rpath, ship->shp_rflags);
370 pr("Plague Stage <a>: %d\t\t", ship->shp_pstage);
371 pr("Plague Time <b>: %d\n", ship->shp_ptime);
372 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
373 pr(" c m u f s g p i d o l h r\n");
374 pr("%3d", ship->shp_item[I_CIVIL]);
375 pr("%4d", ship->shp_item[I_MILIT]);
376 pr("%4d", ship->shp_item[I_UW]);
377 pr("%5d", ship->shp_item[I_FOOD]);
378 pr("%4d", ship->shp_item[I_SHELL]);
379 pr("%4d", ship->shp_item[I_GUN]);
380 pr("%5d", ship->shp_item[I_PETROL]);
381 pr("%5d", ship->shp_item[I_IRON]);
382 pr("%5d", ship->shp_item[I_DUST]);
383 pr("%5d", ship->shp_item[I_OIL]);
384 pr("%5d", ship->shp_item[I_LCM]);
385 pr("%5d", ship->shp_item[I_HCM]);
386 pr("%4d", ship->shp_item[I_RAD]);
391 getin(char *buf, char **valp)
398 p = getstarg(NULL, "%c xxxxx -- thing value : ", line);
401 switch (parse(p, buf, argp, NULL, NULL, NULL)) {
412 #if 0 /* not needed right now */
414 warn_deprecated(char key)
416 pr("Key <%c> is deprecated and will go away in a future release\n", key);
421 edit_sect(struct sctstr *sect, char *key, int arg, char *p)
425 struct sctstr newsect;
429 if (arg < 0 || arg >= MAXNOC)
431 pr("Owner of %s changed from %s to %s.\n",
432 xyas(sect->sct_x, sect->sct_y, player->cnum),
433 prnatid(sect->sct_own), prnatid(arg));
434 if (arg == sect->sct_own)
436 report_god_takes("Sector ",
437 xyas(sect->sct_x, sect->sct_y, sect->sct_own),
439 report_god_gives("Sector ",
440 xyas(sect->sct_x, sect->sct_y, arg),
445 if (arg < 0 || arg >= MAXNOC)
447 pr("Old owner of %s changed from %s to %s.\n",
448 xyas(sect->sct_x, sect->sct_y, player->cnum),
449 prnatid(sect->sct_oldown), prnatid(arg));
450 if (arg == sect->sct_oldown)
452 if (sect->sct_own && sect->sct_own != player->cnum)
454 "Old owner of %s changed from %s to %s by an act of %s\n",
455 xyas(sect->sct_x, sect->sct_y, player->cnum),
456 prnatid(sect->sct_oldown), prnatid(arg),
457 cname(player->cnum));
458 sect->sct_oldown = arg;
461 new = LIMIT_TO(arg, 0, 100);
462 noise(sect, "Efficiency", sect->sct_effic, new);
463 sect->sct_effic = new;
466 new = LIMIT_TO(arg, -127, 127);
467 noise(sect, "Mobility", sect->sct_mobil, new);
468 sect->sct_mobil = new;
471 new = LIMIT_TO(arg, 0, 100);
472 noise(sect, "Iron ore content", sect->sct_min, new);
473 sect->sct_min = (unsigned char)new;
476 new = LIMIT_TO(arg, 0, 100);
477 noise(sect, "Gold content", sect->sct_gmin, new);
478 sect->sct_gmin = (unsigned char)new;
481 new = LIMIT_TO(arg, 0, 100);
482 noise(sect, "Fertility", sect->sct_fertil, new);
483 sect->sct_fertil = (unsigned char)new;
486 new = LIMIT_TO(arg, 0, 100);
487 noise(sect, "Oil content", sect->sct_oil, new);
488 sect->sct_oil = (unsigned char)new;
491 new = LIMIT_TO(arg, 0, 100);
492 noise(sect, "Uranium content", sect->sct_uran, new);
493 sect->sct_uran = (unsigned char)new;
496 new = LIMIT_TO(arg, 0, 100);
497 noise(sect, "Workforce percentage", sect->sct_work, new);
498 sect->sct_work = (unsigned char)new;
501 new = LIMIT_TO(arg, 0, 127);
502 pr("Loyalty of %s changed from %d to %d\n",
503 xyas(sect->sct_x, sect->sct_y, player->cnum),
504 sect->sct_loyal, new);
505 sect->sct_loyal = (unsigned char)new;
508 new = LIMIT_TO(arg, 0, CHE_MAX);
509 pr("Guerillas in %s changed from %d to %d\n",
510 xyas(sect->sct_x, sect->sct_y, player->cnum),
515 if (arg < 0 || arg >= MAXNOC)
517 pr("Che target of %s changed from %s to %s.\n",
518 xyas(sect->sct_x, sect->sct_y, player->cnum),
519 prnatid(sect->sct_che_target), prnatid(arg));
520 sect->sct_che_target = arg;
525 new = LIMIT_TO(arg, 0, PLG_EXPOSED);
526 pr("Plague stage of %s changed from %d to %d\n",
527 xyas(sect->sct_x, sect->sct_y, player->cnum),
528 sect->sct_pstage, new);
529 sect->sct_pstage = new;
532 new = LIMIT_TO(arg, 0, 32767);
533 pr("Plague time of %s changed from %d to %d\n",
534 xyas(sect->sct_x, sect->sct_y, player->cnum),
535 sect->sct_ptime, new);
536 sect->sct_ptime = new;
539 new = LIMIT_TO(arg, 0, FALLOUT_MAX);
540 noise(sect, "Fallout", 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 if (sect->sct_own == sect->sct_oldown)
551 noise(sect, "Mines", sect->sct_mines, new);
553 pr("Mines of %s changed from %d to %d\n",
554 xyas(sect->sct_x, sect->sct_y, player->cnum),
555 sect->sct_mines, new);
556 sect->sct_mines = new;
559 if (!sarg_xy(p, &newx, &newy))
561 getsect(newx, newy, &newsect);
562 pr("Sector %s duplicated to %s\n",
563 xyas(sect->sct_x, sect->sct_y, player->cnum),
564 xyas(newx, newy, player->cnum));
565 report_god_takes("Sector ", xyas(newx, newy, newsect.sct_own),
567 report_god_gives("Sector ", xyas(newx, newy, sect->sct_own),
571 ef_set_uid(EF_SECTOR, §, XYOFFSET(newx, newy));
574 if (!sarg_xy(p, &newx, &newy))
576 pr("Distribution sector of sector %s changed from %s to %s\n",
577 xyas(sect->sct_x, sect->sct_y, player->cnum),
578 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
579 xyas(newx, newy, player->cnum));
580 if (newx == sect->sct_dist_x && newy == sect->sct_dist_y)
582 if (sect->sct_own && sect->sct_own != player->cnum)
584 "Distribution sector of sector %s changed from %s to %s"
585 " by an act of %s\n",
586 xyas(sect->sct_x, sect->sct_y, player->cnum),
587 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
588 xyas(newx, newy, player->cnum),
589 cname(player->cnum));
590 sect->sct_dist_x = newx;
591 sect->sct_dist_y = newy;
594 new = sct_typematch(p);
597 pr("Designation of sector %s changed from %c to %c\n",
598 xyas(sect->sct_x, sect->sct_y, player->cnum),
599 dchr[sect->sct_type].d_mnem, dchr[new].d_mnem);
600 if (new == sect->sct_type)
602 if (sect->sct_own && sect->sct_own != player->cnum)
604 "Designation of sector %s changed from %c to %c"
605 " by an act of %s\n",
606 xyas(sect->sct_x, sect->sct_y, player->cnum),
607 dchr[sect->sct_type].d_mnem, dchr[new].d_mnem,
608 cname(player->cnum));
609 set_coastal(sect, sect->sct_type, new);
610 sect->sct_type = new;
613 new = sct_typematch(p);
616 pr("New designation of sector %s changed from %c to %c\n",
617 xyas(sect->sct_x, sect->sct_y, player->cnum),
618 dchr[sect->sct_newtype].d_mnem, dchr[new].d_mnem);
619 if (new == sect->sct_newtype)
621 if (sect->sct_own && sect->sct_own != player->cnum)
623 "New designation of sector %s changed from %c to %c"
624 " by an act of %s\n",
625 xyas(sect->sct_x, sect->sct_y, player->cnum),
626 dchr[sect->sct_newtype].d_mnem, dchr[new].d_mnem,
627 cname(player->cnum));
628 sect->sct_newtype = new;
631 new = LIMIT_TO(arg, 0, 100);
632 noise(sect, "Road percentage", sect->sct_road, new);
633 sect->sct_road = new;
636 new = LIMIT_TO(arg, 0, 100);
637 noise(sect, "Rail percentage", sect->sct_rail, new);
638 sect->sct_rail = new;
641 new = LIMIT_TO(arg, 0, 100);
642 noise(sect, "Defense percentage", sect->sct_defense, new);
643 sect->sct_defense = new;
646 pr("huh? (%s)\n", key);
653 edit_nat(struct natstr *np, char *key, int arg, char *p)
656 natid nat = np->nat_cnum;
657 float farg = (float)atof(p);
661 if (!check_nat_name(p, nat))
663 pr("Country name changed from %s to %s\n", np->nat_cnam, p);
664 strcpy(np->nat_cnam, p);
667 pr("Country representative changed from %s to %s\n",
669 strncpy(np->nat_pnam, p, sizeof(np->nat_pnam) - 1);
672 arg = LIMIT_TO(arg, 0, USHRT_MAX);
676 arg = LIMIT_TO(arg, 0, max_btus);
677 pr("BTU's changed from %d to %d\n", np->nat_btu, arg);
681 arg = LIMIT_TO(arg, 0, INT_MAX);
682 benefit(nat, arg - np->nat_reserve);
683 pr("Military reserves changed from %d to %d\n",
684 np->nat_reserve, arg);
685 if (arg == np->nat_reserve)
687 if (nat != player->cnum)
689 "Military reserves changed from %d to %d by an act of %s\n",
690 np->nat_reserve, arg, cname(player->cnum));
691 np->nat_reserve = arg;
694 if (!sarg_xy(p, &newx, &newy))
696 pr("Capital coordinates changed from %s to %s\n",
697 xyas(np->nat_xcap, np->nat_ycap, player->cnum),
698 xyas(newx, newy, player->cnum));
703 if (!sarg_xy(p, &newx, &newy))
705 pr("Origin coordinates changed from %s to %s\n",
706 xyas(np->nat_xorg, np->nat_yorg, player->cnum),
707 xyas(newx, newy, player->cnum));
712 np->nat_stat = LIMIT_TO(arg, STAT_UNUSED, STAT_GOD);
715 arg = LIMIT_TO(arg, 0, m_m_p_d * 60);
716 pr("Number of seconds used changed from %d to %d.\n",
717 np->nat_timeused, arg);
718 np->nat_timeused = arg;
721 pr("Money changed from %d to %d\n", np->nat_money, arg);
722 if (arg == np->nat_money)
724 if (nat != player->cnum)
725 wu(0, nat, "Money changed from %d to %d by an act of %s\n",
726 np->nat_money, arg, cname(player->cnum));
730 farg = MAX(0.0, farg);
731 pr("Tech changed from %.2f to %.2f.\n",
732 np->nat_level[NAT_TLEV], farg);
733 np->nat_level[NAT_TLEV] = farg;
736 farg = MAX(0.0, farg);
737 pr("Research changed from %.2f to %.2f.\n",
738 np->nat_level[NAT_RLEV], farg);
739 np->nat_level[NAT_RLEV] = farg;
742 farg = MAX(0.0, farg);
743 pr("Education changed from %.2f to %.2f.\n",
744 np->nat_level[NAT_ELEV], farg);
745 np->nat_level[NAT_ELEV] = farg;
748 farg = MAX(0.0, farg);
749 pr("Happiness changed from %.2f to %.2f.\n",
750 np->nat_level[NAT_HLEV], farg);
751 np->nat_level[NAT_HLEV] = farg;
754 pr("huh? (%s)\n", key);
762 edit_ship(struct shpstr *ship, char *key, int arg, char *p)
764 struct mchrstr *mcp = &mchr[ship->shp_type];
771 arg = LIMIT_TO(arg, 0, PLG_EXPOSED);
772 ship->shp_pstage = arg;
775 arg = LIMIT_TO(arg, 0, 32767);
776 ship->shp_ptime = arg;
779 strncpy(ship->shp_rpath, p, sizeof(ship->shp_rpath) - 1);
782 ship->shp_rflags = arg;
785 ef_set_uid(EF_SHIP, ship, arg);
788 if (arg < 0 || arg >= MAXNOC)
790 if (arg == ship->shp_own)
792 if (ship->shp_own && ship->shp_own != player->cnum)
793 wu(0, ship->shp_own, "%s taken from you by an act of %s!\n",
794 prship(ship), cname(player->cnum));
795 if (arg && arg != player->cnum)
796 wu(0, arg, "%s given to you by an act of %s!\n",
797 prship(ship), cname(player->cnum));
801 if (!sarg_xy(p, &newx, &newy))
807 arg = LIMIT_TO(arg, mcp->m_tech, SHRT_MAX);
808 shp_set_tech(ship, arg);
811 ship->shp_effic = LIMIT_TO(arg, SHIP_MINEFF, 100);
814 arg = LIMIT_TO(arg, -127, 127);
815 ship->shp_mobil = arg;
820 else if (isalpha(p[0]))
821 ship->shp_fleet = p[0];
823 pr("%c: invalid fleet\n", p[0]);
840 ip = item_by_name(key);
841 arg = LIMIT_TO(arg, 0, mchr[ship->shp_type].m_item[ip->i_uid]);
842 ship->shp_item[ip->i_uid] = arg;
845 pr("huh? (%s)\n", key);
852 edit_land(struct lndstr *land, char *key, int arg, char *p)
854 struct lchrstr *lcp = &lchr[land->lnd_type];
861 if (arg < -1 || arg >= ef_nelem(EF_LAND))
863 if (arg >= 0 && arg != land->lnd_land)
865 land->lnd_land = arg;
868 ef_set_uid(EF_LAND, land, arg);
871 if (arg < 0 || arg >= MAXNOC)
873 if (arg == land->lnd_own)
875 if (land->lnd_own && land->lnd_own != player->cnum)
876 wu(0, land->lnd_own, "%s taken from you by an act of %s!\n",
877 prland(land), cname(player->cnum));
878 if (arg && arg != player->cnum)
879 wu(0, arg, "%s given to you by an act of %s!\n",
880 prland(land), cname(player->cnum));
884 if (!sarg_xy(p, &newx, &newy))
890 land->lnd_effic = LIMIT_TO(arg, LAND_MINEFF, 100);
893 arg = LIMIT_TO(arg, -127, 127);
894 land->lnd_mobil = arg;
897 arg = LIMIT_TO(arg, lcp->l_tech, SHRT_MAX);
898 lnd_set_tech(land, arg);
903 else if (isalpha(p[0]))
904 land->lnd_army = p[0];
906 pr("%c: invalid army\n", p[0]);
911 land->lnd_harden = LIMIT_TO(arg, 0, 127);
914 if (arg < -1 || arg >= ef_nelem(EF_SHIP))
916 if (arg >= 0 && arg != land->lnd_ship)
918 land->lnd_ship = arg;
921 arg = LIMIT_TO(arg, 0, 100);
922 land->lnd_retreat = arg;
925 strncpy(land->lnd_rpath, p, sizeof(land->lnd_rpath) - 1);
928 land->lnd_rflags = arg;
943 ip = item_by_name(key);
944 arg = LIMIT_TO(arg, 0, lchr[land->lnd_type].l_item[ip->i_uid]);
945 land->lnd_item[ip->i_uid] = arg;
948 pr("huh? (%s)\n", key);
955 edit_plane(struct plnstr *plane, char *key, int arg, char *p)
957 struct plchrstr *pcp = &plchr[plane->pln_type];
962 ef_set_uid(EF_PLANE, plane, arg);
965 if (!sarg_xy(p, &newx, &newy))
971 if (arg < 0 || arg >= MAXNOC)
973 if (arg == plane->pln_own)
975 if (plane->pln_own && plane->pln_own != player->cnum)
976 wu(0, plane->pln_own, "%s taken from you by an act of %s!\n",
977 prplane(plane), cname(player->cnum));
978 if (arg && arg != player->cnum)
979 wu(0, arg, "%s given to you by an act of %s!\n",
980 prplane(plane), cname(player->cnum));
981 plane->pln_own = arg;
984 plane->pln_effic = LIMIT_TO(arg, PLANE_MINEFF, 100);
987 plane->pln_mobil = LIMIT_TO(arg, -127, 127);
990 arg = LIMIT_TO(arg, pcp->pl_tech, SHRT_MAX);
991 pln_set_tech(plane, arg);
996 else if (isalpha(p[0]))
997 plane->pln_wing = p[0];
999 pr("%c: invalid wing\n", p[0]);
1004 arg = LIMIT_TO(arg, 0, pl_range(pcp, plane->pln_tech));
1005 plane->pln_range = (unsigned char)arg;
1008 if (arg < -1 || arg >= ef_nelem(EF_SHIP))
1010 if (arg >= 0 && arg != plane->pln_ship)
1011 plane->pln_land = -1;
1012 plane->pln_ship = arg;
1015 if (arg < -1 || arg >= ef_nelem(EF_LAND))
1017 if (arg >= 0 && arg != plane->pln_land)
1018 plane->pln_ship = -1;
1019 plane->pln_land = arg;
1022 plane->pln_flags = arg;
1025 pr("huh? (%s)\n", key);