Merge remote-tracking branch 'eressea/master'

This commit is contained in:
Enno Rehling 2014-12-20 21:37:14 +01:00
commit 4018aa2dfe
3 changed files with 36 additions and 9 deletions

View File

@ -103,6 +103,7 @@
<param name="rules.guard.guard_number_stop_prob" value="0.001"/> <param name="rules.guard.guard_number_stop_prob" value="0.001"/>
<param name="rules.guard.castle_stop_prob" value="0.05"/> <param name="rules.guard.castle_stop_prob" value="0.05"/>
<param name="rules.guard.region_type_stop_prob" value="0.05"/> <param name="rules.guard.region_type_stop_prob" value="0.05"/>
<param name="rules.economy.repopulate_maximum" value="500"/>
<param name="game.id" value="2"/> <param name="game.id" value="2"/>
<param name="game.name" value="Eressea"/> <param name="game.name" value="Eressea"/>
</game> </game>

View File

@ -674,6 +674,39 @@ growing_herbs(region * r, const int current_season, const int last_weeks_season)
} }
} }
void immigration(void)
{
region *r;
log_info(" - Einwanderung...");
int repopulate=get_param_int(global.parameters, "rules.economy.repopulate_maximum", 90);
for (r = regions; r; r = r->next) {
if (r->land && r->land->newpeasants) {
int rp = rpeasants(r) + r->land->newpeasants;
rsetpeasants(r, _max(0, rp));
}
/* Genereate some (0-2 to 0-6 depending on the income) peasants out of nothing */
/*if less then 50 are in the region and there is space and no monster or deamon units in the region */
int peasants = rpeasants(r);
if (repopulate && r->land && (peasants < repopulate) && maxworkingpeasants(r) > (peasants+30)*2)
{
int badunit = 0;
unit *u;
for (u = r->units; u; u = u->next) {
if (!playerrace(u_race(u)) || u_race(u) == get_race(RC_DAEMON))
{
badunit = 1;
break;
}
}
if (badunit == 0)
{
peasants += (int)(rng_double()*(wage(r, NULL, NULL, turn) - 9));
rsetpeasants(r, peasants);
}
}
}
}
void demographics(void) void demographics(void)
{ {
region *r; region *r;
@ -748,15 +781,7 @@ void demographics(void)
}; };
remove_empty_units(); remove_empty_units();
immigration();
log_info(" - Einwanderung...");
for (r = regions; r; r = r->next) {
if (r->land && r->land->newpeasants) {
int rp = rpeasants(r) + r->land->newpeasants;
rsetpeasants(r, _max(0, rp));
}
}
checkorders(); checkorders();
} }

View File

@ -34,6 +34,7 @@ extern "C" {
int writepasswd(void); int writepasswd(void);
void demographics(void); void demographics(void);
void immigration(void);
void update_guards(void); void update_guards(void);
void update_subscriptions(void); void update_subscriptions(void);
void deliverMail(struct faction *f, struct region *r, struct unit *u, void deliverMail(struct faction *f, struct region *r, struct unit *u,