mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-27 04:41:23 +00:00
Merge branch 'actual-blockmap-fix' into 'next'
Actual blockmap fix MI's "fix" was a reversion of something that allowed 2.0 maps to use the entire blockmap. This MR reverts that fix and adds a proper fix to the issue of west/south edges of the blockmap not working as they should. Tested with a thokbarrier-less square map (all sides were solid) and with AGZ (objects are tangible all around the map, like they are in 2.1.14). See merge request !10
This commit is contained in:
commit
f7c463418e
6 changed files with 69 additions and 50 deletions
|
@ -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)
|
||||
|
||||
|
|
60
src/p_map.c
60
src/p_map.c
|
@ -1294,10 +1294,12 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
|
|||
// based on their origin point, and can overlap
|
||||
// into adjacent blocks by up to MAXRADIUS units.
|
||||
|
||||
xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
yl = (tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
xl = (unsigned)(tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
xh = (unsigned)(tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
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
|
||||
|
@ -1511,10 +1513,12 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
|
|||
// based on their origin point, and can overlap
|
||||
// into adjacent blocks by up to MAXRADIUS units.
|
||||
|
||||
xl = (tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xh = (tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
yl = (tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
yh = (tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
xl = (unsigned)(tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xh = (unsigned)(tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
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
|
||||
|
@ -1938,10 +1942,12 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
|
|||
{
|
||||
INT32 bx, by, xl, xh, yl, yh;
|
||||
|
||||
yh = (thing->y + MAXRADIUS - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
yl = (thing->y - MAXRADIUS - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
xh = (thing->x + MAXRADIUS - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xl = (thing->x - MAXRADIUS - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
yh = (unsigned)(thing->y + MAXRADIUS - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
yl = (unsigned)(thing->y - MAXRADIUS - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
xh = (unsigned)(thing->x + MAXRADIUS - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xl = (unsigned)(thing->x - MAXRADIUS - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
|
||||
BMBOUNDFIX(xl, xh, yl, yh);
|
||||
|
||||
stand = thing;
|
||||
standx = x;
|
||||
|
@ -3024,10 +3030,12 @@ void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist)
|
|||
fixed_t dist;
|
||||
|
||||
dist = FixedMul(damagedist, spot->scale) + MAXRADIUS;
|
||||
yh = (spot->y + dist - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
yl = (spot->y - dist - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
xh = (spot->x + dist - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xl = (spot->x - dist - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
yh = (unsigned)(spot->y + dist - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
yl = (unsigned)(spot->y - dist - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
xh = (unsigned)(spot->x + dist - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xl = (unsigned)(spot->x - dist - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
|
||||
BMBOUNDFIX(xl, xh, yl, yh);
|
||||
|
||||
bombspot = spot;
|
||||
bombsource = source;
|
||||
|
@ -3645,10 +3653,12 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y)
|
|||
|
||||
validcount++; // used to make sure we only process a line once
|
||||
|
||||
xl = (tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xh = (tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
yl = (tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
yh = (tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
xl = (unsigned)(tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xh = (unsigned)(tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
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++)
|
||||
|
@ -3722,10 +3732,12 @@ void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y)
|
|||
|
||||
validcount++; // used to make sure we only process a line once
|
||||
|
||||
xl = (preciptmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xh = (preciptmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
yl = (preciptmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
yh = (preciptmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
xl = (unsigned)(preciptmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xh = (unsigned)(preciptmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
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++)
|
||||
|
|
|
@ -814,8 +814,8 @@ void P_SetThingPosition(mobj_t *thing)
|
|||
if (!(thing->flags & MF_NOBLOCKMAP))
|
||||
{
|
||||
// inert things don't need to be in blockmap
|
||||
const INT32 blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
const INT32 blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
const INT32 blockx = (unsigned)(thing->x - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
const INT32 blocky = (unsigned)(thing->y - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
if (blockx >= 0 && blockx < bmapwidth
|
||||
&& blocky >= 0 && blocky < bmapheight)
|
||||
{
|
||||
|
@ -1317,10 +1317,10 @@ boolean P_RadiusLinesCheck(fixed_t radius, fixed_t x, fixed_t y,
|
|||
tmbbox[BOXLEFT] = x - radius;
|
||||
|
||||
// check lines
|
||||
xl = (tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xh = (tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
yl = (tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
yh = (tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
xl = (unsigned)(tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xh = (unsigned)(tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
yl = (unsigned)(tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
yh = (unsigned)(tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
|
||||
for (bx = xl; bx <= xh; bx++)
|
||||
for (by = yl; by <= yh; by++)
|
||||
|
|
|
@ -851,10 +851,10 @@ static void Polyobj_linkToBlockmap(polyobj_t *po)
|
|||
M_AddToBox(blockbox, po->vertices[i]->x, po->vertices[i]->y);
|
||||
|
||||
// adjust bounding box relative to blockmap
|
||||
blockbox[BOXRIGHT] = (blockbox[BOXRIGHT] - bmaporgx) >> MAPBLOCKSHIFT;
|
||||
blockbox[BOXLEFT] = (blockbox[BOXLEFT] - bmaporgx) >> MAPBLOCKSHIFT;
|
||||
blockbox[BOXTOP] = (blockbox[BOXTOP] - bmaporgy) >> MAPBLOCKSHIFT;
|
||||
blockbox[BOXBOTTOM] = (blockbox[BOXBOTTOM] - bmaporgy) >> MAPBLOCKSHIFT;
|
||||
blockbox[BOXRIGHT] = (unsigned)(blockbox[BOXRIGHT] - bmaporgx) >> MAPBLOCKSHIFT;
|
||||
blockbox[BOXLEFT] = (unsigned)(blockbox[BOXLEFT] - bmaporgx) >> MAPBLOCKSHIFT;
|
||||
blockbox[BOXTOP] = (unsigned)(blockbox[BOXTOP] - bmaporgy) >> MAPBLOCKSHIFT;
|
||||
blockbox[BOXBOTTOM] = (unsigned)(blockbox[BOXBOTTOM] - bmaporgy) >> MAPBLOCKSHIFT;
|
||||
|
||||
// link polyobject to every block its bounding box intersects
|
||||
for (y = blockbox[BOXBOTTOM]; y <= blockbox[BOXTOP]; ++y)
|
||||
|
@ -1082,10 +1082,10 @@ static INT32 Polyobj_clipThings(polyobj_t *po, line_t *line)
|
|||
return hitflags;
|
||||
|
||||
// adjust linedef bounding box to blockmap, extend by MAXRADIUS
|
||||
linebox[BOXLEFT] = (line->bbox[BOXLEFT] - bmaporgx - MAXRADIUS) >> MAPBLOCKSHIFT;
|
||||
linebox[BOXRIGHT] = (line->bbox[BOXRIGHT] - bmaporgx + MAXRADIUS) >> MAPBLOCKSHIFT;
|
||||
linebox[BOXBOTTOM] = (line->bbox[BOXBOTTOM] - bmaporgy - MAXRADIUS) >> MAPBLOCKSHIFT;
|
||||
linebox[BOXTOP] = (line->bbox[BOXTOP] - bmaporgy + MAXRADIUS) >> MAPBLOCKSHIFT;
|
||||
linebox[BOXLEFT] = (unsigned)(line->bbox[BOXLEFT] - bmaporgx - MAXRADIUS) >> MAPBLOCKSHIFT;
|
||||
linebox[BOXRIGHT] = (unsigned)(line->bbox[BOXRIGHT] - bmaporgx + MAXRADIUS) >> MAPBLOCKSHIFT;
|
||||
linebox[BOXBOTTOM] = (unsigned)(line->bbox[BOXBOTTOM] - bmaporgy - MAXRADIUS) >> MAPBLOCKSHIFT;
|
||||
linebox[BOXTOP] = (unsigned)(line->bbox[BOXTOP] - bmaporgy + MAXRADIUS) >> MAPBLOCKSHIFT;
|
||||
|
||||
// check all mobj blockmap cells the line contacts
|
||||
for (y = linebox[BOXBOTTOM]; y <= linebox[BOXTOP]; ++y)
|
||||
|
|
|
@ -7401,10 +7401,10 @@ void T_Pusher(pusher_t *p)
|
|||
tmbbox[BOXRIGHT] = p->x + radius;
|
||||
tmbbox[BOXLEFT] = p->x - radius;
|
||||
|
||||
xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
yl = (tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
xl = (unsigned)(tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
xh = (unsigned)(tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
yl = (unsigned)(tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
yh = (unsigned)(tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT;
|
||||
for (bx = xl; bx <= xh; bx++)
|
||||
for (by = yl; by <= yh; by++)
|
||||
P_BlockThingsIterator(bx,by, PIT_PushThing);
|
||||
|
|
20
src/p_user.c
20
src/p_user.c
|
@ -2958,10 +2958,12 @@ static void P_DoTeeter(player_t *player)
|
|||
{
|
||||
INT32 bx, by, xl, xh, yl, yh;
|
||||
|
||||
yh = (player->mo->y + player->mo->radius - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
yl = (player->mo->y - player->mo->radius - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
xh = (player->mo->x + player->mo->radius - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xl = (player->mo->x - player->mo->radius - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
yh = (unsigned)(player->mo->y + player->mo->radius - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
yl = (unsigned)(player->mo->y - player->mo->radius - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
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
|
||||
|
@ -8094,10 +8096,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
INT32 xl, xh, yl, yh, bx, by;
|
||||
validcount++;
|
||||
|
||||
xl = (tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xh = (tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
yl = (tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
yh = (tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
xl = (unsigned)(tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
xh = (unsigned)(tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
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++)
|
||||
|
|
Loading…
Reference in a new issue