region owners always feed friends first.

This commit is contained in:
Enno Rehling 2009-07-10 16:52:16 +00:00
parent 51d8232998
commit bfcba5e94e
3 changed files with 43 additions and 22 deletions

View file

@ -1142,13 +1142,6 @@ cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
fprintf(F, "\"%s\";Terrain\n", add_translation(tname, locale_string(f->locale, tname)));
if (sr->mode!=see_unit) fprintf(F, "\"%s\";visibility\n", visibility[sr->mode]);
{
faction * owner = region_get_owner(r);
if (owner) {
fprintf(F, "%d;owner\n", owner->no);
}
}
if (sr->mode == see_neighbour) {
cr_borders(ctx->seen, r, f, sr->mode, F);
} else {
@ -1167,6 +1160,10 @@ cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
fprintf(F, "%d;Pferde\n", rhorses(r));
if (sr->mode>=see_unit) {
faction * owner = region_get_owner(r);
if (owner) {
fprintf(F, "%d;owner\n", owner->no);
}
fprintf(F, "%d;Silber\n", rmoney(r));
if (skill_enabled[SK_ENTERTAINMENT]) {
fprintf(F, "%d;Unterh\n", entertainmoney(r));

View file

@ -179,6 +179,7 @@ checkorders(void)
if (!is_monsters(f) && turn - f->lastorders == NMRTimeout() - 1)
ADDMSG(&f->msgs, msg_message("turnreminder", ""));
}
static boolean
help_money(const unit * u)
{
@ -186,6 +187,22 @@ help_money(const unit * u)
return false;
}
static void
help_feed(unit * donor, unit * u, int * need_p)
{
int need = *need_p;
int give = get_money(donor) - lifestyle(donor);
give = MIN(need, give);
if (give>0) {
change_money(donor, -give);
change_money(u, give);
need -= give;
add_spende(donor->faction, u->faction, give, donor->region);
}
*need_p = need;
}
static void
get_food(region *r)
{
@ -193,6 +210,11 @@ get_food(region *r)
unit *u;
int peasantfood = rpeasants(r)*10;
faction * owner = region_get_owner(r);
static int food_rules = -1;
if (food_rules<0) {
food_rules = get_param_int(global.parameters, "rules.economy.food", 0);
}
/* 1. Versorgung von eigenen Einheiten. Das vorhandene Silber
* wird zunächst so auf die Einheiten aufgeteilt, dass idealerweise
@ -200,18 +222,13 @@ get_food(region *r)
for (u = r->units; u; u = u->next) {
int need = lifestyle(u);
static int food_rules = -1;
if (food_rules<0) {
food_rules = get_param_int(global.parameters, "rules.economy.food", 0);
}
/* Erstmal zurücksetzen */
freset(u, UFL_HUNGER);
if (food_rules&1) {
/* if the region is owned, and the owner is nice, then we'll get
* food from the peasants */
* food from the peasants - should not be used with WORK */
if (owner!=NULL && (get_alliance(owner, u->faction) & HELP_MONEY)) {
int rm = rmoney(r);
int use = MIN(rm, need);
@ -249,17 +266,23 @@ get_food(region *r)
if (need > 0) {
unit *v;
if (food_rules&2) {
/* the owner of the region is the first faction to help out when you're hungry */
if (r->land->ownership) {
faction * owner = r->land->ownership->owner;
if (owner && owner!=u->faction) {
for (v=r->units;v;v=v->next) {
if (v->faction==owner) break;
}
if (v) {
help_feed(v, u, &need);
}
}
}
}
for (v = r->units; need && v; v = v->next) {
if (v->faction != f && alliedunit(v, f, HELP_MONEY) && help_money(v)) {
int give = get_money(v) - lifestyle(v);
give = MIN(need, give);
if (give>0) {
change_money(v, -give);
change_money(u, give);
need -= give;
add_spende(v->faction, u->faction, give, r);
}
help_feed(v, u, &need);
}
}

View file

@ -160,6 +160,7 @@
<param name="rules.magic.elfpower" value="1"/> <!-- elves get ring-of-power bonus in a forest -->
<param name="rules.magic.playerschools" value="gwyrrd illaun draig cerddor"/>
<param name="rules.economy.taxation" value="1"/>
<param name="rules.economy.food" value="2"/>
<param name="rules.economy.wages" value="1"/>
<param name="rules.economy.roqf" value="5"/>
<param name="rules.economy.herbrot" value="0"/>