From d38a2d28d3158f337f310ee27d160909e2ec6df5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 12 Feb 2010 04:39:28 +0000 Subject: [PATCH] friendly transfer of owners fixed. Issue: 1704 --- src/common/gamecode/economy.c | 5 +++-- src/common/kernel/eressea.c | 2 +- src/common/kernel/region.c | 13 ++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 290ffd9d6..4c5770bad 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -634,7 +634,8 @@ recruit(unit * u, struct order * ord, request ** recruitorders) addlist(recruitorders, o); } -static void apply_owner_change(region * r, faction * f) +static void +friendly_takeover(region * r, faction * f) { int morale = region_get_morale(r); region_set_owner(r, f, turn); @@ -653,7 +654,7 @@ give_control(unit * u, unit * u2) if (f==u->faction) { building * b = largestbuilding(r, &cmp_current_owner, false); if (b==u->building) { - apply_owner_change(r, u2->faction); + friendly_takeover(r, u2->faction); } } } diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index a52b4f263..446c8ed81 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -2688,7 +2688,7 @@ cmp_current_owner(const building * b, const building * a) int oldsize = buildingeffsize(a, false); double oldtaxes = a->type->taxes(a, oldsize); - if (newtaxes!=oldtaxes) return (int)(newtaxes-oldtaxes); + if (newtaxes!=oldtaxes) return (newtaxes>oldtaxes)?1:-1; if (newsize!=oldsize) return newsize-oldsize; return (b->size-a->size); } else { diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 0930ff788..d0dacb74a 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -1464,11 +1464,6 @@ region_set_owner(struct region * r, struct faction * owner, int turn) region_set_morale(r, MORALE_DEFAULT, turn); r->land->ownership->owner = NULL; r->land->ownership->flags = 0; - } else if (r->land->ownership->owner) { - region_set_morale(r, MORALE_TAKEOVER, turn); - r->land->ownership->flags |= OWNER_MOURNING; - } else { - r->land->ownership->flags &= ~OWNER_MOURNING; } r->land->ownership->since_turn = turn; assert(r->land->ownership->owner != owner); @@ -1492,14 +1487,22 @@ faction * update_owners(region * r) if (u==NULL) { if (f) { region_set_owner(r, NULL, turn); + r->land->ownership->flags |= OWNER_MOURNING; f = NULL; } } else if (u->faction!=f) { region_set_owner(r, u->faction, turn); + if (f) { + region_set_morale(r, MORALE_TAKEOVER, turn); + r->land->ownership->flags |= OWNER_MOURNING; + } else { + r->land->ownership->flags &= ~OWNER_MOURNING; + } f = u->faction; } } } else if (r->land->ownership && r->land->ownership->owner) { + r->land->ownership->flags |= OWNER_MOURNING; region_set_owner(r, NULL, turn); f = NULL; }