diff --git a/src/kernel/item.c b/src/kernel/item.c index e484e6c35..190e461f2 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -568,11 +568,15 @@ struct order *ord) { if (d == NULL) { int use = use_pooled(s, item2resource(itype), GET_SLACK, n); - if (use < n) + region *r = s->region; + if (use < n) { use += use_pooled(s, item2resource(itype), GET_RESERVE | GET_POOLED_SLACK, n - use); - rsethorses(s->region, rhorses(s->region) + use); + } + if (r->land) { + rsethorses(r, rhorses(r) + use); + } return 0; } return -1; /* use the mechanism */ @@ -584,12 +588,14 @@ struct order *ord) { if (d == NULL) { int use = use_pooled(s, item2resource(itype), GET_SLACK, n); - if (use < n) + region *r = s->region; + if (use < n) { use += use_pooled(s, item2resource(itype), GET_RESERVE | GET_POOLED_SLACK, n - use); - if (s->region->land) { - rsetmoney(s->region, rmoney(s->region) + use); + } + if (r->land) { + rsetmoney(r, rmoney(r) + use); } return 0; } diff --git a/src/kernel/region.c b/src/kernel/region.c index 5a58632e6..80a87552e 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -633,8 +633,9 @@ int rhorses(const region * r) void rsetmoney(region * r, int value) { + assert(r->land || value==0); + assert(value >= 0); if (r->land) { - assert(value >= 0); r->land->money = value; } } @@ -646,8 +647,9 @@ int rherbs(const struct region *r) void rsetherbs(const struct region *r, int value) { + assert(r->land || value==0); + assert(value >= 0); if (r->land) { - assert(value >= 0); r->land->herbs = (short)(value); } } diff --git a/src/laws.c b/src/laws.c index 30bcbf096..5c2bddd55 100755 --- a/src/laws.c +++ b/src/laws.c @@ -721,9 +721,13 @@ void immigration(void) break; } } - if (badunit == 0) { - peasants += (int)(rng_double() * (income + 1)); - rsetpeasants(r, peasants); + if (badunit == 0) + { + int x = wage(r, NULL, NULL, turn) - 9; + if (x>0) { + peasants += (int)(rng_double()*x); + rsetpeasants(r, peasants); + } } } }