Merge branch 'blockmap-cock' into 'master'

Fix blockmap WILD inconsistency when it's not PIT_CheckThing

See merge request KartKrew/Kart!601
This commit is contained in:
James R 2022-05-25 08:03:01 +00:00
commit 1f54579c03
9 changed files with 326 additions and 299 deletions

View file

@ -51,7 +51,7 @@ struct globalsmuggle
} globalsmuggle; } globalsmuggle;
/*-------------------------------------------------- /*--------------------------------------------------
static boolean K_FindEggboxes(mobj_t *thing) static BlockItReturn_t K_FindEggboxes(mobj_t *thing)
Blockmap search function. Blockmap search function.
Increments the random items and egg boxes counters. Increments the random items and egg boxes counters.
@ -60,27 +60,27 @@ struct globalsmuggle
thing - Object passed in from iteration. thing - Object passed in from iteration.
Return:- Return:-
true continues searching, false ends the search early. BlockItReturn_t enum, see its definition for more information.
--------------------------------------------------*/ --------------------------------------------------*/
static boolean K_FindEggboxes(mobj_t *thing) static BlockItReturn_t K_FindEggboxes(mobj_t *thing)
{ {
fixed_t dist; fixed_t dist;
if (thing->type != MT_RANDOMITEM && thing->type != MT_EGGMANITEM) if (thing->type != MT_RANDOMITEM && thing->type != MT_EGGMANITEM)
{ {
return true; return BMIT_CONTINUE;
} }
if (!thing->health) if (!thing->health)
{ {
return true; return BMIT_CONTINUE;
} }
dist = P_AproxDistance(thing->x - globalsmuggle.eggboxx, thing->y - globalsmuggle.eggboxy); dist = P_AproxDistance(thing->x - globalsmuggle.eggboxx, thing->y - globalsmuggle.eggboxy);
if (dist > globalsmuggle.distancetocheck) if (dist > globalsmuggle.distancetocheck)
{ {
return true; return BMIT_CONTINUE;
} }
if (thing->type == MT_RANDOMITEM) if (thing->type == MT_RANDOMITEM)
@ -92,7 +92,7 @@ static boolean K_FindEggboxes(mobj_t *thing)
globalsmuggle.eggboxes++; globalsmuggle.eggboxes++;
} }
return true; return BMIT_CONTINUE;
} }
/*-------------------------------------------------- /*--------------------------------------------------
@ -347,7 +347,7 @@ static boolean K_PlayerAttackSteer(mobj_t *thing, UINT8 side, UINT8 weight, bool
} }
/*-------------------------------------------------- /*--------------------------------------------------
static boolean K_FindObjectsForNudging(mobj_t *thing) static BlockItReturn_t K_FindObjectsForNudging(mobj_t *thing)
Blockmap search function. Blockmap search function.
Finds objects around the bot to steer towards/away from. Finds objects around the bot to steer towards/away from.
@ -356,9 +356,9 @@ static boolean K_PlayerAttackSteer(mobj_t *thing, UINT8 side, UINT8 weight, bool
thing - Object passed in from iteration. thing - Object passed in from iteration.
Return:- Return:-
true continues searching, false ends the search early. BlockItReturn_t enum, see its definition for more information.
--------------------------------------------------*/ --------------------------------------------------*/
static boolean K_FindObjectsForNudging(mobj_t *thing) static BlockItReturn_t K_FindObjectsForNudging(mobj_t *thing)
{ {
INT16 anglediff; INT16 anglediff;
fixed_t fulldist; fixed_t fulldist;
@ -367,29 +367,29 @@ static boolean K_FindObjectsForNudging(mobj_t *thing)
if (!globalsmuggle.botmo || P_MobjWasRemoved(globalsmuggle.botmo) || !globalsmuggle.botmo->player) if (!globalsmuggle.botmo || P_MobjWasRemoved(globalsmuggle.botmo) || !globalsmuggle.botmo->player)
{ {
return false; return BMIT_ABORT;
} }
if (thing->health <= 0) if (thing->health <= 0)
{ {
return true; return BMIT_CONTINUE;
} }
if (globalsmuggle.botmo == thing) if (globalsmuggle.botmo == thing)
{ {
return true; return BMIT_CONTINUE;
} }
fulldist = R_PointToDist2(globalsmuggle.botmo->x, globalsmuggle.botmo->y, thing->x, thing->y) - thing->radius; fulldist = R_PointToDist2(globalsmuggle.botmo->x, globalsmuggle.botmo->y, thing->x, thing->y) - thing->radius;
if (fulldist > globalsmuggle.distancetocheck) if (fulldist > globalsmuggle.distancetocheck)
{ {
return true; return BMIT_CONTINUE;
} }
if (P_CheckSight(globalsmuggle.botmo, thing) == false) if (P_CheckSight(globalsmuggle.botmo, thing) == false)
{ {
return true; return BMIT_CONTINUE;
} }
predictangle = R_PointToAngle2(globalsmuggle.botmo->x, globalsmuggle.botmo->y, globalsmuggle.predict->x, globalsmuggle.predict->y); predictangle = R_PointToAngle2(globalsmuggle.botmo->x, globalsmuggle.botmo->y, globalsmuggle.predict->x, globalsmuggle.predict->y);
@ -607,7 +607,7 @@ static boolean K_FindObjectsForNudging(mobj_t *thing)
break; break;
} }
return true; return BMIT_CONTINUE;
} }
/*-------------------------------------------------- /*--------------------------------------------------
@ -776,7 +776,7 @@ void K_NudgePredictionTowardsObjects(botprediction_t *predict, player_t *player)
} }
/*-------------------------------------------------- /*--------------------------------------------------
static boolean K_FindPlayersToBully(mobj_t *thing) static BlockItReturn_t K_FindPlayersToBully(mobj_t *thing)
Blockmap search function. Blockmap search function.
Finds players around the bot to bump. Finds players around the bot to bump.
@ -785,9 +785,9 @@ void K_NudgePredictionTowardsObjects(botprediction_t *predict, player_t *player)
thing - Object passed in from iteration. thing - Object passed in from iteration.
Return:- Return:-
true continues searching, false ends the search early. BlockItReturn_t enum, see its definition for more information.
--------------------------------------------------*/ --------------------------------------------------*/
static boolean K_FindPlayersToBully(mobj_t *thing) static BlockItReturn_t K_FindPlayersToBully(mobj_t *thing)
{ {
INT16 anglediff; INT16 anglediff;
fixed_t fulldist; fixed_t fulldist;
@ -796,34 +796,34 @@ static boolean K_FindPlayersToBully(mobj_t *thing)
if (!globalsmuggle.botmo || P_MobjWasRemoved(globalsmuggle.botmo) || !globalsmuggle.botmo->player) if (!globalsmuggle.botmo || P_MobjWasRemoved(globalsmuggle.botmo) || !globalsmuggle.botmo->player)
{ {
return false; return BMIT_ABORT;
} }
if (thing->health <= 0) if (thing->health <= 0)
{ {
return true; return BMIT_CONTINUE;
} }
if (!thing->player) if (!thing->player)
{ {
return true; return BMIT_CONTINUE;
} }
if (globalsmuggle.botmo == thing) if (globalsmuggle.botmo == thing)
{ {
return true; return BMIT_CONTINUE;
} }
fulldist = R_PointToDist2(globalsmuggle.botmo->x, globalsmuggle.botmo->y, thing->x, thing->y) - thing->radius; fulldist = R_PointToDist2(globalsmuggle.botmo->x, globalsmuggle.botmo->y, thing->x, thing->y) - thing->radius;
if (fulldist > globalsmuggle.distancetocheck) if (fulldist > globalsmuggle.distancetocheck)
{ {
return true; return BMIT_CONTINUE;
} }
if (P_CheckSight(globalsmuggle.botmo, thing) == false) if (P_CheckSight(globalsmuggle.botmo, thing) == false)
{ {
return true; return BMIT_CONTINUE;
} }
ourangle = globalsmuggle.botmo->angle; ourangle = globalsmuggle.botmo->angle;
@ -860,7 +860,7 @@ static boolean K_FindPlayersToBully(mobj_t *thing)
globalsmuggle.annoymo = thing; globalsmuggle.annoymo = thing;
} }
return true; return BMIT_CONTINUE;
} }
/*-------------------------------------------------- /*--------------------------------------------------

View file

@ -323,26 +323,26 @@ static inline boolean PIT_SSMineChecks(mobj_t *thing)
return false; return false;
} }
static inline boolean PIT_SSMineSearch(mobj_t *thing) static inline BlockItReturn_t PIT_SSMineSearch(mobj_t *thing)
{ {
if (grenade == NULL || P_MobjWasRemoved(grenade)) if (grenade == NULL || P_MobjWasRemoved(grenade))
return false; // There's the possibility these can chain react onto themselves after they've already died if there are enough all in one spot return BMIT_ABORT; // There's the possibility these can chain react onto themselves after they've already died if there are enough all in one spot
if (grenade->flags2 & MF2_DEBRIS) // don't explode twice if (grenade->flags2 & MF2_DEBRIS) // don't explode twice
return false; return BMIT_ABORT;
if (thing->type != MT_PLAYER) // Don't explode for anything but an actual player. if (thing->type != MT_PLAYER) // Don't explode for anything but an actual player.
return true; return BMIT_CONTINUE;
if (thing == grenade->target && grenade->threshold != 0) // Don't blow up at your owner instantly. if (thing == grenade->target && grenade->threshold != 0) // Don't blow up at your owner instantly.
return true; return BMIT_CONTINUE;
if (PIT_SSMineChecks(thing) == true) if (PIT_SSMineChecks(thing) == true)
return true; return BMIT_CONTINUE;
// Explode! // Explode!
P_SetMobjState(grenade, grenade->info->deathstate); P_SetMobjState(grenade, grenade->info->deathstate);
return false; return BMIT_ABORT;
} }
void K_DoMineSearch(mobj_t *actor, fixed_t size) void K_DoMineSearch(mobj_t *actor, fixed_t size)
@ -364,21 +364,21 @@ void K_DoMineSearch(mobj_t *actor, fixed_t size)
P_BlockThingsIterator(bx, by, PIT_SSMineSearch); P_BlockThingsIterator(bx, by, PIT_SSMineSearch);
} }
static inline boolean PIT_SSMineExplode(mobj_t *thing) static inline BlockItReturn_t PIT_SSMineExplode(mobj_t *thing)
{ {
if (grenade == NULL || P_MobjWasRemoved(grenade)) if (grenade == NULL || P_MobjWasRemoved(grenade))
return false; // There's the possibility these can chain react onto themselves after they've already died if there are enough all in one spot return BMIT_ABORT; // There's the possibility these can chain react onto themselves after they've already died if there are enough all in one spot
#if 0 #if 0
if (grenade->flags2 & MF2_DEBRIS) // don't explode twice if (grenade->flags2 & MF2_DEBRIS) // don't explode twice
return false; return BMIT_ABORT;
#endif #endif
if (PIT_SSMineChecks(thing) == true) if (PIT_SSMineChecks(thing) == true)
return true; return BMIT_CONTINUE;
P_DamageMobj(thing, grenade, grenade->target, 1, (explodespin ? DMG_NORMAL : DMG_EXPLODE)); P_DamageMobj(thing, grenade, grenade->target, 1, (explodespin ? DMG_NORMAL : DMG_EXPLODE));
return true; return BMIT_CONTINUE;
} }
void K_MineExplodeAttack(mobj_t *actor, fixed_t size, boolean spin) void K_MineExplodeAttack(mobj_t *actor, fixed_t size, boolean spin)
@ -667,60 +667,54 @@ boolean K_DropTargetCollide(mobj_t *t1, mobj_t *t2)
static mobj_t *lightningSource; static mobj_t *lightningSource;
static fixed_t lightningDist; static fixed_t lightningDist;
static inline boolean PIT_LightningShieldAttack(mobj_t *thing) static inline BlockItReturn_t PIT_LightningShieldAttack(mobj_t *thing)
{ {
if (lightningSource == NULL || P_MobjWasRemoved(lightningSource)) if (lightningSource == NULL || P_MobjWasRemoved(lightningSource))
{ {
// Invalid? // Invalid?
return false; return BMIT_ABORT;
} }
if (thing == lightningSource) if (thing == lightningSource)
{ {
// Don't explode yourself!! // Don't explode yourself!!
return true; return BMIT_CONTINUE;
} }
if (thing->health <= 0) if (thing->health <= 0)
{ {
// Dead // Dead
return true; return BMIT_CONTINUE;
} }
if (!(thing->flags & MF_SHOOTABLE) || (thing->flags & MF_SCENERY)) if (!(thing->flags & MF_SHOOTABLE) || (thing->flags & MF_SCENERY))
{ {
// Not shootable // Not shootable
return true; return BMIT_CONTINUE;
} }
if (thing->player && thing->player->spectator) if (thing->player && thing->player->spectator)
{ {
// Spectator // Spectator
return true; return BMIT_CONTINUE;
}
if ((lightningSource->eflags & MFE_VERTICALFLIP)
? (thing->z > lightningSource->z + lightningSource->height)
: (thing->z + thing->height < lightningSource->z))
{
// Underneath
return true;
} }
if (P_AproxDistance(thing->x - lightningSource->x, thing->y - lightningSource->y) > lightningDist + thing->radius) if (P_AproxDistance(thing->x - lightningSource->x, thing->y - lightningSource->y) > lightningDist + thing->radius)
{ {
// Too far away // Too far away
return true; return BMIT_CONTINUE;
} }
#if 0
if (P_CheckSight(lightningSource, thing) == false) if (P_CheckSight(lightningSource, thing) == false)
{ {
// Not in sight // Not in sight
return true; return BMIT_CONTINUE;
} }
#endif
P_DamageMobj(thing, lightningSource, lightningSource, 1, DMG_NORMAL|DMG_CANTHURTSELF|DMG_WOMBO); P_DamageMobj(thing, lightningSource, lightningSource, 1, DMG_NORMAL|DMG_CANTHURTSELF|DMG_WOMBO);
return true; return BMIT_CONTINUE;
} }
void K_LightningShieldAttack(mobj_t *actor, fixed_t size) void K_LightningShieldAttack(mobj_t *actor, fixed_t size)

View file

@ -7055,57 +7055,57 @@ static mobj_t *attractmo;
static fixed_t attractdist; static fixed_t attractdist;
static fixed_t attractzdist; static fixed_t attractzdist;
static inline boolean PIT_AttractingRings(mobj_t *thing) static inline BlockItReturn_t PIT_AttractingRings(mobj_t *thing)
{ {
if (attractmo == NULL || P_MobjWasRemoved(attractmo) || attractmo->player == NULL) if (attractmo == NULL || P_MobjWasRemoved(attractmo) || attractmo->player == NULL)
{ {
return false; return BMIT_ABORT;
} }
if (thing == NULL || P_MobjWasRemoved(thing)) if (thing == NULL || P_MobjWasRemoved(thing))
{ {
return true; // invalid return BMIT_CONTINUE; // invalid
} }
if (thing == attractmo) if (thing == attractmo)
{ {
return true; // invalid return BMIT_CONTINUE; // invalid
} }
if (!(thing->type == MT_RING || thing->type == MT_FLINGRING)) if (!(thing->type == MT_RING || thing->type == MT_FLINGRING))
{ {
return true; // not a ring return BMIT_CONTINUE; // not a ring
} }
if (thing->health <= 0) if (thing->health <= 0)
{ {
return true; // dead return BMIT_CONTINUE; // dead
} }
if (thing->extravalue1) if (thing->extravalue1)
{ {
return true; // in special ring animation return BMIT_CONTINUE; // in special ring animation
} }
if (thing->tracer != NULL && P_MobjWasRemoved(thing->tracer) == false) if (thing->tracer != NULL && P_MobjWasRemoved(thing->tracer) == false)
{ {
return true; // already attracted return BMIT_CONTINUE; // already attracted
} }
// see if it went over / under // see if it went over / under
if (attractmo->z - attractzdist > thing->z + thing->height) if (attractmo->z - attractzdist > thing->z + thing->height)
{ {
return true; // overhead return BMIT_CONTINUE; // overhead
} }
if (attractmo->z + attractmo->height + attractzdist < thing->z) if (attractmo->z + attractmo->height + attractzdist < thing->z)
{ {
return true; // underneath return BMIT_CONTINUE; // underneath
} }
if (P_AproxDistance(attractmo->x - thing->x, attractmo->y - thing->y) > attractdist + thing->radius) if (P_AproxDistance(attractmo->x - thing->x, attractmo->y - thing->y) > attractdist + thing->radius)
{ {
return true; // Too far away return BMIT_CONTINUE; // Too far away
} }
if (RINGTOTAL(attractmo->player) >= 20 || (attractmo->player->pflags & PF_RINGLOCK)) if (RINGTOTAL(attractmo->player) >= 20 || (attractmo->player->pflags & PF_RINGLOCK))
@ -7132,7 +7132,7 @@ static inline boolean PIT_AttractingRings(mobj_t *thing)
P_SetTarget(&thing->tracer, attractmo); P_SetTarget(&thing->tracer, attractmo);
} }
return true; // find other rings return BMIT_CONTINUE; // find other rings
} }
/** Looks for rings near a player in the blockmap. /** Looks for rings near a player in the blockmap.

View file

@ -4573,26 +4573,26 @@ void A_ShootBullet(mobj_t *actor)
static mobj_t *minus; static mobj_t *minus;
static boolean PIT_MinusCarry(mobj_t *thing) static BlockItReturn_t PIT_MinusCarry(mobj_t *thing)
{ {
if (minus->tracer) if (minus->tracer)
return true; return BMIT_CONTINUE;
if (minus->type == thing->type) if (minus->type == thing->type)
return true; return BMIT_CONTINUE;
if (!(thing->flags & (MF_PUSHABLE|MF_ENEMY))) if (!(thing->flags & (MF_PUSHABLE|MF_ENEMY)))
return true; return BMIT_CONTINUE;
if (P_AproxDistance(minus->x - thing->x, minus->y - thing->y) >= minus->radius*3) if (P_AproxDistance(minus->x - thing->x, minus->y - thing->y) >= minus->radius*3)
return true; return BMIT_CONTINUE;
if (abs(thing->z - minus->z) > minus->height) if (abs(thing->z - minus->z) > minus->height)
return true; return BMIT_CONTINUE;
P_SetTarget(&minus->tracer, thing); P_SetTarget(&minus->tracer, thing);
return true; return BMIT_CONTINUE;
} }
// Function: A_MinusDigging // Function: A_MinusDigging
@ -12145,13 +12145,13 @@ static mobj_t *barrel;
static fixed_t exploderadius; static fixed_t exploderadius;
static fixed_t explodethrust; static fixed_t explodethrust;
static boolean PIT_TNTExplode(mobj_t *nearby) static BlockItReturn_t PIT_TNTExplode(mobj_t *nearby)
{ {
fixed_t dx, dy, dz; fixed_t dx, dy, dz;
fixed_t dm; fixed_t dm;
if (nearby == barrel) if (nearby == barrel)
return true; return BMIT_CONTINUE;
dx = nearby->x - barrel->x; dx = nearby->x - barrel->x;
dy = nearby->y - barrel->y; dy = nearby->y - barrel->y;
@ -12159,7 +12159,7 @@ static boolean PIT_TNTExplode(mobj_t *nearby)
dm = P_AproxDistance(P_AproxDistance(dx, dy), dz); dm = P_AproxDistance(P_AproxDistance(dx, dy), dz);
if (dm >= exploderadius || !P_CheckSight(barrel, nearby)) // out of range or not visible if (dm >= exploderadius || !P_CheckSight(barrel, nearby)) // out of range or not visible
return true; return BMIT_CONTINUE;
if (barrel->type == nearby->type) // nearby is also a barrel if (barrel->type == nearby->type) // nearby is also a barrel
{ {
@ -12200,7 +12200,7 @@ static boolean PIT_TNTExplode(mobj_t *nearby)
} }
} }
return true; return BMIT_CONTINUE;
} }
// Function: A_TNTExplode // Function: A_TNTExplode

View file

@ -435,7 +435,7 @@ void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist, UINT8 dama
fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height); fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height);
fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height); fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height);
boolean PIT_PushableMoved(mobj_t *thing); BlockItReturn_t PIT_PushableMoved(mobj_t *thing);
boolean P_DoSpring(mobj_t *spring, mobj_t *object); boolean P_DoSpring(mobj_t *spring, mobj_t *object);

File diff suppressed because it is too large Load diff

View file

@ -1096,7 +1096,7 @@ void P_SetPrecipitationThingPosition(precipmobj_t *thing)
// to P_BlockLinesIterator, then make one or more calls // to P_BlockLinesIterator, then make one or more calls
// to it. // to it.
// //
boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean (*func)(line_t *)) boolean P_BlockLinesIterator(INT32 x, INT32 y, BlockItReturn_t (*func)(line_t *))
{ {
INT32 offset; INT32 offset;
const INT32 *list; // Big blockmap const INT32 *list; // Big blockmap
@ -1122,11 +1122,22 @@ boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean (*func)(line_t *))
for (i = 0; i < po->numLines; ++i) for (i = 0; i < po->numLines; ++i)
{ {
BlockItReturn_t ret = BMIT_CONTINUE;
if (po->lines[i]->validcount == validcount) // line has been checked if (po->lines[i]->validcount == validcount) // line has been checked
continue; continue;
po->lines[i]->validcount = validcount; po->lines[i]->validcount = validcount;
if (!func(po->lines[i])) ret = func(po->lines[i]);
if (ret == BMIT_ABORT)
{
return false; return false;
}
else if (ret == BMIT_STOP)
{
return true;
}
} }
} }
plink = (polymaplink_t *)(plink->link.next); plink = (polymaplink_t *)(plink->link.next);
@ -1137,15 +1148,24 @@ boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean (*func)(line_t *))
// First index is really empty, so +1 it. // First index is really empty, so +1 it.
for (list = blockmaplump + offset + 1; *list != -1; list++) for (list = blockmaplump + offset + 1; *list != -1; list++)
{ {
BlockItReturn_t ret = BMIT_CONTINUE;
ld = &lines[*list]; ld = &lines[*list];
if (ld->validcount == validcount) if (ld->validcount == validcount)
continue; // Line has already been checked. continue; // Line has already been checked.
ld->validcount = validcount; ld->validcount = validcount;
ret = func(ld);
if (!func(ld)) if (ret == BMIT_ABORT)
{
return false; return false;
}
else if (ret == BMIT_STOP)
{
return true;
}
} }
return true; // Everything was checked. return true; // Everything was checked.
} }
@ -1154,7 +1174,7 @@ boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean (*func)(line_t *))
// //
// P_BlockThingsIterator // P_BlockThingsIterator
// //
boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) boolean P_BlockThingsIterator(INT32 x, INT32 y, BlockItReturn_t (*func)(mobj_t *))
{ {
mobj_t *mobj, *bnext = NULL; mobj_t *mobj, *bnext = NULL;
@ -1164,19 +1184,25 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *))
// Check interaction with the objects in the blockmap. // Check interaction with the objects in the blockmap.
for (mobj = blocklinks[y*bmapwidth + x]; mobj; mobj = bnext) for (mobj = blocklinks[y*bmapwidth + x]; mobj; mobj = bnext)
{ {
BlockItReturn_t ret = BMIT_CONTINUE;
P_SetTarget(&bnext, mobj->bnext); // We want to note our reference to bnext here incase it is MF_NOTHINK and gets removed! P_SetTarget(&bnext, mobj->bnext); // We want to note our reference to bnext here incase it is MF_NOTHINK and gets removed!
if (!func(mobj)) ret = func(mobj);
if (ret == BMIT_ABORT)
{ {
P_SetTarget(&bnext, NULL); P_SetTarget(&bnext, NULL);
return false; return false; // failure
} }
if (P_MobjWasRemoved(tmthing) // func just popped our tmthing, cannot continue.
|| (bnext && P_MobjWasRemoved(bnext))) // func just broke blockmap chain, cannot continue. if ((ret == BMIT_STOP)
|| (bnext && P_MobjWasRemoved(bnext))) // func just broke blockmap chain, cannot continue.
{ {
P_SetTarget(&bnext, NULL); P_SetTarget(&bnext, NULL);
return true; return true; // success
} }
} }
return true; return true;
} }
@ -1220,7 +1246,7 @@ static void P_CheckIntercepts(void)
// are on opposite sides of the trace. // are on opposite sides of the trace.
// Returns true if earlyout and a solid line hit. // Returns true if earlyout and a solid line hit.
// //
static boolean PIT_AddLineIntercepts(line_t *ld) static BlockItReturn_t PIT_AddLineIntercepts(line_t *ld)
{ {
INT32 s1, s2; INT32 s1, s2;
fixed_t frac; fixed_t frac;
@ -1243,18 +1269,18 @@ static boolean PIT_AddLineIntercepts(line_t *ld)
} }
if (s1 == s2) if (s1 == s2)
return true; // Line isn't crossed. return BMIT_CONTINUE; // Line isn't crossed.
// Hit the line. // Hit the line.
P_MakeDivline(ld, &dl); P_MakeDivline(ld, &dl);
frac = P_InterceptVector(&trace, &dl); frac = P_InterceptVector(&trace, &dl);
if (frac < 0) if (frac < 0)
return true; // Behind source. return BMIT_CONTINUE; // Behind source.
// Try to take an early out of the check. // Try to take an early out of the check.
if (earlyout && frac < FRACUNIT && !ld->backsector) if (earlyout && frac < FRACUNIT && !ld->backsector)
return false; // stop checking return BMIT_ABORT; // stop checking
P_CheckIntercepts(); P_CheckIntercepts();
@ -1263,13 +1289,13 @@ static boolean PIT_AddLineIntercepts(line_t *ld)
intercept_p->d.line = ld; intercept_p->d.line = ld;
intercept_p++; intercept_p++;
return true; // continue return BMIT_CONTINUE; // continue
} }
// //
// PIT_AddThingIntercepts // PIT_AddThingIntercepts
// //
static boolean PIT_AddThingIntercepts(mobj_t *thing) static BlockItReturn_t PIT_AddThingIntercepts(mobj_t *thing)
{ {
fixed_t px1, py1, px2, py2, frac; fixed_t px1, py1, px2, py2, frac;
INT32 s1, s2; INT32 s1, s2;
@ -1300,7 +1326,7 @@ static boolean PIT_AddThingIntercepts(mobj_t *thing)
s2 = P_PointOnDivlineSide(px2, py2, &trace); s2 = P_PointOnDivlineSide(px2, py2, &trace);
if (s1 == s2) if (s1 == s2)
return true; // Line isn't crossed. return BMIT_CONTINUE; // Line isn't crossed.
dl.x = px1; dl.x = px1;
dl.y = py1; dl.y = py1;
@ -1310,7 +1336,7 @@ static boolean PIT_AddThingIntercepts(mobj_t *thing)
frac = P_InterceptVector(&trace, &dl); frac = P_InterceptVector(&trace, &dl);
if (frac < 0) if (frac < 0)
return true; // Behind source. return BMIT_CONTINUE; // Behind source.
P_CheckIntercepts(); P_CheckIntercepts();
@ -1319,7 +1345,7 @@ static boolean PIT_AddThingIntercepts(mobj_t *thing)
intercept_p->d.thing = thing; intercept_p->d.thing = thing;
intercept_p++; intercept_p++;
return true; // Keep going. return BMIT_CONTINUE; // Keep going.
} }
// //

View file

@ -67,8 +67,15 @@ extern INT32 opentoppic, openbottompic;
void P_LineOpening(line_t *plinedef, mobj_t *mobj); void P_LineOpening(line_t *plinedef, mobj_t *mobj);
boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean(*func)(line_t *)); typedef enum
boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean(*func)(mobj_t *)); {
BMIT_CONTINUE, // Continue blockmap search
BMIT_STOP, // End blockmap search with success
BMIT_ABORT // End blockmap search with failure
} BlockItReturn_t;
boolean P_BlockLinesIterator(INT32 x, INT32 y, BlockItReturn_t(*func)(line_t *));
boolean P_BlockThingsIterator(INT32 x, INT32 y, BlockItReturn_t(*func)(mobj_t *));
#define PT_ADDLINES 1 #define PT_ADDLINES 1
#define PT_ADDTHINGS 2 #define PT_ADDTHINGS 2

View file

@ -8390,13 +8390,13 @@ static pusher_t *tmpusher; // pusher structure for blockmap searches
* ::tmpusher won't need to be used. * ::tmpusher won't need to be used.
* \sa T_Pusher * \sa T_Pusher
*/ */
static inline boolean PIT_PushThing(mobj_t *thing) static inline BlockItReturn_t PIT_PushThing(mobj_t *thing)
{ {
if (thing->eflags & MFE_PUSHED) if (thing->eflags & MFE_PUSHED)
return false; return BMIT_ABORT;
if (!tmpusher->source) if (!tmpusher->source)
return false; return BMIT_ABORT;
// Allow this to affect pushable objects at some point? // Allow this to affect pushable objects at some point?
if (thing->player && !(thing->flags & (MF_NOGRAVITY | MF_NOCLIP))) if (thing->player && !(thing->flags & (MF_NOGRAVITY | MF_NOCLIP)))
@ -8416,7 +8416,7 @@ static inline boolean PIT_PushThing(mobj_t *thing)
{ {
// Make sure the Z is in range // Make sure the Z is in range
if (thing->z < sz - tmpusher->radius || thing->z > sz + tmpusher->radius) if (thing->z < sz - tmpusher->radius || thing->z > sz + tmpusher->radius)
return false; return BMIT_ABORT;
dist = P_AproxDistance(P_AproxDistance(thing->x - sx, thing->y - sy), dist = P_AproxDistance(P_AproxDistance(thing->x - sx, thing->y - sy),
thing->z - sz); thing->z - sz);
@ -8482,7 +8482,7 @@ static inline boolean PIT_PushThing(mobj_t *thing)
if (tmpusher->exclusive) if (tmpusher->exclusive)
thing->eflags |= MFE_PUSHED; thing->eflags |= MFE_PUSHED;
return true; return BMIT_CONTINUE;
} }
/** Applies a pusher to all affected objects. /** Applies a pusher to all affected objects.