do not read gamename from XML, read it from JSON only (two mechanisms for the same feature are too many)

This commit is contained in:
Enno Rehling 2015-09-12 16:49:18 +02:00
parent d65e9aaf94
commit 7906cdbcb6
6 changed files with 10 additions and 16 deletions

View File

@ -53,7 +53,7 @@
<xi:include href="config://default/names-ghouls.xml"/> <xi:include href="config://default/names-ghouls.xml"/>
<xi:include href="config://default/names-dragons.xml"/> <xi:include href="config://default/names-dragons.xml"/>
<game name="Eressea"> <game>
<!-- Game specific settings --> <!-- Game specific settings -->
<order name="pay" disable="yes"/> <order name="pay" disable="yes"/>

View File

@ -42,7 +42,7 @@
<xi:include href="config://default/names-ghouls.xml"/> <xi:include href="config://default/names-ghouls.xml"/>
<xi:include href="config://default/names-dragons.xml"/> <xi:include href="config://default/names-dragons.xml"/>
<game name="E3"> <game>
<!-- Game specific settings --> <!-- Game specific settings -->
<order name="besiege" disable="yes"/> <order name="besiege" disable="yes"/>
<order name="steal" disable="yes"/> <order name="steal" disable="yes"/>

View File

@ -42,7 +42,7 @@
<xi:include href="config://default/names-ghouls.xml"/> <xi:include href="config://default/names-ghouls.xml"/>
<xi:include href="config://default/names-dragons.xml"/> <xi:include href="config://default/names-dragons.xml"/>
<game name="Deveron"> <game>
<order name="besiege" disable="yes"/> <order name="besiege" disable="yes"/>
<order name="steal" disable="yes"/> <order name="steal" disable="yes"/>
<order name="buy" disable="yes"/> <order name="buy" disable="yes"/>

View File

@ -261,8 +261,6 @@ extern "C" {
unsigned int data_turn; unsigned int data_turn;
struct param *parameters; struct param *parameters;
void *vm_state; void *vm_state;
double producexpchance;
int cookie;
int data_version; /* TODO: eliminate in favor of gamedata.version */ int data_version; /* TODO: eliminate in favor of gamedata.version */
struct _dictionary_ *inifile; struct _dictionary_ *inifile;
@ -271,6 +269,10 @@ extern "C" {
const struct race * rc, int in_turn); const struct race * rc, int in_turn);
int(*maintenance) (const struct unit * u); int(*maintenance) (const struct unit * u);
} functions; } functions;
/* the following are some cached values, because get_param can be slow.
* you should almost never need to touch them */
int cookie;
double producexpchance_;
} settings; } settings;
typedef struct helpmode { typedef struct helpmode {

View File

@ -1937,10 +1937,10 @@ bool unit_can_study(const unit *u) {
static double produceexp_chance(void) { static double produceexp_chance(void) {
static int update = 0; static int update = 0;
if (update != global.cookie) { if (update != global.cookie) {
global.producexpchance = get_param_flt(global.parameters, "study.from_use", 1.0 / 3); global.producexpchance_ = get_param_flt(global.parameters, "study.from_use", 1.0 / 3);
update = global.cookie; update = global.cookie;
} }
return global.producexpchance; return global.producexpchance_;
} }
void produceexp_ex(struct unit *u, skill_t sk, int n, bool (*learn)(unit *, skill_t, double)) void produceexp_ex(struct unit *u, skill_t sk, int n, bool (*learn)(unit *, skill_t, double))

View File

@ -2060,16 +2060,9 @@ static int parse_main(xmlDocPtr doc)
xmlNodeSetPtr nodes = result->nodesetval; xmlNodeSetPtr nodes = result->nodesetval;
int i; int i;
xmlChar *propValue;
if (nodes->nodeNr > 0) { if (nodes->nodeNr > 0) {
xmlNodePtr node = nodes->nodeTab[0]; xmlNodePtr node = nodes->nodeTab[0];
propValue = xmlGetProp(node, BAD_CAST "name");
if (propValue != NULL) {
global.gamename = _strdup((const char *)propValue);
xmlFree(propValue);
}
xmlXPathFreeObject(result); xmlXPathFreeObject(result);
xpath->node = node; xpath->node = node;
@ -2079,9 +2072,8 @@ static int parse_main(xmlDocPtr doc)
for (i = 0; i != nodes->nodeNr; ++i) { for (i = 0; i != nodes->nodeNr; ++i) {
xmlNodePtr node = nodes->nodeTab[i]; xmlNodePtr node = nodes->nodeTab[i];
xmlChar *propName = xmlGetProp(node, BAD_CAST "name"); xmlChar *propName = xmlGetProp(node, BAD_CAST "name");
bool disable = xml_bvalue(node, "disable", false);
if (disable) { if (xml_bvalue(node, "disable", false)) {
int k; int k;
for (k = 0; k != MAXKEYWORDS; ++k) { for (k = 0; k != MAXKEYWORDS; ++k) {
if (strcmp(keywords[k], (const char *)propName) == 0) { if (strcmp(keywords[k], (const char *)propName) == 0) {