From 21fcb3d16707a1577bfaae3de183502e69fa383b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 25 Apr 2005 17:44:19 +0000 Subject: [PATCH] log10(0) ist nicht erlaubt. --- src/common/gamecode/creport.c | 3 ++- src/common/kernel/eressea.c | 15 +++++++++------ src/common/kernel/unit.c | 8 ++++++-- src/common/modules/autoseed.c | 1 + 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index a9f299141..00b8f8053 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -67,9 +67,10 @@ #include /* libc includes */ +#include +#include #include #include -#include #include #include diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 29b72d592..2f648ab0a 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -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; } /*------------------------------------------------------------------*/ diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c index 68fc27be5..d6ef0e171 100644 --- a/src/common/kernel/unit.c +++ b/src/common/kernel/unit.c @@ -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 diff --git a/src/common/modules/autoseed.c b/src/common/modules/autoseed.c index a2430e0ee..8ab04c7c9 100644 --- a/src/common/modules/autoseed.c +++ b/src/common/modules/autoseed.c @@ -25,6 +25,7 @@ /* util includes */ #include +#include #include #include