diff --git a/include/econfig-spec.h b/include/econfig-spec.h index c96ccae3..4c5e97a1 100644 --- a/include/econfig-spec.h +++ b/include/econfig-spec.h @@ -52,6 +52,9 @@ #define EMPCF_COMMENT(comment) \ EMPCFONLYC("", emp_config_dummy, unused , NSC_NOTYPE, 0, (comment)) +#define EMPCF_OPT(fvname, vname, descr) \ +EMPCFBOTH((fvname), (vname), int, NSC_INT, KM_OPTION, (descr)) + /* things that can be changed */ EMPCF_COMMENT("\n### Server configuration and information") EMPCFBOTH("data", datadir, char *, NSC_STRING, KM_INTERNAL, @@ -107,10 +110,75 @@ EMPCFBOTH("game_days", game_days, char *, NSC_STRING, 0, EMPCFBOTH("game_hours", game_hours, char *, NSC_STRING, 0, "Hours game is up and running (6:00-18:00)") -EMPCF_COMMENT("\n\n### Options\n") -EMPCFONLYC("option", emp_config_dummy, unused , NSC_NOTYPE, 0, NULL) -EMPCFONLYC("nooption", emp_config_dummy, unused , NSC_NOTYPE, 0, NULL) - +EMPCF_COMMENT("\n\n### Options") +EMPCF_OPT("ALL_BLEED", opt_ALL_BLEED, + "Let tech bleed to everyone, not just allies") +EMPCF_OPT("BIG_CITY", opt_BIG_CITY, + "Allow 10x civs in 'c' sectors") +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("DRNUKE", opt_DRNUKE, + "Require research for nuke building") +EMPCF_OPT("EASY_BRIDGES", opt_EASY_BRIDGES, + "Allow bridge building without bridge heads") +EMPCF_OPT("FALLOUT", opt_FALLOUT, + "Enable secondary effects caused by radiation") +EMPCF_OPT("FUEL", opt_FUEL, + "Make ships use fuel to move") +EMPCF_OPT("GODNEWS", opt_GODNEWS, + "Inform the world when deities give/take away") +EMPCF_OPT("GO_RENEW", opt_GO_RENEW, + "Make gold and oil renewable resources") +EMPCF_OPT("GUINEA_PIGS", opt_GUINEA_PIGS, + "Enable experimental stuff not ready for prime time") +EMPCF_OPT("HIDDEN", opt_HIDDEN, + "Hide information between players") +EMPCF_OPT("INTERDICT_ATT", opt_INTERDICT_ATT, + "Interdict post-attack move in") +EMPCF_OPT("LANDSPIES", opt_LANDSPIES, + "Enable the land unit type spies") +EMPCF_OPT("LOANS", opt_LOANS, + "Allow bailing out of other countries via S&L scandals") +EMPCF_OPT("LOSE_CONTACT", opt_LOSE_CONTACT, + "Let contact be lost after a few updates") +EMPCF_OPT("MARKET", opt_MARKET, + "Enable time-based market and trading") +EMPCF_OPT("MOB_ACCESS", opt_MOB_ACCESS, + "Update mobility in real-time rather than at the update") +EMPCF_OPT("NOFOOD", opt_NOFOOD, + "Disable food consumption") +EMPCF_OPT("NOMOBCOST", opt_NOMOBCOST, + "Don't charge mobility for firing from ships") +EMPCF_OPT("NO_FORT_FIRE", opt_NO_FORT_FIRE, + "Disable fortress fire") +EMPCF_OPT("NO_PLAGUE", opt_NO_PLAGUE, + "Disable plague") +EMPCF_OPT("PINPOINTMISSILE", opt_PINPOINTMISSILE, + "Enable marine missiles") +EMPCF_OPT("RES_POP", opt_RES_POP, + "Population is limited by research") +EMPCF_OPT("SAIL", opt_SAIL, + "Enable sail command") +EMPCF_OPT("SHOWPLANE", opt_SHOWPLANE, + "Show planes and land units embarked on ships or land units up for trade") +EMPCF_OPT("SLOW_WAR", opt_SLOW_WAR, + "Declaring war takes time") +EMPCF_OPT("SUPER_BARS", opt_SUPER_BARS, + "Make bars immune to damage") +EMPCF_OPT("TECH_POP", opt_TECH_POP, + "Technology costs more as population rises") +EMPCF_OPT("TRADESHIPS", opt_TRADESHIPS, + "Enable Tradeships") +EMPCF_OPT("TREATIES", opt_TREATIES, + "Allow treaties") +EMPCF_OPT("UPDATESCHED", opt_UPDATESCHED, + "Used to control update times and should always be used") EMPCF_COMMENT("\n\n### Countries") EMPCFBOTH("btu_build_rate", btu_build_rate, float, NSC_FLOAT, 0, diff --git a/include/optlist.h b/include/optlist.h index 3b917f7d..af3983b5 100644 --- a/include/optlist.h +++ b/include/optlist.h @@ -40,49 +40,6 @@ /* Default econfig file */ extern char dflt_econfig[]; -struct option_list { - char *opt_key; - int *opt_valuep; -}; - -extern struct option_list Options[]; - -/* Options, can be switched in econfig */ -extern int opt_ALL_BLEED; -extern int opt_BIG_CITY; -extern int opt_BLITZ; -extern int opt_BRIDGETOWERS; -extern int opt_DEFENSE_INFRA; -extern int opt_DEMANDUPDATE; -extern int opt_DRNUKE; -extern int opt_EASY_BRIDGES; -extern int opt_FALLOUT; -extern int opt_FUEL; -extern int opt_GODNEWS; -extern int opt_GO_RENEW; -extern int opt_GUINEA_PIGS; -extern int opt_HIDDEN; -extern int opt_INTERDICT_ATT; -extern int opt_LANDSPIES; -extern int opt_LOANS; -extern int opt_LOSE_CONTACT; -extern int opt_MARKET; -extern int opt_MOB_ACCESS; -extern int opt_NOFOOD; -extern int opt_NOMOBCOST; -extern int opt_NO_FORT_FIRE; -extern int opt_NO_PLAGUE; -extern int opt_PINPOINTMISSILE; -extern int opt_RES_POP; -extern int opt_SAIL; -extern int opt_SHOWPLANE; -extern int opt_SLOW_WAR; -extern int opt_SUPER_BARS; -extern int opt_TECH_POP; -extern int opt_TRADESHIPS; -extern int opt_TREATIES; -extern int opt_UPDATESCHED; - /* Game parameters, can be set in econfig */ #define EMP_CONFIG_H_OUTPUT #include "econfig-spec.h" @@ -100,8 +57,9 @@ extern char *teldir; extern char *telfil; enum { - KM_ALLOC = 0x01, /* memory allocated */ - KM_INTERNAL = 0x02 /* not to be disclosed to players */ + KM_ALLOC = 1, /* memory allocated */ + KM_INTERNAL = 2, /* not to be disclosed to players */ + KM_OPTION = 4 /* historically an option */ }; struct keymatch { diff --git a/info/xdump.t b/info/xdump.t index b2c002cf..04f4bc0f 100644 --- a/info/xdump.t +++ b/info/xdump.t @@ -3,7 +3,6 @@ .LV Expert .SY "xdump " .SY "xdump chr " -.SY "xdump opt" .SY "xdump ver" The xdump command displays information on game configuration and state in machine readable tables. It is intended for use by clients and @@ -62,15 +61,13 @@ abbreviations of table names are recognized. We plan to extend the syntax to select rows and columns to be shown. .s1 Finally, -.SY "xdump opt" -displays game options, and .SY "xdump ver" displays configuration parameters. .s1 The output of \*Qxdump\*U is a table, which consists of two header lines, the table body and a footer line. .s1 -The first header line is of the form \Q*XDUMP +The first header line is of the form \*QXDUMP \*U. It identifies the dump. .s1 The second header line lists column names. The name of a column is diff --git a/src/lib/commands/vers.c b/src/lib/commands/vers.c index 194cf916..cf5b188d 100644 --- a/src/lib/commands/vers.c +++ b/src/lib/commands/vers.c @@ -177,21 +177,24 @@ show_opts(int val) { int col; char *sep; - struct option_list *op; + struct keymatch *kp; sep = ""; col = 0; - for (op = Options; op->opt_key; op++) { - if (!*op->opt_valuep != !val) + for (kp = configkeys; kp->km_key; kp++) { + if (!(kp->km_flags & KM_OPTION)) continue; - - col += strlen(sep) + strlen(op->opt_key); + if (CANT_HAPPEN(kp->km_type != NSC_INT)) + continue; + if (!*(int *)kp->km_data != !val) + continue; + col += strlen(sep) + strlen(kp->km_key); if (col > 70) { pr(",\n "); sep = ""; - col = strlen(op->opt_key); + col = strlen(kp->km_key); } - pr("%s%s", sep, op->opt_key); + pr("%s%s", sep, kp->km_key); sep = ", "; } diff --git a/src/lib/commands/xdump.c b/src/lib/commands/xdump.c index ca61ed40..219e7389 100644 --- a/src/lib/commands/xdump.c +++ b/src/lib/commands/xdump.c @@ -56,7 +56,6 @@ * - News item characteristics: rpt[] * - News page headings: page_headings[] (TODO) * - Commands: player_coms[] (TODO) - * - Options: Options[] * - Configuration: configkeys[] * * Dynamic game data: @@ -247,46 +246,6 @@ xdmeta(int type) return RET_OK; } -/* - * Dump Options[], return RET_OK. - * If META, dump meta-data rather than data. - */ -static int -xdopt(int meta) -{ - int i; - char *sep; - struct castr ca; - - xdhdr("options", meta); - - if (meta) { - for (i = 0; Options[i].opt_key; ++i) { - ca.ca_type = NSC_INT; - ca.ca_flags = 0; - ca.ca_len = 0; - ca.ca_off = 0; - ca.ca_name = Options[i].opt_key; - ca.ca_table = EF_BAD; - xdflds(mdchr_ca, &ca); - pr("\n"); - } - xdftr(i); - return RET_OK; - } - - sep = ""; - for (i = 0; Options[i].opt_key; ++i) { - pr("%s%d", sep, *Options[i].opt_valuep); - sep = " "; - } - pr("\n"); - - xdftr(1); - - return RET_OK; -} - /* * Dump configkeys[], return RET_OK. * If META, dump meta-data rather than data. @@ -363,8 +322,6 @@ xdump(void) return xdmeta(type); else return xditem(type, player->argp[2]); - } else if (!strncmp(p, "opt", strlen(p))) { - return xdopt(meta); } else if (!strncmp(p, "ver", strlen(p))) { return xdver(meta); } diff --git a/src/lib/gen/emp_config.c b/src/lib/gen/emp_config.c index 1189fa2f..398322cf 100644 --- a/src/lib/gen/emp_config.c +++ b/src/lib/gen/emp_config.c @@ -65,7 +65,6 @@ struct keymatch configkeys[] = { }; static struct keymatch *keylookup(s_char *key, struct keymatch tbl[]); -static int set_option(const char *, int); /* * read in empire configuration @@ -135,15 +134,6 @@ emp_config(char *file) *(char **)kp->km_data = strdup(av[1]); kp->km_flags |= KM_ALLOC; break; - case NSC_NOTYPE: - for (i = 1; av[i]; ++i) { - if (set_option(av[i], kp->km_key[0] != 'n') < 0) { - fprintf(stderr, "%s:%d: Unknown option %s\n", - file, lno, av[i]); - errors = 1; - } - } - break; default: assert(0); } @@ -177,7 +167,6 @@ keylookup(register s_char *command, struct keymatch *tbl) void print_config(FILE *fp) { - struct option_list *op; struct keymatch *kp; fprintf(fp, "# Empire Configuration File:\n"); @@ -205,11 +194,6 @@ print_config(FILE *fp) case NSC_LONG: fprintf(fp, "%s %ld\n", kp->km_key, *(long *)kp->km_data); break; - case NSC_NOTYPE: - for (op = Options; op->opt_key; op++) - if (*op->opt_valuep != (kp->km_key[0] == 'n')) - fprintf(fp, "%s %s\n", kp->km_key, op->opt_key); - break; default: assert(0); } @@ -217,19 +201,3 @@ print_config(FILE *fp) fprintf(fp, "\n"); } - - -/* Set option S to value VAL; return 0 on success, -1 on failure. */ -static int -set_option(const char *s, int val) -{ - struct option_list *op; - - for (op = Options; op->opt_key; op++) { - if (strcmp(op->opt_key, s) == 0) { - *op->opt_valuep = val; - return 0; - } - } - return -1; -} diff --git a/src/lib/global/options.c b/src/lib/global/options.c index 4cf2939d..6e022086 100644 --- a/src/lib/global/options.c +++ b/src/lib/global/options.c @@ -242,41 +242,3 @@ int opt_TECH_POP = 1; #else int opt_TECH_POP = 0; #endif - -struct option_list Options[] = { - {"ALL_BLEED", &opt_ALL_BLEED}, - {"BIG_CITY", &opt_BIG_CITY}, - {"BLITZ", &opt_BLITZ}, - {"BRIDGETOWERS", &opt_BRIDGETOWERS}, - {"DEFENSE_INFRA", &opt_DEFENSE_INFRA}, - {"DEMANDUPDATE", &opt_DEMANDUPDATE}, - {"DRNUKE", &opt_DRNUKE}, - {"EASY_BRIDGES", &opt_EASY_BRIDGES}, - {"FALLOUT", &opt_FALLOUT}, - {"FUEL", &opt_FUEL}, - {"GODNEWS", &opt_GODNEWS}, - {"GO_RENEW", &opt_GO_RENEW}, - {"GUINEA_PIGS", &opt_GUINEA_PIGS}, - {"HIDDEN", &opt_HIDDEN}, - {"INTERDICT_ATT", &opt_INTERDICT_ATT}, - {"LANDSPIES", &opt_LANDSPIES}, - {"LOANS", &opt_LOANS}, - {"LOSE_CONTACT", &opt_LOSE_CONTACT}, - {"MARKET", &opt_MARKET}, - {"MOB_ACCESS", &opt_MOB_ACCESS}, - {"NO_FORT_FIRE", &opt_NO_FORT_FIRE}, - {"NO_PLAGUE", &opt_NO_PLAGUE}, - {"NOFOOD", &opt_NOFOOD}, - {"NOMOBCOST", &opt_NOMOBCOST}, - {"PINPOINTMISSILE", &opt_PINPOINTMISSILE}, - {"RES_POP", &opt_RES_POP}, - {"SAIL", &opt_SAIL}, - {"SHOWPLANE", &opt_SHOWPLANE}, - {"SLOW_WAR", &opt_SLOW_WAR}, - {"SUPER_BARS", &opt_SUPER_BARS}, - {"TECH_POP", &opt_TECH_POP}, - {"TRADESHIPS", &opt_TRADESHIPS}, - {"TREATIES", &opt_TREATIES}, - {"UPDATESCHED", &opt_UPDATESCHED}, - {NULL, NULL}, -};