forked from github/server
speeding up u_setfaction
This commit is contained in:
parent
22d63cc8cf
commit
b3d22eae63
2 changed files with 5 additions and 7 deletions
|
@ -1013,22 +1013,19 @@ u_setfaction(unit * u, faction * f)
|
||||||
|
|
||||||
if (u->faction==f) return;
|
if (u->faction==f) return;
|
||||||
if (u->faction) {
|
if (u->faction) {
|
||||||
unit ** iunit;
|
|
||||||
set_number(u, 0);
|
set_number(u, 0);
|
||||||
if (count_unit(u)) --u->faction->no_units;
|
if (count_unit(u)) --u->faction->no_units;
|
||||||
join_group(u, NULL);
|
join_group(u, NULL);
|
||||||
free_orders(&u->orders);
|
free_orders(&u->orders);
|
||||||
set_order(&u->thisorder, NULL);
|
set_order(&u->thisorder, NULL);
|
||||||
|
|
||||||
iunit = &u->faction->units;
|
if (u->nextF) u->nextF->prevF = u->prevF;
|
||||||
while (*iunit && *iunit!=u) {
|
if (u->prevF) u->prevF->nextF = u->nextF;
|
||||||
iunit=&(*iunit)->nextF;
|
else f->units = u->nextF;
|
||||||
}
|
|
||||||
assert(*iunit);
|
|
||||||
*iunit = u->nextF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f!=NULL) {
|
if (f!=NULL) {
|
||||||
|
u->prevF = NULL;
|
||||||
u->nextF = f->units;
|
u->nextF = f->units;
|
||||||
f->units = u;
|
f->units = u;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ extern int countheroes(const struct faction * f);
|
||||||
typedef struct unit {
|
typedef struct unit {
|
||||||
struct unit *next; /* needs to be first entry, for region's unitlist */
|
struct unit *next; /* needs to be first entry, for region's unitlist */
|
||||||
struct unit *nextF; /* nächste Einheit der Partei */
|
struct unit *nextF; /* nächste Einheit der Partei */
|
||||||
|
struct unit *prevF; /* vorherige Einheit der Partei */
|
||||||
struct region *region;
|
struct region *region;
|
||||||
int no;
|
int no;
|
||||||
int hp;
|
int hp;
|
||||||
|
|
Loading…
Reference in a new issue