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: * Commit9eda5f87
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 * Commitbe41e70f
likewise for: - designate second argument - morale second argument - set third argument - tend fourth argument * Commitd000bf92
likewise (with a bogus commit message) for bdes second argument. * Commit9f4ce71a
likewise for ltend third and fourth argument. * Commit9031b03b
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. * Commita7cf69af
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:
parent
c7d2144154
commit
a532c76428
14 changed files with 20 additions and 20 deletions
|
@ -97,7 +97,7 @@ arm(void)
|
|||
}
|
||||
p = getstarg(player->argp[3], "Airburst [n]? ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
|
||||
if (!check_plane_ok(&pl) || !check_nuke_ok(&nuke))
|
||||
return RET_FAIL;
|
||||
|
|
|
@ -59,7 +59,7 @@ bdes(void)
|
|||
xyas(nstr.x, nstr.y, player->cnum),
|
||||
d ? d : ' ');
|
||||
if ((p = getstarg(player->argp[2], prompt, buf)) == 0) {
|
||||
rc = RET_SYN;
|
||||
rc = RET_FAIL;
|
||||
break;
|
||||
}
|
||||
if (!isprint(*p)) {
|
||||
|
|
|
@ -79,7 +79,7 @@ deli(void)
|
|||
dchr[sect.sct_type].d_name, ich->i_name);
|
||||
p = getstarg(player->argp[4], prompt, buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
}
|
||||
}
|
||||
if (p && *p) {
|
||||
|
|
|
@ -69,7 +69,7 @@ desi(void)
|
|||
xyas(sect.sct_x, sect.sct_y, player->cnum),
|
||||
sect.sct_effic, dchr[sect.sct_type].d_name);
|
||||
if ((p = getstarg(player->argp[2], prompt, buf)) == 0) {
|
||||
rc = RET_SYN;
|
||||
rc = RET_FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ desi(void)
|
|||
if (des < 0) {
|
||||
pr("No such designation\n"
|
||||
"See \"info Sector-types\" for possible designations\n");
|
||||
rc = RET_SYN;
|
||||
rc = RET_FAIL;
|
||||
break;
|
||||
}
|
||||
if (!player->god) {
|
||||
|
|
|
@ -76,7 +76,7 @@ ltend(void)
|
|||
continue;
|
||||
if ((p =
|
||||
getstarg(player->argp[3], "Amount to transfer? ", buf)) == 0)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!check_ship_ok(&tender))
|
||||
return RET_FAIL;
|
||||
if ((amt = atoi(p)) == 0)
|
||||
|
@ -95,7 +95,7 @@ ltend(void)
|
|||
}
|
||||
if (!snxtitem(&targets, EF_LAND,
|
||||
player->argp[4], "Units to be tended? "))
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!check_ship_ok(&tender))
|
||||
return RET_FAIL;
|
||||
total = 0;
|
||||
|
|
|
@ -214,7 +214,7 @@ multifire(void)
|
|||
|
||||
ptr = getstarg(player->argp[3], "Firing at? ", buf);
|
||||
if (!ptr)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!*ptr)
|
||||
continue;
|
||||
if (!issector(ptr)) {
|
||||
|
|
|
@ -129,7 +129,7 @@ landmine(void)
|
|||
sprintf(prompt, "Drop how many mines from %s? ", prland(&land));
|
||||
mines_wanted = onearg(player->argp[2], prompt);
|
||||
if (mines_wanted < 0)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (mines_wanted == 0)
|
||||
continue;
|
||||
if (!check_land_ok(&land))
|
||||
|
|
|
@ -59,7 +59,7 @@ morale(void)
|
|||
prland(&land), min);
|
||||
p = getstarg(player->argp[2], mess, buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!check_land_ok(&land))
|
||||
continue;
|
||||
if ((i = atoi(p)) < 0)
|
||||
|
|
|
@ -137,7 +137,7 @@ orde(void)
|
|||
if (!orders) {
|
||||
p = getstarg(player->argp[4], "Second dest? ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!*p || !strcmp(p, "-")) {
|
||||
orders = 1;
|
||||
pr("A one-way order has been accepted.\n");
|
||||
|
|
|
@ -53,7 +53,7 @@ range(void)
|
|||
continue;
|
||||
p = getstarg(player->argp[2], "New range? ", buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!check_plane_ok(&plane))
|
||||
return RET_SYN;
|
||||
if ((i = atoi(p)) < 0)
|
||||
|
|
|
@ -124,7 +124,7 @@ cmd_sail_ship(struct nstr_item *nstr)
|
|||
cp = getpath(navpath, player->argp[2],
|
||||
ship.shp_x, ship.shp_y, 0, 0, P_SAILING);
|
||||
if (!cp)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!check_ship_ok(&ship))
|
||||
continue;
|
||||
strncpy(ship.shp_path, cp, sizeof(ship.shp_path) - 2);
|
||||
|
|
|
@ -93,7 +93,7 @@ set(void)
|
|||
sprintf(prompt, "%s #%d; Price? ",
|
||||
trade_nameof(&trade, &item), ni.cur);
|
||||
if ((p = getstarg(player->argp[3], prompt, buf)) == 0)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!trade_check_item_ok(&item))
|
||||
return RET_FAIL;
|
||||
if ((price = atoi(p)) < 0)
|
||||
|
|
|
@ -91,7 +91,7 @@ tend(void)
|
|||
prship(&tender));
|
||||
p = getstarg(player->argp[3], prompt, buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!*p)
|
||||
continue;
|
||||
if (!check_ship_ok(&tender))
|
||||
|
@ -104,7 +104,7 @@ tend(void)
|
|||
ip->i_name, prship(&tender));
|
||||
p = getstarg(player->argp[3], prompt, buf);
|
||||
if (!p)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!*p)
|
||||
continue;
|
||||
if (!check_ship_ok(&tender))
|
||||
|
@ -127,7 +127,7 @@ tend(void)
|
|||
}
|
||||
if (!snxtitem(&targets, EF_SHIP,
|
||||
player->argp[4], "Ships to be tended? "))
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!check_ship_ok(&tender))
|
||||
return RET_SYN;
|
||||
total = 0;
|
||||
|
@ -228,7 +228,7 @@ tend_land(struct shpstr *tenderp, char *units)
|
|||
}
|
||||
if (!snxtitem(&targets, EF_SHIP,
|
||||
player->argp[4], "Ship to be tended? "))
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!check_land_ok(&land))
|
||||
return RET_SYN;
|
||||
while (nxtitem(&targets, &target)) {
|
||||
|
|
|
@ -71,14 +71,14 @@ thre(void)
|
|||
xyas(nstr.x, nstr.y, player->cnum),
|
||||
dchr[sect.sct_type].d_name);
|
||||
if ((p = getstarg(player->argp[3], prompt, buf)) == 0)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (!*p)
|
||||
continue;
|
||||
if (!check_sect_ok(§))
|
||||
return RET_FAIL;
|
||||
thresh = atoi(p);
|
||||
if (thresh < 0)
|
||||
return RET_SYN;
|
||||
return RET_FAIL;
|
||||
if (thresh > ITEM_MAX)
|
||||
thresh = ITEM_MAX;
|
||||
if ((val > 0) && (val == thresh)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue