eliminated region_list use from get_island_info

This commit is contained in:
Enno Rehling 2011-04-26 21:25:47 -07:00
parent 6798c497f8
commit f00f537336

View file

@ -399,15 +399,15 @@ static quicklist * get_island(region * root)
static void static void
get_island_info(region * root, int *size_p, int *inhabited_p, int *maxage_p) get_island_info(region * root, int *size_p, int *inhabited_p, int *maxage_p)
{ {
int size = 0, maxage = 0, inhabited = 0; int qi, size = 0, maxage = 0, inhabited = 0;
region_list *rlist = NULL; quicklist *ql, *island = NULL;
region_list *island = NULL;
add_regionlist(&rlist, root); ql_push(&island, root);
island = rlist;
fset(root, RF_MARK); fset(root, RF_MARK);
while (rlist) {
for (ql=island,qi=0; ql; ql_advance(&ql, &qi, 1)) {
int d; int d;
region *r = rlist->data; region *r = (region *)ql_get(ql, qi);
if (r->units) { if (r->units) {
unit *u; unit *u;
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
@ -421,19 +421,16 @@ get_island_info(region * root, int *size_p, int *inhabited_p, int *maxage_p)
for (d = 0; d != MAXDIRECTIONS; ++d) { for (d = 0; d != MAXDIRECTIONS; ++d) {
region *rn = rconnect(r, d); region *rn = rconnect(r, d);
if (rn && !fval(rn, RF_MARK) && rn->land) { if (rn && !fval(rn, RF_MARK) && rn->land) {
region_list *rnew = malloc(sizeof(region_list)); ql_push(&island, rn);
rnew->data = rn;
rnew->next = rlist->next;
rlist->next = rnew;
fset(rn, RF_MARK); fset(rn, RF_MARK);
} }
} }
rlist = rlist->next;
} }
for (rlist = island; rlist; rlist = rlist->next) { for (ql=island,qi=0; ql; ql_advance(&ql, &qi, 1)) {
freset(rlist->data, RF_MARK); region *r = (region *)ql_get(ql, qi);
freset(r, RF_MARK);
} }
free_regionlist(island); ql_free(island);
if (size_p) if (size_p)
*size_p = size; *size_p = size;
if (inhabited_p) if (inhabited_p)