forked from github/server
wrap ai.scare and at_scare in rc_set_param
This commit is contained in:
parent
f2ed2c892a
commit
67414f29eb
|
@ -311,6 +311,11 @@ void rc_set_param(struct race *rc, const char *key, const char *value) {
|
||||||
if (strcmp(key, "recruit_multi") == 0) {
|
if (strcmp(key, "recruit_multi") == 0) {
|
||||||
rc->recruit_multi = atof(value);
|
rc->recruit_multi = atof(value);
|
||||||
}
|
}
|
||||||
|
else if (strcmp(key, "ai.scare") == 0) {
|
||||||
|
attrib *a = a_new(&at_scare);
|
||||||
|
a->data.i = atoi(value);
|
||||||
|
a_add(&rc->attribs, a);
|
||||||
|
}
|
||||||
else if (strcmp(key, "migrants.formula") == 0) {
|
else if (strcmp(key, "migrants.formula") == 0) {
|
||||||
if (value[0] == '1') {
|
if (value[0] == '1') {
|
||||||
rc->flags |= RCF_MIGRANTS;
|
rc->flags |= RCF_MIGRANTS;
|
||||||
|
|
|
@ -96,6 +96,8 @@ static void test_rc_set_param(CuTest *tc) {
|
||||||
rc_set_param(rc, "migrants.formula", "1");
|
rc_set_param(rc, "migrants.formula", "1");
|
||||||
CuAssertIntEquals(tc, RCF_MIGRANTS, rc->flags&RCF_MIGRANTS);
|
CuAssertIntEquals(tc, RCF_MIGRANTS, rc->flags&RCF_MIGRANTS);
|
||||||
CuAssertIntEquals(tc, MIGRANTS_LOG10, rc_migrants_formula(rc));
|
CuAssertIntEquals(tc, MIGRANTS_LOG10, rc_migrants_formula(rc));
|
||||||
|
rc_set_param(rc, "ai.scare", "400");
|
||||||
|
CuAssertIntEquals(tc, 400, rc_scare(rc));
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1575,13 +1575,12 @@ static int parse_spells(xmlDocPtr doc)
|
||||||
|
|
||||||
static void parse_ai(race * rc, xmlNodePtr node)
|
static void parse_ai(race * rc, xmlNodePtr node)
|
||||||
{
|
{
|
||||||
int n;
|
xmlChar *propValue;
|
||||||
|
|
||||||
n = xml_ivalue(node, "scare", 0);
|
propValue = xmlGetProp(node, BAD_CAST "scare");
|
||||||
if (n>0) {
|
if (propValue) {
|
||||||
attrib *a = a_new(&at_scare);
|
rc_set_param(rc, "ai.scare", (const char *)propValue);
|
||||||
a->data.i = n;
|
xmlFree(propValue);
|
||||||
a_add(&rc->attribs, a);
|
|
||||||
}
|
}
|
||||||
rc->splitsize = xml_ivalue(node, "splitsize", 0);
|
rc->splitsize = xml_ivalue(node, "splitsize", 0);
|
||||||
rc->aggression = (float)xml_fvalue(node, "aggression", 0.04);
|
rc->aggression = (float)xml_fvalue(node, "aggression", 0.04);
|
||||||
|
|
Loading…
Reference in New Issue