forked from github/server
refactor fractions a little bit.
This commit is contained in:
parent
2328975dc2
commit
0a3e3de5a3
1 changed files with 11 additions and 2 deletions
|
@ -1025,8 +1025,17 @@ static int parse_resources(xmlDocPtr doc)
|
||||||
rdata->modifiers[k].flags = RMF_SKILL;
|
rdata->modifiers[k].flags = RMF_SKILL;
|
||||||
}
|
}
|
||||||
else if (strcmp((const char *)propValue, "material") == 0) {
|
else if (strcmp((const char *)propValue, "material") == 0) {
|
||||||
rdata->modifiers[k].value.sa[0] = (short)(0.5+100*xml_fvalue(node, "value", 0));
|
int num, den = 100;
|
||||||
rdata->modifiers[k].value.sa[1] = 100;
|
double fval = xml_fvalue(node, "value", 0);
|
||||||
|
// TODO: extract into a function for reading fractions?
|
||||||
|
num = (int)(fval * den + 0.5);
|
||||||
|
if (num % 10 == 0) {
|
||||||
|
// TODO: calculating a GCD would be better than this
|
||||||
|
num /= 10;
|
||||||
|
den /= 10;
|
||||||
|
}
|
||||||
|
rdata->modifiers[k].value.sa[0] = (short)num;
|
||||||
|
rdata->modifiers[k].value.sa[1] = (short)den;
|
||||||
rdata->modifiers[k].flags = RMF_SAVEMATERIAL;
|
rdata->modifiers[k].flags = RMF_SAVEMATERIAL;
|
||||||
}
|
}
|
||||||
else if (strcmp((const char *)propValue, "require") == 0) {
|
else if (strcmp((const char *)propValue, "require") == 0) {
|
||||||
|
|
Loading…
Reference in a new issue