Fix starvation not to starve one more than it should

Commit 109dad1b (v4.3.5) promised to round victim fractions down, but
got it wrong for odd population when exactly half of it rounded down
could be fed.  This could starve the last man on a boat or land unit.
Fix famine_victims().
This commit is contained in:
Markus Armbruster 2008-05-17 08:50:56 +02:00
parent 9a7628f05b
commit b37ebbbde3

View file

@ -192,9 +192,9 @@ famine_victims(short *vec, int etu)
{ {
double can_eat = vec[I_FOOD] / (etu * eatrate); double can_eat = vec[I_FOOD] / (etu * eatrate);
int people = vec[I_CIVIL] + vec[I_MILIT] + vec[I_UW]; int people = vec[I_CIVIL] + vec[I_MILIT] + vec[I_UW];
if (people < can_eat) if (people <= can_eat)
return 0; return 0;
if (can_eat < people / 2) if (can_eat <= people / 2)
return people / 2; return people / 2;
return (int)(people - can_eat); return (int)(people - can_eat);
} }