From c9a1984da5f73538e003f6c34e45d5d6f6a4fe32 Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Fri, 13 Dec 2024 19:55:50 -0300 Subject: [PATCH] Simplify P_BlockThingsIterator There was no reason to do what I did, since the loop only needs to hold a reference to the next block. This reverts the function to how it was before 7469a6271b4b1b9e3bfcc7bd81d817cfed0a88c2, but holds the reference properly. --- src/p_maputl.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/p_maputl.c b/src/p_maputl.c index f10a396a3..6842677b3 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -1052,7 +1052,6 @@ boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean (*func)(line_t *)) // boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) { - mobj_t *bnext = NULL; blocknode_t *block, *next = NULL; if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight) @@ -1061,26 +1060,15 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) // Check interaction with the objects in the blockmap. for (block = blocklinks[y*bmapwidth + x]; block; block = next) { - next = block->mnext; - if (next) - P_SetTarget(&bnext, next->mobj); // We want to note our reference to bnext here in case it is MF_NOTHINK and gets removed! + next = block->mnext; // We want to note our reference to mnext here in case the object gets removed! if (!func(block->mobj)) - { - P_SetTarget(&bnext, NULL); return false; - } - if (P_MobjWasRemoved(tmthing) // func just popped our tmthing, cannot continue. - || (bnext && P_MobjWasRemoved(bnext))) // func just broke blockmap chain, cannot continue. - { - P_SetTarget(&bnext, NULL); + if (P_MobjWasRemoved(tmthing)) // func just popped our tmthing, cannot continue. return true; - } } - P_SetTarget(&bnext, NULL); - return true; }