kill static caches for floating-point variables

This commit is contained in:
Enno Rehling 2015-11-22 17:32:35 +01:00
parent 2e392b4d7c
commit 48c75466b6
5 changed files with 9 additions and 26 deletions

View file

@ -2532,12 +2532,9 @@ troop select_ally(fighter * af, int minrow, int maxrow, int allytype)
static int loot_quota(const unit * src, const unit * dst,
const item_type * type, int n)
{
static double divisor = -1;
if (dst && src && src->faction != dst->faction) {
if (divisor < 0) {
divisor = config_get_flt("rules.items.loot_divisor", 1);
assert(divisor == 0 || divisor >= 1);
}
double divisor = config_get_flt("rules.items.loot_divisor", 1);
assert(divisor == 0 || divisor >= 1);
if (divisor >= 1) {
double r = n / divisor;
int x = (int)r;

View file

@ -29,12 +29,7 @@
static double ResourceFactor(void)
{
static double value = -1.0;
if (value < 0) {
const char *str = config_get("resource.factor");
value = str ? atof(str) : 1.0;
}
return value;
return config_get_flt("resource.factor", 1.0);
}
void update_resources(region * r)

View file

@ -3465,7 +3465,8 @@ static int use_item(unit * u, const item_type * itype, int amount, struct order
static double heal_factor(const unit * u)
{
static double elf_regen = -1;
double elf_regen;
switch (old_race(u_race(u))) {
case RC_TROLL:
case RC_DAEMON:
@ -3473,8 +3474,7 @@ static double heal_factor(const unit * u)
case RC_GOBLIN:
return 2.0;
case RC_ELF:
if (elf_regen < 0)
elf_regen = get_param_flt(u_race(u)->parameters, "regen.forest", 1.0F);
elf_regen = get_param_flt(u_race(u)->parameters, "regen.forest", 1.0F);
if (elf_regen != 1.0 && r_isforest(u->region)) {
return elf_regen;
}

View file

@ -108,14 +108,9 @@ attrib_type at_reportspell = {
** TODO: separate castle-appearance from illusion-effects
**/
static float MagicRegeneration(void)
static double MagicRegeneration(void)
{
static float value = -1.0;
if (value < 0) {
const char *str = config_get("magic.regeneration");
value = str ? (float)atof(str) : 1.0F;
}
return value;
return config_get_flt("magic.regeneration", 1.0);
}
static double MagicPower(double force)

View file

@ -700,11 +700,7 @@ static void set_coast(ship * sh, region * r, region * rnext)
static float damage_drift(void)
{
static float value = -1.0F;
if (value < 0) {
value = (float)config_get_flt("rules.ship.damage_drift", 0.02F);
}
return value;
return (float)config_get_flt("rules.ship.damage_drift", 0.02);
}
static void drifting_ships(region * r)