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
This commit is contained in:
Enno Rehling 2016-01-31 22:10:37 +01:00
parent 4683e122fc
commit 7ebfdb0747
1 changed files with 12 additions and 14 deletions

View File

@ -710,9 +710,10 @@ void immigration(void)
} }
/* Genereate some (0-6 depending on the income) peasants out of nothing */ /* 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 */ /* 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 peasants = rpeasants(r);
int income = wage(r, NULL, NULL, turn) - maintenance_cost(NULL); int income = wage(r, NULL, NULL, turn) - maintenance_cost(NULL);
if (repopulate && r->land && (peasants < repopulate) && maxworkingpeasants(r) > (peasants + 30) * 2 && income >= 0) { if (income >= 0 && r->land && (peasants < repopulate) && maxworkingpeasants(r) >(peasants + 30) * 2) {
int badunit = 0; int badunit = 0;
unit *u; unit *u;
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
@ -721,10 +722,7 @@ void immigration(void)
break; break;
} }
} }
if (badunit == 0) if (badunit == 0) {
{
int x = wage(r, NULL, NULL, turn) - 9;
if (x>0) {
peasants += (int)(rng_double()*x); peasants += (int)(rng_double()*x);
rsetpeasants(r, peasants); rsetpeasants(r, peasants);
} }