forked from github/server
fix reading skill modifiers.
This commit is contained in:
parent
177e0159c4
commit
12416e8b0d
1 changed files with 16 additions and 5 deletions
|
@ -417,8 +417,10 @@ static void XMLCALL start_resources(parseinfo *pi, const XML_Char *el, const XML
|
||||||
}
|
}
|
||||||
else if (xml_strcmp(el, "modifier") == 0) {
|
else if (xml_strcmp(el, "modifier") == 0) {
|
||||||
int i;
|
int i;
|
||||||
|
skill_t sk = NOSKILL;
|
||||||
const XML_Char *type = NULL;
|
const XML_Char *type = NULL;
|
||||||
resource_mod * mod = rmods + nrmods;
|
resource_mod * mod = rmods + nrmods;
|
||||||
|
const XML_Char *value = NULL;
|
||||||
|
|
||||||
assert(nrmods < RMOD_MAX);
|
assert(nrmods < RMOD_MAX);
|
||||||
++nrmods;
|
++nrmods;
|
||||||
|
@ -429,13 +431,16 @@ static void XMLCALL start_resources(parseinfo *pi, const XML_Char *el, const XML
|
||||||
else if (xml_strcmp(attr[i], "building") == 0) {
|
else if (xml_strcmp(attr[i], "building") == 0) {
|
||||||
mod->btype = bt_get_or_create(attr[i + 1]);
|
mod->btype = bt_get_or_create(attr[i + 1]);
|
||||||
}
|
}
|
||||||
|
else if (xml_strcmp(attr[i], "skill") == 0) {
|
||||||
|
sk = findskill(attr[i + 1]);
|
||||||
|
}
|
||||||
else if (xml_strcmp(attr[i], "races") == 0) {
|
else if (xml_strcmp(attr[i], "races") == 0) {
|
||||||
char list[64];
|
char list[64];
|
||||||
strcpy(list, attr[i + 1]);
|
strcpy(list, attr[i + 1]);
|
||||||
mod->race_mask = rc_get_mask(list);
|
mod->race_mask = rc_get_mask(list);
|
||||||
}
|
}
|
||||||
else if (xml_strcmp(attr[i], "value") == 0) {
|
else if (xml_strcmp(attr[i], "value") == 0) {
|
||||||
mod->value = xml_fraction(attr[i + 1]);
|
value = attr[i + 1];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
handle_bad_input(pi, el, attr[i]);
|
handle_bad_input(pi, el, attr[i]);
|
||||||
|
@ -443,15 +448,19 @@ static void XMLCALL start_resources(parseinfo *pi, const XML_Char *el, const XML
|
||||||
}
|
}
|
||||||
if (xml_strcmp(type, "skill") == 0) {
|
if (xml_strcmp(type, "skill") == 0) {
|
||||||
mod->type = RMT_PROD_SKILL;
|
mod->type = RMT_PROD_SKILL;
|
||||||
}
|
mod->value.sa[0] = (short)sk;
|
||||||
else if (xml_strcmp(type, "material") == 0) {
|
mod->value.sa[1] = (short)xml_int(value);
|
||||||
mod->type = RMT_PROD_SAVE;
|
|
||||||
}
|
}
|
||||||
else if (xml_strcmp(type, "require") == 0) {
|
else if (xml_strcmp(type, "require") == 0) {
|
||||||
mod->type = RMT_PROD_REQUIRE;
|
mod->type = RMT_PROD_REQUIRE;
|
||||||
}
|
}
|
||||||
|
else if (xml_strcmp(type, "material") == 0) {
|
||||||
|
mod->type = RMT_PROD_SAVE;
|
||||||
|
mod->value = xml_fraction(value);
|
||||||
|
}
|
||||||
else if (xml_strcmp(type, "save") == 0) {
|
else if (xml_strcmp(type, "save") == 0) {
|
||||||
mod->type = RMT_USE_SAVE;
|
mod->type = RMT_USE_SAVE;
|
||||||
|
mod->value = xml_fraction(value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
handle_bad_input(pi, el, type);
|
handle_bad_input(pi, el, type);
|
||||||
|
@ -601,12 +610,14 @@ static void end_weapon(parseinfo *pi, const XML_Char *el) {
|
||||||
static void end_resources(parseinfo *pi, const XML_Char *el) {
|
static void end_resources(parseinfo *pi, const XML_Char *el) {
|
||||||
resource_type *rtype = (resource_type *)pi->object;
|
resource_type *rtype = (resource_type *)pi->object;
|
||||||
if (xml_strcmp(el, "resources") == 0) {
|
if (xml_strcmp(el, "resources") == 0) {
|
||||||
|
pi->type = EXP_UNKNOWN;
|
||||||
|
}
|
||||||
|
else if (xml_strcmp(el, "resource") == 0) {
|
||||||
if (nrmods > 0) {
|
if (nrmods > 0) {
|
||||||
rtype->modifiers = calloc(sizeof(resource_mod), nrmods + 1);
|
rtype->modifiers = calloc(sizeof(resource_mod), nrmods + 1);
|
||||||
memcpy(rtype->modifiers, rmods, sizeof(resource_mod) * nrmods);
|
memcpy(rtype->modifiers, rmods, sizeof(resource_mod) * nrmods);
|
||||||
nrmods = 0;
|
nrmods = 0;
|
||||||
}
|
}
|
||||||
pi->type = EXP_UNKNOWN;
|
|
||||||
}
|
}
|
||||||
else if (xml_strcmp(el, "construction") == 0) {
|
else if (xml_strcmp(el, "construction") == 0) {
|
||||||
if (nreqs > 0) {
|
if (nreqs > 0) {
|
||||||
|
|
Loading…
Reference in a new issue