a littl code cleanup related to peasant growth
This commit is contained in:
Enno Rehling 2005-12-31 14:23:09 +00:00
parent 40b5fa20be
commit c7fe0c33ca
6 changed files with 22 additions and 45 deletions

View File

@ -523,62 +523,45 @@ calculate_emigration(region *r)
} }
#endif #endif
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ /** Bauern vermehren sich */
static void static void
peasants(region * r) peasants(region * r)
{ {
int glueck = 0;
int glueck; int peasants = rpeasants(r);
int money = rmoney(r);
/* Das Geld, daß die Bauern erwirtschaftet haben unter expandwork, gibt int maxp = production(r) * MAXPEASANTS_PER_AREA;
* den Bauern genug für 11 Bauern pro Ebene ohne Wald. Der Wald int n, satiated;
* breitet sich nicht in Gebiete aus, die bebaut werden. */ int dead = 0;
attrib * a = a_find(r->attribs, &at_peasantluck);
int peasants, n, i, satiated, money;
#if PEASANTS_DO_NOT_STARVE == 0
int dead;
#endif
attrib * a;
/* Bauern vermehren sich */
/* Bis zu 1000 Bauern können Zwillinge bekommen oder 1000 Bauern /* Bis zu 1000 Bauern können Zwillinge bekommen oder 1000 Bauern
* wollen nicht! */ * wollen nicht! */
a = a_find(r->attribs, &at_peasantluck); if (a!=NULL) {
if (!a) {
glueck = 0;
} else {
glueck = a->data.i * 1000; glueck = a->data.i * 1000;
} }
peasants = rpeasants(r);
for (n = peasants; n; n--) { for (n = peasants; n; n--) {
int i;
if (glueck >= 0) { /* Sonst keine Vermehrung */ if (glueck >= 0) { /* Sonst keine Vermehrung */
if (rand() % 10000 < PEASANTGROWTH) { if (rand() % 10000 < PEASANTGROWTH) {
if ((float) peasants if (peasants/(float)maxp < 0.9 || rand() % 100 < PEASANTFORCE) {
/ ((float) production(r) * MAXPEASANTS_PER_AREA) ++peasants;
< 0.9 || rand() % 100 < PEASANTFORCE) {
peasants++;
} }
} }
} else --glueck;
glueck++; }
if (glueck > 0) { /* Doppelvermehrung */ for (i=0; i!=PEASANTLUCK; i++) {
for(i=0; i<PEASANTLUCK; i++) { if (rand() % 10000 < PEASANTGROWTH) ++peasants;
if (rand() % 10000 < PEASANTGROWTH)
peasants++;
}
glueck--;
} }
} }
/* Alle werden satt, oder halt soviele für die es auch Geld gibt */ /* Alle werden satt, oder halt soviele für die es auch Geld gibt */
money = rmoney(r);
satiated = min(peasants, money / maintenance_cost(NULL)); satiated = min(peasants, money / maintenance_cost(NULL));
rsetmoney(r, money - satiated * maintenance_cost(NULL)); rsetmoney(r, money - satiated * maintenance_cost(NULL));
@ -588,18 +571,15 @@ peasants(region * r)
/* Es verhungert maximal die unterernährten Bevölkerung. */ /* Es verhungert maximal die unterernährten Bevölkerung. */
#if PEASANTS_DO_NOT_STARVE == 0 for (n = min((peasants - satiated), rpeasants(r)); n; n--) {
dead = 0; if (rand() % 100 > STARVATION_SURVIVAL) ++dead;
for (n = min((peasants - satiated), rpeasants(r)); n; n--) }
if (rand() % 100 > STARVATION_SURVIVAL)
dead++;
if(dead > 0) { if (dead > 0) {
message * msg = add_message(&r->msgs, msg_message("phunger", "dead", dead)); message * msg = add_message(&r->msgs, msg_message("phunger", "dead", dead));
msg_release(msg); msg_release(msg);
peasants -= dead; peasants -= dead;
} }
#endif
rsetpeasants(r, peasants); rsetpeasants(r, peasants);
} }

View File

@ -25,7 +25,6 @@
#define RESOURCE_QUANTITY 0.5 #define RESOURCE_QUANTITY 0.5
#define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ #define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */
#define COMBAT_TURNS 5 #define COMBAT_TURNS 5
#define PEASANTS_DO_NOT_STARVE 0
#define NEW_MIGRATION 1 #define NEW_MIGRATION 1
#define ASTRAL_HUNGER #define ASTRAL_HUNGER
#define NEWATSROI 0 #define NEWATSROI 0

View File

@ -25,7 +25,6 @@
#define RESOURCE_QUANTITY 0.5 #define RESOURCE_QUANTITY 0.5
#define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ #define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */
#define COMBAT_TURNS 5 #define COMBAT_TURNS 5
#define PEASANTS_DO_NOT_STARVE 0
#define NEW_MIGRATION 1 #define NEW_MIGRATION 1
#define ASTRAL_HUNGER #define ASTRAL_HUNGER
#define NEWATSROI 0 #define NEWATSROI 0

View File

@ -26,7 +26,6 @@
#define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ #define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */
#define NEWATSROI 0 #define NEWATSROI 0
#define COMBAT_TURNS 5 #define COMBAT_TURNS 5
#define PEASANTS_DO_NOT_STARVE 0
#define NEW_MIGRATION 1 #define NEW_MIGRATION 1
/* Vermehrungsrate Bauern in 1/10000. /* Vermehrungsrate Bauern in 1/10000.

View File

@ -25,7 +25,6 @@
#define RESOURCE_QUANTITY 0.5 #define RESOURCE_QUANTITY 0.5
#define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */ #define RECRUITFRACTION 40 /* 100/RECRUITFRACTION% */
#define COMBAT_TURNS 5 #define COMBAT_TURNS 5
#define PEASANTS_DO_NOT_STARVE 0
#define NEW_MIGRATION 1 #define NEW_MIGRATION 1
#define ASTRAL_HUNGER #define ASTRAL_HUNGER

View File

@ -17,6 +17,7 @@ Code cleanup:
- give monsters name with lua - give monsters name with lua
- kick init_oldherbs out (good for terrain) - kick init_oldherbs out (good for terrain)
- allocators aus economy nach XML - allocators aus economy nach XML
- reporting units: http://eressea.upb.de/mantis/view.php?id=781
Larger Features: Larger Features:
- eressea (b/g)zip reports? - eressea (b/g)zip reports?