forked from github/server
adding a much-needed getter function for faction_alive
This commit is contained in:
parent
b4389c91fe
commit
ca500a499e
|
@ -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)
|
void faction_getorigin(const faction * f, int id, int *x, int *y)
|
||||||
{
|
{
|
||||||
ursprung *ur;
|
ursprung *ur;
|
||||||
|
|
|
@ -123,6 +123,8 @@ extern "C" {
|
||||||
bool checkpasswd(const faction * f, const char *passwd);
|
bool checkpasswd(const faction * f, const char *passwd);
|
||||||
void destroyfaction(faction ** f);
|
void destroyfaction(faction ** f);
|
||||||
|
|
||||||
|
bool faction_alive(struct faction *f);
|
||||||
|
|
||||||
void set_alliance(struct faction *a, struct faction *b, int status);
|
void set_alliance(struct faction *a, struct faction *b, int status);
|
||||||
int get_alliance(const struct faction *a, const struct faction *b);
|
int get_alliance(const struct faction *a, const struct faction *b);
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ static void test_addfaction(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, 1234, f->subscription);
|
CuAssertIntEquals(tc, 1234, f->subscription);
|
||||||
CuAssertIntEquals(tc, 0, f->flags);
|
CuAssertIntEquals(tc, 0, f->flags);
|
||||||
CuAssertIntEquals(tc, 0, f->age);
|
CuAssertIntEquals(tc, 0, f->age);
|
||||||
CuAssertIntEquals(tc, true, f->_alive);
|
CuAssertIntEquals(tc, true, faction_alive(f));
|
||||||
CuAssertIntEquals(tc, M_GRAY, f->magiegebiet);
|
CuAssertIntEquals(tc, M_GRAY, f->magiegebiet);
|
||||||
CuAssertIntEquals(tc, turn, f->lastorders);
|
CuAssertIntEquals(tc, turn, f->lastorders);
|
||||||
CuAssertPtrEquals(tc, f, findfaction(f->no));
|
CuAssertPtrEquals(tc, f, findfaction(f->no));
|
||||||
|
|
|
@ -1463,7 +1463,7 @@ unit *create_unit(region * r, faction * f, int number, const struct race *urace,
|
||||||
|
|
||||||
assert(urace);
|
assert(urace);
|
||||||
if (f) {
|
if (f) {
|
||||||
assert(f->_alive);
|
assert(faction_alive(f));
|
||||||
u_setfaction(u, f);
|
u_setfaction(u, f);
|
||||||
|
|
||||||
if (f->locale) {
|
if (f->locale) {
|
||||||
|
@ -1828,7 +1828,7 @@ void remove_empty_units_in_region(region * r)
|
||||||
|
|
||||||
if (u->number) {
|
if (u->number) {
|
||||||
faction *f = u->faction;
|
faction *f = u->faction;
|
||||||
if (f == NULL || !f->_alive) {
|
if (f == NULL || !faction_alive(f)) {
|
||||||
set_number(u, 0);
|
set_number(u, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue