use building_taxes everywhere.

make it return an integer, not double.
This commit is contained in:
Enno Rehling 2017-04-28 20:10:20 +02:00
parent 16267c447e
commit 1112890293
5 changed files with 19 additions and 20 deletions

View File

@ -2949,8 +2949,8 @@ static void peasant_taxes(region * r)
maxsize = buildingeffsize(b, false);
if (maxsize > 0) {
double taxfactor = money * b->type->taxes(b, maxsize);
double morale = MORALE_TAX_FACTOR * money * region_get_morale(r);
double taxfactor = money / building_taxes(b, maxsize);
double morale = money * region_get_morale(r) / MORALE_TAX_FACTOR;
if (taxfactor > morale) {
taxfactor = morale;
}

View File

@ -784,12 +784,12 @@ bool is_owner_building(const struct building * b)
return false;
}
double building_taxes(const building *b, int bsize) {
int 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);
return (int)(0.5+1/b->type->taxes(b, level));
}
}
@ -803,12 +803,12 @@ int cmp_taxes(const building * b, const building * a)
return -1;
}
else if (a) {
double newtaxes = building_taxes(b, b->size);
double oldtaxes = building_taxes(a, a->size);
int newtaxes = building_taxes(b, b->size);
int oldtaxes = building_taxes(a, a->size);
if (newtaxes < oldtaxes)
if (newtaxes > oldtaxes)
return -1;
else if (newtaxes > oldtaxes)
else if (newtaxes < oldtaxes)
return 1;
else if (b->size < a->size)
return -1;
@ -840,20 +840,18 @@ int cmp_current_owner(const building * b, const building * a)
if (!u || u->faction != f)
return -1;
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);
int newtaxes = building_taxes(b, b->size);
int oldtaxes = building_taxes(a, a->size);
if (newtaxes > oldtaxes) {
if (newtaxes < oldtaxes) {
return 1;
}
if (newtaxes < oldtaxes) {
if (newtaxes > oldtaxes) {
return -1;
}
if (newsize != oldsize) {
return newsize - oldsize;
}
//if (newsize != oldsize) {
// return newsize - oldsize;
//}
return (b->size - a->size);
}
else {

View File

@ -71,7 +71,7 @@ extern "C" {
const char *(*name) (const struct building_type *,
const struct building * b, int size);
void(*age) (struct building *);
double(*taxes) (const struct building *, int size);
double(*taxes) (const struct building *, int level);
struct attrib *attribs;
} building_type;
@ -139,6 +139,7 @@ extern "C" {
int cmp_taxes(const struct building *b, const struct building *bother);
int cmp_current_owner(const struct building *b,
const struct building *bother);
int building_taxes(const building *b, int bsize);
/* old functions, still in build.c: */
int buildingeffsize(const building * b, int imaginary);

View File

@ -66,7 +66,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
struct faction;
struct gamedata;
#define MORALE_TAX_FACTOR 0.005 /* 0.5% tax per point of morale */
#define MORALE_TAX_FACTOR 200 /* 0.5% tax per point of morale, 1 silver per 200 */
#define MORALE_MAX 10 /* Maximum morale allowed */
#define MORALE_DEFAULT 1 /* Morale of peasants when they are conquered for the first time */
#define MORALE_TAKEOVER 0 /* Morale of peasants after they lose their lord */

View File

@ -46,7 +46,7 @@ void morale_update(region *r) {
building *b = largestbuilding(r, &cmp_taxes, false);
if (b) {
int bsize = buildingeffsize(b, false);
maxmorale = (int)(0.5 + b->type->taxes(b, bsize + 1) / MORALE_TAX_FACTOR);
maxmorale = (int)(0.5 + b->type->taxes(b, bsize + 1) * MORALE_TAX_FACTOR);
}
if (morale < maxmorale) {
if (stability > MORALE_COOLDOWN && r->land->ownership->owner