diff --git a/include/prototypes.h b/include/prototypes.h index 4c10f0f3..c76c63e5 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -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); diff --git a/src/lib/commands/arm.c b/src/lib/commands/arm.c index e689e87b..4393e4ba 100644 --- a/src/lib/commands/arm.c +++ b/src/lib/commands/arm.c @@ -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) diff --git a/src/lib/commands/army.c b/src/lib/commands/army.c index a55b82d7..c3037606 100644 --- a/src/lib/commands/army.c +++ b/src/lib/commands/army.c @@ -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)) { diff --git a/src/lib/commands/carg.c b/src/lib/commands/carg.c index 342739e1..28869b13 100644 --- a/src/lib/commands/carg.c +++ b/src/lib/commands/carg.c @@ -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)) { diff --git a/src/lib/commands/cede.c b/src/lib/commands/cede.c index 4af9da16..bcc1b63a 100644 --- a/src/lib/commands/cede.c +++ b/src/lib/commands/cede.c @@ -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; diff --git a/src/lib/commands/coun.c b/src/lib/commands/coun.c index 24be3468..7b56cbc5 100644 --- a/src/lib/commands/coun.c +++ b/src/lib/commands/coun.c @@ -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", diff --git a/src/lib/commands/decl.c b/src/lib/commands/decl.c index 386fe0ae..b7ed5ebc 100644 --- a/src/lib/commands/decl.c +++ b/src/lib/commands/decl.c @@ -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) { diff --git a/src/lib/commands/fina.c b/src/lib/commands/fina.c index 0bbae079..fca4f886 100644 --- a/src/lib/commands/fina.c +++ b/src/lib/commands/fina.c @@ -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"); diff --git a/src/lib/commands/flee.c b/src/lib/commands/flee.c index 04c24b1f..965f9477 100644 --- a/src/lib/commands/flee.c +++ b/src/lib/commands/flee.c @@ -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)) { diff --git a/src/lib/commands/foll.c b/src/lib/commands/foll.c index bc09f9e4..c81694b0 100644 --- a/src/lib/commands/foll.c +++ b/src/lib/commands/foll.c @@ -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) diff --git a/src/lib/commands/fort.c b/src/lib/commands/fort.c index f42843fa..8630bed8 100644 --- a/src/lib/commands/fort.c +++ b/src/lib/commands/fort.c @@ -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) diff --git a/src/lib/commands/hard.c b/src/lib/commands/hard.c index dc8498ad..2f3bb167 100644 --- a/src/lib/commands/hard.c +++ b/src/lib/commands/hard.c @@ -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) diff --git a/src/lib/commands/land.c b/src/lib/commands/land.c index 3985c09b..46ccad45 100644 --- a/src/lib/commands/land.c +++ b/src/lib/commands/land.c @@ -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; diff --git a/src/lib/commands/laun.c b/src/lib/commands/laun.c index 940144af..01d03c05 100644 --- a/src/lib/commands/laun.c +++ b/src/lib/commands/laun.c @@ -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) diff --git a/src/lib/commands/ldump.c b/src/lib/commands/ldump.c index 5b985104..291fc0c8 100644 --- a/src/lib/commands/ldump.c +++ b/src/lib/commands/ldump.c @@ -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; diff --git a/src/lib/commands/ledg.c b/src/lib/commands/ledg.c index 6bc0febd..6a6be7bf 100644 --- a/src/lib/commands/ledg.c +++ b/src/lib/commands/ledg.c @@ -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; diff --git a/src/lib/commands/load.c b/src/lib/commands/load.c index b677d3ea..d245ba21 100644 --- a/src/lib/commands/load.c +++ b/src/lib/commands/load.c @@ -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)) diff --git a/src/lib/commands/look.c b/src/lib/commands/look.c index f064b8d0..92a635e2 100644 --- a/src/lib/commands/look.c +++ b/src/lib/commands/look.c @@ -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"); diff --git a/src/lib/commands/lost.c b/src/lib/commands/lost.c index 3925e83f..8e410e68 100644 --- a/src/lib/commands/lost.c +++ b/src/lib/commands/lost.c @@ -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(); diff --git a/src/lib/commands/lstat.c b/src/lib/commands/lstat.c index e1e96172..34af6a49 100644 --- a/src/lib/commands/lstat.c +++ b/src/lib/commands/lstat.c @@ -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; diff --git a/src/lib/commands/lten.c b/src/lib/commands/lten.c index 3aaba712..6e982fdf 100644 --- a/src/lib/commands/lten.c +++ b/src/lib/commands/lten.c @@ -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; diff --git a/src/lib/commands/marc.c b/src/lib/commands/marc.c index f497f446..0e97c29d 100644 --- a/src/lib/commands/marc.c +++ b/src/lib/commands/marc.c @@ -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); diff --git a/src/lib/commands/mfir.c b/src/lib/commands/mfir.c index 398b3b7f..7ca3a35d 100644 --- a/src/lib/commands/mfir.c +++ b/src/lib/commands/mfir.c @@ -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)) { diff --git a/src/lib/commands/mine.c b/src/lib/commands/mine.c index 74f44113..c33a558e 100644 --- a/src/lib/commands/mine.c +++ b/src/lib/commands/mine.c @@ -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) diff --git a/src/lib/commands/miss.c b/src/lib/commands/miss.c index abf9d16f..6e4f4fe0 100644 --- a/src/lib/commands/miss.c +++ b/src/lib/commands/miss.c @@ -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 = diff --git a/src/lib/commands/mobq.c b/src/lib/commands/mobq.c index fcd8cf5f..19dff813 100644 --- a/src/lib/commands/mobq.c +++ b/src/lib/commands/mobq.c @@ -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) { diff --git a/src/lib/commands/mora.c b/src/lib/commands/mora.c index 455e73a1..79d07d84 100644 --- a/src/lib/commands/mora.c +++ b/src/lib/commands/mora.c @@ -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) diff --git a/src/lib/commands/name.c b/src/lib/commands/name.c index 493c72f2..9e5d2861 100644 --- a/src/lib/commands/name.c +++ b/src/lib/commands/name.c @@ -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) diff --git a/src/lib/commands/navi.c b/src/lib/commands/navi.c index 122c8ac5..ab6b5e19 100644 --- a/src/lib/commands/navi.c +++ b/src/lib/commands/navi.c @@ -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': diff --git a/src/lib/commands/ndump.c b/src/lib/commands/ndump.c index 08b9a4d6..c9f0098c 100644 --- a/src/lib/commands/ndump.c +++ b/src/lib/commands/ndump.c @@ -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) diff --git a/src/lib/commands/news.c b/src/lib/commands/news.c index db162d0a..6abf9d67 100644 --- a/src/lib/commands/news.c +++ b/src/lib/commands/news.c @@ -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)); diff --git a/src/lib/commands/nuke.c b/src/lib/commands/nuke.c index 848727b1..18705158 100644 --- a/src/lib/commands/nuke.c +++ b/src/lib/commands/nuke.c @@ -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)) { diff --git a/src/lib/commands/orde.c b/src/lib/commands/orde.c index 4bda521d..d4373d05 100644 --- a/src/lib/commands/orde.c +++ b/src/lib/commands/orde.c @@ -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) diff --git a/src/lib/commands/payo.c b/src/lib/commands/payo.c index 10944e95..c7414863 100644 --- a/src/lib/commands/payo.c +++ b/src/lib/commands/payo.c @@ -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; diff --git a/src/lib/commands/pboa.c b/src/lib/commands/pboa.c index 9f911b63..0a9c936a 100644 --- a/src/lib/commands/pboa.c +++ b/src/lib/commands/pboa.c @@ -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, §); diff --git a/src/lib/commands/pdump.c b/src/lib/commands/pdump.c index 6c21a65f..5465e488 100644 --- a/src/lib/commands/pdump.c +++ b/src/lib/commands/pdump.c @@ -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(); diff --git a/src/lib/commands/plan.c b/src/lib/commands/plan.c index 136896ec..b841573c 100644 --- a/src/lib/commands/plan.c +++ b/src/lib/commands/plan.c @@ -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)) { diff --git a/src/lib/commands/powe.c b/src/lib/commands/powe.c index 55046a5c..9376ca0c 100644 --- a/src/lib/commands/powe.c +++ b/src/lib/commands/powe.c @@ -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) diff --git a/src/lib/commands/pstat.c b/src/lib/commands/pstat.c index 5106d0f3..8d5c0d16 100644 --- a/src/lib/commands/pstat.c +++ b/src/lib/commands/pstat.c @@ -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)) { diff --git a/src/lib/commands/rada.c b/src/lib/commands/rada.c index b8f55250..3e488bee 100644 --- a/src/lib/commands/rada.c +++ b/src/lib/commands/rada.c @@ -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; } diff --git a/src/lib/commands/rang.c b/src/lib/commands/rang.c index 96ff29a6..964d4af0 100644 --- a/src/lib/commands/rang.c +++ b/src/lib/commands/rang.c @@ -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) diff --git a/src/lib/commands/reje.c b/src/lib/commands/reje.c index be104878..6bc0af58 100644 --- a/src/lib/commands/reje.c +++ b/src/lib/commands/reje.c @@ -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) { diff --git a/src/lib/commands/repo.c b/src/lib/commands/repo.c index aec2dd7b..2401928b 100644 --- a/src/lib/commands/repo.c +++ b/src/lib/commands/repo.c @@ -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); diff --git a/src/lib/commands/retr.c b/src/lib/commands/retr.c index 5c56219f..c116a886 100644 --- a/src/lib/commands/retr.c +++ b/src/lib/commands/retr.c @@ -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) diff --git a/src/lib/commands/sabo.c b/src/lib/commands/sabo.c index 7911dfc8..45445e48 100644 --- a/src/lib/commands/sabo.c +++ b/src/lib/commands/sabo.c @@ -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)) { diff --git a/src/lib/commands/sail.c b/src/lib/commands/sail.c index 0f1fa0f8..19fa6a81 100644 --- a/src/lib/commands/sail.c +++ b/src/lib/commands/sail.c @@ -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, "-"))) diff --git a/src/lib/commands/scra.c b/src/lib/commands/scra.c index 9c95c2b3..5de18625 100644 --- a/src/lib/commands/scra.c +++ b/src/lib/commands/scra.c @@ -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))) { diff --git a/src/lib/commands/scut.c b/src/lib/commands/scut.c index 8dd892d7..fa305768 100644 --- a/src/lib/commands/scut.c +++ b/src/lib/commands/scut.c @@ -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))) { diff --git a/src/lib/commands/sdump.c b/src/lib/commands/sdump.c index a70ade8d..24307c46 100644 --- a/src/lib/commands/sdump.c +++ b/src/lib/commands/sdump.c @@ -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(); diff --git a/src/lib/commands/set.c b/src/lib/commands/set.c index 62feb357..96a5eb14 100644 --- a/src/lib/commands/set.c +++ b/src/lib/commands/set.c @@ -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) diff --git a/src/lib/commands/shi.c b/src/lib/commands/shi.c index 05d8c018..ccf013bf 100644 --- a/src/lib/commands/shi.c +++ b/src/lib/commands/shi.c @@ -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; diff --git a/src/lib/commands/sona.c b/src/lib/commands/sona.c index 35579ee1..5f3f5bf8 100644 --- a/src/lib/commands/sona.c +++ b/src/lib/commands/sona.c @@ -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))); diff --git a/src/lib/commands/sstat.c b/src/lib/commands/sstat.c index 0498e1b1..e177ad46 100644 --- a/src/lib/commands/sstat.c +++ b/src/lib/commands/sstat.c @@ -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; diff --git a/src/lib/commands/stop.c b/src/lib/commands/stop.c index cd3d9654..414d4840 100644 --- a/src/lib/commands/stop.c +++ b/src/lib/commands/stop.c @@ -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; diff --git a/src/lib/commands/strv.c b/src/lib/commands/strv.c index 3e53ad70..61f41f38 100644 --- a/src/lib/commands/strv.c +++ b/src/lib/commands/strv.c @@ -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)) { diff --git a/src/lib/commands/supp.c b/src/lib/commands/supp.c index 491b3c68..8c1a3e6a 100644 --- a/src/lib/commands/supp.c +++ b/src/lib/commands/supp.c @@ -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; diff --git a/src/lib/commands/tend.c b/src/lib/commands/tend.c index dcf04475..fd02c9ee 100644 --- a/src/lib/commands/tend.c +++ b/src/lib/commands/tend.c @@ -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; diff --git a/src/lib/commands/torp.c b/src/lib/commands/torp.c index 91034f54..b0ce4bef 100644 --- a/src/lib/commands/torp.c +++ b/src/lib/commands/torp.c @@ -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) diff --git a/src/lib/commands/tran.c b/src/lib/commands/tran.c index b2da0d09..259e64eb 100644 --- a/src/lib/commands/tran.c +++ b/src/lib/commands/tran.c @@ -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, diff --git a/src/lib/commands/trea.c b/src/lib/commands/trea.c index 2eda9192..ac1c2da4 100644 --- a/src/lib/commands/trea.c +++ b/src/lib/commands/trea.c @@ -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; diff --git a/src/lib/commands/upgr.c b/src/lib/commands/upgr.c index 3216f7fc..510f08f7 100644 --- a/src/lib/commands/upgr.c +++ b/src/lib/commands/upgr.c @@ -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; diff --git a/src/lib/commands/wing.c b/src/lib/commands/wing.c index f0264d63..51226f05 100644 --- a/src/lib/commands/wing.c +++ b/src/lib/commands/wing.c @@ -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)) { diff --git a/src/lib/commands/work.c b/src/lib/commands/work.c index cf6dc769..8c33d39c 100644 --- a/src/lib/commands/work.c +++ b/src/lib/commands/work.c @@ -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) diff --git a/src/lib/commands/xdump.c b/src/lib/commands/xdump.c index 6b9f0444..d4713ba9 100644 --- a/src/lib/commands/xdump.c +++ b/src/lib/commands/xdump.c @@ -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); diff --git a/src/lib/subs/plnsub.c b/src/lib/subs/plnsub.c index 02cf8139..bb582a27 100644 --- a/src/lib/subs/plnsub.c +++ b/src/lib/subs/plnsub.c @@ -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"); diff --git a/src/lib/subs/satmap.c b/src/lib/subs/satmap.c index 3e37dceb..9c812499 100644 --- a/src/lib/subs/satmap.c +++ b/src/lib/subs/satmap.c @@ -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); diff --git a/src/lib/subs/snxtitem.c b/src/lib/subs/snxtitem.c index e1446444..2c7dc6c5 100644 --- a/src/lib/subs/snxtitem.c +++ b/src/lib/subs/snxtitem.c @@ -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;