diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 23b5e9c24..d9636aa7c 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -849,6 +849,7 @@ hide-under monsters who can be turned to stone aren't able to hide under a don't stop travel when going past a closed door (eg. when traveling along a room wall) some monster corpses can now convey temporary acid or stoning resistance +fix travel getting stuck oscillating between two locations Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/src/hack.c b/src/hack.c index 53f0efd50..219dda937 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1274,26 +1274,29 @@ findtravelpath(int mode) if (mode == TRAVP_GUESS) { int px = tx, py = ty; /* pick location */ int dist, nxtdist, d2, nd2; + int ctrav, ptrav = COLNO*ROWNO; dist = distmin(ux, uy, tx, ty); d2 = dist2(ux, uy, tx, ty); for (tx = 1; tx < COLNO; ++tx) for (ty = 0; ty < ROWNO; ++ty) - if (travel[tx][ty]) { + if (couldsee(tx, ty) && (ctrav = travel[tx][ty]) > 0) { nxtdist = distmin(ux, uy, tx, ty); - if (nxtdist == dist && couldsee(tx, ty)) { + if (nxtdist == dist && ctrav < ptrav) { nd2 = dist2(ux, uy, tx, ty); if (nd2 < d2) { /* prefer non-zigzag path */ px = tx; py = ty; d2 = nd2; + ptrav = ctrav; } - } else if (nxtdist < dist && couldsee(tx, ty)) { + } else if (nxtdist < dist) { px = tx; py = ty; dist = nxtdist; d2 = dist2(ux, uy, tx, ty); + ptrav = ctrav; } }