forked from github/server
CID 22465 Division or modulo by zero
This commit is contained in:
parent
a02b5f343e
commit
978dd1400f
1 changed files with 17 additions and 16 deletions
|
@ -300,9 +300,8 @@ fighter *select_corpse(battle * b, fighter * af)
|
||||||
*
|
*
|
||||||
* Untote werden nicht ausgewählt (casualties, not dead) */
|
* Untote werden nicht ausgewählt (casualties, not dead) */
|
||||||
{
|
{
|
||||||
int si, di, maxcasualties = 0;
|
int si, maxcasualties = 0;
|
||||||
fighter *df;
|
fighter *df;
|
||||||
side *s;
|
|
||||||
|
|
||||||
for (si = 0; si != b->nsides; ++si) {
|
for (si = 0; si != b->nsides; ++si) {
|
||||||
side *s = b->sides + si;
|
side *s = b->sides + si;
|
||||||
|
@ -310,7 +309,9 @@ fighter *select_corpse(battle * b, fighter * af)
|
||||||
maxcasualties += s->casualties;
|
maxcasualties += s->casualties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
di = (int)(rng_int() % maxcasualties);
|
if (maxcasualties > 0) {
|
||||||
|
int di = (int)(rng_int() % maxcasualties);
|
||||||
|
side *s;
|
||||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||||
for (df = s->fighters; df; df = df->next) {
|
for (df = s->fighters; df; df = df->next) {
|
||||||
/* Geflohene haben auch 0 hp, dürfen hier aber nicht ausgewählt
|
/* Geflohene haben auch 0 hp, dürfen hier aber nicht ausgewählt
|
||||||
|
@ -327,7 +328,7 @@ fighter *select_corpse(battle * b, fighter * af)
|
||||||
di -= dead;
|
di -= dead;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue