]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/edit.c
Update copyright notice
[empserver] / src / lib / commands / edit.c
index 6f85648530d8bedf74d1d7f30128639a045f212e..9ba0410f5e5f3253cf1f3d1fb29b782ed13959ae 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2013, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2017, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -31,7 +31,7 @@
  *     Chad Zabel, 1994
  *     Steve McClure, 1998-2000
  *     Ron Koenderink, 2003-2009
- *     Markus Armbruster, 2003-2013
+ *     Markus Armbruster, 2003-2016
  */
 
 #include <config.h>
@@ -54,165 +54,142 @@ static void print_nat(struct natstr *);
 static void print_plane(struct plnstr *);
 static void print_land(struct lndstr *);
 static void print_ship(struct shpstr *);
+static void print_nuke(struct nukstr *);
 static char *getin(char *, char **);
 static int edit_nat(struct natstr *, char *, char *);
 static int edit_ship(struct shpstr *, char *, char *);
 static int edit_land(struct lndstr *, char *, char *);
 static int edit_plane(struct plnstr *, char *, char *);
+static int edit_nuke(struct nukstr *, char *, char *);
 
 int
 edit(void)
 {
     union empobj_storage item;
     char *what;
+    struct nstr_item ni;
     char *key, *ptr;
-    int num;
-    int ret;
-    int arg_index = 3;
-    coord x, y;
     struct natstr *np;
+    int type, arg_index, ret;
     char buf[1024];
-    char ewhat;
 
     what = getstarg(player->argp[1],
                    "Edit what (country, land, ship, plane, nuke, unit)? ",
                    buf);
     if (!what)
        return RET_SYN;
-    ewhat = what[0];
-    switch (ewhat) {
+    switch (what[0]) {
     case 'l':
-       if (!(ptr = getstarg(player->argp[2], "Sector : ", buf)))
-           return RET_FAIL;
-       if (!sarg_xy(ptr, &x, &y))
-           return RET_FAIL;
-       if (!getsect(x, y, &item.sect))
-           return RET_FAIL;
-       break;
-    case 'c':
-       np = natargp(player->argp[2], "Country? ");
-       if (!np)
-           return RET_SYN;
-       item.nat = *np;
+       type = EF_SECTOR;
        break;
     case 'p':
-       if ((num = onearg(player->argp[2], "Plane number? ")) < 0)
-           return RET_SYN;
-       if (!getplane(num, &item.plane))
-           return RET_SYN;
+       type = EF_PLANE;
        break;
     case 's':
-       if ((num = onearg(player->argp[2], "Ship number? ")) < 0)
-           return RET_SYN;
-       if (!getship(num, &item.ship))
-           return RET_SYN;
+       type = EF_SHIP;
        break;
     case 'u':
-       if ((num = onearg(player->argp[2], "Unit number? ")) < 0)
-           return RET_SYN;
-       if (!getland(num, &item.land))
-           return RET_SYN;
+       type = EF_LAND;
        break;
     case 'n':
-       pr("Not implemented yet.\n");
-       return RET_FAIL;
+       type = EF_NUKE;
+       break;
+    case 'c':
+       type = EF_NATION;
+       break;
     default:
        pr("huh?\n");
        return RET_SYN;
     }
-    if (!player->argp[3]) {
-       switch (ewhat) {
-       case 'l':
-           print_sect(&item.sect);
-           break;
-       case 'c':
-           print_nat(np);
-           break;
-       case 'p':
-           print_plane(&item.plane);
-           break;
-       case 's':
-           print_ship(&item.ship);
-           break;
-       case 'u':
-           print_land(&item.land);
-           break;
-       default:
-           CANT_REACH();
+
+    if (!snxtitem(&ni, type, player->argp[2], NULL))
+       return RET_SYN;
+    while (nxtitem(&ni, &item)) {
+       if (!player->argp[3]) {
+           switch (type) {
+           case EF_SECTOR:
+               print_sect(&item.sect);
+               break;
+           case EF_SHIP:
+               print_ship(&item.ship);
+               break;
+           case EF_PLANE:
+               print_plane(&item.plane);
+               break;
+           case EF_LAND:
+               print_land(&item.land);
+               break;
+           case EF_NUKE:
+               print_nuke(&item.nuke);
+               break;
+           case EF_NATION:
+               print_nat(&item.nat);
+               break;
+           default:
+               CANT_REACH();
+           }
        }
-    }
-    for (;;) {
-       if (player->argp[arg_index]) {
-           if (player->argp[arg_index+1]) {
-               key = player->argp[arg_index++];
-               ptr = player->argp[arg_index++];
+
+       arg_index = 3;
+       for (;;) {
+           if (player->argp[arg_index]) {
+               if (player->argp[arg_index+1]) {
+                   key = player->argp[arg_index++];
+                   ptr = player->argp[arg_index++];
+               } else
+                   return RET_SYN;
+           } else if (arg_index == 3) {
+               key = getin(buf, &ptr);
+               if (!key)
+                   return RET_SYN;
+               if (!*key)
+                   break;
            } else
-               return RET_SYN;
-       } else if (arg_index == 3) {
-           key = getin(buf, &ptr);
-           if (!key)
-               return RET_SYN;
-           if (!*key)
-               return RET_OK;
-       } else
-           return RET_OK;
+               break;
 
-       switch (ewhat) {
-       case 'c':
            if (!check_obj_ok(&item.gen))
                return RET_FAIL;
-           /*
-            * edit_nat() may update the edited country by sending it
-            * bulletins.  Writing back item.nat would trigger a seqno
-            * mismatch oops.  Workaround: edit in-place.
-            */
-           ret = edit_nat(np, key, ptr);
+           switch (type) {
+           case EF_NATION:
+               /*
+                * edit_nat() may update the edited country by sending
+                * it bulletins.  Writing back item.nat would trigger
+                * a seqno mismatch oops.  Workaround: edit in-place.
+                */
+               np = getnatp(item.nat.nat_cnum);
+               ret = edit_nat(np, key, ptr);
+               if (ret != RET_OK)
+                   return ret;
+               if (!putnat(np))
+                   return RET_FAIL;
+               item.nat = *np;
+               continue;
+           case EF_SECTOR:
+               ret = edit_sect(&item.sect, key, ptr);
+               break;
+           case EF_SHIP:
+               ret = edit_ship(&item.ship, key, ptr);
+               break;
+           case EF_LAND:
+               ret = edit_land(&item.land, key, ptr);
+               break;
+           case EF_PLANE:
+               ret = edit_plane(&item.plane, key, ptr);
+               break;
+           case EF_NUKE:
+               ret = edit_nuke(&item.nuke, key, ptr);
+               break;
+           default:
+               CANT_REACH();
+           }
            if (ret != RET_OK)
                return ret;
-           if (!putnat(np))
+           if (!put_empobj(type, item.gen.uid, &item.gen))
                return RET_FAIL;
-           item.nat = *np;
-           break;
-       case 'l':
-           if (!check_sect_ok(&item.sect))
-               return RET_FAIL;
-           ret = edit_sect(&item.sect, key, ptr);
-           if (ret != RET_OK)
-               return ret;
-           if (!putsect(&item.sect))
-               return RET_FAIL;
-           break;
-       case 's':
-           if (!check_ship_ok(&item.ship))
-               return RET_FAIL;
-           ret = edit_ship(&item.ship, key, ptr);
-           if (ret != RET_OK)
-               return ret;
-           if (!putship(item.ship.shp_uid, &item.ship))
-               return RET_FAIL;
-           break;
-       case 'u':
-           if (!check_land_ok(&item.land))
-               return RET_FAIL;
-           ret = edit_land(&item.land, key, ptr);
-           if (ret != RET_OK)
-               return ret;
-           if (!putland(item.land.lnd_uid, &item.land))
-               return RET_FAIL;
-           break;
-       case 'p':
-           if (!check_plane_ok(&item.plane))
-               return RET_FAIL;
-           ret = edit_plane(&item.plane, key, ptr);
-           if (ret != RET_OK)
-               return ret;
-           if (!putplane(item.plane.pln_uid, &item.plane))
-               return RET_FAIL;
-           break;
-       default:
-           CANT_REACH();
        }
     }
+
+    return RET_OK;
 }
 
 static void
@@ -249,11 +226,9 @@ print_sect(struct sctstr *sect)
 static void
 print_nat(struct natstr *np)
 {
-    int i;
-
     pr("Country #: %2d\n", np->nat_cnum);
     pr("Name <n>: %-20s\t", np->nat_cnam);
-    pr("Representative <r>: %-20s\n", np->nat_pnam);
+    pr("Representative <r>: %s\n", np->nat_pnam);
     pr("BTUs <b>: %3d\t\t\t", np->nat_btu);
     pr("Reserves <m>: %5d\n", np->nat_reserve);
     pr("Capital <c>: %s\t\t",
@@ -268,14 +243,6 @@ print_nat(struct natstr *np)
     pr("Happiness <H>: %.2f\n", np->nat_level[NAT_HLEV]);
     pr("Money <M>: $%6d\n", np->nat_money);
     pr("Telegrams <t>: %6d\n", np->nat_tgms);
-    if (opt_HIDDEN) {
-       pr("Countries contacted: ");
-       for (i = 0; i < MAXNOC; i++) {
-           if (getcontact(np, i))
-               pr("%d(%d) ", i, getcontact(np, i));
-       }
-       pr("\n");
-    }
 }
 
 static void
@@ -283,6 +250,7 @@ print_plane(struct plnstr *plane)
 {
     pr("%s %s\n", prnatid(plane->pln_own), prplane(plane));
     pr("UID <U>: %d\t\t", plane->pln_uid);
+    pr("Type <T>: %s\n", plchr[plane->pln_type].pl_name);
     pr("Owner <O>: %d\t\t", plane->pln_own);
     pr("Location <l>: %s\n",
        xyas(plane->pln_x, plane->pln_y, player->cnum));
@@ -293,14 +261,15 @@ print_plane(struct plnstr *plane)
     pr("Range <r>: %d\t\t", plane->pln_range);
     pr("Flags <f>: %d\n", plane->pln_flags);
     pr("Ship <s>: %d\t\t", plane->pln_ship);
-    pr("Land Unit <y>: %d\t", plane->pln_land);
+    pr("Land Unit <y>: %d\n", plane->pln_land);
 }
 
 static void
 print_land(struct lndstr *land)
 {
     pr("%s %s\n", prnatid(land->lnd_own), prland(land));
-    pr("UID <U>: %d\n", land->lnd_uid);
+    pr("UID <U>: %d\t\t", land->lnd_uid);
+    pr("Type <T>: %s\n", lchr[land->lnd_type].l_name);
     pr("Owner <O>: %d\n", land->lnd_own);
     pr("Location <L>: %s\n", xyas(land->lnd_x, land->lnd_y, player->cnum));
     pr("Efficiency <e>: %d\t", land->lnd_effic);
@@ -335,7 +304,8 @@ static void
 print_ship(struct shpstr *ship)
 {
     pr("%s %s\n", prnatid(ship->shp_own), prship(ship));
-    pr("UID <U>: %d\n", ship->shp_uid);
+    pr("UID <U>: %d\t\t\t", ship->shp_uid);
+    pr("Type <t>: %s\n", mchr[ship->shp_type].m_name);
     pr("Owner <O>: %d\t\t\t", ship->shp_own);
     pr("Location <L>: %s\n", xyas(ship->shp_x, ship->shp_y, player->cnum));
     pr("Tech <T>: %d\t\t\t", ship->shp_tech);
@@ -364,6 +334,19 @@ print_ship(struct shpstr *ship)
     pr("\n");
 }
 
+static void
+print_nuke(struct nukstr *nuke)
+{
+    pr("%s %s\n", prnatid(nuke->nuk_own), prnuke(nuke));
+    pr("UID <U>: %d\t\t\t", nuke->nuk_uid);
+    pr("Type <t>: %d\n", nuke->nuk_type);
+    pr("Owner <O>: %d\t\t\t", nuke->nuk_own);
+    pr("Location <L>: %s\n", xyas(nuke->nuk_x, nuke->nuk_y, player->cnum));
+    pr("Tech <T>: %d\t\t\t", nuke->nuk_tech);
+    pr("Stockpile <S>: %.1s\n", &nuke->nuk_stockpile);
+    pr("Plane <p>: %d\n", nuke->nuk_plane);
+}
+
 static char *
 getin(char *buf, char **valp)
 {
@@ -566,8 +549,14 @@ edit_sect(struct sctstr *sect, char *key, char *p)
                         newsect.sct_own);
        report_god_gives("Sector ", xyas(newx, newy, sect->sct_own),
                         sect->sct_own);
+       if (sect->sct_x == sect->sct_dist_x
+           && sect->sct_y == sect->sct_dist_y) {
+           sect->sct_dist_x = newx;
+           sect->sct_dist_y = newy;
+       }
        sect->sct_x = newx;
        sect->sct_y = newy;
+       sect->sct_coastal = newsect.sct_coastal;
        ef_set_uid(EF_SECTOR, sect, XYOFFSET(newx, newy));
        break;
     case 'D':
@@ -757,7 +746,7 @@ edit_unit(struct empobj *unit, char *key, char *p,
     coord newx, newy;
     union empobj_storage newunit;
     char newgroup;
+
     switch (toupper(*key)) {
     case 'U':
        if (arg < 0)
@@ -790,6 +779,11 @@ edit_unit(struct empobj *unit, char *key, char *p,
            report_god_takes("", unit_nameof(unit), unit->own);
            report_god_gives("", unit_nameof(unit), arg);
        }
+       if (arg && unit->effic < mineff) {
+           divine_unit_change_quiet(unit, "Efficiency", 1,
+                                    "from %d to %d", unit->effic, mineff);
+           unit->effic = mineff;
+       }
        unit->own = arg;
        break;
     case 'L':
@@ -800,10 +794,12 @@ edit_unit(struct empobj *unit, char *key, char *p,
            return RET_FAIL;
        }
        divine_unit_change_quiet(unit, "Location",
-                                unit->own && unit->own != player->cnum,
+                                newx != unit->x || newy != unit->y,
                                 "from %s to %s",
                                 xyas(unit->x, unit->y, player->cnum),
                                 xyas(newx, newy, player->cnum));
+       if (newx == unit->x && newy == unit->y)
+           break;
        if (unit->own && unit->own != player->cnum)
            wu(0, unit->own,
               "Location of %s changed from %s to %s by an act of %s!\n",
@@ -811,8 +807,7 @@ edit_unit(struct empobj *unit, char *key, char *p,
               xyas(unit->x, unit->y, unit->own),
               xyas(newx, newy, unit->own),
               cname(player->cnum));
-       unit->x = newx;
-       unit->y = newy;
+       unit_teleport(unit, newx, newy);
        break;
     case 'E':
        arg = LIMIT_TO(arg, mineff, 100);
@@ -831,6 +826,7 @@ edit_unit(struct empobj *unit, char *key, char *p,
     case 'F':
     case 'W':
     case 'A':
+    case 'S':
        if (p[0] == '~')
            newgroup = 0;
        else if (isalpha(p[0]))
@@ -850,12 +846,35 @@ edit_unit(struct empobj *unit, char *key, char *p,
     return RET_OK;
 }
 
+static void
+edit_item(struct empobj *unit, short item[], struct ichrstr *ip, int arg,
+         short lim[])
+{
+    arg = LIMIT_TO(arg, 0, lim[ip->i_uid]);
+    divine_unit_change_quiet(unit, ip->i_name, arg != item[ip->i_uid],
+                            "from %d to %d", item[ip->i_uid], arg);
+    report_divine_gift(unit->own, ip, arg - item[ip->i_uid],
+                      unit_nameof(unit));
+    item[ip->i_uid] = arg;
+}
+
+static void
+limit_item(struct empobj *unit, short item[], short lim[])
+{
+    i_type it;
+
+    for (it = I_NONE + 1; it <= I_MAX; it++) {
+       if (item[it] > lim[it])
+           edit_item(unit, item, &ichr[it], item[it], lim);
+    }
+}
+
 static int
 edit_ship(struct shpstr *ship, char *key, char *p)
 {
     struct mchrstr *mcp = &mchr[ship->shp_type];
     int arg = atoi(p);
-    struct ichrstr *ip;
+    int ret;
 
     switch (*key) {
     case 'U':
@@ -864,8 +883,24 @@ edit_ship(struct shpstr *ship, char *key, char *p)
     case 'E':
     case 'M':
     case 'F':
-       return edit_unit((struct empobj *)ship, key, p,
-                        SHIP_MINEFF, "fleet", 0);
+       ret = edit_unit((struct empobj *)ship, key, p,
+                       SHIP_MINEFF, "fleet", 0);
+       return ret;
+    case 't':
+       arg = ef_elt_byname(EF_SHIP_CHR, p);
+       if (arg < 0) {
+           pr("%s: invalid ship type\n", p);
+           return RET_FAIL;
+       }
+       divine_unit_change((struct empobj *)ship, "Type",
+                          arg != ship->shp_type, 0,
+                          "to %s", mchr[arg].m_name);
+       if (ship->shp_tech < mchr[arg].m_tech)
+           shp_set_tech(ship, mchr[arg].m_tech);
+       ship->shp_type = arg;
+       shp_set_tech(ship, ship->shp_tech);
+       limit_item((struct empobj *)ship, ship->shp_item, mchr[arg].m_item);
+       break;
     case 'T':
        arg = LIMIT_TO(arg, mcp->m_tech, SHRT_MAX);
        divine_unit_change((struct empobj *)ship, "Tech level",
@@ -912,15 +947,8 @@ edit_ship(struct shpstr *ship, char *key, char *p)
     case 'l':
     case 'h':
     case 'r':
-       ip = item_by_name(key);
-       arg = LIMIT_TO(arg, 0, mchr[ship->shp_type].m_item[ip->i_uid]);
-       divine_unit_change_quiet((struct empobj *)ship, ip->i_name,
-                                arg != ship->shp_item[ip->i_uid],
-                                "from %d to %d",
-                                ship->shp_item[ip->i_uid], arg);
-       report_divine_gift(ship->shp_own, ip,
-                          arg - ship->shp_item[ip->i_uid], prship(ship));
-       ship->shp_item[ip->i_uid] = arg;
+       edit_item((struct empobj *)ship, ship->shp_item, item_by_name(key),
+                 arg, mcp->m_item);
        break;
     default:
        pr("huh? (%s)\n", key);
@@ -934,7 +962,6 @@ edit_land(struct lndstr *land, char *key, char *p)
 {
     struct lchrstr *lcp = &lchr[land->lnd_type];
     int arg = atoi(p);
-    struct ichrstr *ip;
 
     switch (*key) {
     case 'U':
@@ -946,6 +973,21 @@ edit_land(struct lndstr *land, char *key, char *p)
        return edit_unit((struct empobj *)land, key, p,
                         LAND_MINEFF, "army",
                         land->lnd_ship >= 0 || land->lnd_land >= 0);
+    case 'T':
+       arg = ef_elt_byname(EF_LAND_CHR, p);
+       if (arg < 0) {
+           pr("%s: invalid land unit type\n", p);
+           return RET_FAIL;
+       }
+       divine_unit_change((struct empobj *)land, "Type",
+                          arg != land->lnd_type, 0,
+                          "to %s", lchr[arg].l_name);
+       if (land->lnd_tech < lchr[arg].l_tech)
+           lnd_set_tech(land, lchr[arg].l_tech);
+       land->lnd_type = arg;
+       lnd_set_tech(land, land->lnd_tech);
+       limit_item((struct empobj *)land, land->lnd_item, lchr[arg].l_item);
+       break;
     case 't':
        arg = LIMIT_TO(arg, lcp->l_tech, SHRT_MAX);
        divine_unit_change((struct empobj *)land, "Tech level",
@@ -990,6 +1032,20 @@ edit_land(struct lndstr *land, char *key, char *p)
        divine_load((struct empobj *)land, EF_LAND, arg);
        land->lnd_land = arg;
        break;
+    case 'A':
+       arg = LIMIT_TO(arg, 0, PLG_EXPOSED);
+       divine_unit_change_quiet((struct empobj *)land, "Plague stage",
+                                arg != land->lnd_pstage,
+                                "from %d to %d", land->lnd_pstage, arg);
+       land->lnd_pstage = arg;
+       break;
+    case 'b':
+       arg = LIMIT_TO(arg, 0, 32767);
+       divine_unit_change_quiet((struct empobj *)land, "Plague time",
+                                arg != land->lnd_ptime,
+                                "from %d to %d", land->lnd_ptime, arg);
+       land->lnd_ptime = arg;
+       break;
     case 'Z':
        arg = LIMIT_TO(arg, 0, 100);
        divine_unit_change((struct empobj *)land, "Retreat percentage",
@@ -1022,15 +1078,8 @@ edit_land(struct lndstr *land, char *key, char *p)
     case 'l':
     case 'h':
     case 'r':
-       ip = item_by_name(key);
-       arg = LIMIT_TO(arg, 0, lchr[land->lnd_type].l_item[ip->i_uid]);
-       divine_unit_change_quiet((struct empobj *)land, ip->i_name,
-                                arg != land->lnd_item[ip->i_uid],
-                                "from %d to %d",
-                                land->lnd_item[ip->i_uid], arg);
-       report_divine_gift(land->lnd_own, ip,
-                          arg - land->lnd_item[ip->i_uid], prland(land));
-       land->lnd_item[ip->i_uid] = arg;
+       edit_item((struct empobj *)land, land->lnd_item, item_by_name(key),
+                 arg, lcp->l_item);
        break;
     default:
        pr("huh? (%s)\n", key);
@@ -1055,6 +1104,23 @@ edit_plane(struct plnstr *plane, char *key, char *p)
        return edit_unit((struct empobj *)plane, key, p,
                         PLANE_MINEFF, "wing",
                         plane->pln_ship >= 0 || plane->pln_land >= 0);
+    case 'T':
+       arg = ef_elt_byname(EF_PLANE_CHR, p);
+       if (arg < 0) {
+           pr("%s: invalid plane type\n", p);
+           return RET_FAIL;
+       }
+       divine_unit_change((struct empobj *)plane, "Type",
+                          arg != plane->pln_type, 0,
+                          "to %s", plchr[arg].pl_name);
+       if (plane->pln_tech < plchr[arg].pl_tech)
+           pln_set_tech(plane, plchr[arg].pl_tech);
+       if (plane->pln_range >= pln_range_max(plane))
+           /* preserve unlimited range, pln_set_tech() will adjust */
+           plane->pln_range = UCHAR_MAX;
+       plane->pln_type = arg;
+       pln_set_tech(plane, plane->pln_tech);
+       break;
     case 't':
        arg = LIMIT_TO(arg, pcp->pl_tech, SHRT_MAX);
        divine_unit_change((struct empobj *)plane, "Tech level",
@@ -1110,3 +1176,54 @@ edit_plane(struct plnstr *plane, char *key, char *p)
     }
     return RET_OK;
 }
+
+static int
+edit_nuke(struct nukstr *nuke, char *key, char *p)
+{
+    struct nchrstr *ncp = &nchr[nuke->nuk_type];
+    int arg = atoi(p);
+
+    switch (*key) {
+    case 'U':
+    case 'O':
+    case 'L':
+    case 'S':
+       return edit_unit((struct empobj *)nuke, key, p,
+                        100, "stockpile", nuke->nuk_plane >= 0);
+    case 't':
+       arg = ef_elt_byname(EF_NUKE_CHR, p);
+       if (arg < 0) {
+           pr("%s: invalid nuke type\n", p);
+           return RET_FAIL;
+       }
+       divine_unit_change((struct empobj *)nuke, "Type",
+                          arg != nuke->nuk_type, 0,
+                          "to %s", nchr[arg].n_name);
+       if (nuke->nuk_tech < nchr[arg].n_tech)
+           nuke->nuk_tech = nchr[arg].n_tech;
+       nuke->nuk_type = arg;
+       break;
+    case 'T':
+       arg = LIMIT_TO(arg, ncp->n_tech, SHRT_MAX);
+       divine_unit_change((struct empobj *)nuke, "Tech level",
+                          arg != nuke->nuk_tech, arg - nuke->nuk_tech,
+                          "from %d to %d", nuke->nuk_tech, arg);
+       nuke->nuk_tech = arg;
+       break;
+    case 'p':
+       if (arg < -1 || arg >= ef_nelem(EF_PLANE))
+           return RET_SYN;
+       if (arg == nuke->nuk_plane) {
+           pr("Plane of %s unchanged\n", prnuke(nuke));
+           break;
+       }
+       divine_unload((struct empobj *)nuke, EF_PLANE, nuke->nuk_plane);
+       divine_load((struct empobj *)nuke, EF_PLANE, arg);
+       nuke->nuk_plane = arg;
+       break;
+    default:
+       pr("huh? (%s)\n", key);
+       return RET_FAIL;
+    }
+    return RET_OK;
+}