From 7ebfdb07475cd15b9d7a461f26f6f57cdcd4b335 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 31 Jan 2016 22:10:37 +0100 Subject: [PATCH 1/3] manually smooth out a merge of two commits trying to do the same thing. prevent negative parents https://bugs.eressea.de/view.php?id=2183 --- src/laws.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/laws.c b/src/laws.c index 8b2f781c3..d0239e862 100755 --- a/src/laws.c +++ b/src/laws.c @@ -710,21 +710,19 @@ void immigration(void) } /* Genereate some (0-6 depending on the income) peasants out of nothing */ /* if less than 50 are in the region and there is space and no monster or demon units in the region */ - int peasants = rpeasants(r); - int income = wage(r, NULL, NULL, turn) - maintenance_cost(NULL); - if (repopulate && r->land && (peasants < repopulate) && maxworkingpeasants(r) > (peasants + 30) * 2 && income >= 0) { - int badunit = 0; - unit *u; - for (u = r->units; u; u = u->next) { - if (!playerrace(u_race(u)) || u_race(u) == get_race(RC_DAEMON)) { - badunit = 1; - break; + if (repopulate) { + int peasants = rpeasants(r); + int income = wage(r, NULL, NULL, turn) - maintenance_cost(NULL); + if (income >= 0 && r->land && (peasants < repopulate) && maxworkingpeasants(r) >(peasants + 30) * 2) { + int badunit = 0; + unit *u; + for (u = r->units; u; u = u->next) { + if (!playerrace(u_race(u)) || u_race(u) == get_race(RC_DAEMON)) { + badunit = 1; + break; + } } - } - if (badunit == 0) - { - int x = wage(r, NULL, NULL, turn) - 9; - if (x>0) { + if (badunit == 0) { peasants += (int)(rng_double()*x); rsetpeasants(r, peasants); } From ca81dadedbc0ac1ac17f971d11d8b44f58829ff0 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 31 Jan 2016 22:12:08 +0100 Subject: [PATCH 2/3] missed a spot! --- src/laws.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laws.c b/src/laws.c index d0239e862..c3be6f136 100755 --- a/src/laws.c +++ b/src/laws.c @@ -723,7 +723,7 @@ void immigration(void) } } if (badunit == 0) { - peasants += (int)(rng_double()*x); + peasants += (int)(rng_double()*income); rsetpeasants(r, peasants); } } From ba39fc9284357d3c6d20df17875321f0d23a8629 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 31 Jan 2016 22:17:55 +0100 Subject: [PATCH 3/3] I'm really bad at reading. Fixed! --- src/laws.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laws.c b/src/laws.c index c3be6f136..eb079b8ac 100755 --- a/src/laws.c +++ b/src/laws.c @@ -712,7 +712,7 @@ void immigration(void) /* if less than 50 are in the region and there is space and no monster or demon units in the region */ if (repopulate) { int peasants = rpeasants(r); - int income = wage(r, NULL, NULL, turn) - maintenance_cost(NULL); + int income = wage(r, NULL, NULL, turn) - maintenance_cost(NULL) + 1; if (income >= 0 && r->land && (peasants < repopulate) && maxworkingpeasants(r) >(peasants + 30) * 2) { int badunit = 0; unit *u;