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) {
|
||||
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) {
|
||||
if (value[0] == '1') {
|
||||
rc->flags |= RCF_MIGRANTS;
|
||||
|
|
|
@ -96,6 +96,8 @@ static void test_rc_set_param(CuTest *tc) {
|
|||
rc_set_param(rc, "migrants.formula", "1");
|
||||
CuAssertIntEquals(tc, RCF_MIGRANTS, rc->flags&RCF_MIGRANTS);
|
||||
CuAssertIntEquals(tc, MIGRANTS_LOG10, rc_migrants_formula(rc));
|
||||
rc_set_param(rc, "ai.scare", "400");
|
||||
CuAssertIntEquals(tc, 400, rc_scare(rc));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
|
|
|
@ -1575,13 +1575,12 @@ static int parse_spells(xmlDocPtr doc)
|
|||
|
||||
static void parse_ai(race * rc, xmlNodePtr node)
|
||||
{
|
||||
int n;
|
||||
xmlChar *propValue;
|
||||
|
||||
n = xml_ivalue(node, "scare", 0);
|
||||
if (n>0) {
|
||||
attrib *a = a_new(&at_scare);
|
||||
a->data.i = n;
|
||||
a_add(&rc->attribs, a);
|
||||
propValue = xmlGetProp(node, BAD_CAST "scare");
|
||||
if (propValue) {
|
||||
rc_set_param(rc, "ai.scare", (const char *)propValue);
|
||||
xmlFree(propValue);
|
||||
}
|
||||
rc->splitsize = xml_ivalue(node, "splitsize", 0);
|
||||
rc->aggression = (float)xml_fvalue(node, "aggression", 0.04);
|
||||
|
|
Loading…
Reference in New Issue