converting float->double in a lot of the code to prevent -Wconversion messages

This commit is contained in:
Enno Rehling 2015-05-15 19:08:44 +02:00
parent 062237b0d1
commit dd8449783a
17 changed files with 83 additions and 81 deletions

View File

@ -25,6 +25,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <storage.h> #include <storage.h>
#include <limits.h>
#include <assert.h>
static void static void
write_movement(const attrib * a, const void *owner, struct storage *store) 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) static int age_speedup(attrib * a)
{ {
if (a->data.sa[0] > 0) { 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; return (a->data.sa[0] > 0) ? AT_AGE_KEEP : AT_AGE_REMOVE;
} }

View File

@ -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; castorder co;
@ -1794,7 +1794,7 @@ static void do_combatspell(troop at)
region *r = b->region; region *r = b->region;
quicklist *ql; quicklist *ql;
int level, qi; int level, qi;
float power; double power;
int fumblechance = 0; int fumblechance = 0;
order *ord; order *ord;
int sl; 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); log_error("spell '%s' has no function.\n", sp->sname);
} }
else { else {
float force = (float)a->level * MagicPower(); double force = a->level * MagicPower();
assert(a->level > 0); assert(a->level > 0);
cast_combatspell(at, sp, a->level, force); cast_combatspell(at, sp, a->level, force);
} }

View File

@ -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 give_quota(const unit * src, const unit * dst, const item_type * type,
int n) int n)
{ {
float divisor; double divisor;
if (!limited_give(type)) { if (!limited_give(type)) {
return n; return n;

View File

@ -81,7 +81,7 @@ use_speedsail(struct unit *u, const struct item_type *itype, int amount,
struct order *ord) struct order *ord)
{ {
curse *c; curse *c;
float effect; double effect;
ship *sh = u->ship; ship *sh = u->ship;
if (!sh) { if (!sh) {
cmistake(u, ord, 20, MSG_MOVE); cmistake(u, ord, 20, MSG_MOVE);
@ -120,7 +120,7 @@ struct order *ord)
} }
for (i = 0; i != amount; ++i) { for (i = 0; i != amount; ++i) {
int effect, duration = 2; int effect, duration = 2;
float force; double force;
spell *sp = find_spell("antimagiczone"); spell *sp = find_spell("antimagiczone");
attrib **ap = &r->attribs; attrib **ap = &r->attribs;
unused_arg(ord); unused_arg(ord);
@ -132,7 +132,7 @@ struct order *ord)
/* Hält Sprüche bis zu einem summierten Gesamtlevel von power aus. /* Hält Sprüche bis zu einem summierten Gesamtlevel von power aus.
* Jeder Zauber reduziert die 'Lebenskraft' (vigour) der Antimagiezone * Jeder Zauber reduziert die 'Lebenskraft' (vigour) der Antimagiezone
* um seine Stufe */ * um seine Stufe */
force = (float)effect * 20; /* Stufe 5 =~ 100 */ force = effect * 20; /* Stufe 5 =~ 100 */
/* Regionszauber auflösen */ /* Regionszauber auflösen */
while (*ap && force > 0) { while (*ap && force > 0) {
@ -163,8 +163,8 @@ struct order *ord)
} }
if (force > 0) { if (force > 0) {
create_curse(u, &r->attribs, ct_find("antimagiczone"), (float)force, duration, create_curse(u, &r->attribs, ct_find("antimagiczone"), force, duration,
(float)effect, 0); effect, 0);
} }
} }
use_pooled(u, rt_crystal, GET_DEFAULT, amount); use_pooled(u, rt_crystal, GET_DEFAULT, amount);

View File

@ -101,7 +101,7 @@ static void destroy_road(unit * u, int nmax, struct order *ord)
else { else {
unit *u2; unit *u2;
region *r = u->region; region *r = u->region;
short road, n = (short)nmax; int road, n = nmax;
if (nmax > SHRT_MAX) { if (nmax > SHRT_MAX) {
n = SHRT_MAX; n = SHRT_MAX;
@ -131,7 +131,7 @@ static void destroy_road(unit * u, int nmax, struct order *ord)
if (willdo > SHRT_MAX) if (willdo > SHRT_MAX)
road = 0; road = 0;
else else
road = road - (short)willdo; road = (short)(road - willdo);
rsetroad(r, d, road); rsetroad(r, d, road);
ADDMSG(&u->faction->msgs, msg_message("destroy_road", ADDMSG(&u->faction->msgs, msg_message("destroy_road",
"unit from to", u, r, r2)); "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 /* n is now modified by several special effects, so we have to
* minimize it again to make sure the road will not grow beyond * minimize it again to make sure the road will not grow beyond
* maximum. */ * maximum. */
rsetroad(r, d, rroad(r, d) + (short)n); rsetroad(r, d, rroad(r, d) + n);
if (u_race(u) == get_race(RC_STONEGOLEM)) { if (u_race(u) == get_race(RC_STONEGOLEM)) {
int golemsused = n / GOLEM_STONE; int golemsused = n / GOLEM_STONE;

View File

@ -853,7 +853,7 @@ int forbiddenid(int id)
++len; ++len;
forbid = calloc(len, sizeof(int)); forbid = calloc(len, sizeof(int));
for (i = 0; i != len; ++i) { for (i = 0; i != len; ++i) {
forbid[i] = strtol(forbidden[i], NULL, 36); forbid[i] = atoi36(forbidden[i]);
} }
} }
for (i = 0; i != len; ++i) for (i = 0; i != len; ++i)

View File

@ -392,15 +392,13 @@ bool remove_curse(attrib ** ap, const curse * c)
/* gibt die allgemeine Stärke der Verzauberung zurück. id2 wird wie /* gibt die allgemeine Stärke der Verzauberung zurück. id2 wird wie
* oben benutzt. Dies ist nicht die Wirkung, sondern die Kraft und * oben benutzt. Dies ist nicht die Wirkung, sondern die Kraft und
* damit der gegen Antimagie wirkende Widerstand einer Verzauberung */ * 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 ? c->vigour : 0;
return c->vigour;
return 0;
} }
/* setzt die Stärke der Verzauberung auf i */ /* 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); assert(c && vigour > 0);
c->vigour = vigour; 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 * Stärke zurück. Sollte die Zauberstärke unter Null sinken, löst er
* sich auf. * sich auf.
*/ */
float curse_changevigour(attrib ** ap, curse * c, float vigour) double curse_changevigour(attrib ** ap, curse * c, double vigour)
{ {
vigour += get_cursevigour(c); 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) if (c == NULL)
return 0; return 0;
@ -437,7 +435,7 @@ float curse_geteffect(const curse * c)
int curse_geteffect_int(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) { if (effect - (int)effect != 0) {
log_error("curse has an integer attribute with float value: '%s' = %lf", log_error("curse has an integer attribute with float value: '%s' = %lf",
c->type->cname, effect); 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. * dieses Typs geben, gibt es den bestehenden zurück.
*/ */
static curse *make_curse(unit * mage, attrib ** ap, const curse_type * ct, 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; curse *c;
attrib *a; 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. * passenden Typ verzweigt und die relevanten Variablen weitergegeben.
*/ */
curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct, 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; 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. * die Kraft des Curse um die halbe Stärke der Antimagie reduziert.
* Zurückgegeben wird der noch unverbrauchte Rest von force. * 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 */ if (cast_level < c->vigour) { /* Zauber ist nicht stark genug */
double probability = 0.1 + (cast_level - c->vigour) * 0.2; 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)) { if (chance(probability)) {
force -= c->vigour; force -= c->vigour;
if (c->type->change_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 { else {
c->vigour -= cast_level + 1 / 2; c->vigour -= cast_level + 1 / 2;

View File

@ -194,9 +194,9 @@ extern "C" {
const struct curse_type *type; /* Zeiger auf ein curse_type-struct */ const struct curse_type *type; /* Zeiger auf ein curse_type-struct */
int flags; /* WARNING: these are XORed with type->flags! */ int flags; /* WARNING: these are XORed with type->flags! */
int duration; /* Dauer der Verzauberung. Wird jede Runde vermindert */ 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 */ struct unit *magician; /* Pointer auf den Magier, der den Spruch gewirkt hat */
float effect; double effect;
variant data; /* pointer auf spezielle curse-unterstructs */ variant data; /* pointer auf spezielle curse-unterstructs */
} curse; } curse;
@ -211,7 +211,7 @@ extern "C" {
int mergeflags; int mergeflags;
struct message *(*curseinfo) (const void *, objtype_t, const struct curse *, struct message *(*curseinfo) (const void *, objtype_t, const struct curse *,
int); int);
void(*change_vigour) (curse *, float); void(*change_vigour) (curse *, double);
int(*read) (struct storage * store, curse * c, void *target); int(*read) (struct storage * store, curse * c, void *target);
int(*write) (struct storage * store, const struct curse * c, int(*write) (struct storage * store, const struct curse * c,
const void *target); const void *target);
@ -238,7 +238,7 @@ extern "C" {
*/ */
curse *create_curse(struct unit *magician, struct attrib **ap, 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); int men);
/* Verzweigt automatisch zum passenden struct-typ. Sollte es schon /* Verzweigt automatisch zum passenden struct-typ. Sollte es schon
* einen Zauber dieses Typs geben, so wird der neue dazuaddiert. Die * 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. * gesetzt. Gibt immer den ersten Treffer von ap aus zurück.
*/ */
int curse_geteffect_int(const struct curse *c); 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 */ /* 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 /* gibt bei Personenbeschränkten Verzauberungen die Anzahl der
* betroffenen Personen zurück. Ansonsten wird 0 zurückgegeben. */ * betroffenen Personen zurück. Ansonsten wird 0 zurückgegeben. */
@ -297,7 +297,7 @@ extern "C" {
void curse_done(struct attrib *a); void curse_done(struct attrib *a);
int curse_age(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); int resolve_curse(variant data, void *address);
bool is_cursed_with(const struct attrib *ap, const struct curse *c); bool is_cursed_with(const struct attrib *ap, const struct curse *c);

View File

@ -537,11 +537,12 @@ attrib_type at_travelunit = {
NO_READ NO_READ
}; };
void rsetroad(region * r, direction_t d, short val) void rsetroad(region * r, direction_t d, int val)
{ {
connection *b; connection *b;
region *r2 = rconnect(r, d); region *r2 = rconnect(r, d);
assert(val>=SHRT_MIN && val<=SHRT_MAX);
if (!r2) { if (!r2) {
return; 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; connection *b;
region *r2 = rconnect(r, d); region *r2 = rconnect(r, d);

View File

@ -187,8 +187,8 @@ extern "C" {
void setluxuries(struct region *r, const struct luxury_type *sale); void setluxuries(struct region *r, const struct luxury_type *sale);
int get_maxluxuries(void); int get_maxluxuries(void);
short rroad(const struct region *r, direction_t d); int rroad(const struct region *r, direction_t d);
void rsetroad(struct region *r, direction_t d, short value); void rsetroad(struct region *r, direction_t d, int value);
bool is_coastregion(struct region *r); bool is_coastregion(struct region *r);

View File

@ -98,7 +98,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <limits.h> #include <limits.h>
/* chance that a peasant dies of starvation: */ /* chance that a peasant dies of starvation: */
#define PEASANT_STARVATION_CHANCE 0.9F #define PEASANT_STARVATION_CHANCE 0.9
/* Pferdevermehrung */ /* Pferdevermehrung */
#define HORSEGROWTH 4 #define HORSEGROWTH 4
/* Wanderungschance pro Pferd */ /* 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); 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 #ifdef SLOWLUCK
int peasant_luck_effect(int peasants, int luck, int maxp, double variance) { int peasant_luck_effect(int peasants, int luck, int maxp, double variance) {
int n, births=0; int n, births=0;
float factor = peasant_growth_factor(); double factor = peasant_growth_factor();
for (n = peasants; n && luck; --n) { for (n = peasants; n && luck; --n) {
int chances = 0; int chances = 0;
@ -287,7 +287,7 @@ int peasant_luck_effect(int peasants, int luck, int maxp, double variance) {
return births; return births;
} }
#else #else
static float peasant_luck_factor(void) static double peasant_luck_factor(void)
{ {
return get_param_flt(global.parameters, "rules.peasants.peasantluck.factor", PEASANTLUCK); 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; int births = 0;
double mean; double mean;
if (luck == 0) return 0; if (luck == 0) return 0;
mean = _min(luck, peasants) * peasant_luck_factor() mean = peasant_luck_factor() * peasant_growth_factor() * _min(luck, peasants);
* peasant_growth_factor() * ((peasants / (double)maxp < .9) ? 1 : mean *= ((peasants / (double)maxp < .9) ? 1 : PEASANTFORCE);
PEASANTFORCE);
births = RAND_ROUND(normalvariate(mean, variance * mean)); births = RAND_ROUND(normalvariate(mean, variance * mean));
if (births <= 0) if (births <= 0)
@ -349,7 +347,7 @@ static void peasants(region * r)
/* Es verhungert maximal die unterernährten Bevölkerung. */ /* Es verhungert maximal die unterernährten Bevölkerung. */
n = _min(peasants - satiated, rpeasants(r)); 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) { if (dead > 0) {
message *msg = add_message(&r->msgs, msg_message("phunger", "dead", dead)); message *msg = add_message(&r->msgs, msg_message("phunger", "dead", dead));
@ -433,7 +431,7 @@ static void horses(region * r)
horses = rhorses(r); horses = rhorses(r);
if (horses > 0) { if (horses > 0) {
if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 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) { else if (maxhorses) {
int i; int i;
@ -445,7 +443,7 @@ static void horses(region * r)
if (a_find(r->attribs, &at_horseluck)) if (a_find(r->attribs, &at_horseluck))
growth *= 2; growth *= 2;
/* printf("Horses: <%d> %d -> ", growth, horses); */ /* 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); */ /* printf("%d\n", horses); */
rsethorses(r, horses + i); rsethorses(r, horses + i);
} }
@ -2281,7 +2279,7 @@ static bool display_race(faction * f, unit * u, const race * rc)
int a, at_count; int a, at_count;
char buf[2048], *bufp = buf; char buf[2048], *bufp = buf;
size_t size = sizeof(buf) - 1; size_t size = sizeof(buf) - 1;
int bytes; size_t bytes;
if (u && u_race(u) != rc) if (u && u_race(u) != rc)
return false; 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")); 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) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
@ -2345,28 +2343,28 @@ static bool display_race(faction * f, unit * u, const race * rc)
} }
} }
if (rc->battle_flags & BF_EQUIPMENT) { 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) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
if (rc->battle_flags & BF_RES_PIERCE) { 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) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
if (rc->battle_flags & BF_RES_CUT) { 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) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
if (rc->battle_flags & BF_RES_BASH) { 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) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
bytes = 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")); (at_count == 1) ? "stat_attack" : "stat_attacks"));
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); 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++) { for (a = 0; a < RACE_ATTACKS; a++) {
if (rc->attack[a].type != AT_NONE) { if (rc->attack[a].type != AT_NONE) {
if (a != 0) if (a != 0)
bytes = (int)strlcpy(bufp, ", ", size); bytes = strlcpy(bufp, ", ", size);
else else
bytes = (int)strlcpy(bufp, ": ", size); bytes = strlcpy(bufp, ": ", size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
switch (rc->attack[a].type) { switch (rc->attack[a].type) {
case AT_STANDARD: case AT_STANDARD:
bytes = bytes =
_snprintf(bufp, size, "%s (%s)", (size_t)_snprintf(bufp, size, "%s (%s)",
LOC(f->locale, "attack_standard"), rc->def_damage); LOC(f->locale, "attack_standard"), rc->def_damage);
break; break;
case AT_NATURAL: case AT_NATURAL:
bytes = bytes =
_snprintf(bufp, size, "%s (%s)", (size_t)_snprintf(bufp, size, "%s (%s)",
LOC(f->locale, "attack_natural"), rc->attack[a].data.dice); LOC(f->locale, "attack_natural"), rc->attack[a].data.dice);
break; break;
case AT_SPELL: 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_ST:
case AT_DRAIN_EXP: case AT_DRAIN_EXP:
case AT_DAZZLE: 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; break;
case AT_STRUCTURAL: case AT_STRUCTURAL:
bytes = bytes =
_snprintf(bufp, size, "%s (%s)", (size_t)_snprintf(bufp, size, "%s (%s)",
LOC(f->locale, "attack_structural"), rc->attack[a].data.dice); LOC(f->locale, "attack_structural"), rc->attack[a].data.dice);
break; break;
default: default:
@ -3130,7 +3128,7 @@ static building *age_building(building * b)
else if (mage != NULL) { else if (mage != NULL) {
int sk = effskill(mage, SK_MAGIC); int sk = effskill(mage, SK_MAGIC);
c->duration = _max(c->duration, sk / 2); c->duration = _max(c->duration, sk / 2);
c->vigour = _max(c->vigour, sk); c->vigour = _max(c->vigour, (float)sk);
} }
} }
} }

View File

@ -117,12 +117,12 @@ static float MagicRegeneration(void)
return value; return value;
} }
float MagicPower(void) double MagicPower(void)
{ {
static float value = -1.0; static double value = -1.0;
if (value < 0) { if (value < 0) {
const char *str = get_param(global.parameters, "magic.power"); const char *str = get_param(global.parameters, "magic.power");
value = str ? (float)atof(str) : 1.0f; value = str ? atof(str) : 1.0;
} }
return value; return value;
} }
@ -1012,7 +1012,7 @@ float
spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order *ord) spellpower(region * r, unit * u, const spell * sp, int cast_level, struct order *ord)
{ {
curse *c; curse *c;
float force = (float)cast_level; double force = cast_level;
int elf_power; int elf_power;
const struct resource_type *rtype; 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)) { if (curse_active(c)) {
unit *mage = c->magician; unit *mage = c->magician;
force -= curse_geteffect(c); 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); cmistake(u, ord, 185, MSG_MAGIC);
if (mage != NULL && mage->faction != NULL) { if (mage != NULL && mage->faction != NULL) {
if (force > 0) { if (force > 0) {
@ -1340,7 +1340,7 @@ static void do_fumble(castorder * co)
const spell *sp = co->sp; const spell *sp = co->sp;
int level = co->level; int level = co->level;
int duration; int duration;
float effect; double effect;
ADDMSG(&u->faction->msgs, ADDMSG(&u->faction->msgs,
msg_message("patzer", "unit region spell", u, r, sp)); msg_message("patzer", "unit region spell", u, r, sp));
@ -1382,8 +1382,8 @@ static void do_fumble(castorder * co)
case 2: case 2:
/* temporary skill loss */ /* temporary skill loss */
duration = _max(rng_int() % level / 2, 2); duration = _max(rng_int() % level / 2, 2);
effect = -(float)level / 2; effect = level / -2.0;
c = create_curse(u, &u->attribs, ct_find("skillmod"), (float)level, c = create_curse(u, &u->attribs, ct_find("skillmod"), level,
duration, effect, 1); duration, effect, 1);
c->data.i = SK_MAGIC; c->data.i = SK_MAGIC;
ADDMSG(&u->faction->msgs, msg_message("patzer2", "unit region", u, r)); 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, 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)); if (!co) co = (castorder*)calloc(1, sizeof(castorder));

View File

@ -291,7 +291,7 @@ extern "C" {
struct castorder *create_castorder(struct castorder * co, struct unit *caster, struct castorder *create_castorder(struct castorder * co, struct unit *caster,
struct unit * familiar, const struct spell * sp, struct region * r, 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); void free_castorder(struct castorder *co);
/* Zwischenspreicher für Zauberbefehle, notwendig für Prioritäten */ /* Zwischenspreicher für Zauberbefehle, notwendig für Prioritäten */
void add_castorder(struct spellrank *cll, struct castorder *co); 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 write_spells(struct quicklist *slist, struct storage *store);
extern void read_spells(struct quicklist **slistp, magic_t mtype, extern void read_spells(struct quicklist **slistp, magic_t mtype,
struct storage *store); struct storage *store);
extern float MagicPower(void); extern double MagicPower(void);
extern struct spellbook * get_spellbook(const char * name); extern struct spellbook * get_spellbook(const char * name);
extern void free_spellbooks(void); extern void free_spellbooks(void);

View File

@ -161,8 +161,8 @@ void score(void)
if (f->num_total != 0) { if (f->num_total != 0) {
fprintf(scoreFP, "%8d (%8d/%4.2f%%/%5.2f) %30.30s (%3.3s) %5s (%3d)\n", 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), f->score, f->score - average_score_of_age(f->age, f->age / 24 + 1),
((float)f->score / (float)allscores) * 100.0, ((double)f->score / allscores) * 100,
(float)f->score / f->num_total, (double)f->score / f->num_total,
f->name, LOC(default_locale, rc_name_s(f->race, NAME_SINGULAR)), factionid(f), f->name, LOC(default_locale, rc_name_s(f->race, NAME_SINGULAR)), factionid(f),
f->age); f->age);
} }

View File

@ -1189,7 +1189,7 @@ void plagues(region * r)
int dead = 0; int dead = 0;
peasants = rpeasants(r); peasants = rpeasants(r);
dead = (int)(0.5F + PLAGUE_VICTIMS * peasants); dead = (int)(0.5 + PLAGUE_VICTIMS * peasants);
for (i = dead; i != 0; i--) { for (i = dead; i != 0; i--) {
if (rng_double() < PLAGUE_HEALCHANCE && rmoney(r) >= PLAGUE_HEALCOST) { if (rng_double() < PLAGUE_HEALCHANCE && rmoney(r) >= PLAGUE_HEALCOST) {
rsetmoney(r, rmoney(r) - PLAGUE_HEALCOST); rsetmoney(r, rmoney(r) - PLAGUE_HEALCOST);

View File

@ -25,9 +25,9 @@ extern "C" {
struct region; struct region;
/** Plagues **/ /** Plagues **/
#define PLAGUE_CHANCE 0.1F /* Seuchenwahrscheinlichkeit (siehe plagues()) */ #define PLAGUE_CHANCE 0.1 /* Seuchenwahrscheinlichkeit (siehe plagues()) */
#define PLAGUE_VICTIMS 0.2F /* % Betroffene */ #define PLAGUE_VICTIMS 0.2 /* % Betroffene */
#define PLAGUE_HEALCHANCE 0.25F /* Wahrscheinlichkeit Heilung */ #define PLAGUE_HEALCHANCE 0.25 /* Wahrscheinlichkeit Heilung */
#define PLAGUE_HEALCOST 30 /* Heilkosten */ #define PLAGUE_HEALCOST 30 /* Heilkosten */
void plagues(struct region *r); void plagues(struct region *r);
void encounters(void); void encounters(void);

View File

@ -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; int succ = 0;
/* attrib **a = a_find(*ap, &at_curse); */ /* 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 * auf alle Verzauberungen wirken. Ansonsten pruefe, ob der Curse vom
* richtigen Typ ist. */ * richtigen Typ ist. */
if (!c || c == c1) { if (!c || c == c1) {
float remain = destr_curse(c1, cast_level, force); double remain = destr_curse(c1, cast_level, force);
if (remain < force) { if (remain < force) {
succ = cast_level; succ = cast_level;
force = remain; force = remain;