Monster list iterator

Add some basic functions to iterate through the monster list,
ignoring dead monsters. Mainly just to allow splitting up code
into discrete functions.

Not quite happy with the get_iter_mons_xy - should probably have
a pointer to iterator data struct, which gets passed through instead,
but this works for now.
This commit is contained in:
Pasi Kallinen
2022-04-24 13:03:43 +03:00
parent f886e0d6ce
commit 4a01c8fbd7
10 changed files with 418 additions and 309 deletions

View File

@@ -12,18 +12,25 @@ static void vault_tele(void);
static boolean rloc_pos_ok(int, int, struct monst *);
static void rloc_to_core(struct monst *, int, int, unsigned);
static void mvault_tele(struct monst *);
static boolean m_blocks_teleporting(struct monst *);
/* does monster block others from teleporting? */
static boolean
m_blocks_teleporting(struct monst *mtmp)
{
if (is_dlord(mtmp->data) || is_dprince(mtmp->data))
return TRUE;
return FALSE;
}
/* teleporting is prevented on this level for this monster? */
boolean
noteleport_level(struct monst* mon)
{
struct monst *mtmp;
/* demon court in Gehennom prevent others from teleporting */
if (In_hell(&u.uz) && !(is_dlord(mon->data) || is_dprince(mon->data)))
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon)
if (is_dlord(mtmp->data) || is_dprince(mtmp->data))
return TRUE;
if (get_iter_mons(m_blocks_teleporting))
return TRUE;
/* natural no-teleport level */
if (g.level.flags.noteleport)