From dd8449783a573cadd669f62a47e18abf8d25ac34 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 15 May 2015 19:08:44 +0200 Subject: [PATCH] converting float->double in a lot of the code to prevent -Wconversion messages --- src/attributes/movement.c | 7 +++++- src/battle.c | 6 ++--- src/give.c | 2 +- src/items.c | 10 ++++---- src/kernel/build.c | 6 ++--- src/kernel/config.c | 2 +- src/kernel/curse.c | 22 ++++++++---------- src/kernel/curse.h | 14 ++++++------ src/kernel/region.c | 5 ++-- src/kernel/region.h | 4 ++-- src/laws.c | 48 +++++++++++++++++++-------------------- src/magic.c | 18 +++++++-------- src/magic.h | 4 ++-- src/modules/score.c | 4 ++-- src/randenc.c | 2 +- src/randenc.h | 6 ++--- src/spells.c | 4 ++-- 17 files changed, 83 insertions(+), 81 deletions(-) diff --git a/src/attributes/movement.c b/src/attributes/movement.c index 662affdf3..beb3998f0 100644 --- a/src/attributes/movement.c +++ b/src/attributes/movement.c @@ -25,6 +25,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include +#include +#include + static void write_movement(const attrib * a, const void *owner, struct storage *store) { @@ -65,7 +68,9 @@ void set_movement(attrib ** alist, int type) static int age_speedup(attrib * a) { if (a->data.sa[0] > 0) { - a->data.sa[0] = a->data.sa[0] - a->data.sa[1]; + assert(a->data.sa[0] - a->data.sa[1] >= SHRT_MIN); + assert(a->data.sa[0] - a->data.sa[1] <= SHRT_MAX); + a->data.sa[0] = (short)(a->data.sa[0] - a->data.sa[1]); } return (a->data.sa[0] > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE; } diff --git a/src/battle.c b/src/battle.c index feebe80d4..1ed7df3b0 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1771,7 +1771,7 @@ void do_combatmagic(battle * b, combatmagic_t was) } } -static int cast_combatspell(troop at, const spell * sp, int level, float force) +static int cast_combatspell(troop at, const spell * sp, int level, double force) { castorder co; @@ -1794,7 +1794,7 @@ static void do_combatspell(troop at) region *r = b->region; quicklist *ql; int level, qi; - float power; + double power; int fumblechance = 0; order *ord; int sl; @@ -1867,7 +1867,7 @@ static void do_extra_spell(troop at, const att * a) log_error("spell '%s' has no function.\n", sp->sname); } else { - float force = (float)a->level * MagicPower(); + double force = a->level * MagicPower(); assert(a->level > 0); cast_combatspell(at, sp, a->level, force); } diff --git a/src/give.c b/src/give.c index d22a09c73..d211a5518 100644 --- a/src/give.c +++ b/src/give.c @@ -131,7 +131,7 @@ static bool limited_give(const item_type * type) int give_quota(const unit * src, const unit * dst, const item_type * type, int n) { - float divisor; + double divisor; if (!limited_give(type)) { return n; diff --git a/src/items.c b/src/items.c index d7c9efd5e..5e9a357e6 100644 --- a/src/items.c +++ b/src/items.c @@ -81,7 +81,7 @@ use_speedsail(struct unit *u, const struct item_type *itype, int amount, struct order *ord) { curse *c; - float effect; + double effect; ship *sh = u->ship; if (!sh) { cmistake(u, ord, 20, MSG_MOVE); @@ -120,7 +120,7 @@ struct order *ord) } for (i = 0; i != amount; ++i) { int effect, duration = 2; - float force; + double force; spell *sp = find_spell("antimagiczone"); attrib **ap = &r->attribs; unused_arg(ord); @@ -132,7 +132,7 @@ struct order *ord) /* Hält Sprüche bis zu einem summierten Gesamtlevel von power aus. * Jeder Zauber reduziert die 'Lebenskraft' (vigour) der Antimagiezone * um seine Stufe */ - force = (float)effect * 20; /* Stufe 5 =~ 100 */ + force = effect * 20; /* Stufe 5 =~ 100 */ /* Regionszauber auflösen */ while (*ap && force > 0) { @@ -163,8 +163,8 @@ struct order *ord) } if (force > 0) { - create_curse(u, &r->attribs, ct_find("antimagiczone"), (float)force, duration, - (float)effect, 0); + create_curse(u, &r->attribs, ct_find("antimagiczone"), force, duration, + effect, 0); } } use_pooled(u, rt_crystal, GET_DEFAULT, amount); diff --git a/src/kernel/build.c b/src/kernel/build.c index cfebbfff7..bca970fc4 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -101,7 +101,7 @@ static void destroy_road(unit * u, int nmax, struct order *ord) else { unit *u2; region *r = u->region; - short road, n = (short)nmax; + int road, n = nmax; if (nmax > SHRT_MAX) { n = SHRT_MAX; @@ -131,7 +131,7 @@ static void destroy_road(unit * u, int nmax, struct order *ord) if (willdo > SHRT_MAX) road = 0; else - road = road - (short)willdo; + road = (short)(road - willdo); rsetroad(r, d, road); ADDMSG(&u->faction->msgs, msg_message("destroy_road", "unit from to", u, r, r2)); @@ -360,7 +360,7 @@ void build_road(region * r, unit * u, int size, direction_t d) /* n is now modified by several special effects, so we have to * minimize it again to make sure the road will not grow beyond * maximum. */ - rsetroad(r, d, rroad(r, d) + (short)n); + rsetroad(r, d, rroad(r, d) + n); if (u_race(u) == get_race(RC_STONEGOLEM)) { int golemsused = n / GOLEM_STONE; diff --git a/src/kernel/config.c b/src/kernel/config.c index 2e0f2c32c..b310d3fd6 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -853,7 +853,7 @@ int forbiddenid(int id) ++len; forbid = calloc(len, sizeof(int)); for (i = 0; i != len; ++i) { - forbid[i] = strtol(forbidden[i], NULL, 36); + forbid[i] = atoi36(forbidden[i]); } } for (i = 0; i != len; ++i) diff --git a/src/kernel/curse.c b/src/kernel/curse.c index d01e8900c..0cad2dfa6 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -392,15 +392,13 @@ bool remove_curse(attrib ** ap, const curse * c) /* gibt die allgemeine Stärke der Verzauberung zurück. id2 wird wie * oben benutzt. Dies ist nicht die Wirkung, sondern die Kraft und * damit der gegen Antimagie wirkende Widerstand einer Verzauberung */ -static float get_cursevigour(const curse * c) +static double get_cursevigour(const curse * c) { - if (c) - return c->vigour; - return 0; + return c ? c->vigour : 0; } /* setzt die Stärke der Verzauberung auf i */ -static void set_cursevigour(curse * c, float vigour) +static void set_cursevigour(curse * c, double vigour) { assert(c && vigour > 0); c->vigour = vigour; @@ -410,7 +408,7 @@ static void set_cursevigour(curse * c, float vigour) * Stärke zurück. Sollte die Zauberstärke unter Null sinken, löst er * sich auf. */ -float curse_changevigour(attrib ** ap, curse * c, float vigour) +double curse_changevigour(attrib ** ap, curse * c, double vigour) { vigour += get_cursevigour(c); @@ -426,7 +424,7 @@ float curse_changevigour(attrib ** ap, curse * c, float vigour) /* ------------------------------------------------------------- */ -float curse_geteffect(const curse * c) +double curse_geteffect(const curse * c) { if (c == NULL) return 0; @@ -437,7 +435,7 @@ float curse_geteffect(const curse * c) int curse_geteffect_int(const curse * c) { - float effect = curse_geteffect(c); + double effect = curse_geteffect(c); if (effect - (int)effect != 0) { log_error("curse has an integer attribute with float value: '%s' = %lf", c->type->cname, effect); @@ -491,7 +489,7 @@ static void set_cursedmen(curse * c, int cursedmen) * dieses Typs geben, gibt es den bestehenden zurück. */ static curse *make_curse(unit * mage, attrib ** ap, const curse_type * ct, - float vigour, int duration, float effect, int men) + double vigour, int duration, double effect, int men) { curse *c; attrib *a; @@ -528,7 +526,7 @@ static curse *make_curse(unit * mage, attrib ** ap, const curse_type * ct, * passenden Typ verzweigt und die relevanten Variablen weitergegeben. */ curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct, - float vigour, int duration, float effect, int men) + double vigour, int duration, double effect, int men) { curse *c; @@ -785,7 +783,7 @@ message *cinfo_simple(const void *obj, objtype_t typ, const struct curse * c, * die Kraft des Curse um die halbe Stärke der Antimagie reduziert. * Zurückgegeben wird der noch unverbrauchte Rest von force. */ -float destr_curse(curse * c, int cast_level, float force) +double destr_curse(curse * c, int cast_level, double force) { if (cast_level < c->vigour) { /* Zauber ist nicht stark genug */ double probability = 0.1 + (cast_level - c->vigour) * 0.2; @@ -793,7 +791,7 @@ float destr_curse(curse * c, int cast_level, float force) if (chance(probability)) { force -= c->vigour; if (c->type->change_vigour) { - c->type->change_vigour(c, -((float)cast_level + 1) / 2); + c->type->change_vigour(c, -(cast_level + 1) / 2); } else { c->vigour -= cast_level + 1 / 2; diff --git a/src/kernel/curse.h b/src/kernel/curse.h index 4d6729374..212090281 100644 --- a/src/kernel/curse.h +++ b/src/kernel/curse.h @@ -194,9 +194,9 @@ extern "C" { const struct curse_type *type; /* Zeiger auf ein curse_type-struct */ int flags; /* WARNING: these are XORed with type->flags! */ int duration; /* Dauer der Verzauberung. Wird jede Runde vermindert */ - float vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */ + double vigour; /* Stärke der Verzauberung, Widerstand gegen Antimagie */ struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */ - float effect; + double effect; variant data; /* pointer auf spezielle curse-unterstructs */ } curse; @@ -211,7 +211,7 @@ extern "C" { int mergeflags; struct message *(*curseinfo) (const void *, objtype_t, const struct curse *, int); - void(*change_vigour) (curse *, float); + void(*change_vigour) (curse *, double); int(*read) (struct storage * store, curse * c, void *target); int(*write) (struct storage * store, const struct curse * c, const void *target); @@ -238,7 +238,7 @@ extern "C" { */ curse *create_curse(struct unit *magician, struct attrib **ap, - const curse_type * ctype, float vigour, int duration, float ceffect, + const curse_type * ctype, double vigour, int duration, double ceffect, int men); /* Verzweigt automatisch zum passenden struct-typ. Sollte es schon * einen Zauber dieses Typs geben, so wird der neue dazuaddiert. Die @@ -260,10 +260,10 @@ extern "C" { * gesetzt. Gibt immer den ersten Treffer von ap aus zurück. */ int curse_geteffect_int(const struct curse *c); - float curse_geteffect(const struct curse *c); + double curse_geteffect(const struct curse *c); /* verändert die Stärke der Verzauberung um i */ - float curse_changevigour(struct attrib **ap, curse * c, float i); + double curse_changevigour(struct attrib **ap, curse * c, double delta); /* gibt bei Personenbeschränkten Verzauberungen die Anzahl der * betroffenen Personen zurück. Ansonsten wird 0 zurückgegeben. */ @@ -297,7 +297,7 @@ extern "C" { void curse_done(struct attrib *a); int curse_age(struct attrib *a); - float destr_curse(struct curse *c, int cast_level, float force); + double destr_curse(struct curse *c, int cast_level, double force); int resolve_curse(variant data, void *address); bool is_cursed_with(const struct attrib *ap, const struct curse *c); diff --git a/src/kernel/region.c b/src/kernel/region.c index 807fb3d76..9f1ff1eeb 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -537,11 +537,12 @@ attrib_type at_travelunit = { NO_READ }; -void rsetroad(region * r, direction_t d, short val) +void rsetroad(region * r, direction_t d, int val) { connection *b; region *r2 = rconnect(r, d); + assert(val>=SHRT_MIN && val<=SHRT_MAX); if (!r2) { return; } @@ -561,7 +562,7 @@ void rsetroad(region * r, direction_t d, short val) } } -short rroad(const region * r, direction_t d) +int rroad(const region * r, direction_t d) { connection *b; region *r2 = rconnect(r, d); diff --git a/src/kernel/region.h b/src/kernel/region.h index b9558427a..5c2c3a17c 100644 --- a/src/kernel/region.h +++ b/src/kernel/region.h @@ -187,8 +187,8 @@ extern "C" { void setluxuries(struct region *r, const struct luxury_type *sale); int get_maxluxuries(void); - short rroad(const struct region *r, direction_t d); - void rsetroad(struct region *r, direction_t d, short value); + int rroad(const struct region *r, direction_t d); + void rsetroad(struct region *r, direction_t d, int value); bool is_coastregion(struct region *r); diff --git a/src/laws.c b/src/laws.c index 00553cde5..ed9bc2108 100755 --- a/src/laws.c +++ b/src/laws.c @@ -98,7 +98,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include /* chance that a peasant dies of starvation: */ -#define PEASANT_STARVATION_CHANCE 0.9F +#define PEASANT_STARVATION_CHANCE 0.9 /* Pferdevermehrung */ #define HORSEGROWTH 4 /* Wanderungschance pro Pferd */ @@ -257,7 +257,7 @@ static void calculate_emigration(region * r) } -static float peasant_growth_factor(void) +static double peasant_growth_factor(void) { return get_param_flt(global.parameters, "rules.peasants.growth.factor", 0.0001F * PEASANTGROWTH); } @@ -265,7 +265,7 @@ static float peasant_growth_factor(void) #ifdef SLOWLUCK int peasant_luck_effect(int peasants, int luck, int maxp, double variance) { int n, births=0; - float factor = peasant_growth_factor(); + double factor = peasant_growth_factor(); for (n = peasants; n && luck; --n) { int chances = 0; @@ -287,7 +287,7 @@ int peasant_luck_effect(int peasants, int luck, int maxp, double variance) { return births; } #else -static float peasant_luck_factor(void) +static double peasant_luck_factor(void) { return get_param_flt(global.parameters, "rules.peasants.peasantluck.factor", PEASANTLUCK); } @@ -296,12 +296,10 @@ int peasant_luck_effect(int peasants, int luck, int maxp, double variance) { int births = 0; double mean; - if (luck == 0) return 0; - mean = _min(luck, peasants) * peasant_luck_factor() - * peasant_growth_factor() * ((peasants / (double)maxp < .9) ? 1 : - PEASANTFORCE); + mean = peasant_luck_factor() * peasant_growth_factor() * _min(luck, peasants); + mean *= ((peasants / (double)maxp < .9) ? 1 : PEASANTFORCE); births = RAND_ROUND(normalvariate(mean, variance * mean)); if (births <= 0) @@ -349,7 +347,7 @@ static void peasants(region * r) /* Es verhungert maximal die unterernährten Bevölkerung. */ n = _min(peasants - satiated, rpeasants(r)); - dead += (int)(0.5F + n * PEASANT_STARVATION_CHANCE); + dead += (int)(0.5 + n * PEASANT_STARVATION_CHANCE); if (dead > 0) { message *msg = add_message(&r->msgs, msg_message("phunger", "dead", dead)); @@ -433,7 +431,7 @@ static void horses(region * r) horses = rhorses(r); if (horses > 0) { if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0)) { - rsethorses(r, (int)(horses * 0.9F)); + rsethorses(r, (int)(horses * 0.9)); } else if (maxhorses) { int i; @@ -445,7 +443,7 @@ static void horses(region * r) if (a_find(r->attribs, &at_horseluck)) growth *= 2; /* printf("Horses: <%d> %d -> ", growth, horses); */ - i = (int)(0.5F + (horses * 0.0001F) * growth); + i = (int)(0.5 + (horses * 0.0001) * growth); /* printf("%d\n", horses); */ rsethorses(r, horses + i); } @@ -2281,7 +2279,7 @@ static bool display_race(faction * f, unit * u, const race * rc) int a, at_count; char buf[2048], *bufp = buf; size_t size = sizeof(buf) - 1; - int bytes; + size_t bytes; if (u && u_race(u) != rc) return false; @@ -2297,7 +2295,7 @@ static bool display_race(faction * f, unit * u, const race * rc) info = LOC(f->locale, mkname("raceinfo", "no_info")); } - bytes = (int)strlcpy(bufp, info, size); + bytes = strlcpy(bufp, info, size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -2345,28 +2343,28 @@ static bool display_race(faction * f, unit * u, const race * rc) } } if (rc->battle_flags & BF_EQUIPMENT) { - bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment")); + bytes = (size_t)_snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } if (rc->battle_flags & BF_RES_PIERCE) { - bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce")); + bytes = (size_t)_snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } if (rc->battle_flags & BF_RES_CUT) { - bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut")); + bytes = (size_t)_snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } if (rc->battle_flags & BF_RES_BASH) { - bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash")); + bytes = (size_t)_snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } bytes = - _snprintf(bufp, size, " %d %s", at_count, LOC(f->locale, + (size_t)_snprintf(bufp, size, " %d %s", at_count, LOC(f->locale, (at_count == 1) ? "stat_attack" : "stat_attacks")); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -2374,21 +2372,21 @@ static bool display_race(faction * f, unit * u, const race * rc) for (a = 0; a < RACE_ATTACKS; a++) { if (rc->attack[a].type != AT_NONE) { if (a != 0) - bytes = (int)strlcpy(bufp, ", ", size); + bytes = strlcpy(bufp, ", ", size); else - bytes = (int)strlcpy(bufp, ": ", size); + bytes = strlcpy(bufp, ": ", size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); switch (rc->attack[a].type) { case AT_STANDARD: bytes = - _snprintf(bufp, size, "%s (%s)", + (size_t)_snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_standard"), rc->def_damage); break; case AT_NATURAL: bytes = - _snprintf(bufp, size, "%s (%s)", + (size_t)_snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_natural"), rc->attack[a].data.dice); break; case AT_SPELL: @@ -2396,11 +2394,11 @@ static bool display_race(faction * f, unit * u, const race * rc) case AT_DRAIN_ST: case AT_DRAIN_EXP: case AT_DAZZLE: - bytes = _snprintf(bufp, size, "%s", LOC(f->locale, "attack_magical")); + bytes = (size_t)_snprintf(bufp, size, "%s", LOC(f->locale, "attack_magical")); break; case AT_STRUCTURAL: bytes = - _snprintf(bufp, size, "%s (%s)", + (size_t)_snprintf(bufp, size, "%s (%s)", LOC(f->locale, "attack_structural"), rc->attack[a].data.dice); break; default: @@ -3130,7 +3128,7 @@ static building *age_building(building * b) else if (mage != NULL) { int sk = effskill(mage, SK_MAGIC); c->duration = _max(c->duration, sk / 2); - c->vigour = _max(c->vigour, sk); + c->vigour = _max(c->vigour, (float)sk); } } } diff --git a/src/magic.c b/src/magic.c index 72fe72a25..dd494445c 100644 --- a/src/magic.c +++ b/src/magic.c @@ -117,12 +117,12 @@ static float MagicRegeneration(void) return value; } -float MagicPower(void) +double MagicPower(void) { - static float value = -1.0; + static double value = -1.0; if (value < 0) { const char *str = get_param(global.parameters, "magic.power"); - value = str ? (float)atof(str) : 1.0f; + value = str ? atof(str) : 1.0; } return value; } @@ -1012,7 +1012,7 @@ float spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order *ord) { curse *c; - float force = (float)cast_level; + double force = cast_level; int elf_power; const struct resource_type *rtype; @@ -1041,7 +1041,7 @@ spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order if (curse_active(c)) { unit *mage = c->magician; force -= curse_geteffect(c); - curse_changevigour(&r->attribs, c, (float)-cast_level); + curse_changevigour(&r->attribs, c, -cast_level); cmistake(u, ord, 185, MSG_MAGIC); if (mage != NULL && mage->faction != NULL) { if (force > 0) { @@ -1340,7 +1340,7 @@ static void do_fumble(castorder * co) const spell *sp = co->sp; int level = co->level; int duration; - float effect; + double effect; ADDMSG(&u->faction->msgs, msg_message("patzer", "unit region spell", u, r, sp)); @@ -1382,8 +1382,8 @@ static void do_fumble(castorder * co) case 2: /* temporary skill loss */ duration = _max(rng_int() % level / 2, 2); - effect = -(float)level / 2; - c = create_curse(u, &u->attribs, ct_find("skillmod"), (float)level, + effect = level / -2.0; + c = create_curse(u, &u->attribs, ct_find("skillmod"), level, duration, effect, 1); c->data.i = SK_MAGIC; ADDMSG(&u->faction->msgs, msg_message("patzer2", "unit region", u, r)); @@ -2067,7 +2067,7 @@ struct region * co_get_region(const struct castorder * co) { } castorder *create_castorder(castorder * co, unit *caster, unit * familiar, const spell * sp, region * r, - int lev, float force, int range, struct order * ord, spellparameter * p) + int lev, double force, int range, struct order * ord, spellparameter * p) { if (!co) co = (castorder*)calloc(1, sizeof(castorder)); diff --git a/src/magic.h b/src/magic.h index 1494b0170..280b209d3 100644 --- a/src/magic.h +++ b/src/magic.h @@ -291,7 +291,7 @@ extern "C" { struct castorder *create_castorder(struct castorder * co, struct unit *caster, struct unit * familiar, const struct spell * sp, struct region * r, - int lev, float force, int range, struct order * ord, struct spellparameter * p); + int lev, double force, int range, struct order * ord, struct spellparameter * p); void free_castorder(struct castorder *co); /* Zwischenspreicher für Zauberbefehle, notwendig für Prioritäten */ void add_castorder(struct spellrank *cll, struct castorder *co); @@ -360,7 +360,7 @@ extern "C" { extern void write_spells(struct quicklist *slist, struct storage *store); extern void read_spells(struct quicklist **slistp, magic_t mtype, struct storage *store); - extern float MagicPower(void); + extern double MagicPower(void); extern struct spellbook * get_spellbook(const char * name); extern void free_spellbooks(void); diff --git a/src/modules/score.c b/src/modules/score.c index 644a79f49..bf3e472e1 100644 --- a/src/modules/score.c +++ b/src/modules/score.c @@ -161,8 +161,8 @@ void score(void) if (f->num_total != 0) { fprintf(scoreFP, "%8d (%8d/%4.2f%%/%5.2f) %30.30s (%3.3s) %5s (%3d)\n", f->score, f->score - average_score_of_age(f->age, f->age / 24 + 1), - ((float)f->score / (float)allscores) * 100.0, - (float)f->score / f->num_total, + ((double)f->score / allscores) * 100, + (double)f->score / f->num_total, f->name, LOC(default_locale, rc_name_s(f->race, NAME_SINGULAR)), factionid(f), f->age); } diff --git a/src/randenc.c b/src/randenc.c index 0a6042eec..3c7988a20 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -1189,7 +1189,7 @@ void plagues(region * r) int dead = 0; peasants = rpeasants(r); - dead = (int)(0.5F + PLAGUE_VICTIMS * peasants); + dead = (int)(0.5 + PLAGUE_VICTIMS * peasants); for (i = dead; i != 0; i--) { if (rng_double() < PLAGUE_HEALCHANCE && rmoney(r) >= PLAGUE_HEALCOST) { rsetmoney(r, rmoney(r) - PLAGUE_HEALCOST); diff --git a/src/randenc.h b/src/randenc.h index 1f8ecf739..cc799db5f 100644 --- a/src/randenc.h +++ b/src/randenc.h @@ -25,9 +25,9 @@ extern "C" { struct region; /** Plagues **/ -#define PLAGUE_CHANCE 0.1F /* Seuchenwahrscheinlichkeit (siehe plagues()) */ -#define PLAGUE_VICTIMS 0.2F /* % Betroffene */ -#define PLAGUE_HEALCHANCE 0.25F /* Wahrscheinlichkeit Heilung */ +#define PLAGUE_CHANCE 0.1 /* Seuchenwahrscheinlichkeit (siehe plagues()) */ +#define PLAGUE_VICTIMS 0.2 /* % Betroffene */ +#define PLAGUE_HEALCHANCE 0.25 /* Wahrscheinlichkeit Heilung */ #define PLAGUE_HEALCOST 30 /* Heilkosten */ void plagues(struct region *r); void encounters(void); diff --git a/src/spells.c b/src/spells.c index 5905d4119..b13ed5e3e 100644 --- a/src/spells.c +++ b/src/spells.c @@ -298,7 +298,7 @@ static void magicanalyse_ship(ship * sh, unit * mage, double force) } -static int break_curse(attrib ** alist, int cast_level, float force, curse * c) +static int break_curse(attrib ** alist, int cast_level, double force, curse * c) { int succ = 0; /* attrib **a = a_find(*ap, &at_curse); */ @@ -327,7 +327,7 @@ static int break_curse(attrib ** alist, int cast_level, float force, curse * c) * auf alle Verzauberungen wirken. Ansonsten pruefe, ob der Curse vom * richtigen Typ ist. */ if (!c || c == c1) { - float remain = destr_curse(c1, cast_level, force); + double remain = destr_curse(c1, cast_level, force); if (remain < force) { succ = cast_level; force = remain;