From 16267c447e56a1b1c6c0d1c1fb4c0c9d0fab8d37 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 27 Apr 2017 19:08:10 +0200 Subject: [PATCH] extract taxes into separate function (WIP) --- src/kernel/building.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/kernel/building.c b/src/kernel/building.c index 40f09a6ad..262836f3a 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -784,6 +784,16 @@ bool is_owner_building(const struct building * b) return false; } +double building_taxes(const building *b, int bsize) { + assert(b); + if (!b->type->taxes) return 0; + else { + int level = buildingeffsize(b, false); + return b->type->taxes(b, level); + } +} + + int cmp_taxes(const building * b, const building * a) { faction *f = region_get_owner(b->region); @@ -793,10 +803,8 @@ int cmp_taxes(const building * b, const building * a) return -1; } else if (a) { - int newsize = buildingeffsize(b, false); - double newtaxes = b->type->taxes(b, newsize); - int oldsize = buildingeffsize(a, false); - double oldtaxes = a->type->taxes(a, oldsize); + double newtaxes = building_taxes(b, b->size); + double oldtaxes = building_taxes(a, a->size); if (newtaxes < oldtaxes) return -1;