forked from github/server
fix compilation (what was I thinking?), remove uses of f.alive where they should not be needed.
This commit is contained in:
parent
de512be1ba
commit
b4389c91fe
7 changed files with 22 additions and 24 deletions
|
@ -333,6 +333,7 @@ void destroyfaction(faction ** fp)
|
|||
|
||||
*fp = f->next;
|
||||
fset(f, FFL_QUIT);
|
||||
f->_alive = false;
|
||||
|
||||
if (f->spellbook) {
|
||||
spellbook_clear(f->spellbook);
|
||||
|
@ -388,7 +389,6 @@ void destroyfaction(faction ** fp)
|
|||
u = u->nextF;
|
||||
}
|
||||
}
|
||||
f->alive = false;
|
||||
/* no way! f->units = NULL; */
|
||||
handle_event(f->attribs, "destroy", f);
|
||||
for (ff = factions; ff; ff = ff->next) {
|
||||
|
@ -648,7 +648,7 @@ void remove_empty_factions(void)
|
|||
for (fp = &factions; *fp;) {
|
||||
faction *f = *fp;
|
||||
|
||||
if ((!f->alive || !f->units) && !fval(f, FFL_NOIDLEOUT)) {
|
||||
if (!(f->_alive && f->units!=NULL) && !fval(f, FFL_NOIDLEOUT)) {
|
||||
log_debug("dead: %s", factionname(f));
|
||||
destroyfaction(fp);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ static void test_remove_dead_factions(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, f, findfaction(f->no));
|
||||
CuAssertPtrNotNull(tc, get_monsters());
|
||||
fm->units = 0;
|
||||
f->alive = 0;
|
||||
f->_alive = false;
|
||||
fno = f->no;
|
||||
remove_empty_factions();
|
||||
CuAssertPtrEquals(tc, 0, findfaction(fno));
|
||||
|
@ -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, 1, f->alive);
|
||||
CuAssertIntEquals(tc, true, f->_alive);
|
||||
CuAssertIntEquals(tc, M_GRAY, f->magiegebiet);
|
||||
CuAssertIntEquals(tc, turn, f->lastorders);
|
||||
CuAssertPtrEquals(tc, f, findfaction(f->no));
|
||||
|
|
|
@ -1668,7 +1668,7 @@ int readgame(const char *filename, bool backup)
|
|||
log_debug("marking factions as alive.\n");
|
||||
for (f = factions; f; f = f->next) {
|
||||
if (f->flags & FFL_NPC) {
|
||||
f->alive = 1;
|
||||
f->_alive = true;
|
||||
f->magiegebiet = M_GRAY;
|
||||
if (f->no == 0) {
|
||||
int no = 666;
|
||||
|
@ -1698,7 +1698,7 @@ int readgame(const char *filename, bool backup)
|
|||
}
|
||||
}
|
||||
if (u->number > 0) {
|
||||
f->alive = true;
|
||||
f->_alive = true;
|
||||
if (global.data_version >= SPELL_LEVEL_VERSION) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -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(f->_alive);
|
||||
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 || !f->_alive) {
|
||||
set_number(u, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ static void test_remove_units_with_dead_faction(CuTest *tc) {
|
|||
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
uid = u->no;
|
||||
u->faction->alive = false;
|
||||
u->faction->_alive = false;
|
||||
remove_empty_units_in_region(u->region);
|
||||
CuAssertPtrEquals(tc, 0, findunit(uid));
|
||||
CuAssertIntEquals(tc, 0, u->number);
|
||||
|
|
24
src/laws.c
24
src/laws.c
|
@ -1244,7 +1244,7 @@ static void remove_idle_players(void)
|
|||
age = calloc(_max(4, turn + 1), sizeof(int));
|
||||
for (fp = &factions; *fp;) {
|
||||
faction *f = *fp;
|
||||
if (f->alive && !is_monsters(f)) {
|
||||
if (!is_monsters(f)) {
|
||||
if (RemoveNMRNewbie() && !fval(f, FFL_NOIDLEOUT)) {
|
||||
if (f->age >= 0 && f->age <= turn)
|
||||
++age[f->age];
|
||||
|
@ -4267,18 +4267,16 @@ static int warn_password(void)
|
|||
faction *f;
|
||||
for (f = factions; f; f = f->next) {
|
||||
bool pwok = true;
|
||||
if (f->alive) {
|
||||
const char *c = f->passw;
|
||||
while (*c && pwok) {
|
||||
if (!isalnum((unsigned char)*c))
|
||||
pwok = false;
|
||||
c++;
|
||||
}
|
||||
if (!pwok) {
|
||||
free(f->passw);
|
||||
f->passw = _strdup(itoa36(rng_int()));
|
||||
ADDMSG(&f->msgs, msg_message("illegal_password", "newpass", f->passw));
|
||||
}
|
||||
const char *c = f->passw;
|
||||
while (*c && pwok) {
|
||||
if (!isalnum((unsigned char)*c))
|
||||
pwok = false;
|
||||
c++;
|
||||
}
|
||||
if (!pwok) {
|
||||
free(f->passw);
|
||||
f->passw = _strdup(itoa36(rng_int()));
|
||||
ADDMSG(&f->msgs, msg_message("illegal_password", "newpass", f->passw));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -89,7 +89,7 @@ int update_nmrs(void)
|
|||
if (fval(f, FFL_ISNEW)) {
|
||||
++newplayers;
|
||||
}
|
||||
else if (!fval(f, FFL_NOIDLEOUT) && f->alive) {
|
||||
else if (!fval(f, FFL_NOIDLEOUT)) {
|
||||
int nmr = turn - f->lastorders + 1;
|
||||
if (nmr < 0 || nmr > NMRTimeout()) {
|
||||
log_error("faction %s has %d NMRS\n", factionid(f), nmr);
|
||||
|
@ -370,7 +370,7 @@ summary *make_summary(void)
|
|||
f->nregions = 0;
|
||||
f->num_total = 0;
|
||||
f->money = 0;
|
||||
if (f->alive && f->units) {
|
||||
if (f->units) {
|
||||
s->factions++;
|
||||
/* Problem mit Monsterpartei ... */
|
||||
if (!is_monsters(f)) {
|
||||
|
|
Loading…
Reference in a new issue