Use struct to pass data out of mfndpos
Instead of passing two array pointers to mfndpos, fold the data into a specific struct.
This commit is contained in:
+6
-2
@@ -71,6 +71,10 @@
|
|||||||
#include "artifact.h"
|
#include "artifact.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MFNDPOS_H
|
||||||
|
#include "mfndpos.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ### alloc.c ### */
|
/* ### alloc.c ### */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1748,7 +1752,7 @@ extern boolean can_touch_safely(struct monst *, struct obj *) NONNULLARG12;
|
|||||||
extern int can_carry(struct monst *, struct obj *) NONNULLARG12;
|
extern int can_carry(struct monst *, struct obj *) NONNULLARG12;
|
||||||
extern long mon_allowflags(struct monst *) NONNULLARG1;
|
extern long mon_allowflags(struct monst *) NONNULLARG1;
|
||||||
extern boolean m_in_air(struct monst *) NONNULLARG1;
|
extern boolean m_in_air(struct monst *) NONNULLARG1;
|
||||||
extern int mfndpos(struct monst *, coord *, long *, long) NONNULLPTRS;
|
extern int mfndpos(struct monst *, struct mfndposdata *, long) NONNULLPTRS;
|
||||||
extern boolean monnear(struct monst *, coordxy, coordxy) NONNULLARG1;
|
extern boolean monnear(struct monst *, coordxy, coordxy) NONNULLARG1;
|
||||||
extern void dmonsfree(void);
|
extern void dmonsfree(void);
|
||||||
extern void elemental_clog(struct monst *) NONNULLARG1;
|
extern void elemental_clog(struct monst *) NONNULLARG1;
|
||||||
@@ -1918,7 +1922,7 @@ extern boolean accessible(coordxy, coordxy);
|
|||||||
extern void set_apparxy(struct monst *) NONNULLARG1;
|
extern void set_apparxy(struct monst *) NONNULLARG1;
|
||||||
extern boolean can_ooze(struct monst *) NONNULLARG1;
|
extern boolean can_ooze(struct monst *) NONNULLARG1;
|
||||||
extern boolean can_fog(struct monst *) NONNULLARG1;
|
extern boolean can_fog(struct monst *) NONNULLARG1;
|
||||||
extern boolean should_displace(struct monst *, coord *, long *, int, coordxy,
|
extern boolean should_displace(struct monst *, struct mfndposdata, coordxy,
|
||||||
coordxy) NONNULLPTRS;
|
coordxy) NONNULLPTRS;
|
||||||
extern boolean undesirable_disp(struct monst *, coordxy, coordxy) NONNULLARG1;
|
extern boolean undesirable_disp(struct monst *, coordxy, coordxy) NONNULLARG1;
|
||||||
extern boolean can_hide_under_obj(struct obj *);
|
extern boolean can_hide_under_obj(struct obj *);
|
||||||
|
|||||||
@@ -30,4 +30,10 @@
|
|||||||
#endif
|
#endif
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
|
struct mfndposdata {
|
||||||
|
int cnt;
|
||||||
|
coord poss[9];
|
||||||
|
long info[9];
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* MFNDPOS_H */
|
#endif /* MFNDPOS_H */
|
||||||
|
|||||||
+13
-14
@@ -983,8 +983,8 @@ dog_move(
|
|||||||
coordxy nx, ny; /* temporary coordinates */
|
coordxy nx, ny; /* temporary coordinates */
|
||||||
xint16 cnt, uncursedcnt, chcnt;
|
xint16 cnt, uncursedcnt, chcnt;
|
||||||
int chi = -1, nidist, ndist;
|
int chi = -1, nidist, ndist;
|
||||||
coord poss[9];
|
long allowflags;
|
||||||
long info[9], allowflags;
|
struct mfndposdata mfp;
|
||||||
#define GDIST(x, y) (dist2(x, y, gg.gx, gg.gy))
|
#define GDIST(x, y) (dist2(x, y, gg.gx, gg.gy))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1020,7 +1020,6 @@ dog_move(
|
|||||||
nix = omx; /* set before newdogpos */
|
nix = omx; /* set before newdogpos */
|
||||||
niy = omy;
|
niy = omy;
|
||||||
cursemsg[0] = FALSE; /* lint suppression */
|
cursemsg[0] = FALSE; /* lint suppression */
|
||||||
info[0] = 0; /* ditto */
|
|
||||||
|
|
||||||
if (edog) {
|
if (edog) {
|
||||||
j = dog_invent(mtmp, edog, udist);
|
j = dog_invent(mtmp, edog, udist);
|
||||||
@@ -1054,7 +1053,7 @@ dog_move(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
allowflags = mon_allowflags(mtmp);
|
allowflags = mon_allowflags(mtmp);
|
||||||
cnt = mfndpos(mtmp, poss, info, allowflags);
|
cnt = mfndpos(mtmp, &mfp, allowflags);
|
||||||
|
|
||||||
/* Normally dogs don't step on cursed items, but if they have no
|
/* Normally dogs don't step on cursed items, but if they have no
|
||||||
* other choice they will. This requires checking ahead of time
|
* other choice they will. This requires checking ahead of time
|
||||||
@@ -1062,16 +1061,16 @@ dog_move(
|
|||||||
*/
|
*/
|
||||||
uncursedcnt = 0;
|
uncursedcnt = 0;
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
nx = poss[i].x;
|
nx = mfp.poss[i].x;
|
||||||
ny = poss[i].y;
|
ny = mfp.poss[i].y;
|
||||||
if (MON_AT(nx, ny) && !((info[i] & ALLOW_M) || info[i] & ALLOW_MDISP))
|
if (MON_AT(nx, ny) && !((mfp.info[i] & ALLOW_M) || mfp.info[i] & ALLOW_MDISP))
|
||||||
continue;
|
continue;
|
||||||
if (cursed_object_at(nx, ny))
|
if (cursed_object_at(nx, ny))
|
||||||
continue;
|
continue;
|
||||||
uncursedcnt++;
|
uncursedcnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
better_with_displacing = should_displace(mtmp, poss, info, cnt,
|
better_with_displacing = should_displace(mtmp, mfp,
|
||||||
gg.gx, gg.gy);
|
gg.gx, gg.gy);
|
||||||
|
|
||||||
chcnt = 0;
|
chcnt = 0;
|
||||||
@@ -1079,8 +1078,8 @@ dog_move(
|
|||||||
nidist = GDIST(nix, niy);
|
nidist = GDIST(nix, niy);
|
||||||
|
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
nx = poss[i].x;
|
nx = mfp.poss[i].x;
|
||||||
ny = poss[i].y;
|
ny = mfp.poss[i].y;
|
||||||
cursemsg[i] = FALSE;
|
cursemsg[i] = FALSE;
|
||||||
|
|
||||||
/* if leashed, we drag him along. */
|
/* if leashed, we drag him along. */
|
||||||
@@ -1093,7 +1092,7 @@ dog_move(
|
|||||||
|
|
||||||
ranged_only = FALSE;
|
ranged_only = FALSE;
|
||||||
|
|
||||||
if ((info[i] & ALLOW_M) && MON_AT(nx, ny)) {
|
if ((mfp.info[i] & ALLOW_M) && MON_AT(nx, ny)) {
|
||||||
int mstatus;
|
int mstatus;
|
||||||
struct monst *mtmp2 = m_at(nx, ny);
|
struct monst *mtmp2 = m_at(nx, ny);
|
||||||
/* weight the audacity of the pet to attack a differently-leveled
|
/* weight the audacity of the pet to attack a differently-leveled
|
||||||
@@ -1162,7 +1161,7 @@ dog_move(
|
|||||||
}
|
}
|
||||||
return MMOVE_DONE;
|
return MMOVE_DONE;
|
||||||
}
|
}
|
||||||
if ((info[i] & ALLOW_MDISP) && MON_AT(nx, ny)
|
if ((mfp.info[i] & ALLOW_MDISP) && MON_AT(nx, ny)
|
||||||
&& better_with_displacing && !undesirable_disp(mtmp, nx, ny)) {
|
&& better_with_displacing && !undesirable_disp(mtmp, nx, ny)) {
|
||||||
int mstatus;
|
int mstatus;
|
||||||
struct monst *mtmp2 = m_at(nx, ny);
|
struct monst *mtmp2 = m_at(nx, ny);
|
||||||
@@ -1189,7 +1188,7 @@ dog_move(
|
|||||||
*/
|
*/
|
||||||
struct trap *trap;
|
struct trap *trap;
|
||||||
|
|
||||||
if ((info[i] & ALLOW_TRAPS) && (trap = t_at(nx, ny))) {
|
if ((mfp.info[i] & ALLOW_TRAPS) && (trap = t_at(nx, ny))) {
|
||||||
if (mtmp->mleashed) {
|
if (mtmp->mleashed) {
|
||||||
if (!Deaf)
|
if (!Deaf)
|
||||||
whimper(mtmp);
|
whimper(mtmp);
|
||||||
@@ -1271,7 +1270,7 @@ dog_move(
|
|||||||
if (nix != omx || niy != omy) {
|
if (nix != omx || niy != omy) {
|
||||||
boolean wasseen;
|
boolean wasseen;
|
||||||
|
|
||||||
if (info[chi] & ALLOW_U) {
|
if (mfp.info[chi] & ALLOW_U) {
|
||||||
if (mtmp->mleashed) { /* play it safe */
|
if (mtmp->mleashed) { /* play it safe */
|
||||||
pline_mon(mtmp, "%s breaks loose of %s leash!",
|
pline_mon(mtmp, "%s breaks loose of %s leash!",
|
||||||
Monnam(mtmp), mhis(mtmp));
|
Monnam(mtmp), mhis(mtmp));
|
||||||
|
|||||||
@@ -2111,8 +2111,7 @@ m_in_air(struct monst *mtmp)
|
|||||||
int
|
int
|
||||||
mfndpos(
|
mfndpos(
|
||||||
struct monst *mon,
|
struct monst *mon,
|
||||||
coord *poss, /* coord poss[9] */
|
struct mfndposdata *data,
|
||||||
long *info, /* long info[9] */
|
|
||||||
long flag)
|
long flag)
|
||||||
{
|
{
|
||||||
struct permonst *mdat = mon->data;
|
struct permonst *mdat = mon->data;
|
||||||
@@ -2132,6 +2131,8 @@ mfndpos(
|
|||||||
y = mon->my;
|
y = mon->my;
|
||||||
nowtyp = levl[x][y].typ;
|
nowtyp = levl[x][y].typ;
|
||||||
|
|
||||||
|
(void)memset((genericptr_t) data, 0, sizeof(struct mfndposdata));
|
||||||
|
|
||||||
nodiag = NODIAG(mdat - mons);
|
nodiag = NODIAG(mdat - mons);
|
||||||
wantpool = (mdat->mlet == S_EEL);
|
wantpool = (mdat->mlet == S_EEL);
|
||||||
poolok = ((!Is_waterlevel(&u.uz) && m_in_air(mon))
|
poolok = ((!Is_waterlevel(&u.uz) && m_in_air(mon))
|
||||||
@@ -2247,11 +2248,11 @@ mfndpos(
|
|||||||
dispy = ny;
|
dispy = ny;
|
||||||
}
|
}
|
||||||
|
|
||||||
info[cnt] = 0;
|
data->info[cnt] = 0;
|
||||||
if (onscary(dispx, dispy, mon)) {
|
if (onscary(dispx, dispy, mon)) {
|
||||||
if (!(flag & ALLOW_SSM))
|
if (!(flag & ALLOW_SSM))
|
||||||
continue;
|
continue;
|
||||||
info[cnt] |= ALLOW_SSM;
|
data->info[cnt] |= ALLOW_SSM;
|
||||||
}
|
}
|
||||||
if (u_at(nx, ny)
|
if (u_at(nx, ny)
|
||||||
|| (nx == mon->mux && ny == mon->muy)) {
|
|| (nx == mon->mux && ny == mon->muy)) {
|
||||||
@@ -2267,25 +2268,25 @@ mfndpos(
|
|||||||
}
|
}
|
||||||
if (!(flag & ALLOW_U))
|
if (!(flag & ALLOW_U))
|
||||||
continue;
|
continue;
|
||||||
info[cnt] |= ALLOW_U;
|
data->info[cnt] |= ALLOW_U;
|
||||||
} else {
|
} else {
|
||||||
if (MON_AT(nx, ny)) {
|
if (MON_AT(nx, ny)) {
|
||||||
struct monst *mtmp2 = m_at(nx, ny);
|
struct monst *mtmp2 = m_at(nx, ny);
|
||||||
long mmflag = flag | mm_aggression(mon, mtmp2);
|
long mmflag = flag | mm_aggression(mon, mtmp2);
|
||||||
|
|
||||||
if (mmflag & ALLOW_M) {
|
if (mmflag & ALLOW_M) {
|
||||||
info[cnt] |= ALLOW_M;
|
data->info[cnt] |= ALLOW_M;
|
||||||
if (mtmp2->mtame) {
|
if (mtmp2->mtame) {
|
||||||
if (!(mmflag & ALLOW_TM))
|
if (!(mmflag & ALLOW_TM))
|
||||||
continue;
|
continue;
|
||||||
info[cnt] |= ALLOW_TM;
|
data->info[cnt] |= ALLOW_TM;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
flag &= ~ALLOW_MDISP; /* depends upon defender */
|
flag &= ~ALLOW_MDISP; /* depends upon defender */
|
||||||
mmflag = flag | mm_displacement(mon, mtmp2);
|
mmflag = flag | mm_displacement(mon, mtmp2);
|
||||||
if (!(mmflag & ALLOW_MDISP))
|
if (!(mmflag & ALLOW_MDISP))
|
||||||
continue;
|
continue;
|
||||||
info[cnt] |= ALLOW_MDISP;
|
data->info[cnt] |= ALLOW_MDISP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Note: ALLOW_SANCT only prevents movement, not
|
/* Note: ALLOW_SANCT only prevents movement, not
|
||||||
@@ -2296,23 +2297,23 @@ mfndpos(
|
|||||||
&& in_your_sanctuary((struct monst *) 0, nx, ny)) {
|
&& in_your_sanctuary((struct monst *) 0, nx, ny)) {
|
||||||
if (!(flag & ALLOW_SANCT))
|
if (!(flag & ALLOW_SANCT))
|
||||||
continue;
|
continue;
|
||||||
info[cnt] |= ALLOW_SANCT;
|
data->info[cnt] |= ALLOW_SANCT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (checkobj && sobj_at(CLOVE_OF_GARLIC, nx, ny)) {
|
if (checkobj && sobj_at(CLOVE_OF_GARLIC, nx, ny)) {
|
||||||
if (flag & NOGARLIC)
|
if (flag & NOGARLIC)
|
||||||
continue;
|
continue;
|
||||||
info[cnt] |= NOGARLIC;
|
data->info[cnt] |= NOGARLIC;
|
||||||
}
|
}
|
||||||
if (checkobj && sobj_at(BOULDER, nx, ny)) {
|
if (checkobj && sobj_at(BOULDER, nx, ny)) {
|
||||||
if (!(flag & ALLOW_ROCK))
|
if (!(flag & ALLOW_ROCK))
|
||||||
continue;
|
continue;
|
||||||
info[cnt] |= ALLOW_ROCK;
|
data->info[cnt] |= ALLOW_ROCK;
|
||||||
}
|
}
|
||||||
if (monseeu && monlineu(mon, nx, ny)) {
|
if (monseeu && monlineu(mon, nx, ny)) {
|
||||||
if (flag & NOTONL)
|
if (flag & NOTONL)
|
||||||
continue;
|
continue;
|
||||||
info[cnt] |= NOTONL;
|
data->info[cnt] |= NOTONL;
|
||||||
}
|
}
|
||||||
/* check for diagonal tight squeeze */
|
/* check for diagonal tight squeeze */
|
||||||
if (nx != x && ny != y && bad_rock(mdat, x, ny)
|
if (nx != x && ny != y && bad_rock(mdat, x, ny)
|
||||||
@@ -2332,17 +2333,17 @@ mfndpos(
|
|||||||
}
|
}
|
||||||
/* fixed-destination teleport trap, was used by hero */
|
/* fixed-destination teleport trap, was used by hero */
|
||||||
if (fixed_tele_trap(ttmp) && hastrack(nx, ny))
|
if (fixed_tele_trap(ttmp) && hastrack(nx, ny))
|
||||||
info[cnt] |= ALLOW_TRAPS;
|
data->info[cnt] |= ALLOW_TRAPS;
|
||||||
else if (!m_harmless_trap(mon, ttmp)) {
|
else if (!m_harmless_trap(mon, ttmp)) {
|
||||||
if (!(flag & ALLOW_TRAPS)) {
|
if (!(flag & ALLOW_TRAPS)) {
|
||||||
if (mon_knows_traps(mon, ttmp->ttyp))
|
if (mon_knows_traps(mon, ttmp->ttyp))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
info[cnt] |= ALLOW_TRAPS;
|
data->info[cnt] |= ALLOW_TRAPS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
poss[cnt].x = nx;
|
data->poss[cnt].x = nx;
|
||||||
poss[cnt].y = ny;
|
data->poss[cnt].y = ny;
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2350,6 +2351,7 @@ mfndpos(
|
|||||||
wantpool = FALSE;
|
wantpool = FALSE;
|
||||||
goto nexttry;
|
goto nexttry;
|
||||||
}
|
}
|
||||||
|
data->cnt = cnt;
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+19
-22
@@ -1069,9 +1069,7 @@ itsstuck(struct monst *mtmp)
|
|||||||
boolean
|
boolean
|
||||||
should_displace(
|
should_displace(
|
||||||
struct monst *mtmp,
|
struct monst *mtmp,
|
||||||
coord *poss, /* coord poss[9] */
|
struct mfndposdata data,
|
||||||
long *info, /* long info[9] */
|
|
||||||
int cnt,
|
|
||||||
coordxy ggx,
|
coordxy ggx,
|
||||||
coordxy ggy)
|
coordxy ggy)
|
||||||
{
|
{
|
||||||
@@ -1081,11 +1079,11 @@ should_displace(
|
|||||||
int i, nx, ny;
|
int i, nx, ny;
|
||||||
int ndist;
|
int ndist;
|
||||||
|
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < data.cnt; i++) {
|
||||||
nx = poss[i].x;
|
nx = data.poss[i].x;
|
||||||
ny = poss[i].y;
|
ny = data.poss[i].y;
|
||||||
ndist = dist2(nx, ny, ggx, ggy);
|
ndist = dist2(nx, ny, ggx, ggy);
|
||||||
if (MON_AT(nx, ny) && (info[i] & ALLOW_MDISP) && !(info[i] & ALLOW_M)
|
if (MON_AT(nx, ny) && (data.info[i] & ALLOW_MDISP) && !(data.info[i] & ALLOW_M)
|
||||||
&& !undesirable_disp(mtmp, nx, ny)) {
|
&& !undesirable_disp(mtmp, nx, ny)) {
|
||||||
if (shortest_with_displacing == -1
|
if (shortest_with_displacing == -1
|
||||||
|| (ndist < shortest_with_displacing))
|
|| (ndist < shortest_with_displacing))
|
||||||
@@ -1726,7 +1724,7 @@ m_move(struct monst *mtmp, int after)
|
|||||||
struct permonst *ptr;
|
struct permonst *ptr;
|
||||||
int chi, mmoved = MMOVE_NOTHING, /* not strictly nec.: chi >= 0 will do */
|
int chi, mmoved = MMOVE_NOTHING, /* not strictly nec.: chi >= 0 will do */
|
||||||
preferredrange_min = 0, preferredrange_max = 0;
|
preferredrange_min = 0, preferredrange_max = 0;
|
||||||
long info[9];
|
struct mfndposdata mfp;
|
||||||
long flag;
|
long flag;
|
||||||
coordxy omx = mtmp->mx, omy = mtmp->my;
|
coordxy omx = mtmp->mx, omy = mtmp->my;
|
||||||
|
|
||||||
@@ -1922,9 +1920,8 @@ m_move(struct monst *mtmp, int after)
|
|||||||
int jcnt, cnt;
|
int jcnt, cnt;
|
||||||
int ndist, nidist;
|
int ndist, nidist;
|
||||||
coord *mtrk;
|
coord *mtrk;
|
||||||
coord poss[9];
|
|
||||||
|
|
||||||
cnt = mfndpos(mtmp, poss, info, flag);
|
cnt = mfndpos(mtmp, &mfp, flag);
|
||||||
if (cnt == 0 && !is_unicorn(mtmp->data)) {
|
if (cnt == 0 && !is_unicorn(mtmp->data)) {
|
||||||
if (find_defensive(mtmp, TRUE) && use_defensive(mtmp))
|
if (find_defensive(mtmp, TRUE) && use_defensive(mtmp))
|
||||||
return MMOVE_DONE;
|
return MMOVE_DONE;
|
||||||
@@ -1941,22 +1938,22 @@ m_move(struct monst *mtmp, int after)
|
|||||||
if (is_unicorn(ptr) && noteleport_level(mtmp)) {
|
if (is_unicorn(ptr) && noteleport_level(mtmp)) {
|
||||||
/* on noteleport levels, perhaps we cannot avoid hero */
|
/* on noteleport levels, perhaps we cannot avoid hero */
|
||||||
for (i = 0; i < cnt; i++)
|
for (i = 0; i < cnt; i++)
|
||||||
if (!(info[i] & NOTONL))
|
if (!(mfp.info[i] & NOTONL))
|
||||||
avoid = TRUE;
|
avoid = TRUE;
|
||||||
}
|
}
|
||||||
better_with_displacing =
|
better_with_displacing =
|
||||||
should_displace(mtmp, poss, info, cnt, ggx, ggy);
|
should_displace(mtmp, mfp, ggx, ggy);
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
if (avoid && (info[i] & NOTONL))
|
if (avoid && (mfp.info[i] & NOTONL))
|
||||||
continue;
|
continue;
|
||||||
nx = poss[i].x;
|
nx = mfp.poss[i].x;
|
||||||
ny = poss[i].y;
|
ny = mfp.poss[i].y;
|
||||||
|
|
||||||
if (m_avoid_kicked_loc(mtmp, nx, ny))
|
if (m_avoid_kicked_loc(mtmp, nx, ny))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (MON_AT(nx, ny) && (info[i] & ALLOW_MDISP)
|
if (MON_AT(nx, ny) && (mfp.info[i] & ALLOW_MDISP)
|
||||||
&& !(info[i] & ALLOW_M) && !better_with_displacing)
|
&& !(mfp.info[i] & ALLOW_M) && !better_with_displacing)
|
||||||
continue;
|
continue;
|
||||||
if (appr != 0) {
|
if (appr != 0) {
|
||||||
mtrk = &mtmp->mtrack[0];
|
mtrk = &mtmp->mtrack[0];
|
||||||
@@ -2004,8 +2001,8 @@ m_move(struct monst *mtmp, int after)
|
|||||||
* mfndpos) has no effect for normal attacks, though it lets a
|
* mfndpos) has no effect for normal attacks, though it lets a
|
||||||
* confused monster attack you by accident.
|
* confused monster attack you by accident.
|
||||||
*/
|
*/
|
||||||
assert(IndexOk(chi, info));
|
assert(IndexOk(chi, mfp.info));
|
||||||
if (info[chi] & ALLOW_U) {
|
if (mfp.info[chi] & ALLOW_U) {
|
||||||
nix = mtmp->mux;
|
nix = mtmp->mux;
|
||||||
niy = mtmp->muy;
|
niy = mtmp->muy;
|
||||||
}
|
}
|
||||||
@@ -2020,11 +2017,11 @@ m_move(struct monst *mtmp, int after)
|
|||||||
* Pets get taken care of above and shouldn't reach this code.
|
* Pets get taken care of above and shouldn't reach this code.
|
||||||
* Conflict gets handled even farther away (movemon()).
|
* Conflict gets handled even farther away (movemon()).
|
||||||
*/
|
*/
|
||||||
if ((info[chi] & ALLOW_M) != 0
|
if ((mfp.info[chi] & ALLOW_M) != 0
|
||||||
|| (nix == mtmp->mux && niy == mtmp->muy))
|
|| (nix == mtmp->mux && niy == mtmp->muy))
|
||||||
return m_move_aggress(mtmp, nix, niy);
|
return m_move_aggress(mtmp, nix, niy);
|
||||||
|
|
||||||
if ((info[chi] & ALLOW_MDISP) != 0) {
|
if ((mfp.info[chi] & ALLOW_MDISP) != 0) {
|
||||||
struct monst *mtmp2;
|
struct monst *mtmp2;
|
||||||
int mstatus;
|
int mstatus;
|
||||||
|
|
||||||
@@ -2041,7 +2038,7 @@ m_move(struct monst *mtmp, int after)
|
|||||||
if (!m_in_out_region(mtmp, nix, niy))
|
if (!m_in_out_region(mtmp, nix, niy))
|
||||||
return MMOVE_DONE;
|
return MMOVE_DONE;
|
||||||
|
|
||||||
if ((info[chi] & ALLOW_ROCK) && m_can_break_boulder(mtmp)) {
|
if ((mfp.info[chi] & ALLOW_ROCK) && m_can_break_boulder(mtmp)) {
|
||||||
(void) m_break_boulder(mtmp, nix, niy);
|
(void) m_break_boulder(mtmp, nix, niy);
|
||||||
return MMOVE_DONE;
|
return MMOVE_DONE;
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-9
@@ -46,8 +46,7 @@ move_special(struct monst *mtmp, boolean in_his_shop, schar appr,
|
|||||||
coordxy nx, ny, nix, niy;
|
coordxy nx, ny, nix, niy;
|
||||||
schar i;
|
schar i;
|
||||||
schar chcnt, cnt;
|
schar chcnt, cnt;
|
||||||
coord poss[9];
|
struct mfndposdata mfp;
|
||||||
long info[9];
|
|
||||||
long ninfo = 0;
|
long ninfo = 0;
|
||||||
long allowflags;
|
long allowflags;
|
||||||
#if 0 /* dead code; see below */
|
#if 0 /* dead code; see below */
|
||||||
@@ -64,11 +63,11 @@ move_special(struct monst *mtmp, boolean in_his_shop, schar appr,
|
|||||||
nix = omx;
|
nix = omx;
|
||||||
niy = omy;
|
niy = omy;
|
||||||
allowflags = mon_allowflags(mtmp);
|
allowflags = mon_allowflags(mtmp);
|
||||||
cnt = mfndpos(mtmp, poss, info, allowflags);
|
cnt = mfndpos(mtmp, &mfp, allowflags);
|
||||||
|
|
||||||
if (mtmp->isshk && avoid && uondoor) { /* perhaps we cannot avoid him */
|
if (mtmp->isshk && avoid && uondoor) { /* perhaps we cannot avoid him */
|
||||||
for (i = 0; i < cnt; i++)
|
for (i = 0; i < cnt; i++)
|
||||||
if (!(info[i] & NOTONL))
|
if (!(mfp.info[i] & NOTONL))
|
||||||
goto pick_move;
|
goto pick_move;
|
||||||
avoid = FALSE;
|
avoid = FALSE;
|
||||||
}
|
}
|
||||||
@@ -77,18 +76,18 @@ move_special(struct monst *mtmp, boolean in_his_shop, schar appr,
|
|||||||
pick_move:
|
pick_move:
|
||||||
chcnt = 0;
|
chcnt = 0;
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
nx = poss[i].x;
|
nx = mfp.poss[i].x;
|
||||||
ny = poss[i].y;
|
ny = mfp.poss[i].y;
|
||||||
if (IS_ROOM(levl[nx][ny].typ)
|
if (IS_ROOM(levl[nx][ny].typ)
|
||||||
|| (mtmp->isshk && (!in_his_shop || ESHK(mtmp)->following))) {
|
|| (mtmp->isshk && (!in_his_shop || ESHK(mtmp)->following))) {
|
||||||
if (avoid && (info[i] & NOTONL) && !(info[i] & ALLOW_M))
|
if (avoid && (mfp.info[i] & NOTONL) && !(mfp.info[i] & ALLOW_M))
|
||||||
continue;
|
continue;
|
||||||
if ((!appr && !rn2(++chcnt))
|
if ((!appr && !rn2(++chcnt))
|
||||||
|| (appr && GDIST(nx, ny) < GDIST(nix, niy))
|
|| (appr && GDIST(nx, ny) < GDIST(nix, niy))
|
||||||
|| (info[i] & ALLOW_M)) {
|
|| (mfp.info[i] & ALLOW_M)) {
|
||||||
nix = nx;
|
nix = nx;
|
||||||
niy = ny;
|
niy = ny;
|
||||||
ninfo = info[i];
|
ninfo = mfp.info[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user