]> git.pond.sub.org Git - empserver/commitdiff
Clean up more unreadable assignments within if conditionals
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 23 Mar 2009 21:43:52 +0000 (22:43 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Mon, 23 Mar 2009 22:11:14 +0000 (23:11 +0100)
19 files changed:
src/lib/commands/boar.c
src/lib/commands/deli.c
src/lib/commands/grin.c
src/lib/commands/hard.c
src/lib/commands/improve.c
src/lib/commands/lboard.c
src/lib/commands/load.c
src/lib/commands/miss.c
src/lib/commands/offe.c
src/lib/commands/orde.c
src/lib/commands/rese.c
src/lib/commands/rout.c
src/lib/commands/sell.c
src/lib/commands/setres.c
src/lib/commands/setsect.c
src/lib/commands/show.c
src/lib/commands/tend.c
src/lib/commands/trad.c
src/lib/subs/attsub.c

index 8add3cf733ede16a666f225159f2148eba701e3a..48245d3d6126ceb0a2f4b9aad3e70fbe73e653d3 100644 (file)
@@ -65,9 +65,8 @@ boar(void)
      */
 
     /* What are we boarding? */
-
-    if (!(p = getstarg(player->argp[1], "Victim ship #?  ", buf)) ||
-       (def->shp_uid = atoi(p)) < 0)
+    p = getstarg(player->argp[1], "Victim ship #?  ", buf);
+    if (!p || (def->shp_uid = atoi(p)) < 0)
        return RET_SYN;
 
     /*
index 22e086178940eff41f7efd435b9dc66ba2c88092..a433b3969973198dab9b9c9652ddf4e5f612a09b 100644 (file)
@@ -66,7 +66,8 @@ deli(void)
        sprintf(prompt, "%s %s %s threshold or direction or 'query'? ",
                xyas(nstr.x, nstr.y, player->cnum),
                dchr[sect.sct_type].d_name, ich->i_name);
-       if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
+       p = getstarg(player->argp[3], prompt, buf);
+       if (!p || !*p)
            return RET_SYN;
        if (*p != 'q') {
            if (((*p >= '0') && (*p <= '9')) || *p == '+') {
index 2f311d212b5a39a80dde986bc0dcd4554c0ddee8..0486a50516eacae244967c106a7216f15560494f 100644 (file)
@@ -60,7 +60,8 @@ grin(void)
        return RET_SYN;
     if (!snxtsct(&nstr, p))
        return RET_SYN;
-    if ((p = getstarg(player->argp[2], "amount :  ", buf)) == 0 || *p == 0)
+    p = getstarg(player->argp[2], "amount :  ", buf);
+    if (!p || !*p)
        return RET_SYN;
     qty = atoi(p);
     if (qty < 0)
index 085f749514a22fde7c315f0bda0c7abd21d74a6d..430427789ddcb1c85da7288899129324fbf61554 100644 (file)
@@ -58,8 +58,8 @@ hard(void)
 
     if (!snxtitem(&ni, EF_PLANE, player->argp[1], NULL))
        return RET_SYN;
-    if ((p = getstarg(player->argp[2], "Increase by? ", buf)) == 0
-       || *p == 0)
+    p = getstarg(player->argp[2], "Increase by? ", buf);
+    if (!p || !*p)
        return RET_SYN;
     level = atoi(p);
     if (level < 0)
index 42be1aec2f4889fea214bfb66aff59d2881c23e3..02a1a345e8000745574a148d062293b4a7ae32cc 100644 (file)
@@ -92,7 +92,8 @@ improve(void)
        sprintf(prompt, "Sector %s has a %s of %d%%.  Improve how much? ",
                xyas(sect.sct_x, sect.sct_y, player->cnum),
                intrchr[type].in_name, value);
-       if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
+       p = getstarg(player->argp[3], prompt, buf);
+       if (!p || !*p)
            continue;
        if (!check_sect_ok(&sect))
            continue;
index 05a50134178f1dc5bad979b5238e7994e14498e1..d35e3ec039d91cbbbd2385a09a42676c807ca77a 100644 (file)
@@ -61,9 +61,8 @@ lboa(void)
      */
 
     /* What are we boarding? */
-
-    if (!(p = getstarg(player->argp[1], "Victim land unit #?  ", buf)) ||
-       (def->lnd_uid = atoi(p)) < 0)
+    p = getstarg(player->argp[1], "Victim land unit #?  ", buf);
+    if (!p || (def->lnd_uid = atoi(p)) < 0)
        return RET_SYN;
 
     /*
index c5e84cd9bc630f1f925891489ad4220ffc1982ba..5637c40b5215352a1e4ea51485278fbef7a5e69d 100644 (file)
@@ -83,9 +83,9 @@ load(void)
     char *p;
     char buf[1024];
 
-    if (!(p = getstarg(player->argp[1],
-                      "What commodity (or 'plane' or 'land')? ", buf))
-       || !*p)
+    p = getstarg(player->argp[1],
+                "What commodity (or 'plane' or 'land')? ", buf);
+    if (!p || !*p)
        return RET_SYN;
 
     if (!strncmp(p, "plane", 5))
@@ -99,7 +99,8 @@ load(void)
        return RET_SYN;
     }
 
-    if (!(p = getstarg(player->argp[2], "Ship(s): ", buf)) || !*p)
+    p = getstarg(player->argp[2], "Ship(s): ", buf);
+    if (!p || !*p)
        return RET_SYN;
 
     noisy = isdigit(*p);
@@ -216,9 +217,9 @@ lload(void)
     char *p;
     char buf[1024];
 
-    if (!(p = getstarg(player->argp[1],
-                      "What commodity (or 'plane' or 'land')? ", buf))
-       || !*p)
+    p = getstarg(player->argp[1],
+                "What commodity (or 'plane' or 'land')? ", buf);
+    if (!p || !*p)
        return RET_SYN;
     if (!strncmp(p, "plane", 5))
        type = EF_PLANE;
@@ -231,7 +232,8 @@ lload(void)
        return RET_SYN;
     }
 
-    if (!(p = getstarg(player->argp[2], "Unit(s): ", buf)) || !*p)
+    p = getstarg(player->argp[2], "Unit(s): ", buf);
+    if (!p || !*p)
        return RET_SYN;
 
     noisy = isdigit(*p);
@@ -691,7 +693,8 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
            (load_unload == UNLOAD) ?
            "unload from" : "load onto",
            prship(sp), xyas(sp->shp_x, sp->shp_y, player->cnum));
-    if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
+    p = getstarg(player->argp[3], prompt, buf);
+    if (!p || !*p)
        return RET_SYN;
 
     if (!still_ok_ship(sectp, sp))
@@ -852,7 +855,8 @@ load_comm_land(struct sctstr *sectp, struct lndstr *lp,
            (load_unload == UNLOAD) ?
            "unload from" : "load onto",
            prland(lp), xyas(lp->lnd_x, lp->lnd_y, player->cnum));
-    if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
+    p = getstarg(player->argp[3], prompt, buf);
+    if (!p || !*p)
        return RET_SYN;
 
     if (!still_ok_land(sectp, lp))
index a1243860d487005337064531bdb43b58f8faa2f6..16d60b2fe1466703fc64e23ae2b5e55d676b78f0 100644 (file)
@@ -149,8 +149,8 @@ mission(void)
        return RET_FAIL;
     }
 
-    if ((p = getstarg(player->argp[4], "operations point? ", buf)) == 0
-       || *p == 0)
+    p = getstarg(player->argp[4], "operations point? ", buf);
+    if (!p || !*p)
        return RET_SYN;
 
     if (*p != '.') {
index 11c81666c767c1b3ad0f5aa2ec2dbeab12cb312a..88e47b7959d1491ea7997bbbcc3e57a7afe6ce42 100644 (file)
@@ -48,7 +48,8 @@ offe(void)
     char *cp;
     char buf[1024];
 
-    if (!(cp = getstarg(player->argp[1], "loan or treaty? ", buf)) || !*cp)
+    cp = getstarg(player->argp[1], "loan or treaty? ", buf);
+    if (!cp || !*cp)
        return RET_SYN;
 
     switch (*cp) {
index 4515fb17f1981cc3fc2ac1d63bcfe5ff61c931c5..2c2ea7560446df980fd2479507b0f2f96f34d467 100644 (file)
@@ -124,8 +124,8 @@ orde(void)
            orders = 0;
            scuttling = 0;
            /* Need location */
-           if ((p = getstarg(player->argp[3], "Destination? ", buf)) == 0
-               || *p == 0)
+           p = getstarg(player->argp[3], "Destination? ", buf);
+           if (!p || !*p)
                return RET_SYN;
            if (!sarg_xy(p, &p0x, &p0y))
                return RET_SYN;
index 1f8e635e9559e18ed2274cb8d6cece49b1d6e18e..fd7a5414165b0cadefea47315503c851a0de58b8 100644 (file)
@@ -61,8 +61,8 @@ rese(void)
     }
     check_market();
     check_trade();
-    if ((p = getstarg(player->argp[1], "Which lot :  ", buf)) == 0
-       || *p == 0)
+    p = getstarg(player->argp[1], "Which lot :  ", buf);
+    if (!p || !*p)
        return RET_SYN;
     number_set = atoi(p);
     getcomm(number_set, &comm);
@@ -74,8 +74,8 @@ rese(void)
        pr("Some one already has a bid out on that\n");
        return RET_OK;
     }
-    if ((p = getstarg(player->argp[2], "New (lower) price: ", buf)) == 0
-       || *p == 0)
+    p = getstarg(player->argp[2], "New (lower) price: ", buf);
+    if (!p || !*p)
        return RET_SYN;
     if (!check_comm_ok(&comm))
        return RET_FAIL;
index 26bb7823c0a0228d21aae0b68ae0da3ab76f96b5..244cff2cb7e60c7d338daf17e2760354269f2b5b 100644 (file)
@@ -96,8 +96,8 @@ rout(void)
        if (!player->owner)
            continue;
        p = &map[ns.dy][ns.dx * 2];
-       if ((dir = sect.sct_del[i_del] & 0x7) &&
-           nstr_exec(cond, ncond, &sect))
+       dir = sect.sct_del[i_del] & 0x7;
+       if (dir && nstr_exec(cond, ncond, &sect))
            memcpy(p, routech[dir], 3);
        p[1] = dchr[sect.sct_type].d_mnem;
     }
index e84c9900778efad9c07950ff4a5e3ee0406dfd13..0f7b3b4a2b96b898c7f6a176c5622132fec7bb96 100644 (file)
@@ -100,13 +100,14 @@ sell(void)
        return RET_FAIL;
     }
     number_sub = 0;
-    if ((p = getstarg(player->argp[3], "Quantity: ", buf)) == 0 || *p == 0)
+    p = getstarg(player->argp[3], "Quantity: ", buf);
+    if (!p || !*p)
        return RET_SYN;
     if (!check_sect_ok(&sect))
        return RET_FAIL;
     number_set = atoi(p);
-    if ((p = getstarg(player->argp[4], "Price per unit: ", buf)) == 0 ||
-       *p == 0)
+    p = getstarg(player->argp[4], "Price per unit: ", buf);
+    if (!p || !*p)
        return RET_SYN;
     if (!check_sect_ok(&sect))
        return RET_FAIL;
index 0a3c106775ea1a78bd12b785b3d29e79c637a91e..4d198652329ef15309a316146704c3d0223310a2 100644 (file)
@@ -60,8 +60,8 @@ setres(void)
        if (!snxtsct(&nstr, player->argp[2]))
            return RET_SYN;
        while (nxtsct(&nstr, &sect) > 0) {
-           if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
-               (*p == '\0'))
+           p = getstarg(player->argp[3], "What value : ", buf);
+           if (!p || !*p)
                return RET_SYN;
            amt = atoi(p);
            if (amt > 100)
@@ -79,8 +79,8 @@ setres(void)
        if (!snxtsct(&nstr, player->argp[2]))
            return RET_SYN;
        while (nxtsct(&nstr, &sect) > 0) {
-           if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
-               (*p == '\0'))
+           p = getstarg(player->argp[3], "What value : ", buf);
+           if (!p || !*p)
                return RET_SYN;
            amt = atoi(p);
            if (amt > 100)
@@ -98,8 +98,8 @@ setres(void)
        if (!snxtsct(&nstr, player->argp[2]))
            return RET_SYN;
        while (nxtsct(&nstr, &sect) > 0) {
-           if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
-               (*p == '\0'))
+           p = getstarg(player->argp[3], "What value : ", buf);
+           if (!p || !*p)
                return RET_SYN;
            amt = atoi(p);
            if (amt > 100)
@@ -116,8 +116,8 @@ setres(void)
        if (!snxtsct(&nstr, player->argp[2]))
            return RET_SYN;
        while (nxtsct(&nstr, &sect) > 0) {
-           if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
-               (*p == '\0'))
+           p = getstarg(player->argp[3], "What value : ", buf);
+           if (!p || !*p)
                return RET_SYN;
            amt = atoi(p);
            if (amt > 100)
@@ -135,8 +135,8 @@ setres(void)
        if (!snxtsct(&nstr, player->argp[2]))
            return RET_SYN;
        while (nxtsct(&nstr, &sect) > 0) {
-           if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
-               (*p == '\0'))
+           p = getstarg(player->argp[3], "What value : ", buf);
+           if (!p || !*p)
                return RET_SYN;
            amt = atoi(p);
            if (amt > 100)
index 117e7315537991dbdacab7abfd263ed826e232be..a1d2fb4497e9cbadf844582f9ac9bd94c2f59e2c 100644 (file)
@@ -67,8 +67,8 @@ setsector(void)
        if (!snxtsct(&nstr, player->argp[2]))
            return RET_SYN;
        while (nxtsct(&nstr, &sect) > 0) {
-           if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
-               (*p == '\0'))
+           p = getstarg(player->argp[3], "What value : ", buf);
+           if (!p || !*p)
                return RET_SYN;
            amt = atoi(p);
            current = sect.sct_min;
@@ -88,8 +88,8 @@ setsector(void)
        if (!snxtsct(&nstr, player->argp[2]))
            return RET_SYN;
        while (nxtsct(&nstr, &sect) > 0) {
-           if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
-               (*p == '\0'))
+           p = getstarg(player->argp[3], "What value : ", buf);
+           if (!p || !*p)
                return RET_SYN;
            amt = atoi(p);
            current = sect.sct_gmin;
@@ -111,8 +111,8 @@ setsector(void)
            if (!snxtsct(&nstr, player->argp[2]))
                return RET_SYN;
            while (nxtsct(&nstr, &sect) > 0) {
-               if (!(p = getstarg(player->argp[3], "What value : ", buf))
-                   || (*p == '\0'))
+               p = getstarg(player->argp[3], "What value : ", buf);
+               if (!p || !*p)
                    return RET_SYN;
                amt = atoi(p);
                current = sect.sct_oil;
@@ -132,8 +132,8 @@ setsector(void)
            if (!snxtsct(&nstr, player->argp[2]))
                return RET_SYN;
            while (nxtsct(&nstr, &sect) > 0) {
-               if (!(p = getstarg(player->argp[3], "What value : ", buf))
-                   || (*p == '\0'))
+               p = getstarg(player->argp[3], "What value : ", buf);
+               if (!p || !*p)
                    return RET_SYN;
                amt = atoi(p);
                if ((amt < 0) || (amt > MAXNOC - 1))
@@ -158,8 +158,8 @@ setsector(void)
            if (!snxtsct(&nstr, player->argp[2]))
                return RET_SYN;
            while (nxtsct(&nstr, &sect) > 0) {
-               if (!(p = getstarg(player->argp[3], "What value : ", buf))
-                   || (*p == '\0'))
+               p = getstarg(player->argp[3], "What value : ", buf);
+               if (!p || !*p)
                    return RET_SYN;
                amt = atoi(p);
                if ((amt < 0) || (amt > MAXNOC - 1))
@@ -181,8 +181,8 @@ setsector(void)
        if (!snxtsct(&nstr, player->argp[2]))
            return RET_SYN;
        while (nxtsct(&nstr, &sect) > 0) {
-           if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
-               (*p == '\0'))
+           p = getstarg(player->argp[3], "What value : ", buf);
+           if (!p || !*p)
                return RET_SYN;
            amt = atoi(p);
            current = sect.sct_effic;
@@ -203,8 +203,8 @@ setsector(void)
            if (!snxtsct(&nstr, player->argp[2]))
                return RET_SYN;
            while (nxtsct(&nstr, &sect) > 0) {
-               if (!(p = getstarg(player->argp[3], "What value : ", buf))
-                   || (*p == '\0'))
+               p = getstarg(player->argp[3], "What value : ", buf);
+               if (!p || !*p)
                    return RET_SYN;
                amt = atoi(p);
                current = sect.sct_mines;
@@ -223,8 +223,8 @@ setsector(void)
            if (!snxtsct(&nstr, player->argp[2]))
                return RET_SYN;
            while (nxtsct(&nstr, &sect) > 0) {
-               if (!(p = getstarg(player->argp[3], "What value : ", buf))
-                   || (*p == '\0'))
+               p = getstarg(player->argp[3], "What value : ", buf);
+               if (!p || !*p)
                    return RET_SYN;
                amt = atoi(p);
                current = sect.sct_mobil;
@@ -248,8 +248,8 @@ setsector(void)
        if (!snxtsct(&nstr, player->argp[2]))
            return RET_SYN;
        while (nxtsct(&nstr, &sect) > 0) {
-           if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
-               (*p == '\0'))
+           p = getstarg(player->argp[3], "What value : ", buf);
+           if (!p || !*p)
                return RET_SYN;
            amt = atoi(p);
            current = sect.sct_avail;
@@ -268,8 +268,8 @@ setsector(void)
        if (!snxtsct(&nstr, player->argp[2]))
            return RET_SYN;
        while (nxtsct(&nstr, &sect) > 0) {
-           if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
-               (*p == '\0'))
+           p = getstarg(player->argp[3], "What value : ", buf);
+           if (!p || !*p)
                return RET_SYN;
            amt = atoi(p);
            current = sect.sct_work;
@@ -288,8 +288,8 @@ setsector(void)
        if (!snxtsct(&nstr, player->argp[2]))
            return RET_SYN;
        while (nxtsct(&nstr, &sect) > 0) {
-           if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
-               (*p == '\0'))
+           p = getstarg(player->argp[3], "What value : ", buf);
+           if (!p || !*p)
                return RET_SYN;
            amt = atoi(p);
            current = sect.sct_fertil;
@@ -309,8 +309,8 @@ setsector(void)
        if (!snxtsct(&nstr, player->argp[2]))
            return RET_SYN;
        while (nxtsct(&nstr, &sect) > 0) {
-           if (!(p = getstarg(player->argp[3], "What value : ", buf)) ||
-               (*p == '\0'))
+           p = getstarg(player->argp[3], "What value : ", buf);
+           if (!p || !*p)
                return RET_SYN;
            amt = atoi(p);
            current = sect.sct_uran;
index 131dbe413d81815369571cd7812173acbb120a73..e2e59b04e23733c5b6061f909ef16bc419fd8b72 100644 (file)
@@ -50,10 +50,10 @@ show(void)
     char buf[1024];
     int rlev;
 
-    if (!(p = getstarg(player->argp[1],
-                      "Show what (bridge, item, land, nuke, plane, sect, ship, tower, updates)? ",
-                      buf))
-       || !*p)
+    p = getstarg(player->argp[1],
+                "Show what (bridge, item, land, nuke, plane, sect, ship, tower, updates)? ",
+                buf);
+    if (!p || !*p)
        return RET_SYN;
 
     natp = getnatp(player->cnum);
@@ -124,9 +124,9 @@ show(void)
        return RET_SYN;
     }
 
-    if (!(p = getstarg(player->argp[2],
-                      "Build, stats, or capability data (b,s,c)? ", buf))
-       || !*p)
+    p = getstarg(player->argp[2],
+                "Build, stats, or capability data (b,s,c)? ", buf);
+    if (!p || !*p)
        return RET_SYN;
     pr("Printing for tech level '%d'\n", tlev);
     if (*p == 'B' || *p == 'b')
index 2c7dba377b3e73826da7075be9316c9283728c83..a961fba58205e759b614bcc5bb72368973ba2893 100644 (file)
@@ -67,8 +67,9 @@ tend(void)
     char prompt[512];
     char buf[1024];
 
-    if (!(p = getstarg(player->argp[1],
-                      "Tend what commodity (or 'land')? ", buf)) || !*p)
+    p = getstarg(player->argp[1], "Tend what commodity (or 'land')? ",
+                buf);
+    if (!p || !*p)
        return RET_SYN;
 
     if (!strncmp(p, "land", 4))
index cd7ec22af77ea615d26f34cdef580f73dd69e952..f317359289740bfb0729b44ce7493d49e8aaf6cf 100644 (file)
@@ -114,7 +114,8 @@ trad(void)
        pr("Nothing to buy at the moment...\n");
        return RET_OK;
     }
-    if ((p = getstring("Which lot to buy: ", buf)) == 0 || *p == 0)
+    p = getstring("Which lot to buy: ", buf);
+    if (!p || !*p)
        return RET_OK;
     if (isdigit(*p) == 0)
        return RET_OK;
@@ -239,7 +240,8 @@ trad(void)
        }
     }
 
-    if ((p = getstring("How much do you bid: ", buf)) == 0 || *p == 0)
+    p = getstring("How much do you bid: ", buf);
+    if (!p || !*p)
        return RET_OK;
     if (!trade_check_ok(&trade, &tg))
        return RET_FAIL;
index 1e958a90889e18930775c69d4957e96d0a793989..2abacbdee33d57cd2c086eaddc1ead834e9681d8 100644 (file)
@@ -2450,7 +2450,8 @@ ask_move_in_off(struct combat *off, struct combat *def)
        return;
     sprintf(prompt, "How many mil to move in from %s (%d max)? ",
            xyas(off->x, off->y, player->cnum), mob_support);
-    if (!(p = getstring(prompt, buf)) || !*p || (num_mil = atoi(p)) <= 0)
+    p = getstring(prompt, buf);
+    if (!p || !*p || (num_mil = atoi(p)) <= 0)
        return;
 /* Make sure we don't move in more than we can support mobility-wise */
     if (num_mil > mob_support)