adding a much-needed getter function for faction_alive

This commit is contained in:
Enno Rehling 2016-01-11 12:25:23 +01:00
parent b4389c91fe
commit ca500a499e
4 changed files with 10 additions and 3 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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));

View File

@ -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);
}
}