- Fix Bauernmigration, negative Bauern wandern nicht.

This commit is contained in:
Christian Schlittchen 2002-03-03 14:53:59 +00:00
parent 5d1676dd09
commit c42b27d211
1 changed files with 14 additions and 10 deletions

View File

@ -437,15 +437,17 @@ calculate_emigration(region *r)
{ {
direction_t i; direction_t i;
int overpopulation = rpeasants(r) - maxworkingpeasants(r); int overpopulation = rpeasants(r) - maxworkingpeasants(r);
int weight[MAXDIRECTIONS]; int weight[MAXDIRECTIONS], weightall;
int weightall = 0;
if(overpopulation <= 0) return;
weightall = 0;
for (i = 0; i != MAXDIRECTIONS; i++) { for (i = 0; i != MAXDIRECTIONS; i++) {
region *rc = rconnect(r,i); region *rc = rconnect(r,i);
int w; int w;
if (rc ==NULL || rterrain(rc) == T_OCEAN) { if (rc == NULL || rterrain(rc) == T_OCEAN) {
w = 0; w = 0;
} else { } else {
w = rpeasants(rc) - maxworkingpeasants(rc); w = rpeasants(rc) - maxworkingpeasants(rc);
@ -457,13 +459,15 @@ calculate_emigration(region *r)
weightall += w; weightall += w;
} }
if (weightall!=0) for (i = 0; i != MAXDIRECTIONS; i++) { if (weightall !=0 ) for (i = 0; i != MAXDIRECTIONS; i++) {
region *rc = rconnect(r,i); region *rc;
int wandering_peasants = (overpopulation * weight[i])/weightall; if((rc = rconnect(r,i)) != NULL) {
if (wandering_peasants==0 || rc==NULL) continue; int wandering_peasants = (overpopulation * weight[i])/weightall;
if (wandering_peasants > 0) {
r->land->newpeasants -= wandering_peasants; r->land->newpeasants -= wandering_peasants;
rc->land->newpeasants += wandering_peasants; rc->land->newpeasants += wandering_peasants;
}
}
} }
} }