Make getpos monster targeting use glyph lookup
This commit is contained in:
+19
-15
@@ -244,24 +244,28 @@ const char *goal;
|
|||||||
goto nxtc;
|
goto nxtc;
|
||||||
} else if (c == 'm' || c == 'M') {
|
} else if (c == 'm' || c == 'M') {
|
||||||
if (!monarr) {
|
if (!monarr) {
|
||||||
struct monst *mtmp;
|
int x,y,s;
|
||||||
|
|
||||||
moncount = 0;
|
moncount = 0;
|
||||||
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
|
for (s = 0; s < 2; s++) {
|
||||||
if (canspotmon(mtmp)
|
if (s) {
|
||||||
&& (mtmp->mx != u.ux || mtmp->my != u.uy))
|
/* moncount + 1: always allocate a non-zero amount */
|
||||||
moncount++;
|
monarr = (coord *) alloc(sizeof (coord) * (moncount + 1));
|
||||||
}
|
monidx = 0;
|
||||||
/* moncount + 1: always allocate a non-zero amount */
|
|
||||||
monarr = (coord *) alloc(sizeof (coord) * (moncount + 1));
|
|
||||||
monidx = 0;
|
|
||||||
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
|
|
||||||
if (canspotmon(mtmp)
|
|
||||||
&& (mtmp->mx != u.ux || mtmp->my != u.uy)) {
|
|
||||||
monarr[monidx].x = mtmp->mx;
|
|
||||||
monarr[monidx].y = mtmp->my;
|
|
||||||
monidx++;
|
|
||||||
}
|
}
|
||||||
|
if (!s || s && moncount)
|
||||||
|
for (x = 0; x < COLNO; x++)
|
||||||
|
for (y = 0; y < ROWNO; y++)
|
||||||
|
if (glyph_is_monster(glyph_at(x,y))
|
||||||
|
&& !(x == u.ux && y == u.uy)) {
|
||||||
|
if (!s)
|
||||||
|
moncount++;
|
||||||
|
else {
|
||||||
|
monarr[monidx].x = x;
|
||||||
|
monarr[monidx].y = y;
|
||||||
|
monidx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
qsort(monarr, moncount, sizeof (coord), cmp_coord_distu);
|
qsort(monarr, moncount, sizeof (coord), cmp_coord_distu);
|
||||||
/* ready for first increment/decrement to change to zero */
|
/* ready for first increment/decrement to change to zero */
|
||||||
|
|||||||
Reference in New Issue
Block a user