optimization: elf-special "regen.forest" is now a config.

this is an E3 feature
eliminates rc.parameters for elves
allows use of a local cached static
This commit is contained in:
Enno Rehling 2017-02-04 23:21:36 +01:00
parent 2ecbf89f1a
commit 3b3e39a319
4 changed files with 6 additions and 5 deletions

View File

@ -42,6 +42,7 @@
"nmr.timeout": 5,
"nmr.removenewbie": 0,
"GiveRestriction": 3,
"healing.forest": 2.0,
"hunger.long": false,
"hunger.damage": "1d9+9",
"hunger.demons.skill": true,

View File

@ -127,7 +127,6 @@
<race name="elf" magres="10" maxaura="1.0" regaura="1.1" recruitcost="200" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<function name="itemdrop" value="defaultdrops"/>
<param name="regen.forest" value="2.0"/>
<skill name="armorer" modifier="-1"/>
<skill name="bow" modifier="2"/>
<skill name="building" modifier="-1"/>

View File

@ -2060,9 +2060,10 @@ double u_heal_factor(const unit * u)
rc_elf = get_race(RC_ELF);
}
if (rc == rc_elf) {
double elf_regen = 1.0;
if (rc->parameters) {
elf_regen = get_param_flt(rc->parameters, "regen.forest", elf_regen);
static int cache;
static double elf_regen;
if (config_changed(&cache)) {
elf_regen = config_get_flt("healing.forest", 1.0);
}
return elf_regen;
}

View File

@ -505,7 +505,7 @@ static void test_heal_factor(CuTest *tc) {
CuAssertPtrEquals(tc, (void *)rc, (void *)get_race(RC_ELF));
u_setrace(u, get_race(RC_ELF));
CuAssertDblEquals(tc, 1.0, u_heal_factor(u), 0.0);
set_param(&rc->parameters, "regen.forest", "1.5");
config_set("healing.forest", "1.5");
CuAssertDblEquals(tc, 1.5, u_heal_factor(u), 0.0);
test_cleanup();
}