]> git.pond.sub.org Git - empserver/commitdiff
Fix recently changed command failures to use BTUs
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 9 Aug 2008 15:44:26 +0000 (11:44 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 9 Aug 2008 16:09:50 +0000 (12:09 -0400)
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.

14 files changed:
src/lib/commands/arm.c
src/lib/commands/bdes.c
src/lib/commands/deli.c
src/lib/commands/desi.c
src/lib/commands/lten.c
src/lib/commands/mfir.c
src/lib/commands/mine.c
src/lib/commands/mora.c
src/lib/commands/orde.c
src/lib/commands/rang.c
src/lib/commands/sail.c
src/lib/commands/set.c
src/lib/commands/tend.c
src/lib/commands/thre.c

index 4393e4ba0d1882a0717c5067aec82ea79a735603..5a9109c58e153ae975d0254d0cc846da970635fc 100644 (file)
@@ -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;
index ce1dd85732456067213dd39fe7f790f729a963ee..8e20b62d7af2e8b94008484137e9854416c4a9cf 100644 (file)
@@ -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)) {
index a52e5f0f82eda00fb9608e4710327fd6b9c31f5c..4d894636dac835ef8a7cf66321f44a92f0d8c19b 100644 (file)
@@ -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) {
index 5ba9792383cfd297dad9c78c3fb683df08c4707f..917cfdf62695ef19968e75cefae8ee6f82dcfa13 100644 (file)
@@ -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) {
index 6e982fdf0901144fee82fe4531f65f139dd8294f..32fd31e3e627e006ee90d7022abb8bea8eed4048 100644 (file)
@@ -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;
index 7ca3a35da26eae716e9fd60cc7b0d044840b1776..db768ff3a965542b566777872ced6deb4f96cc17 100644 (file)
@@ -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)) {
index c33a558e2cbdf7d8a601baad3b6a30b44b81eab7..b220895fc99671c90a4ecb8a388b397e05a19dd4 100644 (file)
@@ -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))
index 79d07d84912a39d960c300985891348944dd5745..23e2cd8e84d9321f3e0a37745bfdfe1cb2bd2c3b 100644 (file)
@@ -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)
index d4373d054dceab40739c857cb8fa6e50b1855082..5aebcf605c42a8015ac87a59e98b3e200cbb56fe 100644 (file)
@@ -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");
index 964d4af0d298cf49c5ba0712c85d71c0fa9ccf38..3e1d2c585ae919652e23968ddb7619fd6ec730c2 100644 (file)
@@ -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)
index 19fa6a81a81adc463e94192eb6973b83691b0cde..230e06e81e868aedb8c385d8b91833cbfabf9403 100644 (file)
@@ -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);
index 96a5eb14a12b5505a6b2160d3649c791b9f90a2c..567e47c2f08ec4410386f2a8ed111707b4af87ca 100644 (file)
@@ -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)
index fd02c9eec4643187262ba53900cfd055def8e7f2..6b55f80b6bbfd8bac57acf0e874af1dd23e47ca9 100644 (file)
@@ -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)) {
index b888aeecf8e1abe2476ad5de08400e304eb2f7b3..03aed85a63432dde50c53b834c0f9889ee5d30b1 100644 (file)
@@ -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(&sect))
            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)) {