From d2c74e1b13c4a20f4f7d65b0ea09123dda56a455 Mon Sep 17 00:00:00 2001 From: RedEnchilada Date: Wed, 8 Apr 2015 21:32:07 -0500 Subject: [PATCH] Fix the west/south blockmap issue without fucking up huge maps --- src/p_local.h | 3 +++ src/p_map.c | 12 ++++++++++++ src/p_user.c | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/src/p_local.h b/src/p_local.h index 2f0b06268..926a51788 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -38,6 +38,9 @@ #define MAPBMASK (MAPBLOCKSIZE-1) #define MAPBTOFRAC (MAPBLOCKSHIFT-FRACBITS) +// Convenience macro to fix issue with collision along bottom/left edges of blockmap -Red +#define BMBOUNDFIX(xl, xh, yl, yh) {if (xl > xh) xl = 0; if (yl > yh) yl = 0;} + // player radius used only in am_map.c #define PLAYERRADIUS (16*FRACUNIT) diff --git a/src/p_map.c b/src/p_map.c index 5706e6d3c..c88b91e94 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1299,6 +1299,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) yl = (unsigned)(tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT; yh = (unsigned)(tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT; + BMBOUNDFIX(xl, xh, yl, yh); + #ifdef POLYOBJECTS // Check polyobjects and see if tmfloorz/tmceilingz need to be altered { @@ -1516,6 +1518,8 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) yl = (unsigned)(tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; yh = (unsigned)(tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; + BMBOUNDFIX(xl, xh, yl, yh); + #ifdef POLYOBJECTS // Check polyobjects and see if tmfloorz/tmceilingz need to be altered { @@ -1943,6 +1947,8 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) xh = (unsigned)(thing->x + MAXRADIUS - bmaporgx)>>MAPBLOCKSHIFT; xl = (unsigned)(thing->x - MAXRADIUS - bmaporgx)>>MAPBLOCKSHIFT; + BMBOUNDFIX(xl, xh, yl, yh); + stand = thing; standx = x; standy = y; @@ -3029,6 +3035,8 @@ void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist) xh = (unsigned)(spot->x + dist - bmaporgx)>>MAPBLOCKSHIFT; xl = (unsigned)(spot->x - dist - bmaporgx)>>MAPBLOCKSHIFT; + BMBOUNDFIX(xl, xh, yl, yh); + bombspot = spot; bombsource = source; bombdamage = FixedMul(damagedist, spot->scale); @@ -3650,6 +3658,8 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) yl = (unsigned)(tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; yh = (unsigned)(tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; + BMBOUNDFIX(xl, xh, yl, yh); + for (bx = xl; bx <= xh; bx++) for (by = yl; by <= yh; by++) P_BlockLinesIterator(bx, by, PIT_GetSectors); @@ -3727,6 +3737,8 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) yl = (unsigned)(preciptmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; yh = (unsigned)(preciptmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; + BMBOUNDFIX(xl, xh, yl, yh); + for (bx = xl; bx <= xh; bx++) for (by = yl; by <= yh; by++) P_BlockLinesIterator(bx, by, PIT_GetPrecipSectors); diff --git a/src/p_user.c b/src/p_user.c index 6270d7896..870f028c7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2963,6 +2963,8 @@ static void P_DoTeeter(player_t *player) xh = (unsigned)(player->mo->x + player->mo->radius - bmaporgx)>>MAPBLOCKSHIFT; xl = (unsigned)(player->mo->x - player->mo->radius - bmaporgx)>>MAPBLOCKSHIFT; + BMBOUNDFIX(xl, xh, yl, yh); + // Polyobjects #ifdef POLYOBJECTS validcount++; @@ -8099,6 +8101,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall yl = (unsigned)(tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; yh = (unsigned)(tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; + BMBOUNDFIX(xl, xh, yl, yh); + for (by = yl; by <= yh; by++) for (bx = xl; bx <= xh; bx++) {