]> git.pond.sub.org Git - empserver/commitdiff
(sctintrins): New member in_enable. Update infra.config. Use it
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 16 Jun 2006 18:39:35 +0000 (18:39 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 16 Jun 2006 18:39:35 +0000 (18:39 +0000)
instead of opt_DEFENSE_INFRA.
(improve): Test for it.
(show_sect_build): Show only enabled infrastructure.
(opt_DEFENSE_INFRA): Remove.  Deities can edit infra.config instead.

(improve): Dumb down prompt.

include/econfig-spec.h
include/sect.h
src/lib/commands/improve.c
src/lib/global/infra.config
src/lib/global/nsc.c
src/lib/global/options.c
src/lib/subs/show.c

index 3983ad31df0d5d5b0d90e50a5492abbe75a248f9..f15f61a856d3670a1b13c7f990c7b0d955968ddb 100644 (file)
@@ -155,8 +155,6 @@ EMPCF_OPT("BLITZ", opt_BLITZ,
     "Enable blitz mode")
 EMPCF_OPT("BRIDGETOWERS", opt_BRIDGETOWERS,
     "Allow bridge towers")
-EMPCF_OPT("DEFENSE_INFRA", opt_DEFENSE_INFRA,
-    "Allow the improvement of defensive infrastructure")
 EMPCF_OPT("DEMANDUPDATE", opt_DEMANDUPDATE,
     "Allow demand updates")
 EMPCF_OPT("EASY_BRIDGES", opt_EASY_BRIDGES,
index c8031e1725bf5c9dc08365188c7ca4f2f5da4a3c..7ace7da75aca8866cf4b1dd85e0ac6f72ba84ce6 100644 (file)
@@ -172,8 +172,9 @@ extern struct dchrstr bigcity_dchr;
 /* Work required for building */
 #define SCT_BLD_WORK(lcm, hcm) ((lcm) + 2 * (hcm))
 
+/* Return SP's defense efficiency */
 #define SCT_DEFENSE(sp) \
-    (opt_DEFENSE_INFRA ? (sp)->sct_defense : (sp)->sct_effic)
+    (intrchr[INT_DEF].in_enable ? (sp)->sct_defense : (sp)->sct_effic)
 
 #define FORTEFF 5              /* forts must be 5% efficient to fire. */
 
@@ -202,10 +203,11 @@ extern struct dchrstr bigcity_dchr;
 /* Each cost is per point of efficency */
 struct sctintrins {
     char *in_name;
-    unsigned char in_lcms;
+    unsigned char in_lcms;     /* construction materials */
     unsigned char in_hcms;
-    unsigned char in_dcost;
-    unsigned char in_mcost;
+    unsigned char in_dcost;    /* dollars */
+    unsigned char in_mcost;    /* mobility */
+    unsigned char in_enable;   /* enabled iff non-zero */
 };
 
 extern struct sctintrins intrchr[INT_DEF + 2];
index e20e3a4367aa71d8226762671b1b04b1d6bd04b0..1cb24bd471601aeb1e08b7494643b850a8d36443 100644 (file)
 #include "optlist.h"
 #include "commands.h"
 
-static char *prompt[] = {
-    "Improve what ('road' or 'rail')? ",
-    "Improve what ('road', 'rail' or 'defense')? "
-};
-
 int
 improve(void)
 {
@@ -58,7 +53,7 @@ improve(void)
     struct nstr_sect nstr;
     char *p;
     char buf[1024];
-    char inbuf[128];
+    char prompt[128];
     int type;
     int value;
     int ovalue;
@@ -70,21 +65,25 @@ improve(void)
     int dneeded;
     int wanted;
 
-    if (!(p = getstarg(player->argp[1],
-                      prompt[!!opt_DEFENSE_INFRA], buf)) || !*p)
+    p = getstarg(player->argp[1],
+                "Improve what ('road', 'rail' or 'defense')? ",
+                buf);
+    if (!p || !*p)
        return RET_SYN;
     if (!strncmp(p, "ro", 2))
        type = INT_ROAD;
     else if (!strncmp(p, "ra", 2))
        type = INT_RAIL;
     else if (!strncmp(p, "de", 2)) {
-       if (!opt_DEFENSE_INFRA) {
-           pr("Defense infrastructure is disabled.\n");
-           return RET_FAIL;
-       }
        type = INT_DEF;
     } else
        return RET_SYN;
+
+    if (!intrchr[type].in_enable) {
+       pr("%s improvement is disabled.\n", intrchr[type].in_name);
+       return RET_FAIL;
+    }
+
     if (!snxtsct(&nstr, player->argp[2]))
        return RET_SYN;
     prdate();
@@ -98,10 +97,10 @@ improve(void)
            value = sect.sct_rail;
        else /* type == INT_DEF */
            value = sect.sct_defense;
-       sprintf(inbuf, "Sector %s has a %s of %d%%.  Improve how much? ",
+       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], inbuf, buf)) || !*p)
+       if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
            continue;
        if (!check_sect_ok(&sect))
            continue;
index e062e96ab3248e72cbb498b954f0b0c132028927..4835f4efd7e13766d2b08d494e09ea2965146b7f 100644 (file)
@@ -1,6 +1,50 @@
+#
+#   Empire - A multi-player, client/server Internet based war game.
+#   Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+#                            Ken Stevens, Steve McClure
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, write to the Free Software
+#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#   ---
+#
+#   See files README, COPYING and CREDITS in the root of the source
+#   tree for related information and legal notices.  It is expected
+#   that future projects/authors will amend these files as needed.
+#
+#   ---
+#
+#   infra.config: Infrastructure characteristics
+#
+#   Known contributors to this file:
+#      Markus Armbruster, 2006
+#
+#   Derived from sect.c; known contributors:
+#      Dave Pare, 1986
+#      Jeff Bailey
+#      Thomas Ruschak, 1992
+#      Ken Stevens, 1995
+#      Steve McClure, 1998
+#
+
+# Do not edit this file to customize a game!  Create your own custom
+# configuration file(s), best next to your econfig, and name them in
+# econfig key custom_tables.
+
 config infrastructure
-name             lcm hcm dcost mcost
-"road network"     2   2     2     1
-"rail network"     1   1     1     1
-"defense factor"   1   1     1     1
+name             lcm hcm dcost mcost enab
+"road network"     2   2     2     1   1
+"rail network"     1   1     1     1   1
+"defense factor"   1   1     1     1   0
 /config
index 3db54e286b51c6523f4462687e66521922938672..44e4dd45aeae9b8d8ae09c42a7ef330d998a8944 100644 (file)
@@ -567,6 +567,8 @@ struct castr intrchr_ca[] = {
     {NSC_UCHAR, 0, 0, offsetof(struct sctintrins, in_hcms), "hcms", EF_BAD},
     {NSC_UCHAR, 0, 0, offsetof(struct sctintrins, in_dcost), "dcost", EF_BAD},
     {NSC_UCHAR, 0, 0, offsetof(struct sctintrins, in_mcost), "mcost", EF_BAD},
+    {NSC_UCHAR, 0, 0, offsetof(struct sctintrins, in_enable), "enable",
+     EF_BAD},
     {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
 };
 
index dab7575186480893e70e142a1ef13534d91826b9..ead3349476b21b8043b2dd2decd2006c62dcf274 100644 (file)
@@ -39,7 +39,6 @@
 int opt_ALL_BLEED = 1;
 int opt_BLITZ = 1;
 int opt_BRIDGETOWERS = 1;
-int opt_DEFENSE_INFRA = 0;
 int opt_DEMANDUPDATE = 1;
 int opt_EASY_BRIDGES = 1;
 int opt_FALLOUT = 1;
index 1a66d745255569e2413a07fd25441da7f5a58f55..aeaac665f59b0a44d7d792f0e954dce56c60da41 100644 (file)
@@ -496,8 +496,9 @@ show_land_stats(int tlev)
 void
 show_sect_build(int foo)
 {
-    int x, first = 1;
+    int x, first;
 
+    first = 1;
     for (x = 0; x <= SCT_MAXDEF; x++) {
        if (dchr[x].d_mnem == 0)
            continue;
@@ -514,13 +515,18 @@ show_sect_build(int foo)
               dchr[x].d_lcms, dchr[x].d_hcms);
        }
     }
-    pr("\n");
-    pr("Infrastructure building - adding 1 point of efficiency costs:\n");
-    pr("       type          lcms    hcms    mobility    $$$$\n");
+
+    first = 1;
     for (x = 0; intrchr[x].in_name; x++) {
+       if (!intrchr[x].in_enable)
+           continue;
+       if (first)
+           pr("\nInfrastructure building - adding 1 point of efficiency costs:\n"
+              "       type          lcms    hcms    mobility    $$$$\n");
        pr("%-20s %4d    %4d    %8d    %4d\n",
           intrchr[x].in_name, intrchr[x].in_lcms, intrchr[x].in_hcms,
           intrchr[x].in_mcost, intrchr[x].in_dcost);
+       first = 0;
     }
 }