]> git.pond.sub.org Git - empserver/commitdiff
(improve): Fix confusing diagnostics when refusing to improve defense
authorMarkus Armbruster <armbru@pond.sub.org>
Tue, 24 Aug 2004 08:23:09 +0000 (08:23 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Tue, 24 Aug 2004 08:23:09 +0000 (08:23 +0000)
because option DEFENSE_INFRA is off.

(improve): Simplify use of `value' to avoid compiler warning.

src/lib/commands/improve.c

index 25f69653067bb8c337baa9a9eb6293590c7ff548..c8fb3a0842fd18480f60fa3b4da10108f24a608e 100644 (file)
@@ -76,9 +76,13 @@ improve(void)
        type = INT_ROAD;
     else if (!strncmp(p, "ra", 2))
        type = INT_RAIL;
-    else if (!strncmp(p, "de", 2) && opt_DEFENSE_INFRA)
+    else if (!strncmp(p, "de", 2)) {
+       if (!opt_DEFENSE_INFRA) {
+           pr("Defense infrastructure is disabled.\n");
+           return RET_FAIL;
+       }
        type = INT_DEF;
-    else
+    else
        return RET_SYN;
     if (!snxtsct(&nstr, player->argp[2]))
        return RET_SYN;
@@ -91,7 +95,7 @@ improve(void)
            value = sect.sct_road;
        else if (type == INT_RAIL)
            value = sect.sct_rail;
-       else if (type == INT_DEF)
+       else /* type == INT_DEF */
            value = sect.sct_defense;
        sprintf(inbuf, "Sector %s has a %s of %d%%.  Improve how much? ",
                xyas(sect.sct_x, sect.sct_y, player->cnum),
@@ -172,7 +176,7 @@ improve(void)
        sect.sct_mobil -= mneeded;
        ovalue = value;
        value += maxup;
-       if (value > 100)
+       if (CANT_HAPPEN(value > 100))
            value = 100;
        pr("Sector %s %s increased from %d%% to %d%%\n",
           xyas(sect.sct_x, sect.sct_y, player->cnum),