fix MBF21 ripper weapons causing too much damage (#1977)

* fix clang-tidy warnings

* don't do "blockmapfix" for MF2_RIP projectiles
This commit is contained in:
Roman Fomin 2024-11-04 13:13:46 +07:00 committed by GitHub
parent 3b43ebad50
commit 7e9a70c2eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 48 additions and 47 deletions

View File

@ -957,20 +957,20 @@ static boolean P_LookForMonsters(mobj_t *actor, boolean allaround)
// Search first in the immediate vicinity. // Search first in the immediate vicinity.
if (!P_BlockThingsIterator(x, y, PIT_FindTarget)) if (!P_BlockThingsIterator(x, y, PIT_FindTarget, true))
return true; return true;
for (d=1; d<5; d++) for (d=1; d<5; d++)
{ {
int i = 1 - d; int i = 1 - d;
do do
if (!P_BlockThingsIterator(x+i, y-d, PIT_FindTarget) || if (!P_BlockThingsIterator(x+i, y-d, PIT_FindTarget, true) ||
!P_BlockThingsIterator(x+i, y+d, PIT_FindTarget)) !P_BlockThingsIterator(x+i, y+d, PIT_FindTarget, true))
return true; return true;
while (++i < d); while (++i < d);
do do
if (!P_BlockThingsIterator(x-d, y+i, PIT_FindTarget) || if (!P_BlockThingsIterator(x-d, y+i, PIT_FindTarget, true) ||
!P_BlockThingsIterator(x+d, y+i, PIT_FindTarget)) !P_BlockThingsIterator(x+d, y+i, PIT_FindTarget, true))
return true; return true;
while (--i + d >= 0); while (--i + d >= 0);
} }
@ -1726,7 +1726,7 @@ static boolean P_HealCorpse(mobj_t* actor, int radius, statenum_t healstate, sfx
// Call PIT_VileCheck to check // Call PIT_VileCheck to check
// whether object is a corpse // whether object is a corpse
// that canbe raised. // that canbe raised.
if (!P_BlockThingsIterator(bx,by,PIT_VileCheck)) if (!P_BlockThingsIterator(bx, by, PIT_VileCheck, true))
{ {
mobjinfo_t *info; mobjinfo_t *info;

View File

@ -295,7 +295,7 @@ boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, boolean boss)
for (bx=xl ; bx<=xh ; bx++) for (bx=xl ; bx<=xh ; bx++)
for (by=yl ; by<=yh ; by++) for (by=yl ; by<=yh ; by++)
if (!P_BlockThingsIterator(bx,by,PIT_StompThing)) if (!P_BlockThingsIterator(bx, by, PIT_StompThing, true))
return false; return false;
// the move is ok, // the move is ok,
@ -637,7 +637,7 @@ static boolean PIT_CheckThing(mobj_t *thing) // killough 3/26/98: make static
P_DamageMobj(thing, tmthing, tmthing->target, damage); P_DamageMobj(thing, tmthing, tmthing->target, damage);
numspechit = 0; numspechit = 0;
return (true); return true;
} }
// damage / explode // damage / explode
@ -809,7 +809,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
for (bx=xl ; bx<=xh ; bx++) for (bx=xl ; bx<=xh ; bx++)
for (by=yl ; by<=yh ; by++) for (by=yl ; by<=yh ; by++)
if (!P_BlockThingsIterator(bx,by,PIT_CheckThing)) if (!P_BlockThingsIterator(bx, by, PIT_CheckThing, !(tmthing->flags2 & MF2_RIP)))
return false; return false;
// check lines // check lines
@ -2006,7 +2006,7 @@ void P_RadiusAttack(mobj_t *spot, mobj_t *source, int damage, int distance)
for (y=yl ; y<=yh ; y++) for (y=yl ; y<=yh ; y++)
for (x=xl ; x<=xh ; x++) for (x=xl ; x<=xh ; x++)
P_BlockThingsIterator(x, y, PIT_RadiusAttack); P_BlockThingsIterator(x, y, PIT_RadiusAttack, false);
} }
// //
@ -2120,7 +2120,7 @@ boolean P_ChangeSector(sector_t *sector,boolean crunch)
for (x=sector->blockbox[BOXLEFT] ; x<= sector->blockbox[BOXRIGHT] ; x++) for (x=sector->blockbox[BOXLEFT] ; x<= sector->blockbox[BOXRIGHT] ; x++)
for (y=sector->blockbox[BOXBOTTOM];y<= sector->blockbox[BOXTOP] ; y++) for (y=sector->blockbox[BOXBOTTOM];y<= sector->blockbox[BOXTOP] ; y++)
P_BlockThingsIterator (x, y, PIT_ChangeSector); P_BlockThingsIterator (x, y, PIT_ChangeSector, false);
return nofit; return nofit;
} }

View File

@ -421,7 +421,8 @@ boolean P_BlockLinesIterator(int x, int y, boolean func(line_t*))
boolean blockmapfix; boolean blockmapfix;
boolean P_BlockThingsIterator(int x, int y, boolean func(mobj_t*)) boolean P_BlockThingsIterator(int x, int y, boolean func(mobj_t*),
boolean do_blockmapfix)
{ {
mobj_t *mobj; mobj_t *mobj;
@ -435,15 +436,11 @@ boolean P_BlockThingsIterator(int x, int y, boolean func(mobj_t*))
// Blockmap bug fix by Terry Hearst // Blockmap bug fix by Terry Hearst
// https://github.com/fabiangreffrath/crispy-doom/pull/723 // https://github.com/fabiangreffrath/crispy-doom/pull/723
// Add other mobjs from surrounding blocks that overlap this one // Add other mobjs from surrounding blocks that overlap this one
if (CRITICAL(blockmapfix)) if (CRITICAL(blockmapfix) && do_blockmapfix)
{ {
if (demo_compatibility && overflow[emu_intercepts].enabled) if (demo_compatibility && overflow[emu_intercepts].enabled)
return true; return true;
// Don't do for explosions and crashers
if (func == PIT_RadiusAttack || func == PIT_ChangeSector)
return true;
// Unwrapped for least number of bounding box checks // Unwrapped for least number of bounding box checks
// (-1, -1) // (-1, -1)
if (x > 0 && y > 0) if (x > 0 && y > 0)
@ -710,8 +707,8 @@ boolean P_TraverseIntercepts(traverser_t func, fixed_t maxfrac)
typedef struct typedef struct
{ {
int len; int len;
void *addr;
boolean int16_array; boolean int16_array;
void *addr;
} intercepts_overrun_t; } intercepts_overrun_t;
// Intercepts memory table. This is where various variables are located // Intercepts memory table. This is where various variables are located
@ -724,29 +721,29 @@ typedef struct
static intercepts_overrun_t intercepts_overrun[] = static intercepts_overrun_t intercepts_overrun[] =
{ {
{4, NULL, false}, {4, false, NULL, },
{4, NULL, /* &earlyout, */ false}, {4, false, NULL, /* &earlyout, */ },
{4, NULL, /* &intercept_p, */ false}, {4, false, NULL, /* &intercept_p, */ },
{4, &lowfloor, false}, {4, false, &lowfloor, },
{4, &openbottom, false}, {4, false, &openbottom, },
{4, &opentop, false}, {4, false, &opentop, },
{4, &openrange, false}, {4, false, &openrange, },
{4, NULL, false}, {4, false, NULL, },
{120, NULL, /* &activeplats, */ false}, {120, false, NULL, /* &activeplats, */ },
{8, NULL, false}, {8, false, NULL, },
{4, &bulletslope, false}, {4, false, &bulletslope, },
{4, NULL, /* &swingx, */ false}, {4, false, NULL, /* &swingx, */ },
{4, NULL, /* &swingy, */ false}, {4, false, NULL, /* &swingy, */ },
{4, NULL, false}, {4, false, NULL, },
{40, &playerstarts, true}, {40, true, &playerstarts, },
{4, NULL, /* &blocklinks, */ false}, {4, false, NULL, /* &blocklinks, */ },
{4, &bmapwidth, false}, {4, false, &bmapwidth, },
{4, NULL, /* &blockmap, */ false}, {4, false, NULL, /* &blockmap, */ },
{4, &bmaporgx, false}, {4, false, &bmaporgx, },
{4, &bmaporgy, false}, {4, false, &bmaporgy, },
{4, NULL, /* &blockmaplump, */ false}, {4, false, NULL, /* &blockmaplump, */},
{4, &bmapheight, false}, {4, false, &bmapheight, },
{0, NULL, false}, {0, false, NULL, },
}; };
// Overwrite a specific memory location with a value. // Overwrite a specific memory location with a value.
@ -928,7 +925,7 @@ boolean P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2,
return false; // early out return false; // early out
if (flags & PT_ADDTHINGS) if (flags & PT_ADDTHINGS)
if (!P_BlockThingsIterator(mapx, mapy,PIT_AddThingIntercepts)) if (!P_BlockThingsIterator(mapx, mapy, PIT_AddThingIntercepts, true))
return false; // early out return false; // early out
if (mapx == xt2 && mapy == yt2) if (mapx == xt2 && mapy == yt2)
@ -1204,7 +1201,7 @@ static boolean P_SightTraverseIntercepts(void)
// //
// go through in order // go through in order
// //
in = 0; // shut up compiler warning in = NULL; // shut up compiler warning
while (count--) while (count--)
{ {
@ -1216,10 +1213,13 @@ static boolean P_SightTraverseIntercepts(void)
in = scan; in = scan;
} }
if (in)
{
if (!PTR_SightTraverse(in)) if (!PTR_SightTraverse(in))
return false; // don't bother going farther return false; // don't bother going farther
in->frac = INT_MAX; in->frac = INT_MAX;
} }
}
return true; // everything was traversed return true; // everything was traversed
} }

View File

@ -66,7 +66,8 @@ void P_LineOpening(struct line_s *linedef);
void P_UnsetThingPosition(struct mobj_s *thing); void P_UnsetThingPosition(struct mobj_s *thing);
void P_SetThingPosition(struct mobj_s *thing); void P_SetThingPosition(struct mobj_s *thing);
boolean P_BlockLinesIterator (int x, int y, boolean func(struct line_s *)); boolean P_BlockLinesIterator (int x, int y, boolean func(struct line_s *));
boolean P_BlockThingsIterator(int x, int y, boolean func(struct mobj_s *)); boolean P_BlockThingsIterator(int x, int y, boolean func(struct mobj_s *),
boolean do_blockmapfix);
boolean ThingIsOnLine(struct mobj_s *t, struct line_s *l); // killough 3/15/98 boolean ThingIsOnLine(struct mobj_s *t, struct line_s *l); // killough 3/15/98
boolean P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, boolean P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2,
int flags, boolean trav(intercept_t *)); int flags, boolean trav(intercept_t *));

View File

@ -3314,7 +3314,7 @@ void T_Pusher(pusher_t *p)
yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT; yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT;
for (bx=xl ; bx<=xh ; bx++) for (bx=xl ; bx<=xh ; bx++)
for (by=yl ; by<=yh ; by++) for (by=yl ; by<=yh ; by++)
P_BlockThingsIterator(bx,by,PIT_PushThing); P_BlockThingsIterator(bx, by, PIT_PushThing, true);
return; return;
} }