Fixes an fix_otherfaction (null-pointer)

This commit is contained in:
Enno Rehling 2005-02-06 08:23:28 +00:00
parent 05f6eec60d
commit d221ca4db7
1 changed files with 9 additions and 7 deletions

View File

@ -23,6 +23,7 @@
/* misc includes */ /* misc includes */
#include <attributes/key.h> #include <attributes/key.h>
#include <attributes/otherfaction.h>
#include <modules/xecmd.h> #include <modules/xecmd.h>
/* gamecode includes */ /* gamecode includes */
@ -491,15 +492,16 @@ fix_otherfaction(void)
unit * u; unit * u;
for (u=r->units;u;u=u->next) { for (u=r->units;u;u=u->next) {
attrib * a = a_find(u->attribs, &at_otherfaction); attrib * a = a_find(u->attribs, &at_otherfaction);
faction * f = (faction*)a->data.v; if (a!=NULL) {
if (f==u->faction) { faction * f = (faction*)a->data.v;
a_remove(&u->attribs, a); if (f==u->faction) {
++ncount; a_remove(&u->attribs, a);
} ++count;
}
}
} }
r = r->next;
} }
if (count) log_warning(("%u units had otherfaction=own faction.\n")); if (count) log_warning(("%u units had otherfaction=own faction.\n", count));
} }
extern attrib * make_atgmcreate(const struct item_type * itype); extern attrib * make_atgmcreate(const struct item_type * itype);