From d053d5f8ba7c4166155d11ef784dfec029539a01 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 23 May 2022 17:37:29 -0400 Subject: [PATCH 1/2] Fix blockmap WILD inconsistency when it's not PIT_CheckThing An optimized error check was put into P_BlockThingsIterator for tmthing, but this meant that anything that was not using or even setting this variable (the supermajority of them) would exit after finding 1 thing in each block. To keep this error check & keep it optimized, the PIT_ functions were expanded to three options instead of two: BMIT_CONTINUE lets the search continue. If used as the last mobj, it will return true when the iterator finishes. BMIT_ABORT ends the search and forces the iterator to return false. BMIT_STOP ends the search and forces the iterator to return true. --- src/k_botsearch.c | 52 +++---- src/k_collide.c | 52 +++---- src/k_kart.c | 24 +-- src/p_enemy.c | 22 +-- src/p_local.h | 2 +- src/p_map.c | 383 +++++++++++++++++++++++----------------------- src/p_maputl.c | 62 +++++--- src/p_maputl.h | 11 +- src/p_spec.c | 10 +- 9 files changed, 324 insertions(+), 294 deletions(-) diff --git a/src/k_botsearch.c b/src/k_botsearch.c index 07935d79c..b62b55852 100644 --- a/src/k_botsearch.c +++ b/src/k_botsearch.c @@ -51,7 +51,7 @@ struct globalsmuggle } globalsmuggle; /*-------------------------------------------------- - static boolean K_FindEggboxes(mobj_t *thing) + static BlockItReturn_t K_FindEggboxes(mobj_t *thing) Blockmap search function. Increments the random items and egg boxes counters. @@ -60,27 +60,27 @@ struct globalsmuggle thing - Object passed in from iteration. 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; if (thing->type != MT_RANDOMITEM && thing->type != MT_EGGMANITEM) { - return true; + return BMIT_CONTINUE; } if (!thing->health) { - return true; + return BMIT_CONTINUE; } dist = P_AproxDistance(thing->x - globalsmuggle.eggboxx, thing->y - globalsmuggle.eggboxy); if (dist > globalsmuggle.distancetocheck) { - return true; + return BMIT_CONTINUE; } if (thing->type == MT_RANDOMITEM) @@ -92,7 +92,7 @@ static boolean K_FindEggboxes(mobj_t *thing) 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. 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. 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; fixed_t fulldist; @@ -367,29 +367,29 @@ static boolean K_FindObjectsForNudging(mobj_t *thing) if (!globalsmuggle.botmo || P_MobjWasRemoved(globalsmuggle.botmo) || !globalsmuggle.botmo->player) { - return false; + return BMIT_ABORT; } if (thing->health <= 0) { - return true; + return BMIT_CONTINUE; } if (globalsmuggle.botmo == thing) { - return true; + return BMIT_CONTINUE; } fulldist = R_PointToDist2(globalsmuggle.botmo->x, globalsmuggle.botmo->y, thing->x, thing->y) - thing->radius; if (fulldist > globalsmuggle.distancetocheck) { - return true; + return BMIT_CONTINUE; } 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); @@ -607,7 +607,7 @@ static boolean K_FindObjectsForNudging(mobj_t *thing) 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. 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. 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; fixed_t fulldist; @@ -796,34 +796,34 @@ static boolean K_FindPlayersToBully(mobj_t *thing) if (!globalsmuggle.botmo || P_MobjWasRemoved(globalsmuggle.botmo) || !globalsmuggle.botmo->player) { - return false; + return BMIT_ABORT; } if (thing->health <= 0) { - return true; + return BMIT_CONTINUE; } if (!thing->player) { - return true; + return BMIT_CONTINUE; } if (globalsmuggle.botmo == thing) { - return true; + return BMIT_CONTINUE; } fulldist = R_PointToDist2(globalsmuggle.botmo->x, globalsmuggle.botmo->y, thing->x, thing->y) - thing->radius; if (fulldist > globalsmuggle.distancetocheck) { - return true; + return BMIT_CONTINUE; } if (P_CheckSight(globalsmuggle.botmo, thing) == false) { - return true; + return BMIT_CONTINUE; } ourangle = globalsmuggle.botmo->angle; @@ -860,7 +860,7 @@ static boolean K_FindPlayersToBully(mobj_t *thing) globalsmuggle.annoymo = thing; } - return true; + return BMIT_CONTINUE; } /*-------------------------------------------------- diff --git a/src/k_collide.c b/src/k_collide.c index 92c4bd7fd..306c01dd8 100644 --- a/src/k_collide.c +++ b/src/k_collide.c @@ -323,26 +323,26 @@ static inline boolean PIT_SSMineChecks(mobj_t *thing) 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)) - 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 - return false; + return BMIT_ABORT; 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. - return true; + return BMIT_CONTINUE; if (PIT_SSMineChecks(thing) == true) - return true; + return BMIT_CONTINUE; // Explode! P_SetMobjState(grenade, grenade->info->deathstate); - return false; + return BMIT_ABORT; } 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); } -static inline boolean PIT_SSMineExplode(mobj_t *thing) +static inline BlockItReturn_t PIT_SSMineExplode(mobj_t *thing) { 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 (grenade->flags2 & MF2_DEBRIS) // don't explode twice - return false; + return BMIT_ABORT; #endif if (PIT_SSMineChecks(thing) == true) - return true; + return BMIT_CONTINUE; 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) @@ -667,60 +667,54 @@ boolean K_DropTargetCollide(mobj_t *t1, mobj_t *t2) static mobj_t *lightningSource; 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)) { // Invalid? - return false; + return BMIT_ABORT; } if (thing == lightningSource) { // Don't explode yourself!! - return true; + return BMIT_CONTINUE; } if (thing->health <= 0) { // Dead - return true; + return BMIT_CONTINUE; } if (!(thing->flags & MF_SHOOTABLE) || (thing->flags & MF_SCENERY)) { // Not shootable - return true; + return BMIT_CONTINUE; } if (thing->player && thing->player->spectator) { // Spectator - return true; - } - - if ((lightningSource->eflags & MFE_VERTICALFLIP) - ? (thing->z > lightningSource->z + lightningSource->height) - : (thing->z + thing->height < lightningSource->z)) - { - // Underneath - return true; + return BMIT_CONTINUE; } if (P_AproxDistance(thing->x - lightningSource->x, thing->y - lightningSource->y) > lightningDist + thing->radius) { // Too far away - return true; + return BMIT_CONTINUE; } +#if 0 if (P_CheckSight(lightningSource, thing) == false) { // Not in sight - return true; + return BMIT_CONTINUE; } +#endif 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) diff --git a/src/k_kart.c b/src/k_kart.c index 81374d9c6..183d16a5f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7062,57 +7062,57 @@ static mobj_t *attractmo; static fixed_t attractdist; 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) { - return false; + return BMIT_ABORT; } if (thing == NULL || P_MobjWasRemoved(thing)) { - return true; // invalid + return BMIT_CONTINUE; // invalid } if (thing == attractmo) { - return true; // invalid + return BMIT_CONTINUE; // invalid } if (!(thing->type == MT_RING || thing->type == MT_FLINGRING)) { - return true; // not a ring + return BMIT_CONTINUE; // not a ring } if (thing->health <= 0) { - return true; // dead + return BMIT_CONTINUE; // dead } 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) { - return true; // already attracted + return BMIT_CONTINUE; // already attracted } // see if it went over / under if (attractmo->z - attractzdist > thing->z + thing->height) { - return true; // overhead + return BMIT_CONTINUE; // overhead } 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) { - return true; // Too far away + return BMIT_CONTINUE; // Too far away } if (RINGTOTAL(attractmo->player) >= 20 || (attractmo->player->pflags & PF_RINGLOCK)) @@ -7139,7 +7139,7 @@ static inline boolean PIT_AttractingRings(mobj_t *thing) 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. diff --git a/src/p_enemy.c b/src/p_enemy.c index 65f00e116..cf28c31d6 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -4573,26 +4573,26 @@ void A_ShootBullet(mobj_t *actor) static mobj_t *minus; -static boolean PIT_MinusCarry(mobj_t *thing) +static BlockItReturn_t PIT_MinusCarry(mobj_t *thing) { if (minus->tracer) - return true; + return BMIT_CONTINUE; if (minus->type == thing->type) - return true; + return BMIT_CONTINUE; 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) - return true; + return BMIT_CONTINUE; if (abs(thing->z - minus->z) > minus->height) - return true; + return BMIT_CONTINUE; P_SetTarget(&minus->tracer, thing); - return true; + return BMIT_CONTINUE; } // Function: A_MinusDigging @@ -12145,13 +12145,13 @@ static mobj_t *barrel; static fixed_t exploderadius; 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 dm; if (nearby == barrel) - return true; + return BMIT_CONTINUE; dx = nearby->x - barrel->x; dy = nearby->y - barrel->y; @@ -12159,7 +12159,7 @@ static boolean PIT_TNTExplode(mobj_t *nearby) dm = P_AproxDistance(P_AproxDistance(dx, dy), dz); 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 { @@ -12200,7 +12200,7 @@ static boolean PIT_TNTExplode(mobj_t *nearby) } } - return true; + return BMIT_CONTINUE; } // Function: A_TNTExplode diff --git a/src/p_local.h b/src/p_local.h index 4940daf81..82b1d445c 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -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_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); diff --git a/src/p_map.c b/src/p_map.c index f75968169..a64f9d761 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -523,17 +523,20 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) // // PIT_CheckThing // -static boolean PIT_CheckThing(mobj_t *thing) +static BlockItReturn_t PIT_CheckThing(mobj_t *thing) { fixed_t blockdist; + if (tmthing == NULL || P_MobjWasRemoved(tmthing) == true) + return BMIT_STOP; // func just popped our tmthing, cannot continue. + // don't clip against self if (thing == tmthing) - return true; + return BMIT_CONTINUE; // Ignore... things. if (!tmthing || !thing || P_MobjWasRemoved(thing)) - return true; + return BMIT_CONTINUE; I_Assert(!P_MobjWasRemoved(tmthing)); I_Assert(!P_MobjWasRemoved(thing)); @@ -541,19 +544,19 @@ static boolean PIT_CheckThing(mobj_t *thing) // Ignore spectators if ((tmthing->player && tmthing->player->spectator) || (thing->player && thing->player->spectator)) - return true; + return BMIT_CONTINUE; // Ignore the collision if BOTH things are in hitlag. if (thing->hitlag > 0 && tmthing->hitlag > 0) - return true; + return BMIT_CONTINUE; if ((thing->flags & MF_NOCLIPTHING) || !(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE|MF_SPRING))) - return true; + return BMIT_CONTINUE; blockdist = thing->radius + tmthing->radius; if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) - return true; // didn't hit it + return BMIT_CONTINUE; // didn't hit it if (thing->flags & MF_PAPERCOLLISION) // CAUTION! Very easy to get stuck inside MF_SOLID objects. Giving the player MF_PAPERCOLLISION is a bad idea unless you know what you're doing. { @@ -580,23 +583,23 @@ static boolean PIT_CheckThing(mobj_t *thing) fixed_t tmcosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT)); fixed_t tmsinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT)); if (abs(thing->x - tmx) >= (abs(tmcosradius) + abs(cosradius)) || abs(thing->y - tmy) >= (abs(tmsinradius) + abs(sinradius))) - return true; // didn't hit it + return BMIT_CONTINUE; // didn't hit it check1 = P_PointOnLineSide(tmx - tmcosradius, tmy - tmsinradius, &junk); check2 = P_PointOnLineSide(tmx + tmcosradius, tmy + tmsinradius, &junk); check3 = P_PointOnLineSide(tmx + tmthing->momx - tmcosradius, tmy + tmthing->momy - tmsinradius, &junk); check4 = P_PointOnLineSide(tmx + tmthing->momx + tmcosradius, tmy + tmthing->momy + tmsinradius, &junk); if ((check1 == check2) && (check2 == check3) && (check3 == check4)) - return true; // the line doesn't cross between collider's start or end + return BMIT_CONTINUE; // the line doesn't cross between collider's start or end } else { if (abs(thing->x - tmx) >= (tmthing->radius + abs(cosradius)) || abs(thing->y - tmy) >= (tmthing->radius + abs(sinradius))) - return true; // didn't hit it + return BMIT_CONTINUE; // didn't hit it if ((P_PointOnLineSide(tmx - tmthing->radius, tmy - tmthing->radius, &junk) == P_PointOnLineSide(tmx + tmthing->radius, tmy + tmthing->radius, &junk)) && (P_PointOnLineSide(tmx + tmthing->radius, tmy - tmthing->radius, &junk) == P_PointOnLineSide(tmx - tmthing->radius, tmy + tmthing->radius, &junk))) - return true; // the line doesn't cross between either pair of opposite corners + return BMIT_CONTINUE; // the line doesn't cross between either pair of opposite corners } } else if (tmthing->flags & MF_PAPERCOLLISION) @@ -609,7 +612,7 @@ static boolean PIT_CheckThing(mobj_t *thing) tmsinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT)); if (abs(thing->x - tmx) >= (thing->radius + abs(tmcosradius)) || abs(thing->y - tmy) >= (thing->radius + abs(tmsinradius))) - return true; // didn't hit it + return BMIT_CONTINUE; // didn't hit it v1.x = tmx - tmcosradius; v1.y = tmy - tmsinradius; @@ -626,34 +629,34 @@ static boolean PIT_CheckThing(mobj_t *thing) == P_PointOnLineSide(thing->x + thing->radius, thing->y + thing->radius, &junk)) && (P_PointOnLineSide(thing->x + thing->radius, thing->y - thing->radius, &junk) == P_PointOnLineSide(thing->x - thing->radius, thing->y + thing->radius, &junk))) - return true; // the line doesn't cross between either pair of opposite corners + return BMIT_CONTINUE; // the line doesn't cross between either pair of opposite corners } { UINT8 shouldCollide = LUAh_MobjCollide(thing, tmthing); // checks hook for thing's type if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) - return true; // one of them was removed??? + return BMIT_CONTINUE; // one of them was removed??? if (shouldCollide == 1) - return false; // force collide + return BMIT_ABORT; // force collide else if (shouldCollide == 2) - return true; // force no collide + return BMIT_CONTINUE; // force no collide shouldCollide = LUAh_MobjMoveCollide(tmthing, thing); // checks hook for tmthing's type if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) - return true; // one of them was removed??? + return BMIT_CONTINUE; // one of them was removed??? if (shouldCollide == 1) - return false; // force collide + return BMIT_ABORT; // force collide else if (shouldCollide == 2) - return true; // force no collide + return BMIT_CONTINUE; // force no collide } // When solid spikes move, assume they just popped up and teleport things on top of them to hurt. if (tmthing->type == MT_SPIKE && tmthing->flags & MF_SOLID) { if (thing->z > tmthing->z + tmthing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (thing->z + thing->height < tmthing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath if (tmthing->eflags & MFE_VERTICALFLIP) P_SetOrigin(thing, thing->x, thing->y, tmthing->z - thing->height - FixedMul(FRACUNIT, tmthing->scale)); @@ -661,16 +664,16 @@ static boolean PIT_CheckThing(mobj_t *thing) P_SetOrigin(thing, thing->x, thing->y, tmthing->z + tmthing->height + FixedMul(FRACUNIT, tmthing->scale)); if (thing->flags & MF_SHOOTABLE) P_DamageMobj(thing, tmthing, tmthing, 1, 0); - return true; + return BMIT_CONTINUE; } if (thing->flags & MF_PAIN) { // Player touches painful thing sitting on the floor // see if it went over / under if (thing->z > tmthing->z + tmthing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (thing->z + thing->height < tmthing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath if (tmthing->flags & MF_SHOOTABLE && thing->health > 0) { UINT32 damagetype = (thing->info->mass & 0xFF); @@ -678,15 +681,15 @@ static boolean PIT_CheckThing(mobj_t *thing) if (P_DamageMobj(tmthing, thing, thing, 1, damagetype) && (damagetype = (thing->info->mass>>8))) S_StartSound(thing, damagetype); } - return true; + return BMIT_CONTINUE; } else if (tmthing->flags & MF_PAIN && thing->player) { // Painful thing splats player in the face // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath if (thing->flags & MF_SHOOTABLE && tmthing->health > 0) { UINT32 damagetype = (tmthing->info->mass & 0xFF); @@ -694,7 +697,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (P_DamageMobj(thing, tmthing, tmthing, 1, damagetype) && (damagetype = (tmthing->info->mass>>8))) S_StartSound(tmthing, damagetype); } - return true; + return BMIT_CONTINUE; } // check for skulls slamming into things @@ -702,13 +705,13 @@ static boolean PIT_CheckThing(mobj_t *thing) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath tmthing->flags2 &= ~MF2_SKULLFLY; tmthing->momx = tmthing->momy = tmthing->momz = 0; - return false; // stop moving + return BMIT_ABORT; // stop moving } // SRB2kart 011617 - Colission[sic] code for kart items //{ @@ -717,46 +720,46 @@ static boolean PIT_CheckThing(mobj_t *thing) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_SMKIceBlockCollide(tmthing, thing); + return K_SMKIceBlockCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_SMK_ICEBLOCK) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_SMKIceBlockCollide(thing, tmthing); + return K_SMKIceBlockCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; } if (tmthing->type == MT_EGGMANITEM || tmthing->type == MT_EGGMANITEM_SHIELD) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_EggItemCollide(tmthing, thing); + return K_EggItemCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_EGGMANITEM || thing->type == MT_EGGMANITEM_SHIELD) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_EggItemCollide(thing, tmthing); + return K_EggItemCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; } if (tmthing->type == MT_RANDOMITEM) - return true; + return BMIT_CONTINUE; // Bubble Shield reflect if (((thing->type == MT_BUBBLESHIELD && thing->target->player && thing->target->player->bubbleblowup) @@ -768,11 +771,11 @@ static boolean PIT_CheckThing(mobj_t *thing) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_BubbleShieldCollide(thing, tmthing); + return K_BubbleShieldCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (((tmthing->type == MT_BUBBLESHIELD && tmthing->target->player && tmthing->target->player->bubbleblowup) || (tmthing->player && tmthing->player->bubbleblowup)) @@ -783,16 +786,16 @@ static boolean PIT_CheckThing(mobj_t *thing) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_BubbleShieldCollide(tmthing, thing); + return K_BubbleShieldCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } // double make sure bubbles won't collide with anything else if (thing->type == MT_BUBBLESHIELD || tmthing->type == MT_BUBBLESHIELD) - return true; + return BMIT_CONTINUE; // Droptarget reflect if ((thing->type == MT_DROPTARGET || thing->type == MT_DROPTARGET_SHIELD) @@ -803,11 +806,11 @@ static boolean PIT_CheckThing(mobj_t *thing) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_DropTargetCollide(thing, tmthing); + return K_DropTargetCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; } else if ((tmthing->type == MT_DROPTARGET || tmthing->type == MT_DROPTARGET_SHIELD) && (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ || thing->type == MT_JAWZ_DUD @@ -817,144 +820,144 @@ static boolean PIT_CheckThing(mobj_t *thing) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_DropTargetCollide(tmthing, thing); + return K_DropTargetCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } // double make sure drop targets won't collide with anything else if (thing->type == MT_DROPTARGET || tmthing->type == MT_DROPTARGET || thing->type == MT_DROPTARGET_SHIELD || tmthing->type == MT_DROPTARGET_SHIELD) - return true; + return BMIT_CONTINUE; if (tmthing->type == MT_ORBINAUT || tmthing->type == MT_JAWZ || tmthing->type == MT_JAWZ_DUD || tmthing->type == MT_ORBINAUT_SHIELD || tmthing->type == MT_JAWZ_SHIELD) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_OrbinautJawzCollide(tmthing, thing); + return K_OrbinautJawzCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ || thing->type == MT_JAWZ_DUD || thing->type == MT_ORBINAUT_SHIELD || thing->type == MT_JAWZ_SHIELD) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_OrbinautJawzCollide(thing, tmthing); + return K_OrbinautJawzCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; } if (tmthing->type == MT_BANANA || tmthing->type == MT_BANANA_SHIELD || tmthing->type == MT_BALLHOG) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_BananaBallhogCollide(tmthing, thing); + return K_BananaBallhogCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_BANANA || thing->type == MT_BANANA_SHIELD || thing->type == MT_BALLHOG) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_BananaBallhogCollide(thing, tmthing); + return K_BananaBallhogCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; } if (tmthing->type == MT_SSMINE || tmthing->type == MT_SSMINE_SHIELD) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_MineCollide(tmthing, thing); + return K_MineCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_SSMINE || thing->type == MT_SSMINE_SHIELD) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_MineCollide(thing, tmthing); + return K_MineCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; } if (tmthing->type == MT_LANDMINE) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_LandMineCollide(tmthing, thing); + return K_LandMineCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_LANDMINE) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_LandMineCollide(thing, tmthing); + return K_LandMineCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; } if (tmthing->type == MT_SINK) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_KitchenSinkCollide(tmthing, thing); + return K_KitchenSinkCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_SINK) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_KitchenSinkCollide(thing, tmthing); + return K_KitchenSinkCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; } if (tmthing->type == MT_FALLINGROCK) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_FallingRockCollide(tmthing, thing); + return K_FallingRockCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; } else if (thing->type == MT_FALLINGROCK) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath - return K_FallingRockCollide(thing, tmthing); + return K_FallingRockCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; } //} @@ -972,10 +975,10 @@ static boolean PIT_CheckThing(mobj_t *thing) if (tmznext <= thzh) { P_DoSpring(thing, tmthing); - // return true; + // return BMIT_CONTINUE; } //else if (tmz > thzh - sprarea && tmz < thzh) // Don't damage people springing up / down - return true; + return BMIT_CONTINUE; } // missiles can hit other things @@ -985,35 +988,35 @@ static boolean PIT_CheckThing(mobj_t *thing) // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath if (tmthing->target && tmthing->target->type == thing->type) { // Don't hit same species as originator. if (thing == tmthing->target) - return true; + return BMIT_CONTINUE; if (thing->type != MT_PLAYER) { // Explode, but do no damage. // Let players missile other players. - return false; + return BMIT_ABORT; } } if (!(thing->flags & MF_SHOOTABLE)) { // didn't do any damage - return !(thing->flags & MF_SOLID); + return (thing->flags & MF_SOLID) ? BMIT_ABORT : BMIT_CONTINUE; } // damage / explode P_DamageMobj(thing, tmthing, tmthing->target, 1, damagetype); // don't traverse any more - return false; + return BMIT_ABORT; } if (thing->flags & MF_PUSHABLE && (tmthing->player || tmthing->flags & MF_PUSHABLE) @@ -1080,13 +1083,13 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->flags & MF_SPECIAL && tmthing->player) { P_TouchSpecialThing(thing, tmthing, true); // can remove thing - return true; + return BMIT_CONTINUE; } // check again for special pickup if (tmthing->flags & MF_SPECIAL && thing->player) { P_TouchSpecialThing(tmthing, thing, true); // can remove thing - return true; + return BMIT_CONTINUE; } // Sprite Spikes! @@ -1142,7 +1145,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (playerangle > ANGLE_180) playerangle = InvAngle(playerangle); if (playerangle < ANGLE_90) - return true; // Yes, this is intentionally outside the z-height check. No standing on spikes whilst moving away from them. + return BMIT_CONTINUE; // Yes, this is intentionally outside the z-height check. No standing on spikes whilst moving away from them. } bottomz = thing->z; @@ -1176,15 +1179,15 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->type == MT_FAN || thing->type == MT_STEAM) { P_DoFanAndGasJet(thing, tmthing); - return true; + return BMIT_CONTINUE; } else if (thing->flags & MF_SPRING) { if ( thing->z <= tmthing->z + tmthing->height && tmthing->z <= thing->z + thing->height) if (P_DoSpring(thing, tmthing)) - return false; - return true; + return BMIT_ABORT; + return BMIT_CONTINUE; } } @@ -1193,7 +1196,7 @@ static boolean PIT_CheckThing(mobj_t *thing) { if ((thing->z + thing->height >= tmthing->z) && (tmthing->z + tmthing->height >= thing->z)) - return false; + return BMIT_ABORT; } if (thing->player) @@ -1205,7 +1208,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (tmthing->player) // Is the moving/interacting object the player? { if (!tmthing->health) - return true; + return BMIT_CONTINUE; if (thing->type == MT_FAN || thing->type == MT_STEAM) P_DoFanAndGasJet(thing, tmthing); @@ -1214,27 +1217,27 @@ static boolean PIT_CheckThing(mobj_t *thing) if ( thing->z <= tmthing->z + tmthing->height && tmthing->z <= thing->z + thing->height) if (P_DoSpring(thing, tmthing)) - return false; - return true; + return BMIT_ABORT; + return BMIT_CONTINUE; } else if (thing->player) // bounce when players collide { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath if (thing->player->hyudorotimer || tmthing->player->hyudorotimer) { - return true; + return BMIT_CONTINUE; } if ((gametyperules & GTR_BUMPERS) && ((thing->player->bumpers && !tmthing->player->bumpers) || (tmthing->player->bumpers && !thing->player->bumpers))) { - return true; + return BMIT_CONTINUE; } // The bump has to happen last @@ -1252,18 +1255,18 @@ static boolean PIT_CheckThing(mobj_t *thing) K_PvPTouchDamage(tmthing, thing); } - return true; + return BMIT_CONTINUE; } else if (thing->type == MT_BLUEROBRA_HEAD || thing->type == MT_BLUEROBRA_JOINT) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath if (!thing->health) - return true; // dead + return BMIT_CONTINUE; // dead if (tmthing->player->invincibilitytimer > 0 || tmthing->player->growshrinktimer > 0) @@ -1272,42 +1275,42 @@ static boolean PIT_CheckThing(mobj_t *thing) P_KillMobj(thing->target, tmthing, tmthing, DMG_NORMAL); else P_KillMobj(thing, tmthing, tmthing, DMG_NORMAL); - return true; + return BMIT_CONTINUE; } else { K_KartSolidBounce(tmthing, thing); - return true; + return BMIT_CONTINUE; } } else if (thing->type == MT_SMK_PIPE) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath if (!thing->health) - return true; // dead + return BMIT_CONTINUE; // dead if (tmthing->player->invincibilitytimer > 0 || tmthing->player->growshrinktimer > 0) { P_KillMobj(thing, tmthing, tmthing, DMG_NORMAL); - return true; // kill + return BMIT_CONTINUE; // kill } K_KartSolidBounce(tmthing, thing); - return true; + return BMIT_CONTINUE; } else if (thing->type == MT_SMK_THWOMP) { if (!thing->health) - return true; // dead + return BMIT_CONTINUE; // dead if (!thwompsactive) - return true; // not active yet + return BMIT_CONTINUE; // not active yet if ((tmthing->z < thing->z) && (thing->z >= thing->movefactor-(256<z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath // kill if (tmthing->player->invincibilitytimer > 0 || tmthing->player->growshrinktimer > 0) { P_KillMobj(thing, tmthing, tmthing, DMG_NORMAL); - return true; + return BMIT_CONTINUE; } // no interaction if (tmthing->player->flashing > 0 || tmthing->player->hyudorotimer > 0 || tmthing->player->spinouttimer > 0) - return true; + return BMIT_CONTINUE; // collide if (tmthing->z < thing->z && thing->momz < 0) @@ -1344,29 +1347,29 @@ static boolean PIT_CheckThing(mobj_t *thing) } } - return true; + return BMIT_CONTINUE; } else if (thing->type == MT_KART_LEFTOVER) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath K_KartBouncing(tmthing, thing); - return true; + return BMIT_CONTINUE; } else if (thing->flags & MF_SOLID) { // see if it went over / under if (tmthing->z > thing->z + thing->height) - return true; // overhead + return BMIT_CONTINUE; // overhead if (tmthing->z + tmthing->height < thing->z) - return true; // underneath + return BMIT_CONTINUE; // underneath K_KartSolidBounce(tmthing, thing); - return true; + return BMIT_CONTINUE; } } @@ -1393,7 +1396,7 @@ static boolean PIT_CheckThing(mobj_t *thing) tmfloorslope = NULL; tmfloorpic = -1; } - return true; + return BMIT_CONTINUE; } topz = thing->z - thing->scale; // FixedMul(FRACUNIT, thing->scale), but thing->scale == FRACUNIT in base scale anyways @@ -1406,7 +1409,7 @@ static boolean PIT_CheckThing(mobj_t *thing) && tmthing->z + tmthing->height < tmthing->ceilingz) { if (thing->flags & MF_GRENADEBOUNCE && (thing->flags & MF_MONITOR || thing->info->flags & MF_MONITOR)) // Gold monitor hack... - return false; + return BMIT_ABORT; tmfloorz = tmceilingz = topz; // block while in air tmceilingrover = NULL; @@ -1437,7 +1440,7 @@ static boolean PIT_CheckThing(mobj_t *thing) tmceilingslope = NULL; tmceilingpic = -1; } - return true; + return BMIT_CONTINUE; } topz = thing->z + thing->height + thing->scale; // FixedMul(FRACUNIT, thing->scale), but thing->scale == FRACUNIT in base scale anyways @@ -1450,7 +1453,7 @@ static boolean PIT_CheckThing(mobj_t *thing) && tmthing->z > tmthing->floorz) { if (thing->flags & MF_GRENADEBOUNCE && (thing->flags & MF_MONITOR || thing->info->flags & MF_MONITOR)) // Gold monitor hack... - return false; + return BMIT_ABORT; tmfloorz = tmceilingz = topz; // block while in air tmfloorrover = NULL; @@ -1470,24 +1473,24 @@ static boolean PIT_CheckThing(mobj_t *thing) } // not solid not blocked - return true; + return BMIT_CONTINUE; } // PIT_CheckCameraLine // Adjusts tmfloorz and tmceilingz as lines are contacted - FOR CAMERA ONLY -static boolean PIT_CheckCameraLine(line_t *ld) +static BlockItReturn_t PIT_CheckCameraLine(line_t *ld) { if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) - return true; + return BMIT_CONTINUE; if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) { - return true; + return BMIT_CONTINUE; } if (P_BoxOnLineSide(tmbbox, ld) != -1) - return true; + return BMIT_CONTINUE; // A line has been hit @@ -1505,8 +1508,8 @@ static boolean PIT_CheckCameraLine(line_t *ld) if (!ld->backsector) // one sided line { if (P_PointOnLineSide(mapcampointer->x, mapcampointer->y, ld)) - return true; // don't hit the back side - return false; + return BMIT_CONTINUE; // don't hit the back side + return BMIT_ABORT; } // set openrange, opentop, openbottom @@ -1530,7 +1533,7 @@ static boolean PIT_CheckCameraLine(line_t *ld) if (lowfloor < tmdropoffz) tmdropoffz = lowfloor; - return true; + return BMIT_CONTINUE; } boolean P_IsLineBlocking(const line_t *ld, const mobj_t *thing) @@ -1559,19 +1562,19 @@ boolean P_IsLineTripWire(const line_t *ld) // PIT_CheckLine // Adjusts tmfloorz and tmceilingz as lines are contacted // -static boolean PIT_CheckLine(line_t *ld) +static BlockItReturn_t PIT_CheckLine(line_t *ld) { const fixed_t thingtop = tmthing->z + tmthing->height; if (ld->polyobj && !(ld->polyobj->flags & POF_SOLID)) - return true; + return BMIT_CONTINUE; if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - return true; + return BMIT_CONTINUE; if (P_BoxOnLineSide(tmbbox, ld) != -1) - return true; + return BMIT_CONTINUE; if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag. { @@ -1580,7 +1583,7 @@ static boolean PIT_CheckLine(line_t *ld) sinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT)); if (P_PointOnLineSide(tmx - cosradius, tmy - sinradius, ld) == P_PointOnLineSide(tmx + cosradius, tmy + sinradius, ld)) - return true; // the line doesn't cross between collider's start or end + return BMIT_CONTINUE; // the line doesn't cross between collider's start or end #ifdef PAPER_COLLISIONCORRECTION { fixed_t dist; @@ -1616,22 +1619,22 @@ static boolean PIT_CheckLine(line_t *ld) { UINT8 shouldCollide = LUAh_MobjLineCollide(tmthing, blockingline); // checks hook for thing's type if (P_MobjWasRemoved(tmthing)) - return true; // one of them was removed??? + return BMIT_CONTINUE; // one of them was removed??? if (shouldCollide == 1) - return false; // force collide + return BMIT_ABORT; // force collide else if (shouldCollide == 2) - return true; // force no collide + return BMIT_CONTINUE; // force no collide } if (!ld->backsector) // one sided line { if (P_PointOnLineSide(tmthing->x, tmthing->y, ld)) - return true; // don't hit the back side - return false; + return BMIT_CONTINUE; // don't hit the back side + return BMIT_ABORT; } if (P_IsLineBlocking(ld, tmthing)) - return false; + return BMIT_ABORT; // set openrange, opentop, openbottom P_LineOpening(ld, tmthing); @@ -1676,7 +1679,7 @@ static boolean PIT_CheckLine(line_t *ld) add_spechit(ld); } - return true; + return BMIT_CONTINUE; } // ========================================================================= @@ -2322,32 +2325,32 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) static mobj_t *stand; static fixed_t standx, standy; -boolean PIT_PushableMoved(mobj_t *thing) +BlockItReturn_t PIT_PushableMoved(mobj_t *thing) { fixed_t blockdist; if (!(thing->flags & MF_SOLID) || (thing->flags & MF_NOGRAVITY)) - return true; // Don't move something non-solid! + return BMIT_CONTINUE; // Don't move something non-solid! // Only pushables are supported... in 2.0. Now players can be moved too! if (!(thing->flags & MF_PUSHABLE || thing->player)) - return true; + return BMIT_CONTINUE; if (thing == stand) - return true; + return BMIT_CONTINUE; blockdist = stand->radius + thing->radius; if (abs(thing->x - stand->x) >= blockdist || abs(thing->y - stand->y) >= blockdist) - return true; // didn't hit it + return BMIT_CONTINUE; // didn't hit it if ((!(stand->eflags & MFE_VERTICALFLIP) && thing->z != stand->z + stand->height + FixedMul(FRACUNIT, stand->scale)) || ((stand->eflags & MFE_VERTICALFLIP) && thing->z + thing->height != stand->z - FixedMul(FRACUNIT, stand->scale))) - return true; // Not standing on top + return BMIT_CONTINUE; // Not standing on top if (!stand->momx && !stand->momy) - return true; + return BMIT_CONTINUE; // Move this guy! if (thing->player) @@ -2396,7 +2399,7 @@ boolean PIT_PushableMoved(mobj_t *thing) thing->momy = stand->momy; thing->momz = stand->momz; } - return true; + return BMIT_CONTINUE; } static boolean P_WaterRunning(mobj_t *thing) @@ -3952,18 +3955,18 @@ static boolean bombsightcheck; // "bombsource" is the creature // that caused the explosion at "bombspot". // -static boolean PIT_RadiusAttack(mobj_t *thing) +static BlockItReturn_t PIT_RadiusAttack(mobj_t *thing) { fixed_t dx, dy, dz, dist; if (thing == bombspot) // ignore the bomb itself (Deton fix) - return true; + return BMIT_CONTINUE; if ((bombdamagetype & DMG_CANTHURTSELF) && bombsource && thing->type == bombsource->type) // ignore the type of guys who dropped the bomb (Jetty-Syn Bomber or Skim can bomb eachother, but not themselves.) - return true; + return BMIT_CONTINUE; if ((thing->flags & (MF_MONITOR|MF_SHOOTABLE)) != MF_SHOOTABLE) - return true; + return BMIT_CONTINUE; dx = abs(thing->x - bombspot->x); dy = abs(thing->y - bombspot->y); @@ -3976,20 +3979,20 @@ static boolean PIT_RadiusAttack(mobj_t *thing) dist = 0; if (dist >= bombdamage) - return true; // out of range + return BMIT_CONTINUE; // out of range if (thing->floorz > bombspot->z && bombspot->ceilingz < thing->z) - return true; + return BMIT_CONTINUE; if (thing->ceilingz < bombspot->z && bombspot->floorz > thing->z) - return true; + return BMIT_CONTINUE; if (!bombsightcheck || P_CheckSight(thing, bombspot)) { // must be in direct path P_DamageMobj(thing, bombspot, bombsource, 1, bombdamagetype); // Tails 01-11-2001 } - return true; + return BMIT_CONTINUE; } // @@ -4623,19 +4626,19 @@ void P_DelPrecipSeclist(mprecipsecnode_t *node) // at this location, so don't bother with checking impassable or // blocking lines. -static inline boolean PIT_GetSectors(line_t *ld) +static inline BlockItReturn_t PIT_GetSectors(line_t *ld) { if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - return true; + return BMIT_CONTINUE; if (P_BoxOnLineSide(tmbbox, ld) != -1) - return true; + return BMIT_CONTINUE; if (ld->polyobj) // line belongs to a polyobject, don't add it - return true; + return BMIT_CONTINUE; // This line crosses through the object. @@ -4654,23 +4657,23 @@ static inline boolean PIT_GetSectors(line_t *ld) if (ld->backsector) sector_list = P_AddSecnode(ld->backsector, tmthing, sector_list); - return true; + return BMIT_CONTINUE; } // Tails 08-25-2002 -static inline boolean PIT_GetPrecipSectors(line_t *ld) +static inline BlockItReturn_t PIT_GetPrecipSectors(line_t *ld) { if (preciptmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || preciptmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || preciptmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || preciptmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - return true; + return BMIT_CONTINUE; if (P_BoxOnLineSide(preciptmbbox, ld) != -1) - return true; + return BMIT_CONTINUE; if (ld->polyobj) // line belongs to a polyobject, don't add it - return true; + return BMIT_CONTINUE; // This line crosses through the object. @@ -4689,7 +4692,7 @@ static inline boolean PIT_GetPrecipSectors(line_t *ld) if (ld->backsector) precipsector_list = P_AddPrecipSecnode(ld->backsector, tmprecipthing, precipsector_list); - return true; + return BMIT_CONTINUE; } // P_CreateSecNodeList alters/creates the sector_list that shows what sectors diff --git a/src/p_maputl.c b/src/p_maputl.c index 555928a3a..37a24267c 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -1096,7 +1096,7 @@ void P_SetPrecipitationThingPosition(precipmobj_t *thing) // to P_BlockLinesIterator, then make one or more calls // 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; 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) { + BlockItReturn_t ret = BMIT_CONTINUE; + if (po->lines[i]->validcount == validcount) // line has been checked continue; + po->lines[i]->validcount = validcount; - if (!func(po->lines[i])) + ret = func(po->lines[i]); + + if (ret == BMIT_ABORT) + { return false; + } + else if (ret == BMIT_STOP) + { + return true; + } } } 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. for (list = blockmaplump + offset + 1; *list != -1; list++) { + BlockItReturn_t ret = BMIT_CONTINUE; + ld = &lines[*list]; if (ld->validcount == validcount) continue; // Line has already been checked. ld->validcount = validcount; + ret = func(ld); - if (!func(ld)) + if (ret == BMIT_ABORT) + { return false; + } + else if (ret == BMIT_STOP) + { + return true; + } } return true; // Everything was checked. } @@ -1154,7 +1174,7 @@ boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean (*func)(line_t *)) // // 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; @@ -1164,19 +1184,25 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) // Check interaction with the objects in the blockmap. 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! - if (!func(mobj)) + ret = func(mobj); + + if (ret == BMIT_ABORT) { 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); - return true; + return true; // success } } + return true; } @@ -1220,7 +1246,7 @@ static void P_CheckIntercepts(void) // are on opposite sides of the trace. // 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; fixed_t frac; @@ -1243,18 +1269,18 @@ static boolean PIT_AddLineIntercepts(line_t *ld) } if (s1 == s2) - return true; // Line isn't crossed. + return BMIT_CONTINUE; // Line isn't crossed. // Hit the line. P_MakeDivline(ld, &dl); frac = P_InterceptVector(&trace, &dl); if (frac < 0) - return true; // Behind source. + return BMIT_CONTINUE; // Behind source. // Try to take an early out of the check. if (earlyout && frac < FRACUNIT && !ld->backsector) - return false; // stop checking + return BMIT_ABORT; // stop checking P_CheckIntercepts(); @@ -1263,13 +1289,13 @@ static boolean PIT_AddLineIntercepts(line_t *ld) intercept_p->d.line = ld; intercept_p++; - return true; // continue + return BMIT_CONTINUE; // continue } // // PIT_AddThingIntercepts // -static boolean PIT_AddThingIntercepts(mobj_t *thing) +static BlockItReturn_t PIT_AddThingIntercepts(mobj_t *thing) { fixed_t px1, py1, px2, py2, frac; INT32 s1, s2; @@ -1300,7 +1326,7 @@ static boolean PIT_AddThingIntercepts(mobj_t *thing) s2 = P_PointOnDivlineSide(px2, py2, &trace); if (s1 == s2) - return true; // Line isn't crossed. + return BMIT_CONTINUE; // Line isn't crossed. dl.x = px1; dl.y = py1; @@ -1310,7 +1336,7 @@ static boolean PIT_AddThingIntercepts(mobj_t *thing) frac = P_InterceptVector(&trace, &dl); if (frac < 0) - return true; // Behind source. + return BMIT_CONTINUE; // Behind source. P_CheckIntercepts(); @@ -1319,7 +1345,7 @@ static boolean PIT_AddThingIntercepts(mobj_t *thing) intercept_p->d.thing = thing; intercept_p++; - return true; // Keep going. + return BMIT_CONTINUE; // Keep going. } // diff --git a/src/p_maputl.h b/src/p_maputl.h index 43a7fb507..c17ad5d33 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -67,8 +67,15 @@ extern INT32 opentoppic, openbottompic; void P_LineOpening(line_t *plinedef, mobj_t *mobj); -boolean P_BlockLinesIterator(INT32 x, INT32 y, boolean(*func)(line_t *)); -boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean(*func)(mobj_t *)); +typedef enum +{ + 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_ADDTHINGS 2 diff --git a/src/p_spec.c b/src/p_spec.c index b6079e6cf..56e7ae455 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -8390,13 +8390,13 @@ static pusher_t *tmpusher; // pusher structure for blockmap searches * ::tmpusher won't need to be used. * \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) - return false; + return BMIT_ABORT; if (!tmpusher->source) - return false; + return BMIT_ABORT; // Allow this to affect pushable objects at some point? 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 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), thing->z - sz); @@ -8482,7 +8482,7 @@ static inline boolean PIT_PushThing(mobj_t *thing) if (tmpusher->exclusive) thing->eflags |= MFE_PUSHED; - return true; + return BMIT_CONTINUE; } /** Applies a pusher to all affected objects. From 052e72c4096eceae6a65f9053e50ce17728b79bb Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 23 May 2022 19:20:21 -0400 Subject: [PATCH 2/2] PIT_CheckThing valid checks more consistent --- src/p_map.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index a64f9d761..473ded5fe 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -530,17 +530,14 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) if (tmthing == NULL || P_MobjWasRemoved(tmthing) == true) return BMIT_STOP; // func just popped our tmthing, cannot continue. + // Ignore... things. + if (thing == NULL || P_MobjWasRemoved(thing) == true) + return BMIT_CONTINUE; + // don't clip against self if (thing == tmthing) return BMIT_CONTINUE; - // Ignore... things. - if (!tmthing || !thing || P_MobjWasRemoved(thing)) - return BMIT_CONTINUE; - - I_Assert(!P_MobjWasRemoved(tmthing)); - I_Assert(!P_MobjWasRemoved(thing)); - // Ignore spectators if ((tmthing->player && tmthing->player->spectator) || (thing->player && thing->player->spectator))