forked from github/server
Merge pull request #467 from ennorehling/develop
prevent negative parents: manual merge, code cleanup
This commit is contained in:
commit
665a271972
1 changed files with 13 additions and 15 deletions
28
src/laws.c
28
src/laws.c
|
@ -710,22 +710,20 @@ 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 */
|
||||||
int peasants = rpeasants(r);
|
if (repopulate) {
|
||||||
int income = wage(r, NULL, NULL, turn) - maintenance_cost(NULL);
|
int peasants = rpeasants(r);
|
||||||
if (repopulate && r->land && (peasants < repopulate) && maxworkingpeasants(r) > (peasants + 30) * 2 && income >= 0) {
|
int income = wage(r, NULL, NULL, turn) - maintenance_cost(NULL) + 1;
|
||||||
int badunit = 0;
|
if (income >= 0 && r->land && (peasants < repopulate) && maxworkingpeasants(r) >(peasants + 30) * 2) {
|
||||||
unit *u;
|
int badunit = 0;
|
||||||
for (u = r->units; u; u = u->next) {
|
unit *u;
|
||||||
if (!playerrace(u_race(u)) || u_race(u) == get_race(RC_DAEMON)) {
|
for (u = r->units; u; u = u->next) {
|
||||||
badunit = 1;
|
if (!playerrace(u_race(u)) || u_race(u) == get_race(RC_DAEMON)) {
|
||||||
break;
|
badunit = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (badunit == 0) {
|
||||||
if (badunit == 0)
|
peasants += (int)(rng_double()*income);
|
||||||
{
|
|
||||||
int x = wage(r, NULL, NULL, turn) - 9;
|
|
||||||
if (x>0) {
|
|
||||||
peasants += (int)(rng_double()*x);
|
|
||||||
rsetpeasants(r, peasants);
|
rsetpeasants(r, peasants);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue