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
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
/** Bauern vermehren sich */
static void
peasants(region * r)
{
int glueck;
/* Das Geld, daß die Bauern erwirtschaftet haben unter expandwork, gibt
* den Bauern genug für 11 Bauern pro Ebene ohne Wald. Der Wald
* breitet sich nicht in Gebiete aus, die bebaut werden. */
int peasants, n, i, satiated, money;
#if PEASANTS_DO_NOT_STARVE == 0
int dead;
#endif
attrib * a;
/* Bauern vermehren sich */
int glueck = 0;
int peasants = rpeasants(r);
int money = rmoney(r);
int maxp = production(r) * MAXPEASANTS_PER_AREA;
int n, satiated;
int dead = 0;
attrib * a = a_find(r->attribs, &at_peasantluck);
/* Bis zu 1000 Bauern können Zwillinge bekommen oder 1000 Bauern
* wollen nicht! */
a = a_find(r->attribs, &at_peasantluck);
if (!a) {
glueck = 0;
} else {
if (a!=NULL) {
glueck = a->data.i * 1000;
}
peasants = rpeasants(r);
for (n = peasants; n; n--) {
int i;
if (glueck >= 0) { /* Sonst keine Vermehrung */
if (rand() % 10000 < PEASANTGROWTH) {
if ((float) peasants
/ ((float) production(r) * MAXPEASANTS_PER_AREA)
< 0.9 || rand() % 100 < PEASANTFORCE) {
peasants++;
if (peasants/(float)maxp < 0.9 || rand() % 100 < PEASANTFORCE) {
++peasants;
}
}
} else
glueck++;
--glueck;
}
if (glueck > 0) { /* Doppelvermehrung */
for(i=0; i<PEASANTLUCK; i++) {
if (rand() % 10000 < PEASANTGROWTH)
peasants++;
}
glueck--;
for (i=0; i!=PEASANTLUCK; i++) {
if (rand() % 10000 < PEASANTGROWTH) ++peasants;
}
}
/* Alle werden satt, oder halt soviele für die es auch Geld gibt */
money = rmoney(r);
satiated = min(peasants, money / 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. */
#if PEASANTS_DO_NOT_STARVE == 0
dead = 0;
for (n = min((peasants - satiated), rpeasants(r)); n; n--)
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));
msg_release(msg);
peasants -= dead;
}
#endif
rsetpeasants(r, peasants);
}

View File

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

View File

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

View File

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

View File

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

View File

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