collect_coords() revisited

Make recently added collect_coords() global even though it is still
only being used in teleport.c.

Add CC_SKIP_INACCS flag to only collect accessible locations so that
there's no need for a custom filter callback or of collecting spots
that will always be rejected when put to use.  Caller needs to check
Passes_walls/passes_walls() to decide whether that is suitable.

Merge some of the old safe_teleds() with the new, making it try
randomly 40 times before collecting coordinates for an exhaustive
selection.  Prior to the recent change which added collect_coords()
it was trying 400 times and giving up if that didn't find a good spot.

Start using collect_coords() for rloc() as well as for safe_teleds().
Only try to pick a spot randomly 50 times now instead of 1000.  If
those all fail, it does an exhaustive search of a randomized list of
candidates instead of old left-to-right, top-to-bottom map traversal.
Has not had nearly as much testing as safe_teleds() underwent.

rloc() was explicilty ignoring map column 1 for some reason.  Unlike
reserved column 0, column 1 is part of every level and should be
considered for monster teleport destination even though most levels
don't utilize it.
This commit is contained in:
PatR
2023-05-17 00:33:54 -07:00
parent d7f581d8ad
commit 49e93760a8
4 changed files with 97 additions and 78 deletions

View File

@@ -2803,6 +2803,8 @@ extern boolean enexto(coord *, coordxy, coordxy, struct permonst *);
extern boolean enexto_core(coord *, coordxy, coordxy, struct permonst *,
mmflags_nht);
extern void teleds(coordxy, coordxy, int);
extern int collect_coords(coord *, coordxy, coordxy, int, unsigned,
boolean (*)(coordxy, coordxy));
extern boolean safe_teleds(int);
extern boolean teleport_pet(struct monst *, boolean);
extern void tele(void);