From 835f51c51232e3d1245d5d55514e0fe329017bb2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 25 Apr 2011 22:20:27 -0700 Subject: [PATCH] eliminate region_list usage from the monster pathfinder --- src/monsters.c | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/src/monsters.c b/src/monsters.c index 44671ebb4..1a3ee65b6 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -398,11 +398,11 @@ static attrib *set_new_dragon_target(unit * u, region * r, int range) { int max_affinity = 0; region *max_region = NULL; + quicklist *ql, *rlist = regions_in_range(r, range, allowed_dragon); + int qi; -#if 1 - region_list *rptr, *rlist = regions_in_range(r, range, allowed_dragon); - for (rptr = rlist; rptr; rptr = rptr->next) { - region *r2 = rptr->data; + for (qi=0, ql = rlist; ql; ql_advance(&ql, &qi, 1)) { + region *r2 = (region *)ql_get(ql, qi); int affinity = dragon_affinity_value(r2, u); if (affinity > max_affinity) { max_affinity = affinity; @@ -410,28 +410,8 @@ static attrib *set_new_dragon_target(unit * u, region * r, int range) } } - free_regionlist(rlist); -#else - int tx, ty; - for (tx = r->x - range; tx < r->x + range; tx++) { - for (ty = r->y - range; ty < r->y + range; ty++) { - region *r2; - int x = tx, y = ty; - pnormalize(&x, &y, r->planep); - r2 = findregion(x, y); - if (r2 != NULL) { - int affinity = dragon_affinity_value(r2, u); - if (affinity > max_affinity) { - if (koor_distance(r->x, r->y, x, y) <= range - && path_exists(r, r2, range, allowed_dragon)) { - max_affinity = affinity; - max_region = r2; - } - } - } - } - } -#endif + ql_free(rlist); + if (max_region && max_region != r) { attrib *a = a_find(u->attribs, &at_targetregion); if (!a) {