From a532c764284bb04257ee3878ecd061929e5ccba2 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 9 Aug 2008 11:44:26 -0400 Subject: [PATCH] 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. --- src/lib/commands/arm.c | 2 +- src/lib/commands/bdes.c | 2 +- src/lib/commands/deli.c | 2 +- src/lib/commands/desi.c | 4 ++-- src/lib/commands/lten.c | 4 ++-- src/lib/commands/mfir.c | 2 +- src/lib/commands/mine.c | 2 +- src/lib/commands/mora.c | 2 +- src/lib/commands/orde.c | 2 +- src/lib/commands/rang.c | 2 +- src/lib/commands/sail.c | 2 +- src/lib/commands/set.c | 2 +- src/lib/commands/tend.c | 8 ++++---- src/lib/commands/thre.c | 4 ++-- 14 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/lib/commands/arm.c b/src/lib/commands/arm.c index 4393e4ba..5a9109c5 100644 --- a/src/lib/commands/arm.c +++ b/src/lib/commands/arm.c @@ -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; diff --git a/src/lib/commands/bdes.c b/src/lib/commands/bdes.c index ce1dd857..8e20b62d 100644 --- a/src/lib/commands/bdes.c +++ b/src/lib/commands/bdes.c @@ -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)) { diff --git a/src/lib/commands/deli.c b/src/lib/commands/deli.c index a52e5f0f..4d894636 100644 --- a/src/lib/commands/deli.c +++ b/src/lib/commands/deli.c @@ -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) { diff --git a/src/lib/commands/desi.c b/src/lib/commands/desi.c index 5ba97923..917cfdf6 100644 --- a/src/lib/commands/desi.c +++ b/src/lib/commands/desi.c @@ -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) { diff --git a/src/lib/commands/lten.c b/src/lib/commands/lten.c index 6e982fdf..32fd31e3 100644 --- a/src/lib/commands/lten.c +++ b/src/lib/commands/lten.c @@ -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; diff --git a/src/lib/commands/mfir.c b/src/lib/commands/mfir.c index 7ca3a35d..db768ff3 100644 --- a/src/lib/commands/mfir.c +++ b/src/lib/commands/mfir.c @@ -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)) { diff --git a/src/lib/commands/mine.c b/src/lib/commands/mine.c index c33a558e..b220895f 100644 --- a/src/lib/commands/mine.c +++ b/src/lib/commands/mine.c @@ -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)) diff --git a/src/lib/commands/mora.c b/src/lib/commands/mora.c index 79d07d84..23e2cd8e 100644 --- a/src/lib/commands/mora.c +++ b/src/lib/commands/mora.c @@ -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) diff --git a/src/lib/commands/orde.c b/src/lib/commands/orde.c index d4373d05..5aebcf60 100644 --- a/src/lib/commands/orde.c +++ b/src/lib/commands/orde.c @@ -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"); diff --git a/src/lib/commands/rang.c b/src/lib/commands/rang.c index 964d4af0..3e1d2c58 100644 --- a/src/lib/commands/rang.c +++ b/src/lib/commands/rang.c @@ -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) diff --git a/src/lib/commands/sail.c b/src/lib/commands/sail.c index 19fa6a81..230e06e8 100644 --- a/src/lib/commands/sail.c +++ b/src/lib/commands/sail.c @@ -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); diff --git a/src/lib/commands/set.c b/src/lib/commands/set.c index 96a5eb14..567e47c2 100644 --- a/src/lib/commands/set.c +++ b/src/lib/commands/set.c @@ -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) diff --git a/src/lib/commands/tend.c b/src/lib/commands/tend.c index fd02c9ee..6b55f80b 100644 --- a/src/lib/commands/tend.c +++ b/src/lib/commands/tend.c @@ -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)) { diff --git a/src/lib/commands/thre.c b/src/lib/commands/thre.c index b888aeec..03aed85a 100644 --- a/src/lib/commands/thre.c +++ b/src/lib/commands/thre.c @@ -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)) {