speeding up u_setfaction

This commit is contained in:
Enno Rehling 2008-06-09 21:09:18 +00:00
parent 22d63cc8cf
commit b3d22eae63
2 changed files with 5 additions and 7 deletions

View File

@ -1013,22 +1013,19 @@ u_setfaction(unit * u, faction * f)
if (u->faction==f) return;
if (u->faction) {
unit ** iunit;
set_number(u, 0);
if (count_unit(u)) --u->faction->no_units;
join_group(u, NULL);
free_orders(&u->orders);
set_order(&u->thisorder, NULL);
iunit = &u->faction->units;
while (*iunit && *iunit!=u) {
iunit=&(*iunit)->nextF;
}
assert(*iunit);
*iunit = u->nextF;
if (u->nextF) u->nextF->prevF = u->prevF;
if (u->prevF) u->prevF->nextF = u->nextF;
else f->units = u->nextF;
}
if (f!=NULL) {
u->prevF = NULL;
u->nextF = f->units;
f->units = u;
}

View File

@ -72,6 +72,7 @@ extern int countheroes(const struct faction * f);
typedef struct unit {
struct unit *next; /* needs to be first entry, for region's unitlist */
struct unit *nextF; /* nächste Einheit der Partei */
struct unit *prevF; /* vorherige Einheit der Partei */
struct region *region;
int no;
int hp;