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:
Pasi Kallinen
2026-01-04 13:56:02 +02:00
parent 01928276d5
commit 37df18b59c
6 changed files with 70 additions and 63 deletions

View File

@@ -983,8 +983,8 @@ dog_move(
coordxy nx, ny; /* temporary coordinates */
xint16 cnt, uncursedcnt, chcnt;
int chi = -1, nidist, ndist;
coord poss[9];
long info[9], allowflags;
long allowflags;
struct mfndposdata mfp;
#define GDIST(x, y) (dist2(x, y, gg.gx, gg.gy))
/*
@@ -1020,7 +1020,6 @@ dog_move(
nix = omx; /* set before newdogpos */
niy = omy;
cursemsg[0] = FALSE; /* lint suppression */
info[0] = 0; /* ditto */
if (edog) {
j = dog_invent(mtmp, edog, udist);
@@ -1054,7 +1053,7 @@ dog_move(
}
#endif
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
* other choice they will. This requires checking ahead of time
@@ -1062,16 +1061,16 @@ dog_move(
*/
uncursedcnt = 0;
for (i = 0; i < cnt; i++) {
nx = poss[i].x;
ny = poss[i].y;
if (MON_AT(nx, ny) && !((info[i] & ALLOW_M) || info[i] & ALLOW_MDISP))
nx = mfp.poss[i].x;
ny = mfp.poss[i].y;
if (MON_AT(nx, ny) && !((mfp.info[i] & ALLOW_M) || mfp.info[i] & ALLOW_MDISP))
continue;
if (cursed_object_at(nx, ny))
continue;
uncursedcnt++;
}
better_with_displacing = should_displace(mtmp, poss, info, cnt,
better_with_displacing = should_displace(mtmp, mfp,
gg.gx, gg.gy);
chcnt = 0;
@@ -1079,8 +1078,8 @@ dog_move(
nidist = GDIST(nix, niy);
for (i = 0; i < cnt; i++) {
nx = poss[i].x;
ny = poss[i].y;
nx = mfp.poss[i].x;
ny = mfp.poss[i].y;
cursemsg[i] = FALSE;
/* if leashed, we drag him along. */
@@ -1093,7 +1092,7 @@ dog_move(
ranged_only = FALSE;
if ((info[i] & ALLOW_M) && MON_AT(nx, ny)) {
if ((mfp.info[i] & ALLOW_M) && MON_AT(nx, ny)) {
int mstatus;
struct monst *mtmp2 = m_at(nx, ny);
/* weight the audacity of the pet to attack a differently-leveled
@@ -1162,7 +1161,7 @@ dog_move(
}
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)) {
int mstatus;
struct monst *mtmp2 = m_at(nx, ny);
@@ -1189,7 +1188,7 @@ dog_move(
*/
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 (!Deaf)
whimper(mtmp);
@@ -1271,7 +1270,7 @@ dog_move(
if (nix != omx || niy != omy) {
boolean wasseen;
if (info[chi] & ALLOW_U) {
if (mfp.info[chi] & ALLOW_U) {
if (mtmp->mleashed) { /* play it safe */
pline_mon(mtmp, "%s breaks loose of %s leash!",
Monnam(mtmp), mhis(mtmp));