forked from github/server
use building_taxes everywhere.
make it return an integer, not double.
This commit is contained in:
parent
16267c447e
commit
1112890293
|
@ -2949,8 +2949,8 @@ static void peasant_taxes(region * r)
|
||||||
|
|
||||||
maxsize = buildingeffsize(b, false);
|
maxsize = buildingeffsize(b, false);
|
||||||
if (maxsize > 0) {
|
if (maxsize > 0) {
|
||||||
double taxfactor = money * b->type->taxes(b, maxsize);
|
double taxfactor = money / building_taxes(b, maxsize);
|
||||||
double morale = MORALE_TAX_FACTOR * money * region_get_morale(r);
|
double morale = money * region_get_morale(r) / MORALE_TAX_FACTOR;
|
||||||
if (taxfactor > morale) {
|
if (taxfactor > morale) {
|
||||||
taxfactor = morale;
|
taxfactor = morale;
|
||||||
}
|
}
|
||||||
|
|
|
@ -784,12 +784,12 @@ bool is_owner_building(const struct building * b)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
double building_taxes(const building *b, int bsize) {
|
int building_taxes(const building *b, int bsize) {
|
||||||
assert(b);
|
assert(b);
|
||||||
if (!b->type->taxes) return 0;
|
if (!b->type->taxes) return 0;
|
||||||
else {
|
else {
|
||||||
int level = buildingeffsize(b, false);
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (a) {
|
else if (a) {
|
||||||
double newtaxes = building_taxes(b, b->size);
|
int newtaxes = building_taxes(b, b->size);
|
||||||
double oldtaxes = building_taxes(a, a->size);
|
int oldtaxes = building_taxes(a, a->size);
|
||||||
|
|
||||||
if (newtaxes < oldtaxes)
|
if (newtaxes > oldtaxes)
|
||||||
return -1;
|
return -1;
|
||||||
else if (newtaxes > oldtaxes)
|
else if (newtaxes < oldtaxes)
|
||||||
return 1;
|
return 1;
|
||||||
else if (b->size < a->size)
|
else if (b->size < a->size)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -840,20 +840,18 @@ int cmp_current_owner(const building * b, const building * a)
|
||||||
if (!u || u->faction != f)
|
if (!u || u->faction != f)
|
||||||
return -1;
|
return -1;
|
||||||
if (a) {
|
if (a) {
|
||||||
int newsize = buildingeffsize(b, false);
|
int newtaxes = building_taxes(b, b->size);
|
||||||
double newtaxes = b->type->taxes(b, newsize);
|
int 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;
|
||||||
}
|
}
|
||||||
if (newtaxes < oldtaxes) {
|
if (newtaxes > oldtaxes) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (newsize != oldsize) {
|
//if (newsize != oldsize) {
|
||||||
return newsize - oldsize;
|
// return newsize - oldsize;
|
||||||
}
|
//}
|
||||||
return (b->size - a->size);
|
return (b->size - a->size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -71,7 +71,7 @@ extern "C" {
|
||||||
const char *(*name) (const struct building_type *,
|
const char *(*name) (const struct building_type *,
|
||||||
const struct building * b, int size);
|
const struct building * b, int size);
|
||||||
void(*age) (struct building *);
|
void(*age) (struct building *);
|
||||||
double(*taxes) (const struct building *, int size);
|
double(*taxes) (const struct building *, int level);
|
||||||
struct attrib *attribs;
|
struct attrib *attribs;
|
||||||
} building_type;
|
} building_type;
|
||||||
|
|
||||||
|
@ -139,6 +139,7 @@ extern "C" {
|
||||||
int cmp_taxes(const struct building *b, const struct building *bother);
|
int cmp_taxes(const struct building *b, const struct building *bother);
|
||||||
int cmp_current_owner(const struct building *b,
|
int cmp_current_owner(const struct building *b,
|
||||||
const struct building *bother);
|
const struct building *bother);
|
||||||
|
int building_taxes(const building *b, int bsize);
|
||||||
|
|
||||||
/* old functions, still in build.c: */
|
/* old functions, still in build.c: */
|
||||||
int buildingeffsize(const building * b, int imaginary);
|
int buildingeffsize(const building * b, int imaginary);
|
||||||
|
|
|
@ -66,7 +66,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
struct faction;
|
struct faction;
|
||||||
struct gamedata;
|
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_MAX 10 /* Maximum morale allowed */
|
||||||
#define MORALE_DEFAULT 1 /* Morale of peasants when they are conquered for the first time */
|
#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 */
|
#define MORALE_TAKEOVER 0 /* Morale of peasants after they lose their lord */
|
||||||
|
|
|
@ -46,7 +46,7 @@ void morale_update(region *r) {
|
||||||
building *b = largestbuilding(r, &cmp_taxes, false);
|
building *b = largestbuilding(r, &cmp_taxes, false);
|
||||||
if (b) {
|
if (b) {
|
||||||
int bsize = buildingeffsize(b, false);
|
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 (morale < maxmorale) {
|
||||||
if (stability > MORALE_COOLDOWN && r->land->ownership->owner
|
if (stability > MORALE_COOLDOWN && r->land->ownership->owner
|
||||||
|
|
Loading…
Reference in New Issue