fix -Wconversion in battle.c

This commit is contained in:
Enno Rehling 2015-05-15 08:02:54 +02:00
parent d2af6a2f88
commit ca585de332
1 changed files with 15 additions and 15 deletions

View File

@ -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()); float force = (float)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);
} }
@ -2965,19 +2965,19 @@ static void print_header(battle * b)
side *s; side *s;
char *bufp = zText; char *bufp = zText;
size_t size = sizeof(zText) - 1; size_t size = sizeof(zText) - 1;
int bytes; size_t bytes;
for (s = b->sides; s != b->sides + b->nsides; ++s) { for (s = b->sides; s != b->sides + b->nsides; ++s) {
fighter *df; fighter *df;
for (df = s->fighters; df; df = df->next) { for (df = s->fighters; df; df = df->next) {
if (is_attacker(df)) { if (is_attacker(df)) {
if (first) { if (first) {
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();
} }
if (lastf) { if (lastf) {
bytes = (int)strlcpy(bufp, (const char *)lastf, size); bytes = strlcpy(bufp, (const char *)lastf, size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
first = true; first = true;
@ -2991,18 +2991,18 @@ static void print_header(battle * b)
} }
} }
if (first) { if (first) {
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();
bytes = (int)strlcpy(bufp, (const char *)LOC(f->locale, "and"), size); bytes = strlcpy(bufp, (const char *)LOC(f->locale, "and"), size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
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();
} }
if (lastf) { if (lastf) {
bytes = (int)strlcpy(bufp, (const char *)lastf, size); bytes = strlcpy(bufp, (const char *)lastf, size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
@ -3348,7 +3348,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
} }
assert(w >= 0); assert(w >= 0);
fig->weapons = (weapon *)calloc(sizeof(weapon), (size_t)(w + 1)); fig->weapons = (weapon *)calloc(sizeof(weapon), (size_t)(w + 1));
memcpy(fig->weapons, weapons, (size_t)(w * sizeof(weapon))); memcpy(fig->weapons, weapons, (size_t)w * sizeof(weapon));
for (i = 0; i != w; ++i) { for (i = 0; i != w; ++i) {
int j, o = 0, d = 0; int j, o = 0, d = 0;
@ -3717,7 +3717,7 @@ static int battle_report(battle * b)
faction *fac = bf->faction; faction *fac = bf->faction;
char buf[32 * MAXSIDES]; char buf[32 * MAXSIDES];
char *bufp = buf; char *bufp = buf;
int bytes; size_t bytes;
size_t size = sizeof(buf) - 1; size_t size = sizeof(buf) - 1;
message *m; message *m;
@ -3740,32 +3740,32 @@ static int battle_report(battle * b)
char buffer[32]; char buffer[32];
if (komma) { if (komma) {
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();
} }
slprintf(buffer, sizeof(buffer), "%s %2d(%s): ", slprintf(buffer, sizeof(buffer), "%s %2d(%s): ",
loc_army, army_index(s), abbrev); loc_army, army_index(s), abbrev);
bytes = (int)strlcpy(bufp, buffer, size); bytes = strlcpy(bufp, buffer, size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
for (r = FIGHT_ROW; r != NUMROWS; ++r) { for (r = FIGHT_ROW; r != NUMROWS; ++r) {
if (alive[r]) { if (alive[r]) {
if (l != FIGHT_ROW) { if (l != FIGHT_ROW) {
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();
} }
while (k--) { while (k--) {
bytes = (int)strlcpy(bufp, "0+", size); bytes = strlcpy(bufp, "0+", size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
} }
sprintf(buffer, "%d", alive[r]); sprintf(buffer, "%d", alive[r]);
bytes = (int)strlcpy(bufp, buffer, size); bytes = strlcpy(bufp, buffer, size);
if (wrptr(&bufp, &size, bytes) != 0) if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();