forked from github/server
Pausierte Parteien bewachen nicht.
This commit is contained in:
parent
a3916b8271
commit
e6da5d92d8
18
src/guard.c
18
src/guard.c
|
@ -84,25 +84,25 @@ static bool is_guardian_u(const unit * guard, unit * u)
|
||||||
return true;
|
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;
|
return false;
|
||||||
|
|
||||||
/* if region_owners exist then they may be guardians: */
|
/* if region_owners exist then they may be guardians: */
|
||||||
if (guard->building && rule_region_owners() && guard == building_owner(guard->building)) {
|
if (u->building && rule_region_owners() && u == building_owner(u->building)) {
|
||||||
faction *owner = region_get_owner(guard->region);
|
faction *owner = region_get_owner(u->region);
|
||||||
if (owner == guard->faction) {
|
if (owner == u->faction) {
|
||||||
building *bowner = largestbuilding(guard->region, cmp_taxes, false);
|
building *bowner = largestbuilding(u->region, cmp_taxes, false);
|
||||||
if (bowner == guard->building) {
|
if (bowner == u->building) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((guard->flags & UFL_GUARD) == 0)
|
if ((u->flags & UFL_GUARD) == 0)
|
||||||
return false;
|
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)
|
bool is_guard(const struct unit * u)
|
||||||
|
|
|
@ -97,6 +97,12 @@ static void test_is_guard(CuTest * tc)
|
||||||
set_level(ug, SK_MELEE, 1);
|
set_level(ug, SK_MELEE, 1);
|
||||||
CuAssertIntEquals(tc, 1, armedmen(ug, false));
|
CuAssertIntEquals(tc, 1, armedmen(ug, false));
|
||||||
CuAssertTrue(tc, is_guard(ug));
|
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();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue