region ownership fixes

This commit is contained in:
Enno Rehling 2009-07-19 08:38:39 +00:00
parent a2475ebdc0
commit 88d64f13e8
5 changed files with 15 additions and 7 deletions

View File

@ -3211,7 +3211,7 @@ peasant_taxes(region * r)
money = rmoney(r);
if (money<=0) return;
b = largestbuilding(r, &is_tax_building, false);
b = largestbuilding(r, &is_owner_building, false);
if (b==NULL) return;
u = buildingowner(r, b);

View File

@ -1469,7 +1469,7 @@ display_cmd(unit * u, struct order * ord)
cmistake(u, ord, 148, MSG_EVENT);
break;
}
if (b != largestbuilding(r, &is_tax_building, false)) {
if (b != largestbuilding(r, &is_owner_building, false)) {
cmistake(u, ord, 147, MSG_EVENT);
break;
}
@ -1712,7 +1712,7 @@ name_cmd(unit * u, struct order * ord)
cmistake(u, ord, 148, MSG_EVENT);
break;
}
if (b != largestbuilding(r, &is_tax_building, false)) {
if (b != largestbuilding(r, &is_owner_building, false)) {
cmistake(u, ord, 147, MSG_EVENT);
break;
}

View File

@ -2621,6 +2621,16 @@ is_castle(const struct building * b)
return (b->type==bt_castle);
}
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);
return u && u->faction == r->land->ownership->owner;
}
return false;
}
boolean is_tax_building(const building * b)
{
if (b->type->taxes) {

View File

@ -247,6 +247,7 @@ extern char * write_unitname(const struct unit * u, char * buffer, size_t size);
struct building *largestbuilding(const struct region * r, boolean (*eval)(const struct building *), boolean imaginary);
boolean is_castle(const struct building * b);
boolean is_tax_building(const struct building * b);
boolean is_owner_building(const struct building * b);
extern int count_all(const struct faction * f);
extern int count_migrants (const struct faction * f);
extern int count_maxmigrants(const struct faction * f);

View File

@ -834,11 +834,8 @@ can_leave(unit * u)
rule_leave = get_param_int(global.parameters, "rules.move.owner_leave", 0);
}
if (rule_leave && u->building && u==buildingowner(u->region, u->building)) {
building * b = largestbuilding(u->region, &is_tax_building, false);
if (b==u->building) {
return false;
}
}
return true;
}