Fix recently changed command failures to use BTUs

Failing a command with code RET_SYN prints help and doesn't charge
BTUs.  Failing with code RET_FAIL doesn't print help and charges BTUs.

A couple of command failures were changed or added recently to fail
with RET_SYN, because they're due to invalid player input.  Some of
them, however, can happen after the command already did something, so
BTUs must be charged, or else players can deliberately fail the
command to save BTUs:

* Commit 9eda5f87 adds RET_SYN failures when getting player input
  fails for:

  - arm third argument
  - deliver fourth argument
  - fire third argument
  - lmine second argument
  - order d fourth argument
  - range second argument
  - sail second argument
  - tend third argument

* Commit be41e70f likewise for:

  - designate second argument
  - morale second argument
  - set third argument
  - tend fourth argument

* Commit d000bf92 likewise (with a bogus commit message) for bdes
  second argument.

* Commit 9f4ce71a likewise for ltend third and fourth argument.

* Commit 9031b03b changes failure code from RET_FAIL when getting
  player input fails for threshold third argument.  It adds RET_SYN
  failure when the argument is bad.  Some bad arguments already failed
  that way before.

* Commit a7cf69af changes it from RET_FAIL when designate second
  argument is bad.

Change them all to fail with RET_FAIL.

Many other places have the same bug, but those are left for another
day.
This commit is contained in:
Markus Armbruster 2008-08-09 11:44:26 -04:00
parent c7d2144154
commit a532c76428
14 changed files with 20 additions and 20 deletions

View file

@ -97,7 +97,7 @@ arm(void)
} }
p = getstarg(player->argp[3], "Airburst [n]? ", buf); p = getstarg(player->argp[3], "Airburst [n]? ", buf);
if (!p) if (!p)
return RET_SYN; return RET_FAIL;
if (!check_plane_ok(&pl) || !check_nuke_ok(&nuke)) if (!check_plane_ok(&pl) || !check_nuke_ok(&nuke))
return RET_FAIL; return RET_FAIL;

View file

@ -59,7 +59,7 @@ bdes(void)
xyas(nstr.x, nstr.y, player->cnum), xyas(nstr.x, nstr.y, player->cnum),
d ? d : ' '); d ? d : ' ');
if ((p = getstarg(player->argp[2], prompt, buf)) == 0) { if ((p = getstarg(player->argp[2], prompt, buf)) == 0) {
rc = RET_SYN; rc = RET_FAIL;
break; break;
} }
if (!isprint(*p)) { if (!isprint(*p)) {

View file

@ -79,7 +79,7 @@ deli(void)
dchr[sect.sct_type].d_name, ich->i_name); dchr[sect.sct_type].d_name, ich->i_name);
p = getstarg(player->argp[4], prompt, buf); p = getstarg(player->argp[4], prompt, buf);
if (!p) if (!p)
return RET_SYN; return RET_FAIL;
} }
} }
if (p && *p) { if (p && *p) {

View file

@ -69,7 +69,7 @@ desi(void)
xyas(sect.sct_x, sect.sct_y, player->cnum), xyas(sect.sct_x, sect.sct_y, player->cnum),
sect.sct_effic, dchr[sect.sct_type].d_name); sect.sct_effic, dchr[sect.sct_type].d_name);
if ((p = getstarg(player->argp[2], prompt, buf)) == 0) { if ((p = getstarg(player->argp[2], prompt, buf)) == 0) {
rc = RET_SYN; rc = RET_FAIL;
break; break;
} }
@ -80,7 +80,7 @@ desi(void)
if (des < 0) { if (des < 0) {
pr("No such designation\n" pr("No such designation\n"
"See \"info Sector-types\" for possible designations\n"); "See \"info Sector-types\" for possible designations\n");
rc = RET_SYN; rc = RET_FAIL;
break; break;
} }
if (!player->god) { if (!player->god) {

View file

@ -76,7 +76,7 @@ ltend(void)
continue; continue;
if ((p = if ((p =
getstarg(player->argp[3], "Amount to transfer? ", buf)) == 0) getstarg(player->argp[3], "Amount to transfer? ", buf)) == 0)
return RET_SYN; return RET_FAIL;
if (!check_ship_ok(&tender)) if (!check_ship_ok(&tender))
return RET_FAIL; return RET_FAIL;
if ((amt = atoi(p)) == 0) if ((amt = atoi(p)) == 0)
@ -95,7 +95,7 @@ ltend(void)
} }
if (!snxtitem(&targets, EF_LAND, if (!snxtitem(&targets, EF_LAND,
player->argp[4], "Units to be tended? ")) player->argp[4], "Units to be tended? "))
return RET_SYN; return RET_FAIL;
if (!check_ship_ok(&tender)) if (!check_ship_ok(&tender))
return RET_FAIL; return RET_FAIL;
total = 0; total = 0;

View file

@ -214,7 +214,7 @@ multifire(void)
ptr = getstarg(player->argp[3], "Firing at? ", buf); ptr = getstarg(player->argp[3], "Firing at? ", buf);
if (!ptr) if (!ptr)
return RET_SYN; return RET_FAIL;
if (!*ptr) if (!*ptr)
continue; continue;
if (!issector(ptr)) { if (!issector(ptr)) {

View file

@ -129,7 +129,7 @@ landmine(void)
sprintf(prompt, "Drop how many mines from %s? ", prland(&land)); sprintf(prompt, "Drop how many mines from %s? ", prland(&land));
mines_wanted = onearg(player->argp[2], prompt); mines_wanted = onearg(player->argp[2], prompt);
if (mines_wanted < 0) if (mines_wanted < 0)
return RET_SYN; return RET_FAIL;
if (mines_wanted == 0) if (mines_wanted == 0)
continue; continue;
if (!check_land_ok(&land)) if (!check_land_ok(&land))

View file

@ -59,7 +59,7 @@ morale(void)
prland(&land), min); prland(&land), min);
p = getstarg(player->argp[2], mess, buf); p = getstarg(player->argp[2], mess, buf);
if (!p) if (!p)
return RET_SYN; return RET_FAIL;
if (!check_land_ok(&land)) if (!check_land_ok(&land))
continue; continue;
if ((i = atoi(p)) < 0) if ((i = atoi(p)) < 0)

View file

@ -137,7 +137,7 @@ orde(void)
if (!orders) { if (!orders) {
p = getstarg(player->argp[4], "Second dest? ", buf); p = getstarg(player->argp[4], "Second dest? ", buf);
if (!p) if (!p)
return RET_SYN; return RET_FAIL;
if (!*p || !strcmp(p, "-")) { if (!*p || !strcmp(p, "-")) {
orders = 1; orders = 1;
pr("A one-way order has been accepted.\n"); pr("A one-way order has been accepted.\n");

View file

@ -53,7 +53,7 @@ range(void)
continue; continue;
p = getstarg(player->argp[2], "New range? ", buf); p = getstarg(player->argp[2], "New range? ", buf);
if (!p) if (!p)
return RET_SYN; return RET_FAIL;
if (!check_plane_ok(&plane)) if (!check_plane_ok(&plane))
return RET_SYN; return RET_SYN;
if ((i = atoi(p)) < 0) if ((i = atoi(p)) < 0)

View file

@ -124,7 +124,7 @@ cmd_sail_ship(struct nstr_item *nstr)
cp = getpath(navpath, player->argp[2], cp = getpath(navpath, player->argp[2],
ship.shp_x, ship.shp_y, 0, 0, P_SAILING); ship.shp_x, ship.shp_y, 0, 0, P_SAILING);
if (!cp) if (!cp)
return RET_SYN; return RET_FAIL;
if (!check_ship_ok(&ship)) if (!check_ship_ok(&ship))
continue; continue;
strncpy(ship.shp_path, cp, sizeof(ship.shp_path) - 2); strncpy(ship.shp_path, cp, sizeof(ship.shp_path) - 2);

View file

@ -93,7 +93,7 @@ set(void)
sprintf(prompt, "%s #%d; Price? ", sprintf(prompt, "%s #%d; Price? ",
trade_nameof(&trade, &item), ni.cur); trade_nameof(&trade, &item), ni.cur);
if ((p = getstarg(player->argp[3], prompt, buf)) == 0) if ((p = getstarg(player->argp[3], prompt, buf)) == 0)
return RET_SYN; return RET_FAIL;
if (!trade_check_item_ok(&item)) if (!trade_check_item_ok(&item))
return RET_FAIL; return RET_FAIL;
if ((price = atoi(p)) < 0) if ((price = atoi(p)) < 0)

View file

@ -91,7 +91,7 @@ tend(void)
prship(&tender)); prship(&tender));
p = getstarg(player->argp[3], prompt, buf); p = getstarg(player->argp[3], prompt, buf);
if (!p) if (!p)
return RET_SYN; return RET_FAIL;
if (!*p) if (!*p)
continue; continue;
if (!check_ship_ok(&tender)) if (!check_ship_ok(&tender))
@ -104,7 +104,7 @@ tend(void)
ip->i_name, prship(&tender)); ip->i_name, prship(&tender));
p = getstarg(player->argp[3], prompt, buf); p = getstarg(player->argp[3], prompt, buf);
if (!p) if (!p)
return RET_SYN; return RET_FAIL;
if (!*p) if (!*p)
continue; continue;
if (!check_ship_ok(&tender)) if (!check_ship_ok(&tender))
@ -127,7 +127,7 @@ tend(void)
} }
if (!snxtitem(&targets, EF_SHIP, if (!snxtitem(&targets, EF_SHIP,
player->argp[4], "Ships to be tended? ")) player->argp[4], "Ships to be tended? "))
return RET_SYN; return RET_FAIL;
if (!check_ship_ok(&tender)) if (!check_ship_ok(&tender))
return RET_SYN; return RET_SYN;
total = 0; total = 0;
@ -228,7 +228,7 @@ tend_land(struct shpstr *tenderp, char *units)
} }
if (!snxtitem(&targets, EF_SHIP, if (!snxtitem(&targets, EF_SHIP,
player->argp[4], "Ship to be tended? ")) player->argp[4], "Ship to be tended? "))
return RET_SYN; return RET_FAIL;
if (!check_land_ok(&land)) if (!check_land_ok(&land))
return RET_SYN; return RET_SYN;
while (nxtitem(&targets, &target)) { while (nxtitem(&targets, &target)) {

View file

@ -71,14 +71,14 @@ thre(void)
xyas(nstr.x, nstr.y, player->cnum), xyas(nstr.x, nstr.y, player->cnum),
dchr[sect.sct_type].d_name); dchr[sect.sct_type].d_name);
if ((p = getstarg(player->argp[3], prompt, buf)) == 0) if ((p = getstarg(player->argp[3], prompt, buf)) == 0)
return RET_SYN; return RET_FAIL;
if (!*p) if (!*p)
continue; continue;
if (!check_sect_ok(&sect)) if (!check_sect_ok(&sect))
return RET_FAIL; return RET_FAIL;
thresh = atoi(p); thresh = atoi(p);
if (thresh < 0) if (thresh < 0)
return RET_SYN; return RET_FAIL;
if (thresh > ITEM_MAX) if (thresh > ITEM_MAX)
thresh = ITEM_MAX; thresh = ITEM_MAX;
if ((val > 0) && (val == thresh)) { if ((val > 0) && (val == thresh)) {