extract taxes into separate function (WIP)

This commit is contained in:
Enno Rehling 2017-04-27 19:08:10 +02:00
parent a313e78de5
commit 16267c447e
1 changed files with 12 additions and 4 deletions

View File

@ -784,6 +784,16 @@ bool is_owner_building(const struct building * b)
return false; 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) int cmp_taxes(const building * b, const building * a)
{ {
faction *f = region_get_owner(b->region); faction *f = region_get_owner(b->region);
@ -793,10 +803,8 @@ int cmp_taxes(const building * b, const building * a)
return -1; return -1;
} }
else if (a) { else if (a) {
int newsize = buildingeffsize(b, false); double newtaxes = building_taxes(b, b->size);
double newtaxes = b->type->taxes(b, newsize); double oldtaxes = building_taxes(a, a->size);
int oldsize = buildingeffsize(a, false);
double oldtaxes = a->type->taxes(a, oldsize);
if (newtaxes < oldtaxes) if (newtaxes < oldtaxes)
return -1; return -1;