Skip to content

Commit

Permalink
Further improve traversing adjacent liquid sectors at different heights
Browse files Browse the repository at this point in the history
  • Loading branch information
bradharding committed Dec 5, 2024
1 parent c3d665f commit c1c74fa
Showing 1 changed file with 6 additions and 35 deletions.
41 changes: 6 additions & 35 deletions src/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

//
Expand Down

0 comments on commit c1c74fa

Please sign in to comment.