Pausierte Parteien bewachen nicht.

This commit is contained in:
Enno Rehling 2021-05-22 12:48:06 +02:00
parent a3916b8271
commit e6da5d92d8
2 changed files with 15 additions and 9 deletions

View File

@ -84,25 +84,25 @@ static bool is_guardian_u(const unit * guard, unit * u)
return true;
}
static bool is_guardian_r(const unit * guard)
static bool is_guardian_r(const unit * u)
{
if (guard->number == 0)
if (u->number == 0 || is_paused(u->faction))
return false;
/* if region_owners exist then they may be guardians: */
if (guard->building && rule_region_owners() && guard == building_owner(guard->building)) {
faction *owner = region_get_owner(guard->region);
if (owner == guard->faction) {
building *bowner = largestbuilding(guard->region, cmp_taxes, false);
if (bowner == guard->building) {
if (u->building && rule_region_owners() && u == building_owner(u->building)) {
faction *owner = region_get_owner(u->region);
if (owner == u->faction) {
building *bowner = largestbuilding(u->region, cmp_taxes, false);
if (bowner == u->building) {
return true;
}
}
}
if ((guard->flags & UFL_GUARD) == 0)
if ((u->flags & UFL_GUARD) == 0)
return false;
return fval(u_race(guard), RCF_UNARMEDGUARD) || is_monsters(guard->faction) || (armedmen(guard, true) > 0);
return fval(u_race(u), RCF_UNARMEDGUARD) || is_monsters(u->faction) || (armedmen(u, true) > 0);
}
bool is_guard(const struct unit * u)

View File

@ -97,6 +97,12 @@ static void test_is_guard(CuTest * tc)
set_level(ug, SK_MELEE, 1);
CuAssertIntEquals(tc, 1, armedmen(ug, false));
CuAssertTrue(tc, is_guard(ug));
ug->faction->flags |= FFL_PAUSED;
CuAssertTrue(tc, !is_guard(ug));
i_change(&ug->items, itype, -1);
CuAssertIntEquals(tc, 0, armedmen(ug, false));
CuAssertTrue(tc, !is_guard(ug));
test_teardown();
}