log10(0) ist nicht erlaubt.

This commit is contained in:
Enno Rehling 2005-04-25 17:44:19 +00:00
parent 20c9112b07
commit 21fcb3d167
4 changed files with 18 additions and 9 deletions

View File

@ -67,9 +67,10 @@
#include <language.h>
/* libc includes */
#include <assert.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>

View File

@ -1246,12 +1246,15 @@ count_migrants (const faction * f)
int
count_maxmigrants(const faction * f)
{
int x = 0;
if (old_race(f->race) == RC_HUMAN) {
x = (int)(log10(count_all(f) / 50.0) * 20);
if (x < 0) x = 0;
}
return x;
int x = 0;
if (old_race(f->race) == RC_HUMAN) {
int nsize = count_all(f);
if (nsize>0) {
x = (int)(log10(nsize / 50.0) * 20);
if (x < 0) x = 0;
}
}
return x;
}
/*------------------------------------------------------------------*/

View File

@ -1136,8 +1136,12 @@ unitlist_insert(struct unit_list **ul, struct unit *u)
int
maxheroes(const struct faction * f)
{
int nmax = (int)(log10(count_all(f) / 50.0) * 20);
return (nmax<0)?0:nmax;
int nsize = count_all(f);
if (nsize==0) return 0;
else {
int nmax = (int)(log10(nsize / 50.0) * 20);
return (nmax<0)?0:nmax;
}
}
int

View File

@ -25,6 +25,7 @@
/* util includes */
#include <util/base36.h>
#include <util/sql.h>
#include <util/goodies.h>
#include <util/sql.h>