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 *, char *);
58 static int edit_sect_i(struct sctstr *, char *, int);
59 static int edit_nat(struct natstr *, char *, char *);
60 static int edit_ship(struct shpstr *, char *, char *);
61 static int edit_land(struct lndstr *, char *, char *);
62 static int edit_plane(struct plnstr *, char *, 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++];
152 } else if (arg_index == 3) {
153 key = getin(buf, &ptr);
181 if ((err = edit_nat(np, key, ptr)) != RET_OK)
185 if (!check_sect_ok(§))
187 if ((err = edit_sect(§, key, ptr)) != RET_OK)
193 if (!check_ship_ok(&ship))
195 if ((err = edit_ship(&ship, key, ptr)) != RET_OK)
197 if (!ef_ensure_space(EF_SHIP, ship.shp_uid, 50))
199 if (!putship(ship.shp_uid, &ship))
203 if (!check_land_ok(&land))
205 if ((err = edit_land(&land, key, ptr)) != RET_OK)
207 if (!ef_ensure_space(EF_LAND, land.lnd_uid, 50))
209 if (!putland(land.lnd_uid, &land))
213 if (!check_plane_ok(&plane))
215 if ((err = edit_plane(&plane, key, ptr)) != RET_OK)
217 if (!ef_ensure_space(EF_PLANE, plane.pln_uid, 50))
219 if (!putplane(plane.pln_uid, &plane))
227 benefit(natid who, int goodness)
229 if (opt_GODNEWS && getnatp(who)->nat_stat != STAT_GOD && goodness)
230 nreport(player->cnum, goodness > 0 ? N_AIDS : N_HURTS, who, 1);
234 noise(struct sctstr *sptr, char *name, int old, int new)
236 pr("%s of %s changed from %d to %d\n",
237 name, xyas(sptr->sct_x, sptr->sct_y, player->cnum), old, new);
238 if (sptr->sct_own && sptr->sct_own != player->cnum && new != old)
240 "%s in %s was changed from %d to %d by an act of %s\n",
241 name, xyas(sptr->sct_x, sptr->sct_y, sptr->sct_own),
242 old, new, cname(player->cnum));
243 benefit(sptr->sct_own, new - old);
247 print_sect(struct sctstr *sect)
249 pr("Location <L>: %s\t", xyas(sect->sct_x, sect->sct_y, player->cnum));
250 pr("Distribution sector <D>: %s\n",
251 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum));
252 pr("Designation <s>: %c\tNew designation <S>: %c\n",
253 dchr[sect->sct_type].d_mnem, dchr[sect->sct_newtype].d_mnem);
254 pr("own oo eff mob min gld frt oil urn wrk lty che ctg plg ptime fall avail\n");
255 pr(" o O e m i g f c u w l x X p t F a\n");
256 pr("%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %5d %4d %5d\n",
257 sect->sct_own, sect->sct_oldown, sect->sct_effic, sect->sct_mobil,
258 sect->sct_min, sect->sct_gmin, sect->sct_fertil, sect->sct_oil,
259 sect->sct_uran, sect->sct_work, sect->sct_loyal,
260 sect->sct_che, sect->sct_che_target,
261 sect->sct_pstage, sect->sct_ptime,
262 sect->sct_fallout, sect->sct_avail);
264 pr("Mines <M>: %d\n", sect->sct_mines);
265 pr("Road %% <R>: %d\t", sect->sct_road);
266 pr("Rail %% <r>: %d\t", sect->sct_rail);
267 pr("Defense %% <d>: %d\n", sect->sct_defense);
271 print_nat(struct natstr *np)
275 pr("Country #: %2d\n", np->nat_cnum);
276 pr("Name <n>: %-20s\t", np->nat_cnam);
277 pr("Representative <r>: %-20s\n", np->nat_pnam);
278 pr("BTUs <b>: %3d\t\t\t", np->nat_btu);
279 pr("Reserves <m>: %5d\n", np->nat_reserve);
280 pr("Capital <c>: %s\t\t",
281 xyas(np->nat_xcap, np->nat_ycap, player->cnum));
282 pr("Origin <o>: %3s\n",
283 xyas(np->nat_xorg, np->nat_yorg, player->cnum));
284 pr("Status <s>: 0x%x\t\t\t", np->nat_stat);
285 pr("Seconds Used <u>: %3d\n", np->nat_timeused);
286 pr("Technology <T>: %.2f\t\t", np->nat_level[NAT_TLEV]);
287 pr("Research <R>: %.2f\n", np->nat_level[NAT_RLEV]);
288 pr("Education <E>: %.2f\t\t", np->nat_level[NAT_ELEV]);
289 pr("Happiness <H>: %.2f\n", np->nat_level[NAT_HLEV]);
290 pr("Money <M>: $%6d\n", np->nat_money);
291 pr("Telegrams <t>: %6d\n", np->nat_tgms);
293 pr("Countries contacted: ");
294 for (i = 0; i < MAXNOC; i++) {
295 if (getcontact(np, i))
296 pr("%d(%d) ", i, getcontact(np, i));
303 print_plane(struct plnstr *plane)
305 pr("%s %s\n", prnatid(plane->pln_own), prplane(plane));
306 pr("UID <U>: %d\t\t", plane->pln_uid);
307 pr("Owner <O>: %d\t\t", plane->pln_own);
308 pr("Location <l>: %s\n",
309 xyas(plane->pln_x, plane->pln_y, player->cnum));
310 pr("Efficiency <e>: %d\t", plane->pln_effic);
311 pr("Mobility <m>: %d\n", plane->pln_mobil);
312 pr("Tech <t>: %d\t\t", plane->pln_tech);
313 pr("Wing <w>: %.1s\n", &plane->pln_wing);
314 pr("Range <r>: %d\t\t", plane->pln_range);
315 pr("Flags <f>: %d\n", plane->pln_flags);
316 pr("Ship <s>: %d\t\t", plane->pln_ship);
317 pr("Land Unit <y>: %d\t", plane->pln_land);
321 print_land(struct lndstr *land)
323 pr("%s %s\n", prnatid(land->lnd_own), prland(land));
324 pr("UID <U>: %d\n", land->lnd_uid);
325 pr("Owner <O>: %d\n", land->lnd_own);
326 pr("Location <L>: %s\n", xyas(land->lnd_x, land->lnd_y, player->cnum));
327 pr("Efficiency <e>: %d\t", land->lnd_effic);
328 pr("Mobility <M>: %d\n", land->lnd_mobil);
329 pr("Tech <t>: %d\t\t", land->lnd_tech);
330 pr("Army <a>: %.1s\n", &land->lnd_army);
331 pr("Fortification <F>: %d\t", land->lnd_harden);
332 pr("Land unit <Y>: %d\n", land->lnd_land);
333 pr("Ship <S>: %d\t\t", land->lnd_ship);
334 pr("Retreat percentage <Z>: %d\n", land->lnd_retreat);
335 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
336 land->lnd_rpath, land->lnd_rflags);
337 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
338 pr(" c m u f s g p i d o l h r\n");
339 pr("%3d", land->lnd_item[I_CIVIL]);
340 pr("%4d", land->lnd_item[I_MILIT]);
341 pr("%4d", land->lnd_item[I_UW]);
342 pr("%5d", land->lnd_item[I_FOOD]);
343 pr("%4d", land->lnd_item[I_SHELL]);
344 pr("%4d", land->lnd_item[I_GUN]);
345 pr("%5d", land->lnd_item[I_PETROL]);
346 pr("%5d", land->lnd_item[I_IRON]);
347 pr("%5d", land->lnd_item[I_DUST]);
348 pr("%5d", land->lnd_item[I_OIL]);
349 pr("%5d", land->lnd_item[I_LCM]);
350 pr("%5d", land->lnd_item[I_HCM]);
351 pr("%4d", land->lnd_item[I_RAD]);
356 print_ship(struct shpstr *ship)
358 pr("%s %s\n", prnatid(ship->shp_own), prship(ship));
359 pr("UID <U>: %d\n", ship->shp_uid);
360 pr("Owner <O>: %d\t\t\t", ship->shp_own);
361 pr("Location <L>: %s\n", xyas(ship->shp_x, ship->shp_y, player->cnum));
362 pr("Tech <T>: %d\t\t\t", ship->shp_tech);
363 pr("Efficiency <E>: %d\n", ship->shp_effic);
364 pr("Mobility <M>: %d\t\t", ship->shp_mobil);
365 pr("Fleet <F>: %.1s\n", &ship->shp_fleet);
366 pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
367 ship->shp_rpath, ship->shp_rflags);
368 pr("Plague Stage <a>: %d\t\t", ship->shp_pstage);
369 pr("Plague Time <b>: %d\n", ship->shp_ptime);
370 pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
371 pr(" c m u f s g p i d o l h r\n");
372 pr("%3d", ship->shp_item[I_CIVIL]);
373 pr("%4d", ship->shp_item[I_MILIT]);
374 pr("%4d", ship->shp_item[I_UW]);
375 pr("%5d", ship->shp_item[I_FOOD]);
376 pr("%4d", ship->shp_item[I_SHELL]);
377 pr("%4d", ship->shp_item[I_GUN]);
378 pr("%5d", ship->shp_item[I_PETROL]);
379 pr("%5d", ship->shp_item[I_IRON]);
380 pr("%5d", ship->shp_item[I_DUST]);
381 pr("%5d", ship->shp_item[I_OIL]);
382 pr("%5d", ship->shp_item[I_LCM]);
383 pr("%5d", ship->shp_item[I_HCM]);
384 pr("%4d", ship->shp_item[I_RAD]);
389 getin(char *buf, char **valp)
396 p = getstarg(NULL, "%c xxxxx -- thing value : ", line);
399 switch (parse(p, buf, argp, NULL, NULL, NULL)) {
410 #if 0 /* not needed right now */
412 warn_deprecated(char key)
414 pr("Key <%c> is deprecated and will go away in a future release\n", key);
419 edit_sect_i(struct sctstr *sect, char *key, int arg)
425 if (arg < 0 || arg >= MAXNOC)
427 pr("Owner of %s changed from %s to %s.\n",
428 xyas(sect->sct_x, sect->sct_y, player->cnum),
429 prnatid(sect->sct_own), prnatid(arg));
430 if (arg == sect->sct_own)
432 report_god_takes("Sector ",
433 xyas(sect->sct_x, sect->sct_y, sect->sct_own),
435 report_god_gives("Sector ",
436 xyas(sect->sct_x, sect->sct_y, arg),
441 if (arg < 0 || arg >= MAXNOC)
443 pr("Old owner of %s changed from %s to %s.\n",
444 xyas(sect->sct_x, sect->sct_y, player->cnum),
445 prnatid(sect->sct_oldown), prnatid(arg));
446 if (arg == sect->sct_oldown)
448 if (sect->sct_own && sect->sct_own != player->cnum)
450 "Old owner of %s changed from %s to %s by an act of %s\n",
451 xyas(sect->sct_x, sect->sct_y, player->cnum),
452 prnatid(sect->sct_oldown), prnatid(arg),
453 cname(player->cnum));
454 sect->sct_oldown = arg;
457 new = LIMIT_TO(arg, 0, 100);
458 noise(sect, "Efficiency", sect->sct_effic, new);
459 sect->sct_effic = new;
462 new = LIMIT_TO(arg, -127, 127);
463 noise(sect, "Mobility", sect->sct_mobil, new);
464 sect->sct_mobil = new;
467 new = LIMIT_TO(arg, 0, 100);
468 noise(sect, "Iron ore content", sect->sct_min, new);
469 sect->sct_min = (unsigned char)new;
472 new = LIMIT_TO(arg, 0, 100);
473 noise(sect, "Gold content", sect->sct_gmin, new);
474 sect->sct_gmin = (unsigned char)new;
477 new = LIMIT_TO(arg, 0, 100);
478 noise(sect, "Fertility", sect->sct_fertil, new);
479 sect->sct_fertil = (unsigned char)new;
482 new = LIMIT_TO(arg, 0, 100);
483 noise(sect, "Oil content", sect->sct_oil, new);
484 sect->sct_oil = (unsigned char)new;
487 new = LIMIT_TO(arg, 0, 100);
488 noise(sect, "Uranium content", sect->sct_uran, new);
489 sect->sct_uran = (unsigned char)new;
492 new = LIMIT_TO(arg, 0, 100);
493 noise(sect, "Workforce percentage", sect->sct_work, new);
494 sect->sct_work = (unsigned char)new;
497 new = LIMIT_TO(arg, 0, 127);
498 pr("Loyalty of %s changed from %d to %d\n",
499 xyas(sect->sct_x, sect->sct_y, player->cnum),
500 sect->sct_loyal, new);
501 sect->sct_loyal = (unsigned char)new;
504 new = LIMIT_TO(arg, 0, CHE_MAX);
505 pr("Guerillas in %s changed from %d to %d\n",
506 xyas(sect->sct_x, sect->sct_y, player->cnum),
511 if (arg < 0 || arg >= MAXNOC)
513 pr("Che target of %s changed from %s to %s.\n",
514 xyas(sect->sct_x, sect->sct_y, player->cnum),
515 prnatid(sect->sct_che_target), prnatid(arg));
516 sect->sct_che_target = arg;
521 new = LIMIT_TO(arg, 0, PLG_EXPOSED);
522 pr("Plague stage of %s changed from %d to %d\n",
523 xyas(sect->sct_x, sect->sct_y, player->cnum),
524 sect->sct_pstage, new);
525 sect->sct_pstage = new;
528 new = LIMIT_TO(arg, 0, 32767);
529 pr("Plague time of %s changed from %d to %d\n",
530 xyas(sect->sct_x, sect->sct_y, player->cnum),
531 sect->sct_ptime, new);
532 sect->sct_ptime = new;
535 new = LIMIT_TO(arg, 0, FALLOUT_MAX);
536 noise(sect, "Fallout", sect->sct_fallout, new);
537 sect->sct_fallout = new;
540 new = LIMIT_TO(arg, 0, 9999);
541 noise(sect, "Available workforce", sect->sct_avail, new);
542 sect->sct_avail = new;
545 new = LIMIT_TO(arg, 0, MINES_MAX);
546 if (sect->sct_own == sect->sct_oldown)
547 noise(sect, "Mines", sect->sct_mines, new);
549 pr("Mines of %s changed from %d to %d\n",
550 xyas(sect->sct_x, sect->sct_y, player->cnum),
551 sect->sct_mines, new);
552 sect->sct_mines = new;
555 new = LIMIT_TO(arg, 0, 100);
556 noise(sect, "Road percentage", sect->sct_road, new);
557 sect->sct_road = new;
560 new = LIMIT_TO(arg, 0, 100);
561 noise(sect, "Rail percentage", sect->sct_rail, new);
562 sect->sct_rail = new;
565 new = LIMIT_TO(arg, 0, 100);
566 noise(sect, "Defense percentage", sect->sct_defense, new);
567 sect->sct_defense = new;
570 pr("huh? (%s)\n", key);
577 edit_sect(struct sctstr *sect, char *key, char *p)
581 struct sctstr newsect;
585 if (!sarg_xy(p, &newx, &newy))
587 getsect(newx, newy, &newsect);
588 pr("Sector %s duplicated to %s\n",
589 xyas(sect->sct_x, sect->sct_y, player->cnum),
590 xyas(newx, newy, player->cnum));
591 report_god_takes("Sector ", xyas(newx, newy, newsect.sct_own),
593 report_god_gives("Sector ", xyas(newx, newy, sect->sct_own),
597 ef_set_uid(EF_SECTOR, §, XYOFFSET(newx, newy));
600 if (!sarg_xy(p, &newx, &newy))
602 pr("Distribution sector of sector %s changed from %s to %s\n",
603 xyas(sect->sct_x, sect->sct_y, player->cnum),
604 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
605 xyas(newx, newy, player->cnum));
606 if (newx == sect->sct_dist_x && newy == sect->sct_dist_y)
608 if (sect->sct_own && sect->sct_own != player->cnum)
610 "Distribution sector of sector %s changed from %s to %s"
611 " by an act of %s\n",
612 xyas(sect->sct_x, sect->sct_y, player->cnum),
613 xyas(sect->sct_dist_x, sect->sct_dist_y, player->cnum),
614 xyas(newx, newy, player->cnum),
615 cname(player->cnum));
616 sect->sct_dist_x = newx;
617 sect->sct_dist_y = newy;
620 new = sct_typematch(p);
623 pr("Designation of sector %s changed from %c to %c\n",
624 xyas(sect->sct_x, sect->sct_y, player->cnum),
625 dchr[sect->sct_type].d_mnem, dchr[new].d_mnem);
626 if (new == sect->sct_type)
628 if (sect->sct_own && sect->sct_own != player->cnum)
630 "Designation of sector %s changed from %c to %c"
631 " by an act of %s\n",
632 xyas(sect->sct_x, sect->sct_y, player->cnum),
633 dchr[sect->sct_type].d_mnem, dchr[new].d_mnem,
634 cname(player->cnum));
635 set_coastal(sect, sect->sct_type, new);
636 sect->sct_type = new;
639 new = sct_typematch(p);
642 pr("New designation of sector %s changed from %c to %c\n",
643 xyas(sect->sct_x, sect->sct_y, player->cnum),
644 dchr[sect->sct_newtype].d_mnem, dchr[new].d_mnem);
645 if (new == sect->sct_newtype)
647 if (sect->sct_own && sect->sct_own != player->cnum)
649 "New designation of sector %s changed from %c to %c"
650 " by an act of %s\n",
651 xyas(sect->sct_x, sect->sct_y, player->cnum),
652 dchr[sect->sct_newtype].d_mnem, dchr[new].d_mnem,
653 cname(player->cnum));
654 sect->sct_newtype = new;
657 return edit_sect_i(sect, key, atoi(p));
663 edit_nat(struct natstr *np, char *key, char *p)
666 natid nat = np->nat_cnum;
668 float farg = (float)atof(p);
672 if (!check_nat_name(p, nat))
674 pr("Country name changed from %s to %s\n", np->nat_cnam, p);
675 strcpy(np->nat_cnam, p);
678 pr("Country representative changed from %s to %s\n",
680 strncpy(np->nat_pnam, p, sizeof(np->nat_pnam) - 1);
683 arg = LIMIT_TO(arg, 0, USHRT_MAX);
687 arg = LIMIT_TO(arg, 0, max_btus);
688 pr("BTU's changed from %d to %d\n", np->nat_btu, arg);
692 arg = LIMIT_TO(arg, 0, INT_MAX);
693 benefit(nat, arg - np->nat_reserve);
694 pr("Military reserves changed from %d to %d\n",
695 np->nat_reserve, arg);
696 if (arg == np->nat_reserve)
698 if (nat != player->cnum)
700 "Military reserves changed from %d to %d by an act of %s\n",
701 np->nat_reserve, arg, cname(player->cnum));
702 np->nat_reserve = arg;
705 if (!sarg_xy(p, &newx, &newy))
707 pr("Capital coordinates changed from %s to %s\n",
708 xyas(np->nat_xcap, np->nat_ycap, player->cnum),
709 xyas(newx, newy, player->cnum));
714 if (!sarg_xy(p, &newx, &newy))
716 pr("Origin coordinates changed from %s to %s\n",
717 xyas(np->nat_xorg, np->nat_yorg, player->cnum),
718 xyas(newx, newy, player->cnum));
723 np->nat_stat = LIMIT_TO(arg, STAT_UNUSED, STAT_GOD);
726 arg = LIMIT_TO(arg, 0, m_m_p_d * 60);
727 pr("Number of seconds used changed from %d to %d.\n",
728 np->nat_timeused, arg);
729 np->nat_timeused = arg;
732 pr("Money changed from %d to %d\n", np->nat_money, arg);
733 if (arg == np->nat_money)
735 if (nat != player->cnum)
736 wu(0, nat, "Money changed from %d to %d by an act of %s\n",
737 np->nat_money, arg, cname(player->cnum));
741 farg = MAX(0.0, farg);
742 pr("Tech changed from %.2f to %.2f.\n",
743 np->nat_level[NAT_TLEV], farg);
744 np->nat_level[NAT_TLEV] = farg;
747 farg = MAX(0.0, farg);
748 pr("Research changed from %.2f to %.2f.\n",
749 np->nat_level[NAT_RLEV], farg);
750 np->nat_level[NAT_RLEV] = farg;
753 farg = MAX(0.0, farg);
754 pr("Education changed from %.2f to %.2f.\n",
755 np->nat_level[NAT_ELEV], farg);
756 np->nat_level[NAT_ELEV] = farg;
759 farg = MAX(0.0, farg);
760 pr("Happiness changed from %.2f to %.2f.\n",
761 np->nat_level[NAT_HLEV], farg);
762 np->nat_level[NAT_HLEV] = farg;
765 pr("huh? (%s)\n", key);
773 edit_ship(struct shpstr *ship, char *key, char *p)
775 struct mchrstr *mcp = &mchr[ship->shp_type];
783 arg = LIMIT_TO(arg, 0, PLG_EXPOSED);
784 ship->shp_pstage = arg;
787 arg = LIMIT_TO(arg, 0, 32767);
788 ship->shp_ptime = arg;
791 strncpy(ship->shp_rpath, p, sizeof(ship->shp_rpath) - 1);
794 ship->shp_rflags = arg;
797 ef_set_uid(EF_SHIP, ship, arg);
800 if (arg < 0 || arg >= MAXNOC)
802 if (arg == ship->shp_own)
804 if (ship->shp_own && ship->shp_own != player->cnum)
805 wu(0, ship->shp_own, "%s taken from you by an act of %s!\n",
806 prship(ship), cname(player->cnum));
807 if (arg && arg != player->cnum)
808 wu(0, arg, "%s given to you by an act of %s!\n",
809 prship(ship), cname(player->cnum));
813 if (!sarg_xy(p, &newx, &newy))
819 arg = LIMIT_TO(arg, mcp->m_tech, SHRT_MAX);
820 shp_set_tech(ship, arg);
823 ship->shp_effic = LIMIT_TO(arg, SHIP_MINEFF, 100);
826 arg = LIMIT_TO(arg, -127, 127);
827 ship->shp_mobil = arg;
832 else if (isalpha(p[0]))
833 ship->shp_fleet = p[0];
835 pr("%c: invalid fleet\n", p[0]);
852 ip = item_by_name(key);
853 arg = LIMIT_TO(arg, 0, mchr[ship->shp_type].m_item[ip->i_uid]);
854 ship->shp_item[ip->i_uid] = arg;
857 pr("huh? (%s)\n", key);
864 edit_land(struct lndstr *land, char *key, char *p)
866 struct lchrstr *lcp = &lchr[land->lnd_type];
874 if (arg < -1 || arg >= ef_nelem(EF_LAND))
876 if (arg >= 0 && arg != land->lnd_land)
878 land->lnd_land = arg;
881 ef_set_uid(EF_LAND, land, arg);
884 if (arg < 0 || arg >= MAXNOC)
886 if (arg == land->lnd_own)
888 if (land->lnd_own && land->lnd_own != player->cnum)
889 wu(0, land->lnd_own, "%s taken from you by an act of %s!\n",
890 prland(land), cname(player->cnum));
891 if (arg && arg != player->cnum)
892 wu(0, arg, "%s given to you by an act of %s!\n",
893 prland(land), cname(player->cnum));
897 if (!sarg_xy(p, &newx, &newy))
903 land->lnd_effic = LIMIT_TO(arg, LAND_MINEFF, 100);
906 arg = LIMIT_TO(arg, -127, 127);
907 land->lnd_mobil = arg;
910 arg = LIMIT_TO(arg, lcp->l_tech, SHRT_MAX);
911 lnd_set_tech(land, arg);
916 else if (isalpha(p[0]))
917 land->lnd_army = p[0];
919 pr("%c: invalid army\n", p[0]);
924 land->lnd_harden = LIMIT_TO(arg, 0, 127);
927 if (arg < -1 || arg >= ef_nelem(EF_SHIP))
929 if (arg >= 0 && arg != land->lnd_ship)
931 land->lnd_ship = arg;
934 arg = LIMIT_TO(arg, 0, 100);
935 land->lnd_retreat = arg;
938 strncpy(land->lnd_rpath, p, sizeof(land->lnd_rpath) - 1);
941 land->lnd_rflags = arg;
956 ip = item_by_name(key);
957 arg = LIMIT_TO(arg, 0, lchr[land->lnd_type].l_item[ip->i_uid]);
958 land->lnd_item[ip->i_uid] = arg;
961 pr("huh? (%s)\n", key);
968 edit_plane(struct plnstr *plane, char *key, char *p)
970 struct plchrstr *pcp = &plchr[plane->pln_type];
976 ef_set_uid(EF_PLANE, plane, arg);
979 if (!sarg_xy(p, &newx, &newy))
985 if (arg < 0 || arg >= MAXNOC)
987 if (arg == plane->pln_own)
989 if (plane->pln_own && plane->pln_own != player->cnum)
990 wu(0, plane->pln_own, "%s taken from you by an act of %s!\n",
991 prplane(plane), cname(player->cnum));
992 if (arg && arg != player->cnum)
993 wu(0, arg, "%s given to you by an act of %s!\n",
994 prplane(plane), cname(player->cnum));
995 plane->pln_own = arg;
998 plane->pln_effic = LIMIT_TO(arg, PLANE_MINEFF, 100);
1001 plane->pln_mobil = LIMIT_TO(arg, -127, 127);
1004 arg = LIMIT_TO(arg, pcp->pl_tech, SHRT_MAX);
1005 pln_set_tech(plane, arg);
1009 plane->pln_wing = 0;
1010 else if (isalpha(p[0]))
1011 plane->pln_wing = p[0];
1013 pr("%c: invalid wing\n", p[0]);
1018 arg = LIMIT_TO(arg, 0, pl_range(pcp, plane->pln_tech));
1019 plane->pln_range = (unsigned char)arg;
1022 if (arg < -1 || arg >= ef_nelem(EF_SHIP))
1024 if (arg >= 0 && arg != plane->pln_ship)
1025 plane->pln_land = -1;
1026 plane->pln_ship = arg;
1029 if (arg < -1 || arg >= ef_nelem(EF_LAND))
1031 if (arg >= 0 && arg != plane->pln_land)
1032 plane->pln_ship = -1;
1033 plane->pln_land = arg;
1036 plane->pln_flags = arg;
1039 pr("huh? (%s)\n", key);