From 4d1dd6fa6ae0e418063ac29791730c238aa293ed Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 16 Jun 2006 18:39:35 +0000 Subject: [PATCH] (sctintrins): New member in_enable. Update infra.config. Use it 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 | 2 -- include/sect.h | 10 ++++--- src/lib/commands/improve.c | 27 ++++++++++--------- src/lib/global/infra.config | 52 ++++++++++++++++++++++++++++++++++--- src/lib/global/nsc.c | 2 ++ src/lib/global/options.c | 1 - src/lib/subs/show.c | 14 +++++++--- 7 files changed, 79 insertions(+), 29 deletions(-) diff --git a/include/econfig-spec.h b/include/econfig-spec.h index 3983ad31d..f15f61a85 100644 --- a/include/econfig-spec.h +++ b/include/econfig-spec.h @@ -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, diff --git a/include/sect.h b/include/sect.h index c8031e172..7ace7da75 100644 --- a/include/sect.h +++ b/include/sect.h @@ -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]; diff --git a/src/lib/commands/improve.c b/src/lib/commands/improve.c index e20e3a436..1cb24bd47 100644 --- a/src/lib/commands/improve.c +++ b/src/lib/commands/improve.c @@ -45,11 +45,6 @@ #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(§)) continue; diff --git a/src/lib/global/infra.config b/src/lib/global/infra.config index e062e96ab..4835f4efd 100644 --- a/src/lib/global/infra.config +++ b/src/lib/global/infra.config @@ -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 diff --git a/src/lib/global/nsc.c b/src/lib/global/nsc.c index 3db54e286..44e4dd45a 100644 --- a/src/lib/global/nsc.c +++ b/src/lib/global/nsc.c @@ -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} }; diff --git a/src/lib/global/options.c b/src/lib/global/options.c index dab757518..ead334947 100644 --- a/src/lib/global/options.c +++ b/src/lib/global/options.c @@ -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; diff --git a/src/lib/subs/show.c b/src/lib/subs/show.c index 1a66d7452..aeaac665f 100644 --- a/src/lib/subs/show.c +++ b/src/lib/subs/show.c @@ -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; } } -- 2.43.0