From b37ebbbde3d583578efd80df58598ce5827994d7 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 17 May 2008 08:50:56 +0200 Subject: [PATCH] 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(). --- src/lib/update/human.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/update/human.c b/src/lib/update/human.c index 1a7b1c5f..fea35ade 100644 --- a/src/lib/update/human.c +++ b/src/lib/update/human.c @@ -192,9 +192,9 @@ famine_victims(short *vec, int etu) { double can_eat = vec[I_FOOD] / (etu * eatrate); int people = vec[I_CIVIL] + vec[I_MILIT] + vec[I_UW]; - if (people < can_eat) + if (people <= can_eat) return 0; - if (can_eat < people / 2) + if (can_eat <= people / 2) return people / 2; return (int)(people - can_eat); }