]> git.pond.sub.org Git - empserver/commitdiff
Fix extra prompt after abort due to misuse of snxtitem()
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 27 Jul 2008 01:35:00 +0000 (21:35 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 27 Jul 2008 01:36:37 +0000 (21:36 -0400)
The old code used getstarg() to get an argument with a different
prompt than snxtitem() uses, then passed the value to snxtitem()
unchecked.  If the player aborts, getstarg() returns a null pointer,
and snxtitem() prompts again.  Affected:

* load/lload plane/land third argument; load_plane_ship(),
  load_land_ship(), load_plane_land(), load_land_land()

* bomb, drop, fly, paradrop, recon and sweep second argument;
  get_planes()

* tend and ltend second and fourth argument; ltend(), tend(),
  tend_land()

* mission second argument; mission()

Fix by making snxtitem() taking a prompt argument, null pointer
requests the old prompt.

Use that to simplify multifire() and torp().  Change the other callers
to pass NULL.

67 files changed:
include/prototypes.h
src/lib/commands/arm.c
src/lib/commands/army.c
src/lib/commands/carg.c
src/lib/commands/cede.c
src/lib/commands/coun.c
src/lib/commands/decl.c
src/lib/commands/fina.c
src/lib/commands/flee.c
src/lib/commands/foll.c
src/lib/commands/fort.c
src/lib/commands/hard.c
src/lib/commands/land.c
src/lib/commands/laun.c
src/lib/commands/ldump.c
src/lib/commands/ledg.c
src/lib/commands/load.c
src/lib/commands/look.c
src/lib/commands/lost.c
src/lib/commands/lstat.c
src/lib/commands/lten.c
src/lib/commands/marc.c
src/lib/commands/mfir.c
src/lib/commands/mine.c
src/lib/commands/miss.c
src/lib/commands/mobq.c
src/lib/commands/mora.c
src/lib/commands/name.c
src/lib/commands/navi.c
src/lib/commands/ndump.c
src/lib/commands/news.c
src/lib/commands/nuke.c
src/lib/commands/orde.c
src/lib/commands/payo.c
src/lib/commands/pboa.c
src/lib/commands/pdump.c
src/lib/commands/plan.c
src/lib/commands/powe.c
src/lib/commands/pstat.c
src/lib/commands/rada.c
src/lib/commands/rang.c
src/lib/commands/reje.c
src/lib/commands/repo.c
src/lib/commands/retr.c
src/lib/commands/sabo.c
src/lib/commands/sail.c
src/lib/commands/scra.c
src/lib/commands/scut.c
src/lib/commands/sdump.c
src/lib/commands/set.c
src/lib/commands/shi.c
src/lib/commands/sona.c
src/lib/commands/sstat.c
src/lib/commands/stop.c
src/lib/commands/strv.c
src/lib/commands/supp.c
src/lib/commands/tend.c
src/lib/commands/torp.c
src/lib/commands/tran.c
src/lib/commands/trea.c
src/lib/commands/upgr.c
src/lib/commands/wing.c
src/lib/commands/work.c
src/lib/commands/xdump.c
src/lib/subs/plnsub.c
src/lib/subs/satmap.c
src/lib/subs/snxtitem.c

index 4c10f0f34566b06b2d68d218716d07e85c195f09..c76c63e5be155b6883fb87ef49aa76360275f610 100644 (file)
@@ -666,7 +666,7 @@ extern void shp_missdef(struct shpstr *, natid);
 extern double shp_mobcost(struct shpstr *);
 extern void shp_set_tech(struct shpstr *, int);
 /* snxtitem.c */
-extern int snxtitem(struct nstr_item *, int, char *);
+extern int snxtitem(struct nstr_item *, int, char *, char *);
 extern void snxtitem_area(struct nstr_item *, int,
                          struct range *);
 extern void snxtitem_dist(struct nstr_item *, int, int, int, int);
index e689e87be866675bd919112fbfac62d0eb2aeea0..4393e4ba0d1882a0717c5067aec82ea79a735603 100644 (file)
@@ -55,7 +55,7 @@ arm(void)
     char buf[1024];
     char prompt[128];
 
-    if (!snxtitem(&ni, EF_PLANE, player->argp[1]))
+    if (!snxtitem(&ni, EF_PLANE, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&ni, &pl)) {
        if (!player->owner
@@ -138,7 +138,7 @@ disarm(void)
     struct sctstr sect;
     char buf[128];
 
-    if (!snxtitem(&ni, EF_PLANE, player->argp[1]))
+    if (!snxtitem(&ni, EF_PLANE, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&ni, &pl)) {
        if (!player->owner)
index a55b82d7690966d64bcd658bbf3208399bb42aa0..c30376068a397ebf4fa8d1da8e82841955110d49 100644 (file)
@@ -59,7 +59,7 @@ army(void)
     }
     if (c == '~')
        c = 0;
-    if (!snxtitem(&nstr, EF_LAND, player->argp[2]))
+    if (!snxtitem(&nstr, EF_LAND, player->argp[2], NULL))
        return RET_SYN;
     count = 0;
     while (nxtitem(&nstr, &land)) {
index 342739e119d85fe578e639c55031d54cf7633532..28869b13e271a284459b82e10baf170a7fc15d92 100644 (file)
@@ -45,7 +45,7 @@ carg(void)
     struct nstr_item ni;
     struct shpstr ship;
 
-    if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&ni, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
     nships = 0;
     while (nxtitem(&ni, &ship)) {
@@ -94,7 +94,7 @@ lcarg(void)
     struct nstr_item ni;
     struct lndstr land;
 
-    if (!snxtitem(&ni, EF_LAND, player->argp[1]))
+    if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
     nunits = 0;
     while (nxtitem(&ni, &land)) {
index 4af9da1661a1fd142cae48c649435e679489cfb1..bcc1b63aa24dcdfaf509de28d9ea3084bbc20577 100644 (file)
@@ -67,7 +67,7 @@ cede(void)
        return RET_SYN;
     if (snxtsct(&ns, p))
        is_sector = 1;
-    if (snxtitem(&ni, EF_SHIP, p))
+    if (snxtitem(&ni, EF_SHIP, p, NULL))
        is_ship = 1;
     if (!is_sector && !is_ship)
        return RET_SYN;
index 24be3468546d48b22c12635c2fe55f95933e21dc..7b56cbc503a6df5ea5ee7fedc0fc295131571227 100644 (file)
@@ -44,7 +44,7 @@ coun(void)
     struct nstr_item ni;
     struct natstr nat;
 
-    if (!snxtitem(&ni, EF_NATION, player->argp[1]))
+    if (!snxtitem(&ni, EF_NATION, player->argp[1], NULL))
        return RET_SYN;
     prdate();
     pr("  #   last access                         %sstatus     country name\n",
index 386fe0ae2c0793cc28c05494f6762fb614dcd6ee..b7ed5ebc045dc49b809a93949c1d7b868a3b9a2f 100644 (file)
@@ -85,7 +85,7 @@ decl(void)
        return RET_SYN;
     }
 
-    if (!snxtitem(&ni, EF_NATION, player->argp[2]))
+    if (!snxtitem(&ni, EF_NATION, player->argp[2], NULL))
        return RET_SYN;
     who = player->cnum;
     if (player->god) {
index 0bbae079b979801d1778ef1bb452d8ac7ef755f1..fca4f886d1f9d3ca92f67acd579824c13f7f26e1 100644 (file)
@@ -53,7 +53,7 @@ fina(void)
        pr("Loans are not enabled.\n");
        return RET_FAIL;
     }
-    if (!snxtitem(&ni, EF_LOAN, "*"))
+    if (!snxtitem(&ni, EF_LOAN, "*", NULL))
        return RET_SYN;
     (void)time(&now);
     pr("\n");
index 04c24b1f47f1ba86cb0706afc1f3082093db3152..965f9477535348b860dea4f6944d38e86686c814 100644 (file)
@@ -59,7 +59,7 @@ flee(void)
     }
     if (c == '~')
        c = 0;
-    if (!snxtitem(&nstr, EF_SHIP, player->argp[2]))
+    if (!snxtitem(&nstr, EF_SHIP, player->argp[2], NULL))
        return RET_SYN;
     count = 0;
     while (nxtitem(&nstr, &ship)) {
index bc09f9e4b95e40a143d7b48ca808ce6ef6c9fcff..c81694b02a81e19737e0689c15b7c187d8ea9214 100644 (file)
@@ -51,7 +51,7 @@ foll(void)
        pr("The SAIL option is not enabled, so this command is not valid.\n");
        return RET_FAIL;
     }
-    if (!snxtitem(&nstr, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&nstr, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
     cp = getstarg(player->argp[2], "leader? ", buf);
     if (cp == 0)
index f42843fa92a3b1627a0b7f517c0dc2d3de22988d..8630bed847832ef72797301af47f9ef4bb0d3e60 100644 (file)
@@ -47,7 +47,7 @@ fort(void)
     char *p;
     char buf[1024];
 
-    if (!snxtitem(&ni, EF_LAND, player->argp[1]))
+    if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
     p = getstarg(player->argp[2], "Amount: ", buf);
     if (p == 0 || *p == 0)
index dc8498ad1bf8e919cb76669ec258d58186b796a3..2f3bb167cfff62ee4aec1def1bae1f10b914d5c8 100644 (file)
@@ -56,7 +56,7 @@ hard(void)
     long cash;
     struct natstr *natp;
 
-    if (!snxtitem(&ni, EF_PLANE, player->argp[1]))
+    if (!snxtitem(&ni, EF_PLANE, player->argp[1], NULL))
        return RET_SYN;
     if ((p = getstarg(player->argp[2], "Increase by? ", buf)) == 0
        || *p == 0)
index 3985c09bac19f59ab948628ea2dd80921655df21..46ccad45274f6f4526ba5ede341d8e6613f0812a 100644 (file)
@@ -44,7 +44,7 @@ land(void)
     struct nstr_item ni;
     struct lndstr land;
 
-    if (!snxtitem(&ni, EF_LAND, player->argp[1]))
+    if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
 
     nunits = noff = 0;
index 940144afcdc5aac463011e92134ef82046976886..01d03c0543f3ba9d312e21e9414a01a7ce9800e4 100644 (file)
@@ -62,7 +62,7 @@ laun(void)
     struct plchrstr *pcp;
     int retval, gone;
 
-    if (!snxtitem(&nstr, EF_PLANE, player->argp[1]))
+    if (!snxtitem(&nstr, EF_PLANE, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&nstr, &plane)) {
        if (plane.pln_own != player->cnum)
index 5b9851041df4945b14fa7a8ec404286dd354de72..291fc0c8854fc34b1987f06674b5fbeb39596d11 100644 (file)
@@ -49,7 +49,7 @@ ldump(void)
     struct natstr *np;
     time_t now;
 
-    if (!snxtitem(&ni, EF_LAND, player->argp[1]))
+    if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
     prdate();
     nunits = 0;
index 6bc0febd5b441e9fb79df72665235feec28985e8..6a6be7bf0998efb7c21591303216276eaf0dcf8d 100644 (file)
@@ -48,7 +48,7 @@ ledg(void)
        pr("Loans are not enabled.\n");
        return RET_FAIL;
     }
-    if (!snxtitem(&nstr, EF_LOAN, player->argp[1]))
+    if (!snxtitem(&nstr, EF_LOAN, player->argp[1], NULL))
        return RET_SYN;
     pr("\n... %s Ledger ...\n", cname(player->cnum));
     nloan = 0;
index b677d3eaddb520ecafdcfc881f529867962c3d61..d245ba2152152505eccabca29b3b9cc74fd9fb5b 100644 (file)
@@ -102,7 +102,7 @@ load(void)
 
     noisy = isdigit(*p);
 
-    if (!snxtitem(&nbst, EF_SHIP, p))
+    if (!snxtitem(&nbst, EF_SHIP, p, NULL))
        return RET_SYN;
 
     load_unload = **player->argp == 'l' ? LOAD : UNLOAD;
@@ -237,7 +237,7 @@ lload(void)
 
     noisy = isdigit(*p);
 
-    if (!snxtitem(&nbst, EF_LAND, p))
+    if (!snxtitem(&nbst, EF_LAND, p, NULL))
        return RET_SYN;
 
     load_unload = player->argp[0][1] == 'l' ? LOAD : UNLOAD;
@@ -370,8 +370,10 @@ load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
     }
     sprintf(prompt, "Plane(s) to %s %s? ",
            load_unload == LOAD ? "load onto" : "unload from", prship(sp));
-    if (!snxtitem(&ni, EF_PLANE,
-                 p = getstarg(player->argp[3], prompt, buf)))
+    p = getstarg(player->argp[3], prompt, buf);
+    if (!p)
+       return RET_SYN;
+    if (!snxtitem(&ni, EF_PLANE, p, NULL))
        return RET_SYN;
 
     if (!still_ok_ship(sectp, sp))
@@ -505,8 +507,10 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
     }
     sprintf(prompt, "Land unit(s) to %s %s? ",
            load_unload == LOAD ? "load onto" : "unload from", prship(sp));
-    if (!snxtitem(&ni, EF_LAND,
-                 p = getstarg(player->argp[3], prompt, buf)))
+    p = getstarg(player->argp[3], prompt, buf);
+    if (!p)
+       return RET_SYN;
+    if (!snxtitem(&ni, EF_LAND, p, NULL))
        return RET_SYN;
 
     if (!still_ok_ship(sectp, sp))
@@ -767,8 +771,10 @@ load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
     }
     sprintf(prompt, "Plane(s) to %s %s? ",
            load_unload == LOAD ? "load onto" : "unload from", prland(lp));
-    if (!snxtitem(&ni, EF_PLANE,
-                 p = getstarg(player->argp[3], prompt, buf)))
+    p = getstarg(player->argp[3], prompt, buf);
+    if (!p)
+       return RET_SYN;
+    if (!snxtitem(&ni, EF_PLANE, p, NULL))
        return RET_SYN;
 
     if (!still_ok_land(sectp, lp))
@@ -958,8 +964,10 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
     }
     sprintf(prompt, "Land unit(s) to %s %s? ",
            load_unload == LOAD ? "load onto" : "unload from", prland(lp));
-    if (!snxtitem(&ni, EF_LAND,
-                 p = getstarg(player->argp[3], prompt, buf)))
+    p = getstarg(player->argp[3], prompt, buf);
+    if (!p)
+       return RET_SYN;
+    if (!snxtitem(&ni, EF_LAND, p, NULL))
        return RET_SYN;
 
     if (!still_ok_land(sectp, lp))
index f064b8d0782cc063df9a61d41904307c0fdafa62..92a635e2b780faa9d590029f1ed4925c4c6b2e16 100644 (file)
@@ -70,7 +70,7 @@ do_look(short type)
     if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP))
        type = EF_SHIP;
 
-    if (!snxtitem(&ni, type, player->argp[1]))
+    if (!snxtitem(&ni, type, player->argp[1], NULL))
        return RET_SYN;
     if ((bitmap = malloc((WORLD_X * WORLD_Y) / 8)) == 0) {
        logerror("malloc failed in do_look\n");
index 3925e83f6111f69674aad0a802b84f67b1299b7d..8e410e68ac91eae20d6bbff3bf8af1dc4b0ba420 100644 (file)
@@ -44,7 +44,9 @@ lost(void)
     struct loststr lost;
     time_t now;
 
-    if (!snxtitem(&ni, EF_LOST, player->argp[1] ? player->argp[1] : "*"))
+    if (!snxtitem(&ni, EF_LOST,
+                 player->argp[1] ? player->argp[1] : "*",
+                 NULL))
        return RET_SYN;
 
     prdate();
index e1e961720fe5bb3e6203c8b2010f158e1ef6d61f..34af6a490d6635b921ebf88399deb3afc10e368e 100644 (file)
@@ -44,7 +44,7 @@ lsta(void)
     struct lndstr land;
     struct lchrstr *lcp;
 
-    if (!snxtitem(&ni, EF_LAND, player->argp[1]))
+    if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
 
     nunits = 0;
index 3aaba7129bd1178cdc60864f9216d2df651ebb08..6e982fdf0901144fee82fe4531f65f139dd8294f 100644 (file)
@@ -69,8 +69,7 @@ ltend(void)
     if (!(ip = whatitem(player->argp[1], "Transfer what commodity? ")))
        return RET_SYN;
 
-    if (!snxtitem(&tenders, EF_SHIP,
-                 getstarg(player->argp[2], "Tender(s)? ", buf)))
+    if (!snxtitem(&tenders, EF_SHIP, player->argp[2], "Tender(s)? "))
        return RET_SYN;
     while (nxtitem(&tenders, &tender)) {
        if (!player->owner)
@@ -95,8 +94,7 @@ ltend(void)
            return RET_FAIL;
        }
        if (!snxtitem(&targets, EF_LAND,
-                     getstarg(player->argp[4], "Units to be tended? ",
-                              buf)))
+                     player->argp[4], "Units to be tended? "))
            return RET_SYN;
        if (!check_ship_ok(&tender))
            return RET_FAIL;
index f497f44688434291aec3cbc325ae2e91cdc3dd53..0e97c29dc7e35d51d05351e8ba3b473fe156513c 100644 (file)
@@ -50,7 +50,7 @@ march(void)
     double minmob, maxmob;
     int together;
 
-    if (!snxtitem(&ni_land, EF_LAND, player->argp[1]))
+    if (!snxtitem(&ni_land, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
     lnd_sel(&ni_land, &land_list);
     lnd_mar(&land_list, &minmob, &maxmob, &together, player->cnum);
index 398b3b7f19b4f6e8fd5a90ee98cb9c4a387b977a..7ca3a35da26eae716e9fd60cc7b0d044840b1776 100644 (file)
@@ -111,11 +111,7 @@ multifire(void)
        pr("Ships, land units or sectors only!\n");
        return RET_SYN;
     }
-    if ((ptr = getstarg(player->argp[2], "Firing from? ", buf)) == 0
-       || *ptr == '\0')
-       return RET_SYN;
-
-    if (!snxtitem(&nbst, type, ptr))
+    if (!snxtitem(&nbst, type, player->argp[2], "Firing from? "))
        return RET_SYN;
 
     while (nxtitem(&nbst, &item)) {
index 74f441137c6f980ab9a70a9682d32ca491533568..c33a558e2cbdf7d8a601baad3b6a30b44b81eab7 100644 (file)
@@ -52,7 +52,7 @@ mine(void)
     int shells;
     int mines_avail;
 
-    if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&ni, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
     mines = onearg(player->argp[2],
                   "Drop how many mines from each ship? ");
@@ -101,7 +101,7 @@ landmine(void)
     int total_mines_laid;
     char prompt[128];
 
-    if (!snxtitem(&ni, EF_LAND, player->argp[1]))
+    if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&ni, &land)) {
        if (!player->owner)
index abf9d16f9ee00723f9a50559106d0aa8d8124e63..6e4f4fe0656e4fe17441ed96e0f6485ede616348 100644 (file)
@@ -57,7 +57,6 @@ mission(void)
     struct empobj *gp;
     int num = 0, mobmax, mobused, dist;
     struct nstr_item ni;
-    char prompt[128];
     char buf[1024];
 
     if ((p =
@@ -69,9 +68,7 @@ mission(void)
        pr("Ships, land units or planes only! (s, l, p)\n");
        return RET_SYN;
     }
-    sprintf(prompt, "%s(s)? ", ef_nameof(type));
-    p = getstarg(player->argp[2], prompt, buf);
-    if (!snxtitem(&ni, type, p))
+    if (!snxtitem(&ni, type, player->argp[2], NULL))
        return RET_SYN;
 
     if ((p =
index fcd8cf5f38582f57c4a6974a114e647897e7981a..19dff8135f45e61242f0d8e7a8a325f635b98c7a 100644 (file)
@@ -51,7 +51,7 @@ mobq(void)
        pr("The SAIL option is not enabled, so this command is not valid.\n");
        return RET_FAIL;
     }
-    if (!snxtitem(&nstr, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&nstr, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
     oldmq = player->argp[2];
     if (oldmq) {
index 455e73a1d9b0c1047290046c64d01b414ccdc61b..79d07d84912a39d960c300985891348944dd5745 100644 (file)
@@ -48,7 +48,7 @@ morale(void)
     char mess[128];
     char buf[1024];
 
-    if (!snxtitem(&np, EF_LAND, player->argp[1]))
+    if (!snxtitem(&np, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&np, &land)) {
        if (!player->owner || land.lnd_own == 0)
index 493c72f2e59f1fce0111eb54097a90bae68feaa2..9e5d2861f0c34d5b9e2182108b6e2e842fa6b9f4 100644 (file)
@@ -49,7 +49,7 @@ name(void)
     struct nstr_item nb;
     char buf[1024];
 
-    if (!snxtitem(&nb, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&nb, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&nb, &ship)) {
        if (!player->owner)
index 122c8ac5e2423a41c14668c3d5b22a775a470140..ab6b5e19f807341ddcbeb3c474fff1dbd2465604 100644 (file)
@@ -53,7 +53,7 @@ navi(void)
     double minmob, maxmob;
     int together;
 
-    if (!snxtitem(&ni_ship, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&ni_ship, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
     shp_sel(&ni_ship, &ship_list);
     shp_nav(&ship_list, &minmob, &maxmob, &together, player->cnum);
@@ -199,7 +199,7 @@ do_unit_move(struct emp_qelem *ulist, int *together,
             */
        case 'M':
            do_map(bmap_flag, leader->ef_type, player->argp[1],
-               player->argp[2]);
+                  player->argp[2]);
            skip = 1;
            continue;
        case 'f':
index 08b9a4d6fc55cfb32fd1ba7b221659fd5c7b1670..c9f0098cfe8d302f5541c8f3c28946e5fff1f0e6 100644 (file)
@@ -45,7 +45,7 @@ ndump(void)
     time_t now;
     int nnukes;
 
-    if (!snxtitem(&nstr, EF_NUKE, player->argp[1]))
+    if (!snxtitem(&nstr, EF_NUKE, player->argp[1], NULL))
        return RET_SYN;
     prdate();
     if (player->god)
index db162d0a3376b165f10438d993928299de26d431..6abf9d6769cc055406887347321191b78e3ee6d5 100644 (file)
@@ -61,7 +61,7 @@ news(void)
     char num[128];
     char *verb;
 
-    if (!snxtitem(&nstr, EF_NEWS, "*"))
+    if (!snxtitem(&nstr, EF_NEWS, "*", NULL))
        return RET_SYN;
     memset(page_has_news, 0, sizeof(page_has_news));
     memset(sectors_taken, 0, sizeof(sectors_taken));
index 848727b192eea04bf16c22da96b44fa2b6e640de..18705158bca5615397ba9fbf46342ffbb7071177 100644 (file)
@@ -46,7 +46,7 @@ nuke(void)
     struct nukstr nuk;
     struct plnstr plane;
 
-    if (!snxtitem(&nstr, EF_NUKE, player->argp[1]))
+    if (!snxtitem(&nstr, EF_NUKE, player->argp[1], NULL))
        return RET_SYN;
     nnukes = noff = 0;
     while (nxtitem(&nstr, &nuk)) {
index 4bda521ddb865262ac4b3fd3e6337943ef7398f7..d4373d054dceab40739c857cb8fa6e50b1855082 100644 (file)
@@ -73,7 +73,7 @@ orde(void)
     char buf[1024];
     char prompt[128];
 
-    if (!snxtitem(&nb, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&nb, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
     while (!player->aborted && nxtitem(&nb, (&ship))) {
        if (!player->owner || ship.shp_own == 0)
@@ -357,7 +357,7 @@ qorde(void)
     struct nstr_item nb;
     struct shpstr ship;
 
-    if (!snxtitem(&nb, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&nb, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&nb, (&ship))) {
        if (!player->owner || ship.shp_own == 0)
@@ -419,7 +419,7 @@ sorde(void)
     struct shpstr ship;
     char buf[1024];
 
-    if (!snxtitem(&nb, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&nb, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&nb, (&ship))) {
        if (!player->owner || ship.shp_own == 0)
index 10944e95ccc8ab22f4700bc8bbf52b820f78601f..c7414863c6bfc4bc604cc8a087d34c0f2f71cfc2 100644 (file)
@@ -52,7 +52,7 @@ payo(void)
        pr("Tradeships are not enabled.\n");
        return RET_FAIL;
     }
-    if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&ni, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
 
     nships = 0;
index 9f911b63cfb7068afb316f370663c630ec4eff3f..0a9c936a7a8f96c14fe464154a0188dca8c61bf6 100644 (file)
@@ -43,7 +43,7 @@ pboa(void)
     struct nstr_item np;
     struct plnstr plane;
 
-    if (!snxtitem(&np, EF_PLANE, player->argp[1]))
+    if (!snxtitem(&np, EF_PLANE, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&np, &plane)) {
        getsect(plane.pln_x, plane.pln_y, &sect);
index 6c21a65f196e5ec73ba0bb3158e2044ef926f42b..5465e4885373b9794af5e681fd954de893e2162d 100644 (file)
@@ -50,7 +50,7 @@ pdump(void)
     int n, i;
     time_t now;
 
-    if (!snxtitem(&np, EF_PLANE, player->argp[1]))
+    if (!snxtitem(&np, EF_PLANE, player->argp[1], NULL))
        return RET_SYN;
     prdate();
 
index 136896eca851f83ef2fbcf5d01b25b1498aabcd0..b841573cbfa62c918bc0ecf1a188bed6b93e58a8 100644 (file)
@@ -47,7 +47,7 @@ plan(void)
     struct nstr_item np;
     struct plnstr plane;
 
-    if (!snxtitem(&np, EF_PLANE, player->argp[1]))
+    if (!snxtitem(&np, EF_PLANE, player->argp[1], NULL))
        return RET_SYN;
     nplanes = noff = 0;
     while (nxtitem(&np, &plane)) {
index 55046a5c095dea8438f33ffb6e43874d93860cd0..9376ca0c7c6d1c428cd2430d022e63fd3a889d9b 100644 (file)
@@ -94,7 +94,7 @@ powe(void)
 
     if (player->argp[i]) {
        if (player->argp[i][0] == 'c') {
-           if (!snxtitem(&ni, EF_NATION, player->argp[i + 1]))
+           if (!snxtitem(&ni, EF_NATION, player->argp[i + 1], NULL))
                return RET_SYN;
            while (nxtitem(&ni, &nat)) {
                if (nat.nat_stat == STAT_UNUSED)
index 5106d0f3323198884356ba36880021515672c7d0..8d5c0d16938e9dd74d878e2d1b233d04313bed06 100644 (file)
@@ -43,7 +43,7 @@ pstat(void)
     struct nstr_item np;
     struct plnstr plane;
 
-    if (!snxtitem(&np, EF_PLANE, player->argp[1]))
+    if (!snxtitem(&np, EF_PLANE, player->argp[1], NULL))
        return RET_SYN;
     nplanes = 0;
     while (nxtitem(&np, &plane)) {
index b8f552502a6c374d5e539debac2301b5e339e2c2..3e488bee6aeee85fa219509c1f39c75c0ade3575 100644 (file)
@@ -90,7 +90,7 @@ radar(short type)
     case NS_LIST:
     case NS_GROUP:
        /* assumes a NS_LIST return is a unit no */
-       if (!snxtitem(&ni, type, cp)) {
+       if (!snxtitem(&ni, type, cp, NULL)) {
            pr("Specify at least one %s\n", ef_nameof(type));
            return RET_SYN;
        }
index 96ff29a69e32f8f69b94afbe1b4a32e3e6439adc..964d4af0d298cf49c5ba0712c85d71c0fa9ccf38 100644 (file)
@@ -46,7 +46,7 @@ range(void)
     char *p;
     char buf[1024];
 
-    if (!snxtitem(&np, EF_PLANE, player->argp[1]))
+    if (!snxtitem(&np, EF_PLANE, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&np, &plane)) {
        if (!player->owner || plane.pln_own == 0)
@@ -79,7 +79,7 @@ lrange(void)
     char prompt[128];
     char buf[1024];
 
-    if (!snxtitem(&np, EF_LAND, player->argp[1]))
+    if (!snxtitem(&np, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
     while (nxtitem(&np, &land)) {
        if (!player->owner || land.lnd_own == 0)
index be104878ed3f8fb46cc2b09f295671ad99fa6635..6bc0af58b4a89c609ea9c6a6171af3774a3aaf83 100644 (file)
@@ -80,7 +80,7 @@ reje(void)
        pr("That's not one of the choices!\n");
        return RET_SYN;
     }
-    if (!snxtitem(&ni, EF_NATION, player->argp[3]))
+    if (!snxtitem(&ni, EF_NATION, player->argp[3], NULL))
        return RET_SYN;
     while (nxtitem(&ni, &nat)) {
        if (nat.nat_stat == STAT_GOD) {
index aec2dd7b6cd7d81a9357248624c30d999831ec33..2401928bc9f3e261f3599b25210fb21a834c880e 100644 (file)
@@ -50,7 +50,7 @@ repo(void)
     struct natstr nat;
     struct nstr_item ni;
 
-    if (!snxtitem(&ni, EF_NATION, player->argp[1]))
+    if (!snxtitem(&ni, EF_NATION, player->argp[1], NULL))
        return RET_SYN;
     prdate();
     natp = getnatp(player->cnum);
index 5c56219fe8c492ba4a3b39be455bb9d02e06e86d..c116a886fc337b6ac262eeb7736ea2c1fee2da41 100644 (file)
@@ -83,7 +83,7 @@ retreat(short type)
        type = EF_SHIP;
     rflagsc = type == EF_SHIP ? shp_rflagsc : lnd_rflagsc;
 
-    if (!snxtitem(&ni, type, player->argp[1]))
+    if (!snxtitem(&ni, type, player->argp[1], NULL))
        return RET_SYN;
     nunits = 0;
     if (player->argp[2] != NULL)
index 7911dfc8ea1d9178912fdc3f4fc63138f073a792..45445e48cc9cbd34022a8852e74f6da0b526141b 100644 (file)
@@ -45,7 +45,7 @@ sabo(void)
     double odds;
     int dam;
 
-    if (!snxtitem(&ni, EF_LAND, player->argp[1]))
+    if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
 
     while (nxtitem(&ni, &land)) {
index 0f1fa0f8911fb0ee9c636f7fc4940a96c9c683f9..19fa6a81a81adc463e94192eb6973b83691b0cde 100644 (file)
@@ -144,7 +144,7 @@ sail(void)
        pr("The SAIL option is not enabled, so this command is not valid.\n");
        return RET_FAIL;
     }
-    if (!snxtitem(&nstr, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&nstr, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
     cp = player->argp[2];
     if (*player->argp[0] == 'u' || (cp && !strcmp(cp, "-")))
index 9c95c2b3fbfaa16b081da8063c3ff1fa9c96e0f9..5de186256aef5d035dc038f0038452d288561644 100644 (file)
@@ -77,7 +77,7 @@ scra(void)
     sprintf(prompt, "%s(s)? ", ef_nameof(type));
     if ((p = getstarg(player->argp[2], prompt, buf)) == 0)
        return RET_SYN;
-    if (!snxtitem(&ni, type, p))
+    if (!snxtitem(&ni, type, p, NULL))
        return RET_SYN;
     if (p && (isalpha(*p) || (*p == '*') || (*p == '~') || issector(p)
              || islist(p))) {
index 8dd892d7ab0aba708e01e0ae1955a828d57f6028..fa305768811fdd3bdf9911090966b27e6db02abb 100644 (file)
@@ -70,7 +70,7 @@ scut(void)
     sprintf(prompt, "%s(s)? ", ef_nameof(type));
     if ((p = getstarg(player->argp[2], prompt, buf)) == 0)
        return RET_SYN;
-    if (!snxtitem(&ni, type, p))
+    if (!snxtitem(&ni, type, p, NULL))
        return RET_SYN;
     if (p && (isalpha(*p) || (*p == '*') || (*p == '~') || issector(p)
              || islist(p))) {
index a70ade8dd1600d7b901a32bfdde60df3f9cfe941..24307c46f1f064d61104b4268f3ccaba71d644c7 100644 (file)
@@ -50,7 +50,7 @@ sdump(void)
     int n, i;
     time_t now;
 
-    if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&ni, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
     prdate();
 
index 62feb357460e8155c68cbf3efe5830433c6b6b4f..96a5eb14a12b5505a6b2160d3649c791b9f90a2c 100644 (file)
@@ -79,7 +79,7 @@ set(void)
        pr("You can sell only ships, planes, land units or nukes\n");
        return RET_SYN;
     }
-    if (!snxtitem(&ni, type, player->argp[2]))
+    if (!snxtitem(&ni, type, player->argp[2], NULL))
        return RET_SYN;
     while (nxtitem(&ni, &item)) {
        if (!player->owner && !player->god)
index 05d8c018a28eabd4346bbdcf7693eae2ba148fb0..ccf013bf75e87d8276e9d88b4059757165ff31f6 100644 (file)
@@ -45,7 +45,7 @@ shi(void)
     struct nstr_item ni;
     struct shpstr ship;
 
-    if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&ni, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
 
     nships = noff = 0;
index 35579ee182f113315a0aab8bb2100791eb176e51..5f3f5bf82d151c411cc0ca7a653af547119aec23 100644 (file)
@@ -70,7 +70,7 @@ sona(void)
     static signed char **vis = NULL;
     static signed char *visbuf = NULL;
 
-    if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&ni, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
     if (!radbuf)
        radbuf = malloc((WORLD_Y * (WORLD_X + 1)));
index 0498e1b1017228bee976efce9b2e14831eeee8ee..e177ad4676dddeef8be523f0065a3fd3b57381f8 100644 (file)
@@ -44,7 +44,7 @@ sstat(void)
     struct nstr_item ni;
     struct shpstr ship;
 
-    if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
+    if (!snxtitem(&ni, EF_SHIP, player->argp[1], NULL))
        return RET_SYN;
 
     nships = 0;
index cd3d965435b1b2bac935211d937f21969e104864..414d484009d55d710e35e79238ac2e417e26f06c 100644 (file)
@@ -157,7 +157,7 @@ start_stop_unit(int type, char *arg, int off)
     int nunit;
     struct nstr_item nstr;
 
-    if (!snxtitem(&nstr, type, arg))
+    if (!snxtitem(&nstr, type, arg, NULL))
        return RET_SYN;
     prdate();
     nunit = 0;
index 3e53ad7038c6d492a7e6c8453148e4ed1c171c38..61f41f38464c0d35808cf667009cbdb33658299d 100644 (file)
@@ -170,7 +170,7 @@ starv_ships(char *range)
     int nship = 0;
     int s;
 
-    if (!snxtitem(&ni, EF_SHIP, range))
+    if (!snxtitem(&ni, EF_SHIP, range, NULL))
        return;
 
     while (nxtitem(&ni, &ship)) {
@@ -218,7 +218,7 @@ starv_units(char *range)
     int nunit = 0;
     int s;
 
-    if (!snxtitem(&ni, EF_LAND, range))
+    if (!snxtitem(&ni, EF_LAND, range, NULL))
        return;
 
     while (nxtitem(&ni, &land)) {
index 491b3c684e57d0f39e01d8314064b7068d43717b..8c1a3e6a43f5afa1b32f9c80b73da5ee634ac03d 100644 (file)
@@ -43,7 +43,7 @@ supp(void)
     struct nstr_item ni;
     struct lndstr land;
 
-    if (!snxtitem(&ni, EF_LAND, player->argp[1]))
+    if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
 
     nunits = 0;
index dcf044753f33bed196961839242e2665f1de04d8..fd02c9eec4643187262ba53900cfd055def8e7f2 100644 (file)
@@ -80,8 +80,7 @@ tend(void)
        return RET_SYN;
     }
 
-    if (!snxtitem(&tenders, EF_SHIP,
-                 getstarg(player->argp[2], "Tender(s)? ", buf)))
+    if (!snxtitem(&tenders, EF_SHIP, player->argp[2], "Tender(s)? "))
        return RET_SYN;
 
     while (nxtitem(&tenders, &tender)) {
@@ -127,8 +126,7 @@ tend(void)
            break;
        }
        if (!snxtitem(&targets, EF_SHIP,
-                     getstarg(player->argp[4], "Ships to be tended? ",
-                              buf)))
+                     player->argp[4], "Ships to be tended? "))
            return RET_SYN;
        if (!check_ship_ok(&tender))
            return RET_SYN;
@@ -213,7 +211,7 @@ tend_land(struct shpstr *tenderp, char *units)
     struct nstr_item pni;
     char buf[1024];
 
-    if (!snxtitem(&lni, EF_LAND, units))
+    if (!snxtitem(&lni, EF_LAND, units, NULL))
        return RET_SYN;
 
     while (nxtitem(&lni, &land)) {
@@ -229,8 +227,7 @@ tend_land(struct shpstr *tenderp, char *units)
            continue;
        }
        if (!snxtitem(&targets, EF_SHIP,
-                     getstarg(player->argp[4], "Ship to be tended? ",
-                              buf)))
+                     player->argp[4], "Ship to be tended? "))
            return RET_SYN;
        if (!check_land_ok(&land))
            return RET_SYN;
index 91034f549f679e022dc372912a79e7461b0c46f6..b0ce4befe07a7bcbf3fc292b84c78e0dce53a713 100644 (file)
@@ -62,13 +62,10 @@ torp(void)
     char *ptr;
     struct nstr_item nbst;
     char buf[1024];
-    char *p;
     int ntorping = 0;
     char prompt[128];
 
-    if (!(p = getstarg(player->argp[1], "From ship(s)? ", buf)))
-       return RET_SYN;
-    if (!snxtitem(&nbst, EF_SHIP, p))
+    if (!snxtitem(&nbst, EF_SHIP, player->argp[1], "From ship(s)? "))
        return RET_SYN;
     while (nxtitem(&nbst, &sub)) {
        if (sub.shp_own != player->cnum)
index b2da0d093d6b33fc949086a23debcac48f7eef79..259e64ebb944e25526a709f906fb53333e76104a 100644 (file)
@@ -77,7 +77,7 @@ tran_nuke(void)
 
     weight = 0;
     count = 0;
-    if (!snxtitem(&nstr, EF_NUKE, player->argp[2]))
+    if (!snxtitem(&nstr, EF_NUKE, player->argp[2], NULL))
        return RET_SYN;
     while (nxtitem(&nstr, &nuke)) {
        if (!player->owner)
@@ -156,7 +156,7 @@ tran_plane(void)
 
     weight = 0;
     count = 0;
-    if (!snxtitem(&nstr, EF_PLANE, player->argp[2]))
+    if (!snxtitem(&nstr, EF_PLANE, player->argp[2], NULL))
        return RET_SYN;
     /*
      * First do some sanity checks: make sure that they are all in the,
index 2eda91929d30aea14f6055469b563c8fbdb2b094..ac1c2da45fcf227d0d804e6776bb310c086a05d8 100644 (file)
@@ -43,7 +43,7 @@ trea(void)
     struct nstr_item nstr;
     int ntreaty;
 
-    if (!snxtitem(&nstr, EF_TREATY, player->argp[1]))
+    if (!snxtitem(&nstr, EF_TREATY, player->argp[1], NULL))
        return RET_SYN;
     pr("\t... %s Treaty Report ...\n", cname(player->cnum));
     ntreaty = 0;
index 3216f7fc97bb687172e70b98dd72949d7aeb5a02..510f08f7d73004643ce1c6ab9896af5ba81e04c0 100644 (file)
@@ -87,7 +87,7 @@ lupgr(void)
     int rel;
     long cash;
 
-    if (!snxtitem(&ni, EF_LAND, player->argp[2]))
+    if (!snxtitem(&ni, EF_LAND, player->argp[2], NULL))
        return RET_SYN;
     natp = getnatp(player->cnum);
     cash = natp->nat_money;
@@ -170,7 +170,7 @@ supgr(void)
     int rel;
     long cash;
 
-    if (!snxtitem(&ni, EF_SHIP, player->argp[2]))
+    if (!snxtitem(&ni, EF_SHIP, player->argp[2], NULL))
        return RET_SYN;
     natp = getnatp(player->cnum);
     cash = natp->nat_money;
@@ -252,7 +252,7 @@ pupgr(void)
     int rel;
     long cash;
 
-    if (!snxtitem(&ni, EF_PLANE, player->argp[2]))
+    if (!snxtitem(&ni, EF_PLANE, player->argp[2], NULL))
        return RET_SYN;
     natp = getnatp(player->cnum);
     cash = natp->nat_money;
index f0264d632f6da9a2f0e6e491d00a33828e10aabc..51226f05980f1d6a5faf5284d1701efb39137b02 100644 (file)
@@ -57,7 +57,7 @@ wing(void)
     }
     if (c == '~')
        c = 0;
-    if (!snxtitem(&nstr, EF_PLANE, player->argp[2]))
+    if (!snxtitem(&nstr, EF_PLANE, player->argp[2], NULL))
        return RET_SYN;
     count = 0;
     while (nxtitem(&nstr, &plane)) {
index cf6dc769136a2c47069a5025ce7b408f03ce8314..8c33d39caae78db34e64cfebec7d26eae2ebca32 100644 (file)
@@ -51,7 +51,7 @@ work(void)
     coord donex = 0, doney = 1;
     char buf[1024];
 
-    if (!snxtitem(&ni, EF_LAND, player->argp[1]))
+    if (!snxtitem(&ni, EF_LAND, player->argp[1], NULL))
        return RET_SYN;
     p = getstarg(player->argp[2], "Amount: ", buf);
     if (p == 0 || *p == 0)
index 6b9f044445fcf1f2eb8f291977ad30b7e8238491..d4713ba9c829b988c829dc9414d9b023d1627033 100644 (file)
@@ -129,7 +129,7 @@ xditem(struct xdstr *xd, int type, char *arg)
     if (!ca)
        return RET_SYN;
 
-    if (!snxtitem(&ni, type, arg))
+    if (!snxtitem(&ni, type, arg, NULL))
        return RET_SYN;
 
     xdhdr(xd, ef_nameof(type), 0);
index 02cf81392d2002540ba3e3f50a0c2cc8db28c1c7..bb582a277373aaf3f9b1894d5a4855a22841434f 100644 (file)
@@ -70,12 +70,9 @@ int
 get_planes(struct nstr_item *ni_bomb, struct nstr_item *ni_esc,
           char *input_bomb, char *input_esc)
 {
-    char buf[1024];
-
-    if (!snxtitem(ni_bomb, EF_PLANE, input_bomb))
+    if (!snxtitem(ni_bomb, EF_PLANE, input_bomb, NULL))
        return -1;
-    if (!snxtitem(ni_esc, EF_PLANE,
-                 getstarg(input_esc, "escort(s)? ", buf))) {
+    if (!snxtitem(ni_esc, EF_PLANE, input_esc, "escort(s)? ")) {
        if (player->aborted)
            return -1;
        pr("No escorts...\n");
index 3e37dceba7b56886383f85a3cee3c162eb3d76cf..9c8124992082b698e7822500eb4a2f0d88554bd7 100644 (file)
@@ -145,7 +145,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
     if ((type == EF_BAD || type == EF_SHIP) &&
        (flags & P_S || flags & P_I)) {
        if (type == EF_SHIP)
-           snxtitem(&ni, EF_SHIP, selection);
+           snxtitem(&ni, EF_SHIP, selection, NULL);
        else
            snxtitem_dist(&ni, EF_SHIP, x, y, range);
 
@@ -190,7 +190,7 @@ satmap(int x, int y, int eff, int range, int flags, int type)
     if ((type == EF_BAD || type == EF_LAND) &&
        (flags & P_S || flags & P_I)) {
        if (type == EF_LAND)
-           snxtitem(&ni, EF_LAND, selection);
+           snxtitem(&ni, EF_LAND, selection, NULL);
        else
            snxtitem_dist(&ni, EF_LAND, x, y, range);
 
index e14464446ecaccd99fe37394fbdd1a950d1c026b..2c7dc6c50b1a82720c8d5a84be0ddb5efbd3db8e 100644 (file)
@@ -51,7 +51,7 @@
  * instead.
  */
 int
-snxtitem(struct nstr_item *np, int type, char *str)
+snxtitem(struct nstr_item *np, int type, char *str, char *prompt)
 {
     struct range range;
     int list[NS_LSIZE];
@@ -59,13 +59,16 @@ snxtitem(struct nstr_item *np, int type, char *str)
     coord cx, cy;
     int dist;
     int flags;
-    char prompt[128];
+    char promptbuf[128];
     char buf[1024];
 
     np->type = EF_BAD;
     np->sel = NS_UNDEF;
     if (str == 0) {
-       sprintf(prompt, "%s(s)? ", ef_nameof(type));
+       if (!prompt) {
+           sprintf(promptbuf, "%s(s)? ", ef_nameof(type));
+           prompt = promptbuf;
+       }
        str = getstring(prompt, buf);
        if (str == 0)
            return 0;