diff --git a/src/p_enemy.c b/src/p_enemy.c index 2dbdf17eb..aadf11a99 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -1455,7 +1455,7 @@ static bool P_HealCorpse(mobj_t *actor, int radius, statenum_t healstate, sfxnum for (int bx = xl; bx <= xh; bx++) for (int by = yl; by <= yh; by++) // Call PIT_VileCheck() to check whether object is a corpse that can be raised. - if (!P_BlockThingsIterator(bx, by, &PIT_VileCheck)) + if (!P_BlockThingsIterator(bx, by, &PIT_VileCheck, true)) { // got one! mobj_t *prevtarget = actor->target; diff --git a/src/p_local.h b/src/p_local.h index 6b4bfee1c..31f18c083 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -217,7 +217,7 @@ extern fixed_t lowfloor; void P_LineOpening(const line_t *line); bool P_BlockLinesIterator(const int x, const int y, bool func(line_t *)); -bool P_BlockThingsIterator(const int x, const int y, bool func(mobj_t *)); +bool P_BlockThingsIterator(const int x, const int y, bool func(mobj_t *), bool blockmapfix); #define PT_ADDLINES 1 #define PT_ADDTHINGS 2 diff --git a/src/p_map.c b/src/p_map.c index eae0a5a97..7654bc0fc 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -242,7 +242,7 @@ bool P_TeleportMove(mobj_t *thing, const fixed_t x, const fixed_t y, const fixed for (int bx = xl; bx <= xh; bx++) for (int by = yl; by <= yh; by++) - if (!P_BlockThingsIterator(bx, by, &PIT_StompThing)) + if (!P_BlockThingsIterator(bx, by, &PIT_StompThing, true)) return false; // the move is ok, @@ -847,7 +847,8 @@ bool P_CheckPosition(mobj_t *thing, const fixed_t x, const fixed_t y) for (int bx = xl; bx <= xh; bx++) for (int by = yl; by <= yh; by++) - if (!P_BlockThingsIterator(bx, by, &PIT_CheckThing)) + if (!P_BlockThingsIterator(bx, by, &PIT_CheckThing, + !(tmthing->mbf21flags & MF_MBF21_RIP))) return false; // check lines @@ -979,7 +980,7 @@ mobj_t *P_CheckOnMobj(mobj_t *thing) for (int bx = xl; bx <= xh; bx++) for (int by = yl; by <= yh; by++) - if (!P_BlockThingsIterator(bx, by, &PIT_CheckOnMobjZ)) + if (!P_BlockThingsIterator(bx, by, &PIT_CheckOnMobjZ, true)) { *tmthing = oldmo; return onmobj; @@ -2121,7 +2122,7 @@ void P_RadiusAttack(mobj_t *spot, mobj_t *source, const int damage, const int di for (int y = yl; y <= yh; y++) for (int x = xl; x <= xh; x++) - P_BlockThingsIterator(x, y, &PIT_RadiusAttack); + P_BlockThingsIterator(x, y, &PIT_RadiusAttack, false); } // diff --git a/src/p_maputl.c b/src/p_maputl.c index 935c00730..54386be41 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -364,7 +364,7 @@ bool P_BlockLinesIterator(const int x, const int y, bool func(line_t *)) // // P_BlockThingsIterator // -bool P_BlockThingsIterator(const int x, const int y, bool func(mobj_t *)) +bool P_BlockThingsIterator(const int x, const int y, bool func(mobj_t *), bool blockmapfix) { if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight) return true; @@ -373,66 +373,65 @@ bool P_BlockThingsIterator(const int x, const int y, bool func(mobj_t *)) if (!func(mobj)) return false; - if (func == &PIT_RadiusAttack) - return true; - // Blockmap bug fix by Terry Hearst - - // (-1, -1) - if (x > 0 && y > 0) - for (mobj_t *mobj = blocklinks[(y - 1) * bmapwidth + x - 1]; mobj; mobj = mobj->bnext) - if (x == (mobj->x + mobj->radius - bmaporgx) >> MAPBLOCKSHIFT - && y == (mobj->y + mobj->radius - bmaporgy) >> MAPBLOCKSHIFT - && !func(mobj)) + if (blockmapfix) + { + // (-1, -1) + if (x > 0 && y > 0) + for (mobj_t *mobj = blocklinks[(y - 1) * bmapwidth + x - 1]; mobj; mobj = mobj->bnext) + if (x == (mobj->x + mobj->radius - bmaporgx) >> MAPBLOCKSHIFT + && y == (mobj->y + mobj->radius - bmaporgy) >> MAPBLOCKSHIFT + && !func(mobj)) return false; - // (0, -1) - if (y > 0) - for (mobj_t *mobj = blocklinks[(y - 1) * bmapwidth + x]; mobj; mobj = mobj->bnext) - if (y == (mobj->y + mobj->radius - bmaporgy) >> MAPBLOCKSHIFT && !func(mobj)) + // (0, -1) + if (y > 0) + for (mobj_t *mobj = blocklinks[(y - 1) * bmapwidth + x]; mobj; mobj = mobj->bnext) + if (y == (mobj->y + mobj->radius - bmaporgy) >> MAPBLOCKSHIFT && !func(mobj)) return false; - // (1, -1) - if (x < bmapwidth - 1 && y > 0) - for (mobj_t *mobj = blocklinks[(y - 1) * bmapwidth + x + 1]; mobj; mobj = mobj->bnext) - if (x == (mobj->x - mobj->radius - bmaporgx) >> MAPBLOCKSHIFT - && y == (mobj->y + mobj->radius - bmaporgy) >> MAPBLOCKSHIFT - && !func(mobj)) + // (1, -1) + if (x < bmapwidth - 1 && y > 0) + for (mobj_t *mobj = blocklinks[(y - 1) * bmapwidth + x + 1]; mobj; mobj = mobj->bnext) + if (x == (mobj->x - mobj->radius - bmaporgx) >> MAPBLOCKSHIFT + && y == (mobj->y + mobj->radius - bmaporgy) >> MAPBLOCKSHIFT + && !func(mobj)) return false; - // (1, 0) - if (x < bmapwidth - 1) - for (mobj_t *mobj = blocklinks[y * bmapwidth + x + 1]; mobj; mobj = mobj->bnext) - if (x == (mobj->x - mobj->radius - bmaporgx) >> MAPBLOCKSHIFT && !func(mobj)) + // (1, 0) + if (x < bmapwidth - 1) + for (mobj_t *mobj = blocklinks[y * bmapwidth + x + 1]; mobj; mobj = mobj->bnext) + if (x == (mobj->x - mobj->radius - bmaporgx) >> MAPBLOCKSHIFT && !func(mobj)) return false; - // (1, 1) - if (x < bmapwidth - 1 && y < bmapheight - 1) - for (mobj_t *mobj = blocklinks[(y + 1) * bmapwidth + x + 1]; mobj; mobj = mobj->bnext) - if (x == (mobj->x - mobj->radius - bmaporgx) >> MAPBLOCKSHIFT - && y == (mobj->y - mobj->radius - bmaporgy) >> MAPBLOCKSHIFT - && !func(mobj)) + // (1, 1) + if (x < bmapwidth - 1 && y < bmapheight - 1) + for (mobj_t *mobj = blocklinks[(y + 1) * bmapwidth + x + 1]; mobj; mobj = mobj->bnext) + if (x == (mobj->x - mobj->radius - bmaporgx) >> MAPBLOCKSHIFT + && y == (mobj->y - mobj->radius - bmaporgy) >> MAPBLOCKSHIFT + && !func(mobj)) return false; - // (0, 1) - if (y < bmapheight - 1) - for (mobj_t *mobj = blocklinks[(y + 1) * bmapwidth + x]; mobj; mobj = mobj->bnext) - if (y == (mobj->y - mobj->radius - bmaporgy) >> MAPBLOCKSHIFT && !func(mobj)) + // (0, 1) + if (y < bmapheight - 1) + for (mobj_t *mobj = blocklinks[(y + 1) * bmapwidth + x]; mobj; mobj = mobj->bnext) + if (y == (mobj->y - mobj->radius - bmaporgy) >> MAPBLOCKSHIFT && !func(mobj)) return false; - // (-1, 1) - if (x > 0 && y < bmapheight - 1) - for (mobj_t *mobj = blocklinks[(y + 1) * bmapwidth + x - 1]; mobj; mobj = mobj->bnext) - if (x == (mobj->x + mobj->radius - bmaporgx) >> MAPBLOCKSHIFT - && y == (mobj->y - mobj->radius - bmaporgy) >> MAPBLOCKSHIFT - && !func(mobj)) + // (-1, 1) + if (x > 0 && y < bmapheight - 1) + for (mobj_t *mobj = blocklinks[(y + 1) * bmapwidth + x - 1]; mobj; mobj = mobj->bnext) + if (x == (mobj->x + mobj->radius - bmaporgx) >> MAPBLOCKSHIFT + && y == (mobj->y - mobj->radius - bmaporgy) >> MAPBLOCKSHIFT + && !func(mobj)) return false; - // (-1, 0) - if (x > 0) - for (mobj_t *mobj = blocklinks[y * bmapwidth + x - 1]; mobj; mobj = mobj->bnext) - if (x == (mobj->x + mobj->radius - bmaporgx) >> MAPBLOCKSHIFT && !func(mobj)) + // (-1, 0) + if (x > 0) + for (mobj_t *mobj = blocklinks[y * bmapwidth + x - 1]; mobj; mobj = mobj->bnext) + if (x == (mobj->x + mobj->radius - bmaporgx) >> MAPBLOCKSHIFT && !func(mobj)) return false; + } return true; } @@ -732,7 +731,7 @@ bool P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const int fl return false; // early out if (flags & PT_ADDTHINGS) - if (!P_BlockThingsIterator(mapx, mapy, &PIT_AddThingIntercepts)) + if (!P_BlockThingsIterator(mapx, mapy, &PIT_AddThingIntercepts, true)) return false; // early out if (mapx == xt2 && mapy == yt2) @@ -772,8 +771,8 @@ bool P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const int fl if (flags & PT_ADDTHINGS) { - P_BlockThingsIterator(mapx + mapxstep, mapy, &PIT_AddThingIntercepts); - P_BlockThingsIterator(mapx, mapy + mapystep, &PIT_AddThingIntercepts); + P_BlockThingsIterator(mapx + mapxstep, mapy, &PIT_AddThingIntercepts, true); + P_BlockThingsIterator(mapx, mapy + mapystep, &PIT_AddThingIntercepts, true); } xintercept += xstep; diff --git a/src/p_spec.c b/src/p_spec.c index dca26c575..ec753601a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3326,7 +3326,7 @@ void T_Pusher(pusher_t *pusher) for (int bx = xl; bx <= xh; bx++) for (int by = yl; by <= yh; by++) - P_BlockThingsIterator(bx, by, &PIT_PushThing); + P_BlockThingsIterator(bx, by, &PIT_PushThing, true); return; }