From 3a74778bba66d674a3fd74e2106976839b625557 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 22 Jul 2009 17:55:32 +0000 Subject: [PATCH] Fix taxes with non-taxing buildings. --- src/common/gamecode/economy.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index dd3dd941c..8a8c0db91 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -3210,6 +3210,33 @@ auto_work(region * r) } } +static building * +taxbuilding(const region * r) +{ + building *b, *best = NULL; + double maxmoney = 0; + /* durch die verw. von '>' statt '>=' werden die aelteren burgen + * bevorzugt. */ + + if (r->land && r->land->ownership) { + for (b = rbuildings(r); b; b = b->next) { + if (b->type->taxes && r->land->ownership) { + const attrib * a = a_find(b->attribs, &at_icastle); + if (!a) { + int maxsize = buildingeffsize(b, false); + double money = b->type->taxes(b, maxsize); + if (money>0 && (best==NULL || money > maxmoney)) { + maxmoney = money; + best = b; + } + } + } + } + } + return best; +} + + static void peasant_taxes(region * r) { @@ -3219,14 +3246,14 @@ peasant_taxes(region * r) int money; int maxsize; int morale; - + f = region_get_owner(r); if (f==NULL) return; money = rmoney(r); if (money<=0) return; - b = largestbuilding(r, &is_owner_building, false); + b = taxbuilding(r); if (b==NULL) return; u = buildingowner(r, b);