fix: taxation buildings only count if they are currently in use.

This commit is contained in:
Enno Rehling 2010-02-12 05:06:26 +00:00
parent d38a2d28d3
commit dbde06fb8f
17 changed files with 53 additions and 53 deletions

View File

@ -97,7 +97,7 @@ a_giveitem(attrib * a)
unit * u;
if (gdata->building==NULL || gdata->items==NULL) return 0;
r = gdata->building->region;
u = buildingowner(r, gdata->building);
u = building_owner(gdata->building);
if (u==NULL) return 1;
while (gdata->items) {
item * itm = gdata->items;

View File

@ -206,10 +206,10 @@ cr_output_curses(FILE * F, const faction * viewer, const void * obj, typ_t typ)
}
} else if (typ == TYP_BUILDING) {
building * b = (building*)obj;
unit * owner;
unit * owner = building_owner(b);
a = b->attribs;
r = b->region;
if((owner = buildingowner(r,b)) != NULL){
if (owner != NULL){
if (owner->faction == viewer){
self = 2;
} else { /* steht eine Person der Partei in der Burg? */
@ -1323,7 +1323,7 @@ cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
/* buildings */
for (b = rbuildings(r); b; b = b->next) {
int fno = -1;
u = buildingowner(r, b);
u = building_owner(b);
if (u && !fval(u, UFL_PARTEITARNUNG)) {
const faction * sf = visible_faction(f,u);
fno = sf->no;

View File

@ -1025,7 +1025,7 @@ maintain(building * b, boolean first)
if (fval(b, BLD_DONTPAY)) {
return false;
}
u = buildingowner(r, b);
u = building_owner(b);
if (u==NULL) return false;
for (c=0;b->type->maintenance[c].number;++c) {
const maintenance * m = b->type->maintenance+c;
@ -1165,7 +1165,7 @@ maintain_buildings(region * r, boolean crash)
}
#endif
if (!fval(b, BLD_WORKING)) {
unit * u = buildingowner(r, b);
unit * u = building_owner(b);
const char * msgtype = maintained?"maintenance_nowork":"maintenance_none";
struct message * msg = msg_message(msgtype, "building", b);
@ -2226,11 +2226,11 @@ expandselling(region * r, request * sellorders, int limit)
* Verkauf. Wenn zwei Burgen gleicher Größe bekommt gar keiner etwas. */
for (b = rbuildings(r); b; b = b->next) {
if (b->size > maxsize && buildingowner(r, b) != NULL
if (b->size > maxsize && building_owner(b) != NULL
&& b->type == bt_find("castle")) {
maxb = b;
maxsize = b->size;
maxowner = buildingowner(r, b);
maxowner = building_owner(b);
} else if (b->size == maxsize && b->type == bt_find("castle")) {
maxb = (building *) NULL;
maxowner = (unit *) NULL;
@ -3309,7 +3309,7 @@ peasant_taxes(region * r)
b = largestbuilding(r, cmp_taxes, false);
if (b==NULL) return;
u = buildingowner(r, b);
u = building_owner(b);
if (u==NULL || u->faction!=f) return;
maxsize = buildingeffsize(b, false);

View File

@ -1654,7 +1654,7 @@ name_cmd(unit * u, struct order * ord)
}
}
uo = buildingowner(r, b);
uo = building_owner(b);
if (uo) {
if (cansee(uo->faction, r, u, 0)) {
ADDMSG(&uo->faction->msgs, msg_message("renamed_building_seen",
@ -3697,7 +3697,7 @@ pay_cmd(unit * u, struct order * ord)
skip_token();
p = getparam(u->faction->locale);
if (p==P_NOT) {
unit * owner = buildingowner(u->building->region, u->building);
unit * owner = building_owner(u->building);
if (owner->faction!=u->faction) {
cmistake(u, ord, 1222, MSG_EVENT);
} else {

View File

@ -37,7 +37,7 @@ get_markets(region * r, unit ** results, size_t size)
if (!btype) return 0;
for (b=r->buildings;n<size && b;b=b->next) {
if (b->type==btype && (b->flags&BLD_WORKING) && b->size>=b->type->maxsize) {
unit * u = buildingowner(r, b);
unit * u = building_owner(b);
unsigned int i;
for (i=0;u && i!=n;++i) {
/* only one market per faction */

View File

@ -1258,7 +1258,7 @@ randomevents(void)
building ** blist = &r->buildings;
while (*blist) {
building * b = *blist;
if (fval(b->type, BTF_DECAY) && !buildingowner(r, b)) {
if (fval(b->type, BTF_DECAY) && !building_owner(b)) {
b->size -= MAX(1, (b->size * 20) / 100);
if (b->size == 0) {
remove_building(blist, r->buildings);

View File

@ -570,7 +570,7 @@ nr_curses(FILE *F, const faction *viewer, const void * obj, typ_t typ, int inden
unit * owner;
a = b->attribs;
r = b->region;
if ((owner = buildingowner(r,b)) != NULL){
if ((owner = building_owner(b)) != NULL){
if (owner->faction == viewer){
self = 2;
} else { /* steht eine Person der Partei in der Burg? */
@ -1809,7 +1809,7 @@ nr_building(FILE *F, const seen_region * sr, const building * b, const faction *
bytes = (int)strlcpy(bufp, name, size);
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
if (billusion) {
unit * owner = buildingowner(r, b);
unit * owner = building_owner(b);
if (owner && owner->faction==f) {
/* illusion. report real type */
name = LOC(lang, bname);
@ -1851,7 +1851,7 @@ nr_building(FILE *F, const seen_region * sr, const building * b, const faction *
}
if (b->type == bt_find("pyramid")) {
unit * owner = buildingowner(r, b);
unit * owner = building_owner(b);
scat("Größenstufe ");
icat(wdw_pyramid_level(b));
scat(".");

View File

@ -453,7 +453,7 @@ alliancevictory(void)
building * b = r->buildings;
while (b!=NULL) {
if (b->type==btype) {
unit * u = buildingowner(r, b);
unit * u = building_owner(b);
if (u) {
fset(u->faction->alliance, FFL_MARK);
}

View File

@ -887,7 +887,7 @@ build_building(unit * u, const building_type * btype, int want, order * ord)
rule_other = get_param_int(global.parameters, "rules.build.other_buildings", 1);
}
if (!rule_other) {
unit * owner = buildingowner(r, b);
unit * owner = building_owner(b);
if (!owner || owner->faction!=u->faction) {
cmistake(u, ord, 1222, MSG_PRODUCE);
return;
@ -1117,7 +1117,7 @@ mayenter(region * r, unit * u, building * b)
{
unit *u2;
if (fval(b, BLD_UNGUARDED)) return true;
u2 = buildingowner(r, b);
u2 = building_owner(b);
if (u2==NULL || ucontact(u2, u)
|| alliedunit(u2, u->faction, HELP_GUARD)) return true;
@ -1255,7 +1255,7 @@ enter_building(unit * u, order * ord, int id, boolean report)
}
if (leave(u, false)) {
if (buildingowner(r, b) == 0) {
if (building_owner(b) == 0) {
fset(u, UFL_OWNER);
}
fset(u, UFL_ENTER);

View File

@ -612,32 +612,30 @@ buildingname(const building * b)
}
unit *
buildingowner(const region * r, const building * b)
building_owner(const building * b)
{
unit *u = NULL;
unit *first = NULL;
#ifndef BROKEN_OWNERS
assert(r == b->region);
#endif
/* Prüfen ob Eigentümer am leben. */
unit *u = NULL;
unit *first = NULL;
region * r = b->region;
/* Prüfen ob Eigentümer am leben. */
for (u = r->units; u; u = u->next) {
if (u->building == b) {
if (!first && u->number > 0)
first = u;
if (fval(u, UFL_OWNER) && u->number > 0)
return u;
if (u->number == 0)
freset(u, UFL_OWNER);
}
}
for (u = r->units; u; u = u->next) {
if (u->building == b) {
if (!first && u->number > 0)
first = u;
if (fval(u, UFL_OWNER) && u->number > 0)
return u;
if (u->number == 0)
freset(u, UFL_OWNER);
}
}
/* Eigentümer tot oder kein Eigentümer vorhanden. Erste lebende Einheit
* nehmen. */
/* Eigentümer tot oder kein Eigentümer vorhanden. Erste lebende Einheit
* nehmen. */
if (first)
fset(first, UFL_OWNER);
return first;
if (first)
fset(first, UFL_OWNER);
return first;
}
const char * building_getname(const building * self)

View File

@ -143,7 +143,7 @@ extern variant read_building_reference(struct storage * store);
extern struct building *findbuilding(int n);
extern struct unit * buildingowner(const struct region * r, const struct building * b);
extern struct unit * building_owner(const struct building * b);
extern struct attrib_type at_building_action;
void building_addaction(struct building * b, const char * fname, const char * param);

View File

@ -2637,7 +2637,7 @@ boolean is_owner_building(const struct building * b)
{
region * r = b->region;
if (b->type->taxes && r->land && r->land->ownership) {
unit * u = buildingowner(r, b);
unit * u = building_owner(b);
return u && u->faction == r->land->ownership->owner;
}
return false;
@ -2648,7 +2648,10 @@ cmp_taxes(const building * b, const building * a)
{
faction * f = region_get_owner(b->region);
if (b->type->taxes) {
if (a) {
unit * u = building_owner(b);
if (!u) {
return -1;
} else if (a) {
int newsize = buildingeffsize(b, false);
double newtaxes = b->type->taxes(b, newsize);
int oldsize = buildingeffsize(a, false);
@ -2659,9 +2662,8 @@ cmp_taxes(const building * b, const building * a)
else if (b->size<a->size) return -1;
else if (b->size>a->size) return 1;
else {
unit * u = buildingowner(b->region, b);
if (u && u->faction==f) {
u = buildingowner(a->region, a);
u = building_owner(a);
if (u && u->faction==f) return -1;
return 1;
}
@ -2680,7 +2682,7 @@ cmp_current_owner(const building * b, const building * a)
assert(rule_region_owners());
if (f && b->type->taxes) {
unit * u = buildingowner(b->region, b);
unit * u = building_owner(b);
if (!u || u->faction!=f) return -1;
if (a) {
int newsize = buildingeffsize(b, false);

View File

@ -1599,7 +1599,7 @@ owner_buildingtyp(const region * r, const building_type * bt)
unit *owner;
for (b = rbuildings(r); b; b = b->next) {
owner = buildingowner(r, b);
owner = building_owner(b);
if (b->type == bt && owner != NULL) {
if (b->size >= bt->maxsize) {
return owner;

View File

@ -1482,7 +1482,7 @@ faction * update_owners(region * r)
if (blargest) {
if (!bowner || bowner->size<blargest->size) {
/* region owners update? */
unit * u = buildingowner(r, blargest);
unit * u = building_owner(blargest);
f = region_get_owner(r);
if (u==NULL) {
if (f) {

View File

@ -840,7 +840,7 @@ can_leave(unit * u)
if (rule_leave<0) {
rule_leave = get_param_int(global.parameters, "rules.move.owner_leave", 0);
}
if (rule_leave && u->building && u==buildingowner(u->region, u->building)) {
if (rule_leave && u->building && u==building_owner(u->building)) {
return false;
}
return true;

View File

@ -85,7 +85,7 @@ score(void)
}
for (b = r->buildings; b; b = b->next) {
u = buildingowner(r, b);
u = building_owner(b);
if (u!=NULL) {
faction * fbo = u->faction;

View File

@ -151,7 +151,7 @@ static int
tolua_building_get_owner(lua_State* L)
{
building* b = (building*) tolua_tousertype(L, 1, 0);
unit * u = b?buildingowner(b->region, b):NULL;
unit * u = b?building_owner(b):NULL;
tolua_pushusertype(L, u, TOLUA_CAST "unit");
return 1;
}