From c1c74fa949d3040452432a9d84aa5f8b6ed8ac74 Mon Sep 17 00:00:00 2001 From: Brad Harding Date: Fri, 6 Dec 2024 10:31:45 +1100 Subject: [PATCH] Further improve traversing adjacent liquid sectors at different heights --- src/p_map.c | 41 ++++++----------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 21c9bce28..d5728cbe2 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -995,46 +995,17 @@ mobj_t *P_CheckOnMobj(mobj_t *thing) // bool P_IsInLiquid(mobj_t *thing) { - if (thing->player) - { - for (const struct msecnode_s *seclist = thing->touching_sectorlist; seclist; seclist = seclist->m_tnext) - { - const sector_t *sector = seclist->m_sector; + sector_t *highestsector = thing->subsector->sector; - if ((sector->terraintype < LIQUID && thing->z == sector->floorheight) || sector->isselfreferencing) - return false; - } - } - else + for (const struct msecnode_s *seclist = thing->touching_sectorlist; seclist; seclist = seclist->m_tnext) { - const int flags = thing->flags; - - if (flags & MF_NOGRAVITY) - return false; - - if (flags & MF_SHOOTABLE) - { - for (const struct msecnode_s *seclist = thing->touching_sectorlist; seclist; seclist = seclist->m_tnext) - { - const sector_t *sector = seclist->m_sector; + sector_t *sector = seclist->m_sector; - if ((sector->terraintype < LIQUID && thing->z == sector->floorheight) || sector->isselfreferencing) - return false; - } - } - else - { - const sector_t *sector = thing->subsector->sector; - - if (sector->terraintype < LIQUID || sector->isselfreferencing) - return false; - - if (thing->z > sector->floorheight + FRACUNIT) - return false; - } + if (sector->floorheight > highestsector->floorheight) + highestsector = sector; } - return true; + return (highestsector->terraintype >= LIQUID && !highestsector->isselfreferencing); } //