From bfcba5e94ee6bde9db93b96eccaad743241aefaa Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 10 Jul 2009 16:52:16 +0000 Subject: [PATCH] region owners always feed friends first. --- src/common/gamecode/creport.c | 11 +++----- src/common/gamecode/laws.c | 53 +++++++++++++++++++++++++---------- src/res/e3a.xml | 1 + 3 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index 6219b0b2c..16b0b39c9 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -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)); diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index 7ca607a89..a3561240d 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -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); } } diff --git a/src/res/e3a.xml b/src/res/e3a.xml index 7d61daf0e..cb058de5c 100644 --- a/src/res/e3a.xml +++ b/src/res/e3a.xml @@ -160,6 +160,7 @@ +