store maxaura as an integer, not a float.

This commit is contained in:
Enno Rehling 2017-02-03 20:06:01 +01:00
parent e51742da90
commit 250227cad2
7 changed files with 10 additions and 9 deletions

View File

@ -461,7 +461,7 @@ static void json_race(cJSON *json, race *rc) {
rc->magres = child->valueint;
}
else if (strcmp(child->string, "maxaura") == 0) {
rc->maxaura = (float)child->valuedouble;
rc->maxaura = child->valueint;
}
else if (strcmp(child->string, "regaura") == 0) {
rc->regaura = (float)child->valuedouble;

View File

@ -137,7 +137,7 @@ static void test_races(CuTest * tc)
const char * data = "{\"races\": { \"orc\" : { "
"\"damage\" : \"1d4\","
"\"magres\" : 100,"
"\"maxaura\" : 2.0,"
"\"maxaura\" : 200,"
"\"regaura\" : 3.0,"
"\"speed\" : 4.0,"
"\"recruitcost\" : 1,"
@ -165,7 +165,8 @@ static void test_races(CuTest * tc)
CuAssertStrEquals(tc, "1d4", rc->def_damage);
CuAssertIntEquals(tc, 100, rc->magres);
CuAssertDblEquals(tc, 1.0, rc_magres(rc), 0.0);
CuAssertDblEquals(tc, 2.0, rc->maxaura, 0.0);
CuAssertIntEquals(tc, 200, rc->maxaura);
CuAssertDblEquals(tc, 2.0, rc_maxaura(rc), 0.0);
CuAssertDblEquals(tc, 3.0, rc->regaura, 0.0);
CuAssertDblEquals(tc, 4.0, rc->speed, 0.0);
CuAssertIntEquals(tc, 1, rc->recruitcost);

View File

@ -287,7 +287,7 @@ double rc_magres(const race *rc) {
}
double rc_maxaura(const race *rc) {
return rc->maxaura;
return rc->maxaura / 100.0;
}
const char* rc_name(const race * rc, name_t n, char *name, size_t size) {

View File

@ -118,7 +118,7 @@ extern "C" {
char *_name;
int magres;
int healing;
double maxaura; /* Faktor auf Maximale Aura */
int maxaura; /* Faktor auf Maximale Aura */
double regaura; /* Faktor auf Regeneration */
double recruit_multi; /* Faktor f<>r Bauernverbrauch */
int index;

View File

@ -1637,7 +1637,7 @@ static int parse_races(xmlDocPtr doc)
rc->magres = xml_ivalue(node, "magres", rc->magres);
rc->healing = (int)(xml_fvalue(node, "healing", rc->healing) * 100); // TODO: store as int in XML
rc->maxaura = (float)xml_fvalue(node, "maxaura", rc->maxaura);
rc->maxaura = (int)(xml_fvalue(node, "maxaura", rc->maxaura) * 100); // TODO: store as int in XML
rc->regaura = (float)xml_fvalue(node, "regaura", rc->regaura);
rc->recruitcost = xml_ivalue(node, "recruitcost", rc->recruitcost);
rc->maintenance = xml_ivalue(node, "maintenance", rc->maintenance);

View File

@ -433,9 +433,9 @@ static void test_max_spellpoints(CuTest *tc) {
rc = test_create_race("human");
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u));
rc->maxaura = 1.0;
rc->maxaura = 100;
CuAssertIntEquals(tc, 1, max_spellpoints(u->region, u));
rc->maxaura = 2.0;
rc->maxaura = 200;
CuAssertIntEquals(tc, 2, max_spellpoints(u->region, u));
create_mage(u, M_GRAY);
set_level(u, SK_MAGIC, 1);

View File

@ -40,7 +40,7 @@ struct race *test_create_race(const char *name)
race *rc = rc_get_or_create(name);
rc->maintenance = 10;
rc->hitpoints = 20;
rc->maxaura = 1.0;
rc->maxaura = 100;
rc->ec_flags |= GETITEM;
rc->battle_flags = BF_EQUIPMENT;
return rc;