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_nat(struct natstr *, char *, char *);
58 static int edit_ship(struct shpstr *, char *, char *);
59 static int edit_land(struct lndstr *, char *, char *);
60 static int edit_plane(struct plnstr *, char *, char *);
79 what = getstarg(player->argp[1],
80 "Edit what (country, land, ship, plane, nuke, unit)? ",
87 if (!(ptr = getstarg(player->argp[2], "Sector : ", buf)))
89 if (!sarg_xy(ptr, &x, &y))
91 if (!getsect(x, y, §))
95 np = natargp(player->argp[2], "Country? ");
100 if ((num = onearg(player->argp[2], "Plane number? ")) < 0)
102 if (!getplane(num, &plane))
106 if ((num = onearg(player->argp[2], "Ship number? ")) < 0)
108 if (!getship(num, &ship))
112 if ((num = onearg(player->argp[2], "Unit number? ")) < 0)
114 if (!getland(num, &land))
118 pr("Not implemented yet.\n");
124 if (!player->argp[3]) {
144 if (player->argp[arg_index]) {
145 if (player->argp[arg_index+1]) {
146 key = player->argp[arg_index++];
147 ptr = player->argp[arg_index++];
150 } else if (arg_index == 3) {
151 key = getin(buf, &ptr);
179 if ((err = edit_nat(np, key, ptr)) != RET_OK)
183 if (!check_sect_ok(§))
185 if ((err = edit_sect(§, key, ptr)) != RET_OK)
191 if (!check_ship_ok(&ship))
193 if ((err = edit_ship(&ship, key, ptr)) != RET_OK)
195 if (!ef_ensure_space(EF_SHIP, ship.shp_uid, 50))
197 if (!putship(ship.shp_uid, &ship))
201 if (!check_land_ok(&land))
203 if ((err = edit_land(&land, key, ptr)) != RET_OK)
205 if (!ef_ensure_space(EF_LAND, land.lnd_uid, 50))
207 if (!putland(land.lnd_uid, &land))
211 if (!check_plane_ok(&plane))
213 if ((err = edit_plane(&plane, key, ptr)) != RET_OK)
215 if (!ef_ensure_space(EF_PLANE, plane.pln_uid, 50))
217 if (!putplane(plane.pln_uid, &plane))
225 benefit(natid who, int goodness)
227 if (opt_GODNEWS && getnatp(who)->nat_stat != STAT_GOD && goodness)
228 nreport(player->cnum, goodness > 0 ? N_AIDS : N_HURTS, who, 1);
232 noise(struct sctstr *sptr, char *name, int old, int new)
234 pr("%s of %s changed from %d to %d\n",
235 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
236 if (sptr->sct_own && sptr->sct_own != player->cnum && new != old)
238 "%s in %s was changed from %d to %d by an act of %s\n",
239 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
240 old, new, cname(player->cnum));
241 benefit(sptr->sct_own, new - old);
245 print_sect(struct sctstr *sect)
247 pr("Location <L>: %s\t", xyas(sect->sct_x, sect->sct_y, player->cnum));
248 pr("Distribution sector <D>: %s\n",
249 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum));
250 pr("Designation <s>: %c\tNew designation <S>: %c\n",
251 dchr[sect->sct_type].d_mnem, dchr[sect->sct_newtype].d_mnem);
252 pr("own oo eff mob min gld frt oil urn wrk lty che ctg plg ptime fall avail\n");
253 pr(" o O e m i g f c u w l x X p t F a\n");
254 pr("%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %5d %4d %5d\n",
255 sect->sct_own, sect->sct_oldown, sect->sct_effic, sect->sct_mobil,
256 sect->sct_min, sect->sct_gmin, sect->sct_fertil, sect->sct_oil,
257 sect->sct_uran, sect->sct_work, sect->sct_loyal,
258 sect->sct_che, sect->sct_che_target,
259 sect->sct_pstage, sect->sct_ptime,
260 sect->sct_fallout, sect->sct_avail);
262 pr("Mines <M>: %d\n", sect->sct_mines);
263 pr("Road %% <R>: %d\t", sect->sct_road);
264 pr("Rail %% <r>: %d\t", sect->sct_rail);
265 pr("Defense %% <d>: %d\n", sect->sct_defense);
269 print_nat(struct natstr *np)
273 pr("Country #: %2d\n", np->nat_cnum);
274 pr("Name <n>: %-20s\t", np->nat_cnam);
275 pr("Representative <r>: %-20s\n", np->nat_pnam);
276 pr("BTUs <b>: %3d\t\t\t", np->nat_btu);
277 pr("Reserves <m>: %5d\n", np->nat_reserve);
278 pr("Capital <c>: %s\t\t",
279 xyas(np->nat_xcap, np->nat_ycap, player->cnum));
280 pr("Origin <o>: %3s\n",
281 xyas(np->nat_xorg, np->nat_yorg, player->cnum));
282 pr("Status <s>: 0x%x\t\t\t", np->nat_stat);
283 pr("Seconds Used <u>: %3d\n", np->nat_timeused);
284 pr("Technology <T>: %.2f\t\t", np->nat_level[NAT_TLEV]);
285 pr("Research <R>: %.2f\n", np->nat_level[NAT_RLEV]);
286 pr("Education <E>: %.2f\t\t", np->nat_level[NAT_ELEV]);
287 pr("Happiness <H>: %.2f\n", np->nat_level[NAT_HLEV]);
288 pr("Money <M>: $%6d\n", np->nat_money);
289 pr("Telegrams <t>: %6d\n", np->nat_tgms);
291 pr("Countries contacted: ");
292 for (i = 0; i < MAXNOC; i++) {
293 if (getcontact(np, i))
294 pr("%d(%d) ", i, getcontact(np, i));
301 print_plane(struct plnstr *plane)
303 pr("%s %s\n", prnatid(plane->pln_own), prplane(plane));
304 pr("UID <U>: %d\t\t", plane->pln_uid);
305 pr("Owner <O>: %d\t\t", plane->pln_own);
306 pr("Location <l>: %s\n",
307 xyas(plane->pln_x, plane->pln_y, player->cnum));
308 pr("Efficiency <e>: %d\t", plane->pln_effic);
309 pr("Mobility <m>: %d\n", plane->pln_mobil);
310 pr("Tech <t>: %d\t\t", plane->pln_tech);
311 pr("Wing <w>: %.1s\n", &plane->pln_wing);
312 pr("Range <r>: %d\t\t", plane->pln_range);
313 pr("Flags <f>: %d\n", plane->pln_flags);
314 pr("Ship <s>: %d\t\t", plane->pln_ship);
315 pr("Land Unit <y>: %d\t", plane->pln_land);
319 print_land(struct lndstr *land)
321 pr("%s %s\n", prnatid(land->lnd_own), prland(land));
322 pr("UID <U>: %d\n", land->lnd_uid);
323 pr("Owner <O>: %d\n", land->lnd_own);
324 pr("Location <L>: %s\n", xyas(land->lnd_x, land->lnd_y, player->cnum));
325 pr("Efficiency <e>: %d\t", land->lnd_effic);
326 pr("Mobility <M>: %d\n", land->lnd_mobil);
327 pr("Tech <t>: %d\t\t", land->lnd_tech);
328 pr("Army <a>: %.1s\n", &land->lnd_army);
329 pr("Fortification <F>: %d\t", land->lnd_harden);
330 pr("Land unit <Y>: %d\n", land->lnd_land);
331 pr("Ship <S>: %d\t\t", land->lnd_ship);
332 pr("Retreat percentage <Z>: %d\n", land->lnd_retreat);
333 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
334 land->lnd_rpath, land->lnd_rflags);
335 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
336 pr(" c m u f s g p i d o l h r\n");
337 pr("%3d", land->lnd_item[I_CIVIL]);
338 pr("%4d", land->lnd_item[I_MILIT]);
339 pr("%4d", land->lnd_item[I_UW]);
340 pr("%5d", land->lnd_item[I_FOOD]);
341 pr("%4d", land->lnd_item[I_SHELL]);
342 pr("%4d", land->lnd_item[I_GUN]);
343 pr("%5d", land->lnd_item[I_PETROL]);
344 pr("%5d", land->lnd_item[I_IRON]);
345 pr("%5d", land->lnd_item[I_DUST]);
346 pr("%5d", land->lnd_item[I_OIL]);
347 pr("%5d", land->lnd_item[I_LCM]);
348 pr("%5d", land->lnd_item[I_HCM]);
349 pr("%4d", land->lnd_item[I_RAD]);
354 print_ship(struct shpstr *ship)
356 pr("%s %s\n", prnatid(ship->shp_own), prship(ship));
357 pr("UID <U>: %d\n", ship->shp_uid);
358 pr("Owner <O>: %d\t\t\t", ship->shp_own);
359 pr("Location <L>: %s\n", xyas(ship->shp_x, ship->shp_y, player->cnum));
360 pr("Tech <T>: %d\t\t\t", ship->shp_tech);
361 pr("Efficiency <E>: %d\n", ship->shp_effic);
362 pr("Mobility <M>: %d\t\t", ship->shp_mobil);
363 pr("Fleet <F>: %.1s\n", &ship->shp_fleet);
364 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
365 ship->shp_rpath, ship->shp_rflags);
366 pr("Plague Stage <a>: %d\t\t", ship->shp_pstage);
367 pr("Plague Time <b>: %d\n", ship->shp_ptime);
368 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
369 pr(" c m u f s g p i d o l h r\n");
370 pr("%3d", ship->shp_item[I_CIVIL]);
371 pr("%4d", ship->shp_item[I_MILIT]);
372 pr("%4d", ship->shp_item[I_UW]);
373 pr("%5d", ship->shp_item[I_FOOD]);
374 pr("%4d", ship->shp_item[I_SHELL]);
375 pr("%4d", ship->shp_item[I_GUN]);
376 pr("%5d", ship->shp_item[I_PETROL]);
377 pr("%5d", ship->shp_item[I_IRON]);
378 pr("%5d", ship->shp_item[I_DUST]);
379 pr("%5d", ship->shp_item[I_OIL]);
380 pr("%5d", ship->shp_item[I_LCM]);
381 pr("%5d", ship->shp_item[I_HCM]);
382 pr("%4d", ship->shp_item[I_RAD]);
387 getin(char *buf, char **valp)
394 p = getstarg(NULL, "%c xxxxx -- thing value : ", line);
397 switch (parse(p, buf, argp, NULL, NULL, NULL)) {
408 #if 0 /* not needed right now */
410 warn_deprecated(char key)
412 pr("Key <%c> is deprecated and will go away in a future release\n", key);
417 edit_sect_i(struct sctstr *sect, char *key, int arg)
423 if (arg < 0 || arg >= MAXNOC)
425 pr("Owner of %s changed from %s to %s.\n",
426 xyas(sect->sct_x, sect->sct_y, player->cnum),
427 prnatid(sect->sct_own), prnatid(arg));
428 if (arg == sect->sct_own)
430 report_god_takes("Sector ",
431 xyas(sect->sct_x, sect->sct_y, sect->sct_own),
433 report_god_gives("Sector ",
434 xyas(sect->sct_x, sect->sct_y, arg),
439 if (arg < 0 || arg >= MAXNOC)
441 pr("Old owner of %s changed from %s to %s.\n",
442 xyas(sect->sct_x, sect->sct_y, player->cnum),
443 prnatid(sect->sct_oldown), prnatid(arg));
444 if (arg == sect->sct_oldown)
446 if (sect->sct_own && sect->sct_own != player->cnum)
448 "Old owner of %s changed from %s to %s by an act of %s\n",
449 xyas(sect->sct_x, sect->sct_y, player->cnum),
450 prnatid(sect->sct_oldown), prnatid(arg),
451 cname(player->cnum));
452 sect->sct_oldown = arg;
455 new = LIMIT_TO(arg, 0, 100);
456 noise(sect, "Efficiency", sect->sct_effic, new);
457 sect->sct_effic = new;
460 new = LIMIT_TO(arg, -127, 127);
461 noise(sect, "Mobility", sect->sct_mobil, new);
462 sect->sct_mobil = new;
465 new = LIMIT_TO(arg, 0, 100);
466 noise(sect, "Iron ore content", sect->sct_min, new);
467 sect->sct_min = (unsigned char)new;
470 new = LIMIT_TO(arg, 0, 100);
471 noise(sect, "Gold content", sect->sct_gmin, new);
472 sect->sct_gmin = (unsigned char)new;
475 new = LIMIT_TO(arg, 0, 100);
476 noise(sect, "Fertility", sect->sct_fertil, new);
477 sect->sct_fertil = (unsigned char)new;
480 new = LIMIT_TO(arg, 0, 100);
481 noise(sect, "Oil content", sect->sct_oil, new);
482 sect->sct_oil = (unsigned char)new;
485 new = LIMIT_TO(arg, 0, 100);
486 noise(sect, "Uranium content", sect->sct_uran, new);
487 sect->sct_uran = (unsigned char)new;
490 new = LIMIT_TO(arg, 0, 100);
491 noise(sect, "Workforce percentage", sect->sct_work, new);
492 sect->sct_work = (unsigned char)new;
495 new = LIMIT_TO(arg, 0, 127);
496 pr("Loyalty of %s changed from %d to %d\n",
497 xyas(sect->sct_x, sect->sct_y, player->cnum),
498 sect->sct_loyal, new);
499 sect->sct_loyal = (unsigned char)new;
502 new = LIMIT_TO(arg, 0, CHE_MAX);
503 pr("Guerillas in %s changed from %d to %d\n",
504 xyas(sect->sct_x, sect->sct_y, player->cnum),
509 if (arg < 0 || arg >= MAXNOC)
511 pr("Che target of %s changed from %s to %s.\n",
512 xyas(sect->sct_x, sect->sct_y, player->cnum),
513 prnatid(sect->sct_che_target), prnatid(arg));
514 sect->sct_che_target = arg;
519 new = LIMIT_TO(arg, 0, PLG_EXPOSED);
520 pr("Plague stage of %s changed from %d to %d\n",
521 xyas(sect->sct_x, sect->sct_y, player->cnum),
522 sect->sct_pstage, new);
523 sect->sct_pstage = new;
526 new = LIMIT_TO(arg, 0, 32767);
527 pr("Plague time of %s changed from %d to %d\n",
528 xyas(sect->sct_x, sect->sct_y, player->cnum),
529 sect->sct_ptime, new);
530 sect->sct_ptime = new;
533 new = LIMIT_TO(arg, 0, FALLOUT_MAX);
534 noise(sect, "Fallout", sect->sct_fallout, new);
535 sect->sct_fallout = new;
538 new = LIMIT_TO(arg, 0, 9999);
539 noise(sect, "Available workforce", sect->sct_avail, new);
540 sect->sct_avail = new;
543 new = LIMIT_TO(arg, 0, MINES_MAX);
544 if (sect->sct_own == sect->sct_oldown)
545 noise(sect, "Mines", sect->sct_mines, new);
547 pr("Mines of %s changed from %d to %d\n",
548 xyas(sect->sct_x, sect->sct_y, player->cnum),
549 sect->sct_mines, new);
550 sect->sct_mines = new;
553 new = LIMIT_TO(arg, 0, 100);
554 noise(sect, "Road percentage", sect->sct_road, new);
555 sect->sct_road = new;
558 new = LIMIT_TO(arg, 0, 100);
559 noise(sect, "Rail percentage", sect->sct_rail, new);
560 sect->sct_rail = new;
563 new = LIMIT_TO(arg, 0, 100);
564 noise(sect, "Defense percentage", sect->sct_defense, new);
565 sect->sct_defense = new;
568 pr("huh? (%s)\n", key);
575 edit_sect(struct sctstr *sect, char *key, char *p)
579 struct sctstr newsect;
583 if (!sarg_xy(p, &newx, &newy))
585 getsect(newx, newy, &newsect);
586 pr("Sector %s duplicated to %s\n",
587 xyas(sect->sct_x, sect->sct_y, player->cnum),
588 xyas(newx, newy, player->cnum));
589 report_god_takes("Sector ", xyas(newx, newy, newsect.sct_own),
591 report_god_gives("Sector ", xyas(newx, newy, sect->sct_own),
595 ef_set_uid(EF_SECTOR, §, XYOFFSET(newx, newy));
598 if (!sarg_xy(p, &newx, &newy))
600 pr("Distribution sector of sector %s changed from %s to %s\n",
601 xyas(sect->sct_x, sect->sct_y, player->cnum),
602 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
603 xyas(newx, newy, player->cnum));
604 if (newx == sect->sct_dist_x && newy == sect->sct_dist_y)
606 if (sect->sct_own && sect->sct_own != player->cnum)
608 "Distribution sector of sector %s changed from %s to %s"
609 " by an act of %s\n",
610 xyas(sect->sct_x, sect->sct_y, player->cnum),
611 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
612 xyas(newx, newy, player->cnum),
613 cname(player->cnum));
614 sect->sct_dist_x = newx;
615 sect->sct_dist_y = newy;
618 new = sct_typematch(p);
621 pr("Designation of sector %s changed from %c to %c\n",
622 xyas(sect->sct_x, sect->sct_y, player->cnum),
623 dchr[sect->sct_type].d_mnem, dchr[new].d_mnem);
624 if (new == sect->sct_type)
626 if (sect->sct_own && sect->sct_own != player->cnum)
628 "Designation of sector %s changed from %c to %c"
629 " by an act of %s\n",
630 xyas(sect->sct_x, sect->sct_y, player->cnum),
631 dchr[sect->sct_type].d_mnem, dchr[new].d_mnem,
632 cname(player->cnum));
633 set_coastal(sect, sect->sct_type, new);
634 sect->sct_type = new;
637 new = sct_typematch(p);
640 pr("New designation of sector %s changed from %c to %c\n",
641 xyas(sect->sct_x, sect->sct_y, player->cnum),
642 dchr[sect->sct_newtype].d_mnem, dchr[new].d_mnem);
643 if (new == sect->sct_newtype)
645 if (sect->sct_own && sect->sct_own != player->cnum)
647 "New designation of sector %s changed from %c to %c"
648 " by an act of %s\n",
649 xyas(sect->sct_x, sect->sct_y, player->cnum),
650 dchr[sect->sct_newtype].d_mnem, dchr[new].d_mnem,
651 cname(player->cnum));
652 sect->sct_newtype = new;
655 return edit_sect_i(sect, key, atoi(p));
661 edit_nat(struct natstr *np, char *key, char *p)
664 natid nat = np->nat_cnum;
666 float farg = (float)atof(p);
670 if (!check_nat_name(p, nat))
672 pr("Country name changed from %s to %s\n", np->nat_cnam, p);
673 strcpy(np->nat_cnam, p);
676 pr("Country representative changed from %s to %s\n",
678 strncpy(np->nat_pnam, p, sizeof(np->nat_pnam) - 1);
681 arg = LIMIT_TO(arg, 0, USHRT_MAX);
685 arg = LIMIT_TO(arg, 0, max_btus);
686 pr("BTU's changed from %d to %d\n", np->nat_btu, arg);
690 arg = LIMIT_TO(arg, 0, INT_MAX);
691 benefit(nat, arg - np->nat_reserve);
692 pr("Military reserves changed from %d to %d\n",
693 np->nat_reserve, arg);
694 if (arg == np->nat_reserve)
696 if (nat != player->cnum)
698 "Military reserves changed from %d to %d by an act of %s\n",
699 np->nat_reserve, arg, cname(player->cnum));
700 np->nat_reserve = arg;
703 if (!sarg_xy(p, &newx, &newy))
705 pr("Capital coordinates changed from %s to %s\n",
706 xyas(np->nat_xcap, np->nat_ycap, player->cnum),
707 xyas(newx, newy, player->cnum));
712 if (!sarg_xy(p, &newx, &newy))
714 pr("Origin coordinates changed from %s to %s\n",
715 xyas(np->nat_xorg, np->nat_yorg, player->cnum),
716 xyas(newx, newy, player->cnum));
721 np->nat_stat = LIMIT_TO(arg, STAT_UNUSED, STAT_GOD);
724 arg = LIMIT_TO(arg, 0, m_m_p_d * 60);
725 pr("Number of seconds used changed from %d to %d.\n",
726 np->nat_timeused, arg);
727 np->nat_timeused = arg;
730 pr("Money changed from %d to %d\n", np->nat_money, arg);
731 if (arg == np->nat_money)
733 if (nat != player->cnum)
734 wu(0, nat, "Money changed from %d to %d by an act of %s\n",
735 np->nat_money, arg, cname(player->cnum));
739 farg = MAX(0.0, farg);
740 pr("Tech changed from %.2f to %.2f.\n",
741 np->nat_level[NAT_TLEV], farg);
742 np->nat_level[NAT_TLEV] = farg;
745 farg = MAX(0.0, farg);
746 pr("Research changed from %.2f to %.2f.\n",
747 np->nat_level[NAT_RLEV], farg);
748 np->nat_level[NAT_RLEV] = farg;
751 farg = MAX(0.0, farg);
752 pr("Education changed from %.2f to %.2f.\n",
753 np->nat_level[NAT_ELEV], farg);
754 np->nat_level[NAT_ELEV] = farg;
757 farg = MAX(0.0, farg);
758 pr("Happiness changed from %.2f to %.2f.\n",
759 np->nat_level[NAT_HLEV], farg);
760 np->nat_level[NAT_HLEV] = farg;
763 pr("huh? (%s)\n", key);
771 edit_ship(struct shpstr *ship, char *key, char *p)
773 struct mchrstr *mcp = &mchr[ship->shp_type];
781 arg = LIMIT_TO(arg, 0, PLG_EXPOSED);
782 ship->shp_pstage = arg;
785 arg = LIMIT_TO(arg, 0, 32767);
786 ship->shp_ptime = arg;
789 strncpy(ship->shp_rpath, p, sizeof(ship->shp_rpath) - 1);
792 ship->shp_rflags = arg;
795 ef_set_uid(EF_SHIP, ship, arg);
798 if (arg < 0 || arg >= MAXNOC)
800 if (arg == ship->shp_own)
802 if (ship->shp_own && ship->shp_own != player->cnum)
803 wu(0, ship->shp_own, "%s taken from you by an act of %s!\n",
804 prship(ship), cname(player->cnum));
805 if (arg && arg != player->cnum)
806 wu(0, arg, "%s given to you by an act of %s!\n",
807 prship(ship), cname(player->cnum));
811 if (!sarg_xy(p, &newx, &newy))
817 arg = LIMIT_TO(arg, mcp->m_tech, SHRT_MAX);
818 shp_set_tech(ship, arg);
821 ship->shp_effic = LIMIT_TO(arg, SHIP_MINEFF, 100);
824 arg = LIMIT_TO(arg, -127, 127);
825 ship->shp_mobil = arg;
830 else if (isalpha(p[0]))
831 ship->shp_fleet = p[0];
833 pr("%c: invalid fleet\n", p[0]);
850 ip = item_by_name(key);
851 arg = LIMIT_TO(arg, 0, mchr[ship->shp_type].m_item[ip->i_uid]);
852 ship->shp_item[ip->i_uid] = arg;
855 pr("huh? (%s)\n", key);
862 edit_land(struct lndstr *land, char *key, char *p)
864 struct lchrstr *lcp = &lchr[land->lnd_type];
872 if (arg < -1 || arg >= ef_nelem(EF_LAND))
874 if (arg >= 0 && arg != land->lnd_land)
876 land->lnd_land = arg;
879 ef_set_uid(EF_LAND, land, arg);
882 if (arg < 0 || arg >= MAXNOC)
884 if (arg == land->lnd_own)
886 if (land->lnd_own && land->lnd_own != player->cnum)
887 wu(0, land->lnd_own, "%s taken from you by an act of %s!\n",
888 prland(land), cname(player->cnum));
889 if (arg && arg != player->cnum)
890 wu(0, arg, "%s given to you by an act of %s!\n",
891 prland(land), cname(player->cnum));
895 if (!sarg_xy(p, &newx, &newy))
901 land->lnd_effic = LIMIT_TO(arg, LAND_MINEFF, 100);
904 arg = LIMIT_TO(arg, -127, 127);
905 land->lnd_mobil = arg;
908 arg = LIMIT_TO(arg, lcp->l_tech, SHRT_MAX);
909 lnd_set_tech(land, arg);
914 else if (isalpha(p[0]))
915 land->lnd_army = p[0];
917 pr("%c: invalid army\n", p[0]);
922 land->lnd_harden = LIMIT_TO(arg, 0, 127);
925 if (arg < -1 || arg >= ef_nelem(EF_SHIP))
927 if (arg >= 0 && arg != land->lnd_ship)
929 land->lnd_ship = arg;
932 arg = LIMIT_TO(arg, 0, 100);
933 land->lnd_retreat = arg;
936 strncpy(land->lnd_rpath, p, sizeof(land->lnd_rpath) - 1);
939 land->lnd_rflags = arg;
954 ip = item_by_name(key);
955 arg = LIMIT_TO(arg, 0, lchr[land->lnd_type].l_item[ip->i_uid]);
956 land->lnd_item[ip->i_uid] = arg;
959 pr("huh? (%s)\n", key);
966 edit_plane(struct plnstr *plane, char *key, char *p)
968 struct plchrstr *pcp = &plchr[plane->pln_type];
974 ef_set_uid(EF_PLANE, plane, arg);
977 if (!sarg_xy(p, &newx, &newy))
983 if (arg < 0 || arg >= MAXNOC)
985 if (arg == plane->pln_own)
987 if (plane->pln_own && plane->pln_own != player->cnum)
988 wu(0, plane->pln_own, "%s taken from you by an act of %s!\n",
989 prplane(plane), cname(player->cnum));
990 if (arg && arg != player->cnum)
991 wu(0, arg, "%s given to you by an act of %s!\n",
992 prplane(plane), cname(player->cnum));
993 plane->pln_own = arg;
996 plane->pln_effic = LIMIT_TO(arg, PLANE_MINEFF, 100);
999 plane->pln_mobil = LIMIT_TO(arg, -127, 127);
1002 arg = LIMIT_TO(arg, pcp->pl_tech, SHRT_MAX);
1003 pln_set_tech(plane, arg);
1007 plane->pln_wing = 0;
1008 else if (isalpha(p[0]))
1009 plane->pln_wing = p[0];
1011 pr("%c: invalid wing\n", p[0]);
1016 arg = LIMIT_TO(arg, 0, pl_range(pcp, plane->pln_tech));
1017 plane->pln_range = (unsigned char)arg;
1020 if (arg < -1 || arg >= ef_nelem(EF_SHIP))
1022 if (arg >= 0 && arg != plane->pln_ship)
1023 plane->pln_land = -1;
1024 plane->pln_ship = arg;
1027 if (arg < -1 || arg >= ef_nelem(EF_LAND))
1029 if (arg >= 0 && arg != plane->pln_land)
1030 plane->pln_ship = -1;
1031 plane->pln_land = arg;
1034 plane->pln_flags = arg;
1037 pr("huh? (%s)\n", key);