From 921add5ac1db9ce611ad54f7662a3dc874cdabda Mon Sep 17 00:00:00 2001 From: Christian Schlittchen Date: Sun, 24 Feb 2002 19:29:21 +0000 Subject: [PATCH] - Neue Wanderungsroutine. Einfacher. Ansehen! --- src/common/gamecode/laws.c | 43 ++++++++++++++++++++++++++++++++++- src/common/settings-eressea.h | 1 + 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 7163e65dc..3026fe167 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -425,6 +425,46 @@ live(region * r) * - movement because of low loyalty relating to present parties. */ +#if NEW_MIGRATION == 1 + +/* Arbeitsversion */ + +void +calculate_emigration(region *r) +{ + direction_t i; + int overpopulation = rpeasants(r) - maxworkingpeasants(r); + int weight[MAXDIRECTIONS]; + int weightall = 0; + + + for (i = 0; i != MAXDIRECTIONS; i++) { + region *rc = rconnect(r,i); + int w; + + if(rterrain(rc) == T_OCEAN) { + w = 0; + } else { + w = rpeasants(rc) - maxworkingpeasants(rc); + } + + if(rterrain(rc) == T_VOLCANO || rterrain(rc) == T_VOLCANO_SMOKING) { + w = w/10; + } + weight[i] = w; + weightall += w; + } + + for (i = 0; i != MAXDIRECTIONS; i++) { + region *rc = rconnect(r,i); + int wandering_peasants = (overpopulation * weight[i])/weightall; + + r->land->newpeasants -= wandering_peasants; + rc->land->newpeasants += wandering_peasants; + } +} + +#else void calculate_emigration(region *r) { @@ -487,7 +527,7 @@ calculate_emigration(region *r) } } - wandering_peasants = (int) (rpeasants(r) * (gfactor + wfactor) + wandering_peasants = (int) (rpeasants(r) * (gfactor+wfactor) * vfactor * PEASANTSWANDER_WEIGHT / 100.0); r->land->newpeasants -= wandering_peasants; @@ -496,6 +536,7 @@ calculate_emigration(region *r) } } } +#endif /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ diff --git a/src/common/settings-eressea.h b/src/common/settings-eressea.h index 449bcd2bf..d58132916 100644 --- a/src/common/settings-eressea.h +++ b/src/common/settings-eressea.h @@ -26,3 +26,4 @@ #define TEACHDIFFERENCE 2 #define PEASANT_ADJUSTMENT 1 #define SKILLPOINTS 0 +#define NEW_MIGRATION 1