]> git.pond.sub.org Git - empserver/commitdiff
Change nuke storage and commands to match other units:
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 6 May 2006 07:20:21 +0000 (07:20 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 6 May 2006 07:20:21 +0000 (07:20 +0000)
(nukstr): Hold one nuke instead of a stockpile: replace members nuk_n,
nuk_types by nuk_type, nuk_plane.  Add nuk_land for completeness, like
nuk_ship it's not yet used.
(nuke_ca): Update accordingly: replace selectors number and types by
type and plane.
(build_nuke): Update accordingly.
(ndump, nuke): Update accordingly.  Output is no longer sorted by
location, and nukes in same location no longer share id.  nuke's extra
columns for nuclear plants are repeated for every nuke.
(trade_desc): Update accordingly.
(cede, grab_sect, check_nuke_ok, detonate, trade_nameof): Talk about
nukes instead of nuclear stockpiles.
(arm, disarm): Rewrite, split off new disarm().  Don't remove nuke
from the nuke file on arm.  Allow usual plane syntax, not just plane
number.  Change second argument from nuke type to nuke number.  When
plane is already armed, ignore nuke argument and rearm (broken in
4.2.6).
(tran_nuke): Update for changed struct nukstr, make as similar as
possible to tran_plane.  Change syntax to match transport plane.
(player_coms): Update arm, disarm and transport accordingly.
(prnuke, nuk_on_plane): New.
(nuk_add, nuk_delete): Stockpile management, remove.

16 files changed:
include/nuke.h
include/prototypes.h
info/arm.t
info/transport.t
src/lib/commands/arm.c
src/lib/commands/buil.c
src/lib/commands/cede.c
src/lib/commands/ndump.c
src/lib/commands/nuke.c
src/lib/commands/tran.c
src/lib/common/check.c
src/lib/global/nsc.c
src/lib/player/empmod.c
src/lib/subs/detonate.c
src/lib/subs/nuke.c
src/lib/subs/trdsub.c

index 8488167657817212b24b60b30074942411afb9d3..27c3215a2339bb4492fc761e03b0677911d9a298 100644 (file)
@@ -42,13 +42,12 @@ struct nukstr {
     short ef_type;
     natid nuk_own;
     short nuk_uid;
-    coord nuk_x;               /* current loc of device */
-    coord nuk_y;
+    coord nuk_x, nuk_y;                /* current loc of device */
+    signed char nuk_type;      /* index in plchr[] */
     /* end of part matching struct genitem */
-    signed char nuk_n;         /* number of nukes in list */
     short nuk_ship;            /* currently aboard ship (unused) */
-    short nuk_trade;           /* index into trade file (unused) */
-    short nuk_types[N_MAXNUKE];        /* # of nukes in sector of given type */
+    short nuk_plane;           /* currently aboard plane */
+    short nuk_land;            /* currently aboard land (unused) */
     time_t nuk_timestamp;      /* Last time this nuke was touched */
 };
 
index ad63a63f00927da5831f4c0acfa5088cff8d1eee..5e193e665d3db13c216f1e16893015b7373abcce 100644 (file)
@@ -109,6 +109,7 @@ int deli(void);
 int demo(void);
 int desi(void);
 int disa(void);
+int disarm(void);
 int dist(void);
 int drop(void);
 int dump(void);
@@ -528,11 +529,11 @@ extern void delete_old_news(void);
 extern void init_nreport(void);
 extern void nreport(natid, int, natid, int);
 /* nuke.c */
+extern char *prnuke(struct nukstr *);
 extern int nuk_postread(int, void *);
 extern int nuk_prewrite(int, void *);
 extern void nuk_init(int, void *);
-extern void nuk_add(coord, coord, int, int);
-extern void nuk_delete(struct nukstr *, int, int);
+extern int nuk_on_plane(struct nukstr *, int);
 /* nxtitem.c */
 extern int nxtitem(struct nstr_item *, void *);
 /* nxtsct.c */
index 81ab076231ad90a53ab9c73925d82e8299586164..865e3324619da0373ae9edc68d2fd334fd97fdfd 100644 (file)
@@ -1,7 +1,7 @@
 .TH Command ARM
 .NA arm "Load nuclear weapons onto planes or missiles"
 .LV Expert
-.SY "arm <PLANE> <NUKETYPE> <airburst?>"
+.SY "arm <PLANE> <NUKE> <airburst?>"
 The \*Qarm\*U command loads nuclear devices
 aboard delivery systems such as planes or missiles.
 .s1
index f03d1ce1393e3bd8da7374cb7c94948846880e14..1d3ae1141bc400e85f347c2745b4043c777eea3a 100644 (file)
@@ -2,7 +2,7 @@
 .NA transport "Move planes or nuclear devices around"
 .LV Basic
 .SY "transport plane <PLANES> <ROUTE|DESTINATION>"
-.SY "transport nuke <SECT> <NUKETYPE> <number> <ROUTE|DESTINATION>"
+.SY "transport nuke <NUKES> <ROUTE|DESTINATION>"
 The transport command is used to move planes and nuclear devices from
 one sector to another, along the ground.
 .s1
@@ -11,8 +11,8 @@ one sector to another, along the ground.
 the route, and empire will use the cheapest path (in terms of mobility)
 from the current sector to the destination sector.
 .s1
-You would move 5 small nukes from 2,0 to 8,0 as follows:
-.EX transport nuke 2,0 small 5 8,0
+You would move nuke #666 to 8,0 as follows:
+.EX transport nuke 666 8,0
 .s1
 You could move all planes in wing d to -6,0 as follows:
 .EX transport plane d -6,0
index 69aecb9dc08a2fbcb80ccab07ed146cae4371f46..9dd9022d70f74c58b6569a40025b06a89335aeac 100644 (file)
@@ -52,73 +52,55 @@ arm(void)
     struct nchrstr *ncp;
     struct plchrstr *plc;
     struct plnstr pl;
-    struct plnstr start;       /* Used for sanity checking */
     struct nukstr nuke;
     char *p;
-    int pno;
-    int nuketype;
-    int found;
+    int pno, nukno;
     struct nstr_item ni;
     char buf[1024];
-    int disarm = **player->argp == 'd';
-    char *prompt = disarm ? "Disarm plane: " : "Arm plane: ";
+    char prompt[128];
 
-    if (!(p = getstarg(player->argp[1], prompt, buf)) || !*p)
+    if (!snxtitem(&ni, EF_PLANE, player->argp[1]))
        return RET_SYN;
-    pno = atoi(p);
-    if (pno < 0 || !getplane(pno, &pl) || pl.pln_own != player->cnum)
-       return RET_FAIL;
-    memcpy(&start, &pl, sizeof(struct plnstr));
-    plc = &plchr[(int)pl.pln_type];
-    if ((plc->pl_flags & (P_O | P_M)) == (P_O | P_M)) {
-       pr("A %s cannot carry nuclear devices!\n", plc->pl_name);
-       return RET_FAIL;
-    }
-    if (opt_MARKET) {
-       if (ontradingblock(EF_PLANE, &pl)) {
-           pr("You cannot arm/disarm an item on the trading block!\n");
-           return RET_FAIL;
-       }
-    }
-    if (pl.pln_nuketype == -1) {
-       if (disarm) {
-           pr("%s is not carrying any nuclear devices\n", prplane(&pl));
+    while (nxtitem(&ni, &pl)) {
+       if (!player->owner)
+           continue;
+       plc = &plchr[(int)pl.pln_type];
+       if ((plc->pl_flags & (P_O | P_M)) == (P_O | P_M)) {
+           pr("A %s cannot carry nuclear devices!\n", plc->pl_name);
            return RET_FAIL;
        }
-       if ((p = getstarg(player->argp[2], "Device type: ", buf)) == 0)
-           return RET_SYN;
-       if (!check_plane_ok(&start))
-           return RET_FAIL;
-       nuketype = typematch(p, EF_NUKE);
-       if (nuketype < 0) {
-           pr("No such nuke type!\n");
-           return RET_SYN;
-       }
-       ncp = &nchr[nuketype];
-       found = 0;
-       snxtitem_xy(&ni, EF_NUKE, pl.pln_x, pl.pln_y);
-       while (nxtitem(&ni, &nuke)) {
-           if (nuke.nuk_own == player->cnum) {
-               found = 1;
-               break;
+       if (opt_MARKET) {
+           if (ontradingblock(EF_PLANE, &pl)) {
+               pr("You cannot disarm %s while it is on the trading block!\n",
+                  prplane(&pl));
+               return RET_FAIL;
            }
        }
-       if (!found) {
-           pr("You don't own any nukes in that sector.\n");
-           return RET_FAIL;
-       }
-       if (nuke.nuk_types[nuketype] == 0) {
-           pr("No nukes of that type in that sector.\n");
-           return RET_FAIL;
+       if (pl.pln_nuketype < 0) {
+           sprintf(prompt, "Nuclear device for %s: ", prplane(&pl));
+           p = getstarg(player->argp[2], prompt, buf);
+           if (!p || !*p)
+               return RET_SYN;
+           if (!check_plane_ok(&pl))
+               return RET_FAIL;
+           nukno = atoi(p);
+           if (!getnuke(nukno, &nuke) || !player->owner)
+               return RET_FAIL;
+       } else {
+           if (nuk_on_plane(&nuke, pl.pln_uid) < 0) {
+               CANT_REACH();
+               continue;
+           }
        }
+       ncp = &nchr[nuke.nuk_type];
        if (pl.pln_load < ncp->n_weight) {
-           pr("A %s cannot carry %s devices!\n", plc->pl_name,
-              ncp->n_name);
+           pr("A %s cannot carry %s devices!\n",
+              plc->pl_name, ncp->n_name);
            return RET_FAIL;
        }
        p = getstarg(player->argp[3], "Airburst [n]? ", buf);
 
-       if (!check_plane_ok(&start))
+       if (!check_plane_ok(&pl) || !check_nuke_ok(&nuke))
            return RET_FAIL;
 
        if (p && (*p == 'y' || *p == 'Y'))
@@ -126,26 +108,52 @@ arm(void)
        else
            pl.pln_flags &= ~PLN_AIRBURST;
 
-       pl.pln_nuketype = nuketype;
-       nuk_delete(&nuke, nuketype, 1);
-    } else if (!disarm) {
-       pr("%s already carrying a warhead.\n", prplane(&pl));
-    }
-    if (disarm) {
-       pr("%s warhead removed from %s and added to %s\n",
-          nchr[(int)pl.pln_nuketype].n_name,
-          prplane(&pl), xyas(pl.pln_x, pl.pln_y, player->cnum));
-       nuk_add(pl.pln_x, pl.pln_y, pl.pln_nuketype, 1);
-       pl.pln_nuketype = -1;
-       pl.pln_flags &= ~PLN_AIRBURST;
-    } else {
-       pr("%s armed with a %s warhead.\n", prplane(&pl),
-          nchr[(int)pl.pln_nuketype].n_name);
+       pl.pln_nuketype = nuke.nuk_type;
+       nuke.nuk_plane = pl.pln_uid;
+       putplane(pl.pln_uid, &pl);
+       putnuke(nuke.nuk_uid, &nuke);
+       pr("%s armed with %s.\n", prplane(&pl), prnuke(&nuke));
        pr("Warhead on %s is programmed to %s\n",
           prplane(&pl),
           pl.pln_flags & PLN_AIRBURST ? "airburst" : "groundburst");
     }
 
-    putplane(pl.pln_uid, &pl);
+    return RET_OK;
+}
+
+int
+disarm(void)
+{
+    struct plnstr pl;
+    struct nukstr nuke;
+    struct nstr_item ni;
+
+    if (!snxtitem(&ni, EF_PLANE, player->argp[1]))
+       return RET_SYN;
+    while (nxtitem(&ni, &pl)) {
+       if (!player->owner)
+           continue;
+       if (pl.pln_nuketype == -1)
+           continue;
+       if (opt_MARKET) {
+           if (ontradingblock(EF_PLANE, &pl)) {
+               pr("You cannot disarm %s while it is on the trading block!\n",
+                  prplane(&pl));
+               return RET_FAIL;
+           }
+       }
+       if (nuk_on_plane(&nuke, pl.pln_uid) < 0) {
+           CANT_REACH();
+           continue;
+       }
+       nuke.nuk_plane = -1;
+       pl.pln_nuketype = -1;
+       pl.pln_flags &= ~PLN_AIRBURST;
+       putplane(pl.pln_uid, &pl);
+       putnuke(nuke.nuk_uid, &nuke);
+       pr("%s removed from %s and added to %s\n",
+          prnuke(&nuke), prplane(&pl),
+          xyas(pl.pln_x, pl.pln_y, player->cnum));
+    }
     return RET_OK;
 }
index 76706fa32635127e7e37d1061af61fa54339559a..95a8917c1ff5cc644f55943e96fb44c3e54e097b 100644 (file)
@@ -639,10 +639,12 @@ build_bridge(struct sctstr *sp, short *vec)
 }
 
 static int
-build_nuke(struct sctstr *sp, struct nchrstr *np,
-          short *vec)
+build_nuke(struct sctstr *sp, struct nchrstr *np, short *vec)
 {
+    struct nukstr nuke;
+    struct nstr_item nstr;
     int avail;
+    int freenuke;
 
     if (sp->sct_type != SCT_NUKE && !player->god) {
        pr("Nuclear weapons must be built in nuclear plants.\n");
@@ -681,12 +683,34 @@ build_nuke(struct sctstr *sp, struct nchrstr *np,
        return 0;
     sp->sct_avail -= avail;
     player->dolcost += np->n_cost;
-    nuk_add(sp->sct_x, sp->sct_y, np - nchr, 1);
+    snxtitem_all(&nstr, EF_NUKE);
+    freenuke = 0;
+    while (nxtitem(&nstr, &nuke)) {
+       if (nuke.nuk_own == 0) {
+           freenuke++;
+           break;
+       }
+    }
+    if (freenuke == 0) {
+       ef_extend(EF_NUKE, 50);
+    }
+    memset(&nuke, 0, sizeof(struct nukstr));
+    nuke.nuk_x = sp->sct_x;
+    nuke.nuk_y = sp->sct_y;
+    nuke.nuk_own = sp->sct_own;
+    nuke.nuk_type = np - nchr;
+    nuke.nuk_ship = nuke.nuk_plane = nuke.nuk_land = -1;
+    nuke.nuk_uid = nstr.cur;
+
     vec[I_HCM] -= np->n_hcm;
     vec[I_LCM] -= np->n_lcm;
     vec[I_OIL] -= np->n_oil;
     vec[I_RAD] -= np->n_rad;
-    pr("%s warhead created in %s\n", np->n_name,
+
+    makenotlost(EF_NUKE, nuke.nuk_own, nuke.nuk_uid,
+               nuke.nuk_x, nuke.nuk_y);
+    putnuke(nuke.nuk_uid, &nuke);
+    pr("%s created in %s\n", prnuke(&nuke),
        xyas(sp->sct_x, sp->sct_y, player->cnum));
     return 1;
 }
@@ -701,7 +725,7 @@ build_plane(struct sctstr *sp, struct plchrstr *pp,
     double cost;
     float eff = PLANE_MINEFF / 100.0;
     int hcm, lcm, mil;
-    int freeplane = 0;
+    int freeplane;
 
     mil = roundavg(((double)pp->pl_crew * eff));
     /* Always use at least 1 mil to build a plane */
index 0ba9623f983dd7b9dfa77b61f2fd5c6e6581f93a..08817061a81161d1b0b34499f31fa36c222726c4 100644 (file)
@@ -231,8 +231,8 @@ grab_sect(struct sctstr *sp, natid to)
        if (np->nuk_own == 0)
            continue;
 
-       wu(0, to, "\tnuclear stockpile #%d ceded to you by %s\n",
-          np->nuk_uid, cname(player->cnum));
+       wu(0, to, "\t%s ceded to you by %s\n",
+          prnuke(np), cname(player->cnum));
        makelost(EF_NUKE, np->nuk_own, np->nuk_uid, np->nuk_x, np->nuk_y);
        np->nuk_own = to;
        makenotlost(EF_NUKE, np->nuk_own, np->nuk_uid, np->nuk_x,
index 8bf9570e4c6624863d257ced6400cd9464c75e25..8c4dab8806a035c3f2d3b9a6f4010a92c3c17097 100644 (file)
@@ -67,17 +67,13 @@ ndump(void)
        if (nuk.nuk_own == 0)
            continue;
        nnukes++;
-       for (i = 0; i < N_MAXNUKE; i++) {
-           if (nuk.nuk_types[i] > 0) {
-               if (player->god)
-                   pr("%d ", nuk.nuk_own);
-               pr("%d ", nuk.nuk_uid);
-               prxy("%d %d", nuk.nuk_x, nuk.nuk_y, player->cnum);
-               pr(" %d", nuk.nuk_types[i]);
-               pr(" %.5s", nchr[i].n_name);
-               pr("\n");
-           }
-       }
+       if (player->god)
+           pr("%d ", nuk.nuk_own);
+       pr("%d ", nuk.nuk_uid);
+       prxy("%d %d", nuk.nuk_x, nuk.nuk_y, player->cnum);
+       pr(" %d", 1);
+       pr(" %.5s", nchr[(int)nuk.nuk_type].n_name);
+       pr("\n");
     }
     if (nnukes == 0) {
        if (player->argp[1])
index 0c6a9651ea73dab6f9a3fcd2888c742ae6963f62..0902b77ff1945ec2d52174895f8d705f24e368eb 100644 (file)
@@ -47,7 +47,6 @@ int
 nuke(void)
 {
     int first_line = 0;
-    int first_nuke;
     int show_comm;
     int i;
     struct nstr_item nstr;
@@ -68,41 +67,31 @@ nuke(void)
            pr("  sect        eff num nuke-type         lcm   hcm   oil   rad avail\n");
        }
        getsect(nuk.nuk_x, nuk.nuk_y, &sect);
-       first_nuke = 1;
        show_comm = 0;
        if (sect.sct_type == SCT_NUKE && sect.sct_effic >= 60)
            show_comm = 1;
-       for (i = 0; i < N_MAXNUKE; i++) {
-           if (nuk.nuk_types[i] > 0) {
-               if (first_nuke) {
-                   if (player->god)
-                       pr("%-3d ", nuk.nuk_own);
-                   prxy("%4d,%-4d", sect.sct_x, sect.sct_y, player->cnum);
-                   pr(" %c", dchr[sect.sct_type].d_mnem);
-                   if (sect.sct_newtype != sect.sct_type)
-                       pr("%c", dchr[sect.sct_newtype].d_mnem);
-                   else
-                       pr(" ");
-                   pr("%4d%%", sect.sct_effic);
-                   first_nuke = 0;
-               } else {
-                   pr("                 ");
-               }
+       if (player->god)
+           pr("%-3d ", nuk.nuk_own);
+       prxy("%4d,%-4d", sect.sct_x, sect.sct_y, player->cnum);
+       pr(" %c", dchr[sect.sct_type].d_mnem);
+       if (sect.sct_newtype != sect.sct_type)
+           pr("%c", dchr[sect.sct_newtype].d_mnem);
+       else
+           pr(" ");
+       pr("%4d%%", sect.sct_effic);
 
-               pr("%3d ", nuk.nuk_types[i]);
-               pr("%-16.16s ", nchr[i].n_name);
+       pr("%3d ", 1);
+       pr("%-16.16s ", nchr[(int)nuk.nuk_type].n_name);
 
-               if (show_comm) {
-                   pr("%5d ", sect.sct_item[I_LCM]);
-                   pr("%5d ", sect.sct_item[I_HCM]);
-                   pr("%5d ", sect.sct_item[I_OIL]);
-                   pr("%5d ", sect.sct_item[I_RAD]);
-                   pr("%5d", sect.sct_avail);
-                   show_comm = 0;
-               }
-               pr("\n");
-           }
+       if (show_comm) {
+           pr("%5d ", sect.sct_item[I_LCM]);
+           pr("%5d ", sect.sct_item[I_HCM]);
+           pr("%5d ", sect.sct_item[I_OIL]);
+           pr("%5d ", sect.sct_item[I_RAD]);
+           pr("%5d", sect.sct_avail);
+           show_comm = 0;
        }
+       pr("\n");
     }
     return RET_OK;
 }
index fcf241dbedce99a09b68f71aff97fed77e786967..3434e13feb5195fcb254b526ff8d690b0c5b4d4e 100644 (file)
@@ -69,122 +69,89 @@ tran(void)
     return RET_SYN;
 }
 
-/*
- * Kinda silly; only moves the first nuke.
- * Maybe nukes should be made into commodities?
- */
 static int
 tran_nuke(void)
 {
-    struct nchrstr *ncp;
-    coord x, y;
+    coord srcx, srcy;
     coord dstx, dsty;
-    int found;
-    char *p;
-    int nuketype;
-    int moving;
+    int mcost;
+    int weight, count;
+    int type, dam;
+    struct nstr_item nstr;
     struct nukstr nuke;
     struct sctstr sect;
     struct sctstr endsect;
-    int mcost, dam;
-    struct nstr_item nstr;
-    char buf[1024];
 
-    if (!(p = getstarg(player->argp[2], "from sector : ", buf)))
-       return RET_SYN;
-    if (!sarg_xy(p, &x, &y))
+    weight = 0;
+    count = 0;
+    if (!snxtitem(&nstr, EF_NUKE, player->argp[2]))
        return RET_SYN;
-    if (!getsect(x, y, &sect) || !player->owner) {
-       pr("Not yours\n");
-       return RET_FAIL;
-    }
-    snxtitem_xy(&nstr, EF_NUKE, sect.sct_x, sect.sct_y);
-    found = 0;
     while (nxtitem(&nstr, &nuke)) {
-       if (player->owner) {
-           found = 1;
-           break;
+       if (!player->owner)
+           continue;
+       type = nuke.nuk_type;
+       if (nuke.nuk_plane >= 0) {
+           pr("%s is armed and can't be transported\n", prnuke(&nuke));
+           return RET_FAIL;
        }
+       if (count == 0) {
+           srcx = nuke.nuk_x;
+           srcy = nuke.nuk_y;
+       } else {
+           if (nuke.nuk_x != srcx || nuke.nuk_y != srcy) {
+               pr("All nukes must be in the same sector.\n");
+               return RET_FAIL;
+           }
+       }
+       weight += nchr[type].n_weight;
+       ++count;
     }
-    if (!found) {
-       pr("There are no nukes in %s\n",
-          xyas(sect.sct_x, sect.sct_y, player->cnum));
-       return RET_FAIL;
-    }
-    if (!(p = getstarg(player->argp[3], "warhead type : ", buf)))
-       return RET_SYN;
-    if (!check_sect_ok(&sect))
-       return RET_FAIL;
-    nuketype = typematch(p, EF_NUKE);
-    if (nuketype < 0) {
-       pr("No such nuke type!\n");
-       return RET_SYN;
-    }
-    ncp = &nchr[nuketype];
-    if (!nuke.nuk_types[nuketype]) {
-       pr("No %s nukes in %s\n",
-          ncp->n_name, xyas(sect.sct_x, sect.sct_y, player->cnum));
+    if (count == 0) {
+       pr("No planes\n");
        return RET_FAIL;
     }
-    p = getstarg(player->argp[4], "number of warheads : ", buf);
-    if (!check_sect_ok(&sect))
-       return RET_FAIL;
-    if (p == 0 || *p == 0 || (moving = atoi(p)) < 0)
+    if (!getsect(srcx, srcy, &sect) || !player->owner) {
+       pr("You don't own %s\n", xyas(srcx, srcy, player->cnum));
        return RET_FAIL;
-    if (moving > nuke.nuk_types[nuketype]) {
-       moving = nuke.nuk_types[nuketype];
-       if (moving)
-           pr("only moving %d\n", moving);
-       else
-           return RET_FAIL;
     }
     if (!military_control(&sect)) {
        pr("Military control required to move nukes.\n");
        return RET_FAIL;
     }
     dam = 0;
-    mcost = move_ground(&sect, &endsect, (double)ncp->n_weight * moving,
-                       player->argp[5], tran_map, 0, &dam);
-
+    mcost = move_ground(&sect, &endsect, weight,
+                       player->argp[3], tran_map, 0, &dam);
     if (mcost < 0)
        return 0;
 
+    dstx = endsect.sct_x;
+    dsty = endsect.sct_y;
+    snxtitem_rewind(&nstr);
+    while (nxtitem(&nstr, &nuke)) {
+       if (!player->owner)
+           continue;
+       /* TODO apply dam */
+       nuke.nuk_x = dstx;
+       nuke.nuk_y = dsty;
+       putnuke(nuke.nuk_uid, &nuke);
+    }
     if (mcost > 0)
        pr("Total movement cost = %d\n", mcost);
     else
        pr("No mobility used\n");
-
-    dstx = endsect.sct_x;
-    dsty = endsect.sct_y;
-    /*
-     * decrement mobility from src sector
-     */
-    getsect(nuke.nuk_x, nuke.nuk_y, &sect);
+    getsect(srcx, srcy, &sect);
     sect.sct_mobil -= mcost;
     if (sect.sct_mobil < 0)
        sect.sct_mobil = 0;
     putsect(&sect);
-    /*
-     * update old nuke
-     */
-    if (!getnuke(nuke.nuk_uid, &nuke)) {
-       pr("Could not find that stockpile again.\n");
-       return RET_FAIL;
-    }
-    if (nuke.nuk_types[nuketype] < moving || nuke.nuk_own != player->cnum) {
-       pr("Stockpile changed!\n");
-       return RET_FAIL;
-    }
-    nuk_delete(&nuke, nuketype, moving);
-    nuk_add(dstx, dsty, nuketype, moving);
     return RET_OK;
 }
 
 static int
 tran_plane(void)
 {
-    int srcx, srcy;
-    int dstx, dsty;
+    coord srcx, srcy;
+    coord dstx, dsty;
     int mcost;
     int weight, count;
     int type, dam;
index af06a80efa7d17ecff43ef0095cb050013c21c40..a41951247e50e3c5c3bc67e30d3f2084a35c0f59 100644 (file)
@@ -129,7 +129,7 @@ check_nuke_ok(struct nukstr *nukep)
     memcpy(&tnuke, nukep, sizeof(struct nukstr));
     tnuke.nuk_timestamp = chknuke.nuk_timestamp = 0;
     if (memcmp(&tnuke, &chknuke, sizeof(struct nukstr))) {
-       pr("Nuclear stockpile %d has changed!\n", nukep->nuk_uid);
+       pr("Nuke %d has changed!\n", nukep->nuk_uid);
        return 0;
     }
     return 1;
index e8f45a4f26e1630077dcc0c5d072c999faef2a92..674acfccaefb979c03dd09aa7fb477bfa7d5325c 100644 (file)
@@ -384,8 +384,8 @@ struct castr nuke_ca[] = {
     {NSC_NATID, 0, 0, fldoff(nukstr, nuk_own), "owner", EF_NATION},
     {NSC_XCOORD, 0, 0, fldoff(nukstr, nuk_x), "xloc", EF_BAD},
     {NSC_YCOORD, 0, 0, fldoff(nukstr, nuk_y), "yloc", EF_BAD},
-    {NSC_CHAR, 0, 0, fldoff(nukstr, nuk_n), "number", EF_BAD},
-    {NSC_SHORT, 0, N_MAXNUKE, fldoff(nukstr, nuk_types), "types", EF_BAD},
+    {NSC_TYPEID, 0, 0, fldoff(nukstr, nuk_type), "type", EF_NUKE_CHR},
+    {NSC_SHORT, 0, 0, fldoff(nukstr, nuk_plane), "plane", EF_BAD},
     {NSC_TIME, NSC_EXTRA, 0, fldoff(nukstr, nuk_timestamp), "timestamp",
      EF_BAD},
     {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
index ba01ebed04c0237247f7e5ef6a99b23ac0ed0dfb..7e0d5e3aa783d3347e99b5a8e57f5f318f3ad947 100644 (file)
@@ -47,8 +47,7 @@ struct cmndstr player_coms[] = {
     {"announce {message}", 0, tele, C_MOD, VIS},
     {"anti <SECT>", 3, anti, C_MOD, NORM + MONEY + CAP},
     {"apropos <topic>", 0, apro, 0, VIS},
-    {"arm <PLANE> <NUKETYPE> <airburst?>", 3, arm, C_MOD,
-     NORM + MONEY + CAP},
+    {"arm <PLANE> <NUKE> <airburst?>", 3, arm, C_MOD, NORM + MONEY + CAP},
     {"army <ARMY> <UNITS>", 0, army, C_MOD, NORM},
     {"assault <to-SECT> <from-SHIP> [<forts?> <ships?> <arty?> <planes?>]",
      3, assa, C_MOD, NORM + MONEY + CAP},
@@ -90,7 +89,7 @@ struct cmndstr player_coms[] = {
      NORM + CAP},
     {"designate <SECTS> <type> [sure?]", 1, desi, C_MOD, NORM},
     {"disable", 0, disa, C_MOD, GOD},
-    {"disarm <PLANE>", 2, arm, C_MOD, NORM + MONEY + CAP},
+    {"disarm <PLANE>", 2, disarm, C_MOD, NORM + MONEY + CAP},
     {"distribute <SECTS> <DISTSECT|.|h>", 1, dist, C_MOD, NORM},
     {"drop <cargo-PLANES> <fighter-PLANES> <ap-SECT> <PATH|DESTINATION> <COMM>", 1, drop, C_MOD, NORM + MONEY + CAP},
     {"dump <SECTS> [<fields>]", 0, dump, 0, NORM},
@@ -253,7 +252,8 @@ struct cmndstr player_coms[] = {
     {"torpedo <submarine-SHIPS> <target-SHIP>", 3, torp, C_MOD,
      NORM + MONEY + CAP},
     {"trade", 1, trad, C_MOD, NORM + CAP + MONEY},
-    {"transport <\"nuke\"|\"plane\"> <SECT|PLANES> [<NUKETYPE> <number>] <PATH|DESTINATION>", 1, tran, C_MOD, NORM + CAP},
+    {"transport <\"nuke\"|\"plane\"> <NUKES|PLANES> <PATH|DESTINATION>",
+     1, tran, C_MOD, NORM + CAP},
     {"treaty <TREATIES>", 0, trea, 0, NORM + MONEY + CAP},
     {"turn <\"on\"|\"off\"|\"mess\">", 0, turn, C_MOD, GOD},
     {"unload <COMM|\"land\"|\"plane\"> <SHIPS> <NUM|UNIT|PLANE>", 1, load,
index 9d7d2eb5bedc1a8560b2b750a06d753f5a66b307..e1a34b81b853136872824ccd9639269008009993 100644 (file)
@@ -301,12 +301,12 @@ detonate(struct plnstr *pp, int x, int y)
                 nuke.nuk_y);
        nuke.nuk_own = 0;
        if (own == bombown) {
-           mpr(bombown, "nuclear stockpile #%d at %s destroyed\n",
-               ni.cur, xyas(nuke.nuk_x, nuke.nuk_y, own));
+           mpr(bombown, "%s at %s destroyed\n",
+               prnuke(&nuke), xyas(nuke.nuk_x, nuke.nuk_y, own));
        } else {
            if (own != 0)
-               mpr(own, "nuclear stockpile #%d at %s destroyed\n",
-                   ni.cur, xyas(nuke.nuk_x, nuke.nuk_y, own));
+               mpr(own, "%s at %s destroyed\n",
+                   prnuke(&nuke), xyas(nuke.nuk_x, nuke.nuk_y, own));
        }
        putnuke(ni.cur, &nuke);
     }
index 68b0299fb94625252218cdec57392cad7b96d45c..fd460d17d511f2e4fdf6d45203a7a7f7246ddbad 100644 (file)
@@ -84,68 +84,22 @@ nuk_init(int n, void *ptr)
     np->nuk_own = 0;
 }
 
-void
-nuk_add(coord x, coord y, int type, int num)
+int
+nuk_on_plane(struct nukstr *np, int pluid)
 {
-    struct nukstr nuke;
-    struct sctstr sect;
-    int nuk_uid;
-    natid own;
-    int n;
+    struct nstr_item ni;
 
-    /* getsect in case of world wraparound */
-    getsect(x, y, &sect);
-    if (!(own = sect.sct_own))
-       return;
-    x = sect.sct_x;
-    y = sect.sct_y;
-
-    /*
-     * either find a stockpile in x,y or add a new one
-     */
-    nuk_uid = -1;
-    for (n = 0; getnuke(n, &nuke); n++) {
-       if (nuke.nuk_own == own) {
-           if (nuke.nuk_x == x && nuke.nuk_y == y) {
-               nuk_uid = n;
-               break;
-           }
-       } else if (nuke.nuk_own == 0 && nuk_uid == -1)
-           nuk_uid = n;
-    }
-    if (nuk_uid == -1)
-       nuk_uid = n;
-    if (getnuke(nuk_uid, &nuke) == 0) {
-       ef_extend(EF_NUKE, 10);
-       memset(&nuke, 0, sizeof(struct nukstr));
-       nuke.nuk_uid = nuk_uid;
+    snxtitem_all(&ni, EF_NUKE);
+    while (nxtitem(&ni, np)) {
+       if (np->nuk_plane == pluid)
+           return np->nuk_uid;
     }
-    if (nuke.nuk_own == 0) {
-       nuke.nuk_ship = -1;
-       nuke.nuk_x = x;
-       nuke.nuk_y = y;
-       nuke.nuk_own = own;
-       makenotlost(EF_NUKE, nuke.nuk_own, nuke.nuk_uid, nuke.nuk_x,
-                   nuke.nuk_y);
-    }
-    nuke.nuk_types[type] += num;
-    nuke.nuk_n += num;
-
-    if (!putnuke(nuke.nuk_uid, &nuke))
-       pr("Problem with the nuclear stockpiles, tell the deity.\n");
-
+    return -1;
 }
 
-void
-nuk_delete(struct nukstr *np, int type, int num)
+char *
+prnuke(struct nukstr *np)
 {
-    if (np->nuk_types[type] < num)
-       num = np->nuk_types[type];
-    np->nuk_types[type] -= num;
-    np->nuk_n -= num;
-    if (np->nuk_n <= 0) {
-       makelost(EF_NUKE, np->nuk_own, np->nuk_uid, np->nuk_x, np->nuk_y);
-       np->nuk_own = 0;
-    }
-    putnuke(np->nuk_uid, np);
+    return prbuf("%s warhead #%d",
+                nchr[(int)np->nuk_type].n_name, np->nuk_uid);
 }
index 15d392037c235e79d09cf0568f137137a6373b7c..3d9f909a2eec1632a668609ee4b50e0a56e748c2 100644 (file)
@@ -79,7 +79,7 @@ trade_nameof(struct trdstr *tp, union trdgenstr *tgp)
 {
     switch (tp->trd_type) {
     case EF_NUKE:
-       return "nuclear stockpile";
+       return nchr[(int)tgp->nuk.nuk_type].n_name;
     case EF_PLANE:
        return plchr[(int)tgp->pln.pln_type].pl_name;
     case EF_SHIP:
@@ -105,7 +105,6 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
     struct shpstr *sp;
     struct plnstr *pp;
     struct lndstr *lp;
-    struct natstr *natp;
     int needcomma;
     struct nstr_item ni;
     struct plnstr plane;
@@ -114,20 +113,10 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
     switch (tp->trd_type) {
     case EF_NUKE:
        np = &tgp->nuk;
-       if (!getsect(np->nuk_x, np->nuk_y, &sect))
-           return 0;
-       tp->trd_owner = sect.sct_own;
-       natp = getnatp(tp->trd_owner);
-       pr("(%3d)  ", sect.sct_own);
-       needcomma = 0;
-       for (i = 0; i < N_MAXNUKE; i++) {
-           if (np->nuk_types[i]) {
-               if (needcomma)
-                   pr(",");
-               pr("%dx%s", np->nuk_types[i], nchr[i].n_name);
-               needcomma = 1;
-           }
-       }
+       tp->trd_owner = np->nuk_own;
+       pr("(%3d)  %s #%d",
+          tp->trd_owner,
+          nchr[(int)np->nuk_type].n_name, tp->trd_unitid);
        break;
     case EF_SHIP:
        sp = &tgp->shp;