From 52ac81707ba877fa0574c1b1c3f35349970e8f1f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 22 May 2006 20:27:55 +0000 Subject: [PATCH] http://eressea.upb.de/mantis/view.php?id=912 - leave no child behind (rounding error in peasants) --- src/common/gamecode/laws.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 7140ac861..b1b7ff8f7 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -553,9 +553,14 @@ peasants(region * r) if (peasants>0) { int glueck = 0; - int births = (int)(0.5F + peasants * 0.0001F * PEASANTGROWTH); + double fraction = peasants * 0.0001F * PEASANTGROWTH; + int births = (int)fraction; attrib * a = a_find(r->attribs, &at_peasantluck); + if (rng_double()<(fraction-births)) { + /* because we don't want regions that never grow pga. rounding. */ + ++births; + } if (a!=NULL) { glueck = a->data.i * 1000; }