forked from github/server
make destroyfaction not have to loop over all factions to clear HELP status.
This commit is contained in:
parent
8742317979
commit
04624179ce
3 changed files with 15 additions and 6 deletions
|
@ -170,6 +170,9 @@ int
|
|||
alliedgroup(const struct plane *pl, const struct faction *f,
|
||||
const struct faction *f2, const struct ally *sf, int mode)
|
||||
{
|
||||
if (!(faction_alive(f) && faction_alive(f2))) {
|
||||
return 0;
|
||||
}
|
||||
while (sf && sf->faction != f2)
|
||||
sf = sf->next;
|
||||
if (sf == NULL) {
|
||||
|
|
|
@ -74,6 +74,9 @@ faction *factions;
|
|||
void free_faction(faction * f)
|
||||
{
|
||||
funhash(f);
|
||||
if (f->alliance && f->alliance->_leader == f) {
|
||||
setalliance(f, 0);
|
||||
}
|
||||
if (f->msgs) {
|
||||
free_messagelist(f->msgs->begin);
|
||||
free(f->msgs);
|
||||
|
@ -389,8 +392,9 @@ void destroyfaction(faction ** fp)
|
|||
u = u->nextF;
|
||||
}
|
||||
}
|
||||
/* no way! f->units = NULL; */
|
||||
|
||||
handle_event(f->attribs, "destroy", f);
|
||||
/* alliedgroup and others should check sf.faction.alive before using a faction from f.allies
|
||||
for (ff = factions; ff; ff = ff->next) {
|
||||
group *g;
|
||||
ally *sf, **sfp;
|
||||
|
@ -417,7 +421,7 @@ void destroyfaction(faction ** fp)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
if (f->alliance && f->alliance->_leader == f) {
|
||||
setalliance(f, 0);
|
||||
}
|
||||
|
@ -650,6 +654,8 @@ void remove_empty_factions(void)
|
|||
if (!(f->_alive && f->units!=NULL) && !fval(f, FFL_NOIDLEOUT)) {
|
||||
log_debug("dead: %s", factionname(f));
|
||||
destroyfaction(fp);
|
||||
free_faction(f);
|
||||
free(f);
|
||||
}
|
||||
else {
|
||||
fp = &(*fp)->next;
|
||||
|
@ -657,7 +663,7 @@ void remove_empty_factions(void)
|
|||
}
|
||||
}
|
||||
|
||||
bool faction_alive(faction *f) {
|
||||
bool faction_alive(const faction *f) {
|
||||
assert(f);
|
||||
return f->_alive || (f->flags&FFL_NPC);
|
||||
}
|
||||
|
|
|
@ -82,8 +82,8 @@ extern "C" {
|
|||
int num_total; /* Anzahl Personen mit Monstern */
|
||||
int options;
|
||||
int no_units;
|
||||
struct ally *allies;
|
||||
struct group *groups;
|
||||
struct ally *allies; /* alliedgroup and others should check sf.faction.alive before using a faction from f.allies */
|
||||
struct group *groups; /* alliedgroup and others should check sf.faction.alive before using a faction from f.groups */
|
||||
int nregions;
|
||||
int money;
|
||||
score_t score;
|
||||
|
@ -123,7 +123,7 @@ extern "C" {
|
|||
bool checkpasswd(const faction * f, const char *passwd);
|
||||
void destroyfaction(faction ** f);
|
||||
|
||||
bool faction_alive(struct faction *f);
|
||||
bool faction_alive(const 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);
|
||||
|
|
Loading…
Reference in a new issue