Turn options into ordinary econfig keys:
(configkeys): Add options. (KM_OPTION): New. (vers): Find options in configkeys[] instead of Options[]. (xdump): Remove xdump opt syntax. (xdopt): Remove. (emp_config, print_config): Remove option special case. (option_list, Options, setoption): Remove.
This commit is contained in:
parent
373a08a0e0
commit
ade510f787
7 changed files with 86 additions and 173 deletions
|
@ -52,6 +52,9 @@
|
||||||
#define EMPCF_COMMENT(comment) \
|
#define EMPCF_COMMENT(comment) \
|
||||||
EMPCFONLYC("", emp_config_dummy, unused , NSC_NOTYPE, 0, (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 */
|
/* things that can be changed */
|
||||||
EMPCF_COMMENT("\n### Server configuration and information")
|
EMPCF_COMMENT("\n### Server configuration and information")
|
||||||
EMPCFBOTH("data", datadir, char *, NSC_STRING, KM_INTERNAL,
|
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,
|
EMPCFBOTH("game_hours", game_hours, char *, NSC_STRING, 0,
|
||||||
"Hours game is up and running (6:00-18:00)")
|
"Hours game is up and running (6:00-18:00)")
|
||||||
|
|
||||||
EMPCF_COMMENT("\n\n### Options\n")
|
EMPCF_COMMENT("\n\n### Options")
|
||||||
EMPCFONLYC("option", emp_config_dummy, unused , NSC_NOTYPE, 0, NULL)
|
EMPCF_OPT("ALL_BLEED", opt_ALL_BLEED,
|
||||||
EMPCFONLYC("nooption", emp_config_dummy, unused , NSC_NOTYPE, 0, NULL)
|
"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")
|
EMPCF_COMMENT("\n\n### Countries")
|
||||||
EMPCFBOTH("btu_build_rate", btu_build_rate, float, NSC_FLOAT, 0,
|
EMPCFBOTH("btu_build_rate", btu_build_rate, float, NSC_FLOAT, 0,
|
||||||
|
|
|
@ -40,49 +40,6 @@
|
||||||
/* Default econfig file */
|
/* Default econfig file */
|
||||||
extern char dflt_econfig[];
|
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 */
|
/* Game parameters, can be set in econfig */
|
||||||
#define EMP_CONFIG_H_OUTPUT
|
#define EMP_CONFIG_H_OUTPUT
|
||||||
#include "econfig-spec.h"
|
#include "econfig-spec.h"
|
||||||
|
@ -100,8 +57,9 @@ extern char *teldir;
|
||||||
extern char *telfil;
|
extern char *telfil;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
KM_ALLOC = 0x01, /* memory allocated */
|
KM_ALLOC = 1, /* memory allocated */
|
||||||
KM_INTERNAL = 0x02 /* not to be disclosed to players */
|
KM_INTERNAL = 2, /* not to be disclosed to players */
|
||||||
|
KM_OPTION = 4 /* historically an option */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct keymatch {
|
struct keymatch {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
.LV Expert
|
.LV Expert
|
||||||
.SY "xdump <STATE-TABLE> <ENTRIES>"
|
.SY "xdump <STATE-TABLE> <ENTRIES>"
|
||||||
.SY "xdump chr <CONFIG-TABLE>"
|
.SY "xdump chr <CONFIG-TABLE>"
|
||||||
.SY "xdump opt"
|
|
||||||
.SY "xdump ver"
|
.SY "xdump ver"
|
||||||
The xdump command displays information on game configuration and state
|
The xdump command displays information on game configuration and state
|
||||||
in machine readable tables. It is intended for use by clients and
|
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.
|
We plan to extend the syntax to select rows and columns to be shown.
|
||||||
.s1
|
.s1
|
||||||
Finally,
|
Finally,
|
||||||
.SY "xdump opt"
|
|
||||||
displays game options, and
|
|
||||||
.SY "xdump ver"
|
.SY "xdump ver"
|
||||||
displays configuration parameters.
|
displays configuration parameters.
|
||||||
.s1
|
.s1
|
||||||
The output of \*Qxdump\*U is a table, which consists of two header
|
The output of \*Qxdump\*U is a table, which consists of two header
|
||||||
lines, the table body and a footer line.
|
lines, the table body and a footer line.
|
||||||
.s1
|
.s1
|
||||||
The first header line is of the form \Q*XDUMP <TABLE-NAME>
|
The first header line is of the form \*QXDUMP <TABLE-NAME>
|
||||||
<TIMESTAMP>\*U. It identifies the dump.
|
<TIMESTAMP>\*U. It identifies the dump.
|
||||||
.s1
|
.s1
|
||||||
The second header line lists column names. The name of a column is
|
The second header line lists column names. The name of a column is
|
||||||
|
|
|
@ -177,21 +177,24 @@ show_opts(int val)
|
||||||
{
|
{
|
||||||
int col;
|
int col;
|
||||||
char *sep;
|
char *sep;
|
||||||
struct option_list *op;
|
struct keymatch *kp;
|
||||||
|
|
||||||
sep = "";
|
sep = "";
|
||||||
col = 0;
|
col = 0;
|
||||||
for (op = Options; op->opt_key; op++) {
|
for (kp = configkeys; kp->km_key; kp++) {
|
||||||
if (!*op->opt_valuep != !val)
|
if (!(kp->km_flags & KM_OPTION))
|
||||||
continue;
|
continue;
|
||||||
|
if (CANT_HAPPEN(kp->km_type != NSC_INT))
|
||||||
col += strlen(sep) + strlen(op->opt_key);
|
continue;
|
||||||
|
if (!*(int *)kp->km_data != !val)
|
||||||
|
continue;
|
||||||
|
col += strlen(sep) + strlen(kp->km_key);
|
||||||
if (col > 70) {
|
if (col > 70) {
|
||||||
pr(",\n ");
|
pr(",\n ");
|
||||||
sep = "";
|
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 = ", ";
|
sep = ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,6 @@
|
||||||
* - News item characteristics: rpt[]
|
* - News item characteristics: rpt[]
|
||||||
* - News page headings: page_headings[] (TODO)
|
* - News page headings: page_headings[] (TODO)
|
||||||
* - Commands: player_coms[] (TODO)
|
* - Commands: player_coms[] (TODO)
|
||||||
* - Options: Options[]
|
|
||||||
* - Configuration: configkeys[]
|
* - Configuration: configkeys[]
|
||||||
*
|
*
|
||||||
* Dynamic game data:
|
* Dynamic game data:
|
||||||
|
@ -247,46 +246,6 @@ xdmeta(int type)
|
||||||
return RET_OK;
|
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.
|
* Dump configkeys[], return RET_OK.
|
||||||
* If META, dump meta-data rather than data.
|
* If META, dump meta-data rather than data.
|
||||||
|
@ -363,8 +322,6 @@ xdump(void)
|
||||||
return xdmeta(type);
|
return xdmeta(type);
|
||||||
else
|
else
|
||||||
return xditem(type, player->argp[2]);
|
return xditem(type, player->argp[2]);
|
||||||
} else if (!strncmp(p, "opt", strlen(p))) {
|
|
||||||
return xdopt(meta);
|
|
||||||
} else if (!strncmp(p, "ver", strlen(p))) {
|
} else if (!strncmp(p, "ver", strlen(p))) {
|
||||||
return xdver(meta);
|
return xdver(meta);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,6 @@ struct keymatch configkeys[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct keymatch *keylookup(s_char *key, struct keymatch tbl[]);
|
static struct keymatch *keylookup(s_char *key, struct keymatch tbl[]);
|
||||||
static int set_option(const char *, int);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* read in empire configuration
|
* read in empire configuration
|
||||||
|
@ -135,15 +134,6 @@ emp_config(char *file)
|
||||||
*(char **)kp->km_data = strdup(av[1]);
|
*(char **)kp->km_data = strdup(av[1]);
|
||||||
kp->km_flags |= KM_ALLOC;
|
kp->km_flags |= KM_ALLOC;
|
||||||
break;
|
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:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
@ -177,7 +167,6 @@ keylookup(register s_char *command, struct keymatch *tbl)
|
||||||
void
|
void
|
||||||
print_config(FILE *fp)
|
print_config(FILE *fp)
|
||||||
{
|
{
|
||||||
struct option_list *op;
|
|
||||||
struct keymatch *kp;
|
struct keymatch *kp;
|
||||||
|
|
||||||
fprintf(fp, "# Empire Configuration File:\n");
|
fprintf(fp, "# Empire Configuration File:\n");
|
||||||
|
@ -205,11 +194,6 @@ print_config(FILE *fp)
|
||||||
case NSC_LONG:
|
case NSC_LONG:
|
||||||
fprintf(fp, "%s %ld\n", kp->km_key, *(long *)kp->km_data);
|
fprintf(fp, "%s %ld\n", kp->km_key, *(long *)kp->km_data);
|
||||||
break;
|
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:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
@ -217,19 +201,3 @@ print_config(FILE *fp)
|
||||||
|
|
||||||
fprintf(fp, "\n");
|
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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -242,41 +242,3 @@ int opt_TECH_POP = 1;
|
||||||
#else
|
#else
|
||||||
int opt_TECH_POP = 0;
|
int opt_TECH_POP = 0;
|
||||||
#endif
|
#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},
|
|
||||||
};
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue