Split deadbook undead pacify effect into separate function
Also make the monster chain iterator functions more robust, in case the called function changes the next monster pointer.
This commit is contained in:
@@ -4125,9 +4125,10 @@ iter_mons_safe(boolean (*func)(struct monst *))
|
||||
void
|
||||
iter_mons(void (*func)(struct monst *))
|
||||
{
|
||||
struct monst *mtmp;
|
||||
struct monst *mtmp, *mtmp2;
|
||||
|
||||
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
|
||||
for (mtmp = fmon; mtmp; mtmp = mtmp2) {
|
||||
mtmp2 = mtmp->nmon;
|
||||
if (DEADMONSTER(mtmp) || mon_offmap(mtmp))
|
||||
continue;
|
||||
func(mtmp);
|
||||
@@ -4140,9 +4141,10 @@ iter_mons(void (*func)(struct monst *))
|
||||
struct monst *
|
||||
get_iter_mons(boolean (*func)(struct monst *))
|
||||
{
|
||||
struct monst *mtmp;
|
||||
struct monst *mtmp, *mtmp2;
|
||||
|
||||
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
|
||||
for (mtmp = fmon; mtmp; mtmp = mtmp2) {
|
||||
mtmp2 = mtmp->nmon;
|
||||
if (DEADMONSTER(mtmp) || mon_offmap(mtmp))
|
||||
continue;
|
||||
if (func(mtmp))
|
||||
@@ -4158,9 +4160,10 @@ struct monst *
|
||||
get_iter_mons_xy(boolean (*func)(struct monst *, coordxy, coordxy),
|
||||
coordxy x, coordxy y)
|
||||
{
|
||||
struct monst *mtmp;
|
||||
struct monst *mtmp, *mtmp2;
|
||||
|
||||
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
|
||||
for (mtmp = fmon; mtmp; mtmp = mtmp2) {
|
||||
mtmp2 = mtmp->nmon;
|
||||
if (DEADMONSTER(mtmp) || mon_offmap(mtmp))
|
||||
continue;
|
||||
if (func(mtmp, x, y))
|
||||
|
||||
Reference in New Issue
Block a user