diff --git a/src/kernel/faction.c b/src/kernel/faction.c index 0ab13c150..fd5799265 100755 --- a/src/kernel/faction.c +++ b/src/kernel/faction.c @@ -658,6 +658,11 @@ void remove_empty_factions(void) } } +bool faction_alive(faction *f) { + assert(f); + return f->_alive || (f->flags&FFL_NPC); +} + void faction_getorigin(const faction * f, int id, int *x, int *y) { ursprung *ur; diff --git a/src/kernel/faction.h b/src/kernel/faction.h index 6692636f0..722904734 100644 --- a/src/kernel/faction.h +++ b/src/kernel/faction.h @@ -123,6 +123,8 @@ extern "C" { bool checkpasswd(const faction * f, const char *passwd); void destroyfaction(faction ** f); + bool faction_alive(struct faction *f); + void set_alliance(struct faction *a, struct faction *b, int status); int get_alliance(const struct faction *a, const struct faction *b); diff --git a/src/kernel/faction.test.c b/src/kernel/faction.test.c index 9299f6370..a94a907e8 100644 --- a/src/kernel/faction.test.c +++ b/src/kernel/faction.test.c @@ -107,7 +107,7 @@ static void test_addfaction(CuTest *tc) { CuAssertIntEquals(tc, 1234, f->subscription); CuAssertIntEquals(tc, 0, f->flags); CuAssertIntEquals(tc, 0, f->age); - CuAssertIntEquals(tc, true, f->_alive); + CuAssertIntEquals(tc, true, faction_alive(f)); CuAssertIntEquals(tc, M_GRAY, f->magiegebiet); CuAssertIntEquals(tc, turn, f->lastorders); CuAssertPtrEquals(tc, f, findfaction(f->no)); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index 4b5c145fd..04d113033 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -1463,7 +1463,7 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace, assert(urace); if (f) { - assert(f->_alive); + assert(faction_alive(f)); u_setfaction(u, f); if (f->locale) { @@ -1828,7 +1828,7 @@ void remove_empty_units_in_region(region * r) if (u->number) { faction *f = u->faction; - if (f == NULL || !f->_alive) { + if (f == NULL || !faction_alive(f)) { set_number(u, 0); } }