forked from github/server
Miscellaneous fixes, all related to region_owners having leaked into E2.
Issue: 1720
This commit is contained in:
parent
61c1dac6ce
commit
ef60ac9ece
8 changed files with 47 additions and 21 deletions
|
@ -1202,9 +1202,11 @@ cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
||||||
fprintf(F, "%d;Pferde\n", rhorses(r));
|
fprintf(F, "%d;Pferde\n", rhorses(r));
|
||||||
|
|
||||||
if (sr->mode>=see_unit) {
|
if (sr->mode>=see_unit) {
|
||||||
faction * owner = region_get_owner(r);
|
if (rule_region_owners()) {
|
||||||
if (owner) {
|
faction * owner = region_get_owner(r);
|
||||||
fprintf(F, "%d;owner\n", owner->no);
|
if (owner) {
|
||||||
|
fprintf(F, "%d;owner\n", owner->no);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fprintf(F, "%d;Silber\n", rmoney(r));
|
fprintf(F, "%d;Silber\n", rmoney(r));
|
||||||
if (skill_enabled[SK_ENTERTAINMENT]) {
|
if (skill_enabled[SK_ENTERTAINMENT]) {
|
||||||
|
|
|
@ -634,21 +634,26 @@ recruit(unit * u, struct order * ord, request ** recruitorders)
|
||||||
addlist(recruitorders, o);
|
addlist(recruitorders, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void apply_owner_change(region * r, faction * f)
|
||||||
|
{
|
||||||
|
int morale = region_get_morale(r);
|
||||||
|
region_set_owner(r, f, turn);
|
||||||
|
if (morale>0) {
|
||||||
|
morale = MAX(0, morale-MORALE_TRANSFER);
|
||||||
|
region_set_morale(r, morale, turn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
give_control(unit * u, unit * u2)
|
give_control(unit * u, unit * u2)
|
||||||
{
|
{
|
||||||
if (u->building && u->faction!=u2->faction) {
|
if (u->building && u->faction!=u2->faction && rule_region_owners()) {
|
||||||
region * r = u->region;
|
region * r = u->region;
|
||||||
faction * f = region_get_owner(r);
|
faction * f = region_get_owner(r);
|
||||||
if (f==u->faction) {
|
if (f==u->faction) {
|
||||||
building * b = largestbuilding(r, &cmp_current_owner, false);
|
building * b = largestbuilding(r, &cmp_current_owner, false);
|
||||||
if (b==u->building) {
|
if (b==u->building) {
|
||||||
int morale = region_get_morale(r);
|
apply_owner_change(r, u2->faction);
|
||||||
region_set_owner(r, u2->faction, turn);
|
|
||||||
if (morale>0) {
|
|
||||||
morale = MAX(0, morale-MORALE_TRANSFER);
|
|
||||||
region_set_morale(r, morale, turn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,6 @@ get_food(region *r)
|
||||||
plane * pl = rplane(r);
|
plane * pl = rplane(r);
|
||||||
unit *u;
|
unit *u;
|
||||||
int peasantfood = rpeasants(r)*10;
|
int peasantfood = rpeasants(r)*10;
|
||||||
faction * owner = region_get_owner(r);
|
|
||||||
static int food_rules = -1;
|
static int food_rules = -1;
|
||||||
|
|
||||||
if (food_rules<0) {
|
if (food_rules<0) {
|
||||||
|
@ -249,6 +248,7 @@ get_food(region *r)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (food_rules&1) {
|
if (food_rules&1) {
|
||||||
|
faction * owner = region_get_owner(r);
|
||||||
/* if the region is owned, and the owner is nice, then we'll get
|
/* if the region is owned, and the owner is nice, then we'll get
|
||||||
* food from the peasants - should not be used with WORK */
|
* food from the peasants - should not be used with WORK */
|
||||||
if (owner!=NULL && (get_alliance(owner, u->faction) & HELP_MONEY)) {
|
if (owner!=NULL && (get_alliance(owner, u->faction) & HELP_MONEY)) {
|
||||||
|
@ -1492,6 +1492,17 @@ prefix_cmd(unit * u, struct order * ord)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static cmp_building_cb
|
||||||
|
get_cmp_region_owner()
|
||||||
|
{
|
||||||
|
if (rule_region_owners()) {
|
||||||
|
return &cmp_current_owner;
|
||||||
|
} else {
|
||||||
|
return &cmp_wage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
display_cmd(unit * u, struct order * ord)
|
display_cmd(unit * u, struct order * ord)
|
||||||
{
|
{
|
||||||
|
@ -1556,7 +1567,7 @@ display_cmd(unit * u, struct order * ord)
|
||||||
cmistake(u, ord, 148, MSG_EVENT);
|
cmistake(u, ord, 148, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (b != largestbuilding(r, rule_region_owners()?&cmp_current_owner:&cmp_wage, false)) {
|
if (b != largestbuilding(r, get_cmp_region_owner(), false)) {
|
||||||
cmistake(u, ord, 147, MSG_EVENT);
|
cmistake(u, ord, 147, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1801,7 +1812,7 @@ name_cmd(unit * u, struct order * ord)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b != largestbuilding(r, rule_region_owners()?&cmp_current_owner:&cmp_wage, false)) {
|
if (b != largestbuilding(r, get_cmp_region_owner(), false)) {
|
||||||
cmistake(u, ord, 147, MSG_EVENT);
|
cmistake(u, ord, 147, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3068,7 +3079,7 @@ age_building(building * b)
|
||||||
effect = 100;
|
effect = 100;
|
||||||
/* the mage reactivates the circle */
|
/* the mage reactivates the circle */
|
||||||
c = create_curse(mage, &rt->attribs, ct_astralblock,
|
c = create_curse(mage, &rt->attribs, ct_astralblock,
|
||||||
(float)sk, sk/2, effect, 0);
|
(float)MAX(1, sk), MAX(1, sk/2), effect, 0);
|
||||||
ADDMSG(&r->msgs, msg_message("astralshield_activate",
|
ADDMSG(&r->msgs, msg_message("astralshield_activate",
|
||||||
"region unit", r, mage));
|
"region unit", r, mage));
|
||||||
}
|
}
|
||||||
|
@ -3195,7 +3206,9 @@ ageing(void)
|
||||||
if (b==*bp) bp = &b->next;
|
if (b==*bp) bp = &b->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_owners(r);
|
if (rule_region_owners()) {
|
||||||
|
update_owners(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1003,7 +1003,7 @@ describe(FILE * F, const seen_region * sr, faction * f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
if (rule_region_owners()) {
|
||||||
const faction * owner = region_get_owner(r);
|
const faction * owner = region_get_owner(r);
|
||||||
if (owner!=NULL) {
|
if (owner!=NULL) {
|
||||||
bytes = snprintf(bufp, size, " Die Region ist im Besitz von %s.",
|
bytes = snprintf(bufp, size, " Die Region ist im Besitz von %s.",
|
||||||
|
|
|
@ -1699,7 +1699,7 @@ cstring(const char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
building *
|
building *
|
||||||
largestbuilding(const region * r, int (*cmp_gt)(const struct building *, const struct building *), boolean imaginary)
|
largestbuilding(const region * r, cmp_building_cb cmp_gt, boolean imaginary)
|
||||||
{
|
{
|
||||||
building *b, *best = NULL;
|
building *b, *best = NULL;
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,8 @@ extern char *cstring_i(char *s);
|
||||||
extern const char *unitname(const struct unit * u);
|
extern const char *unitname(const struct unit * u);
|
||||||
extern char * write_unitname(const struct unit * u, char * buffer, size_t size);
|
extern char * write_unitname(const struct unit * u, char * buffer, size_t size);
|
||||||
|
|
||||||
struct building *largestbuilding(const struct region * r, int (*eval_gt)(const struct building *,const struct building *), boolean imaginary);
|
typedef int (*cmp_building_cb)(const struct building * b, const struct building * a);
|
||||||
|
struct building *largestbuilding(const struct region * r, cmp_building_cb, boolean imaginary);
|
||||||
int cmp_wage(const struct building * b, const struct building * bother);
|
int cmp_wage(const struct building * b, const struct building * bother);
|
||||||
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, const struct building * bother);
|
int cmp_current_owner(const struct building * b, const struct building * bother);
|
||||||
|
|
|
@ -901,6 +901,8 @@ is_guardian_r(const unit * guard)
|
||||||
{
|
{
|
||||||
if (guard->number == 0) return false;
|
if (guard->number == 0) return false;
|
||||||
if (besieged(guard)) return false;
|
if (besieged(guard)) return false;
|
||||||
|
|
||||||
|
/* if region_owners exist then they may be guardians: */
|
||||||
if (guard->building && rule_region_owners() && fval(guard, UFL_OWNER)) {
|
if (guard->building && rule_region_owners() && fval(guard, UFL_OWNER)) {
|
||||||
faction * owner = region_get_owner(guard->region);
|
faction * owner = region_get_owner(guard->region);
|
||||||
if (owner==guard->faction) {
|
if (owner==guard->faction) {
|
||||||
|
@ -910,6 +912,7 @@ is_guardian_r(const unit * guard)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((guard->flags&UFL_GUARD)==0) return false;
|
if ((guard->flags&UFL_GUARD)==0) return false;
|
||||||
if (!armedmen(guard, true) && !fval(guard->race, RCF_UNARMEDGUARD)) return false;
|
if (!armedmen(guard, true) && !fval(guard->race, RCF_UNARMEDGUARD)) return false;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -78,9 +78,11 @@ score(void)
|
||||||
unit * u;
|
unit * u;
|
||||||
building * b;
|
building * b;
|
||||||
ship * s;
|
ship * s;
|
||||||
|
|
||||||
fc = region_get_owner(r);
|
if (rule_region_owners()) {
|
||||||
if (fc) fc->score += 10;
|
fc = region_get_owner(r);
|
||||||
|
if (fc) fc->score += 10;
|
||||||
|
}
|
||||||
|
|
||||||
for (b = r->buildings; b; b = b->next) {
|
for (b = r->buildings; b; b = b->next) {
|
||||||
u = buildingowner(r, b);
|
u = buildingowner(r, b);
|
||||||
|
|
Loading…
Reference in a new issue