Split P_CheckSector further

This commit is contained in:
MascaraSnake 2023-03-16 20:03:42 +01:00
parent 411b79e456
commit afa1a9ab6a

View file

@ -4330,9 +4330,8 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush, boolean crunch
return true;
}
static boolean P_CheckSectorHelper(sector_t *sector, boolean realcrush, boolean crunch)
static boolean P_CheckSectorPolyObjects(sector_t *sector, boolean realcrush, boolean crunch)
{
msecnode_t *n;
size_t i;
// Sal: This stupid function chain is required to fix polyobjects not being able to crush.
@ -4341,16 +4340,18 @@ static boolean P_CheckSectorHelper(sector_t *sector, boolean realcrush, boolean
for (i = 0; i < sector->linecount; i++)
{
if (sector->lines[i]->polyobj)
{
INT32 x, y;
polyobj_t *po = sector->lines[i]->polyobj;
if (!po)
continue;
if (po->validcount == validcount)
continue; // skip if already checked
if (!(po->flags & POF_SOLID))
continue;
if (po->lines[0]->backsector == sector) // Make sure you're currently checking the control sector
{
INT32 x, y;
if (po->lines[0]->backsector != sector) // Make sure you're currently checking the control sector
continue;
po->validcount = validcount;
for (y = po->blockbox[BOXBOTTOM]; y <= po->blockbox[BOXTOP]; ++y)
@ -4377,17 +4378,50 @@ static boolean P_CheckSectorHelper(sector_t *sector, boolean realcrush, boolean
}
}
}
}
return true;
}
if (sector->numattached)
static boolean P_CheckTouchingThinglist(sector_t *sector, boolean realcrush, boolean crunch)
{
msecnode_t *n;
for (n = sector->touching_thinglist; n; n = n->m_thinglist_next)
n->visited = false;
do
{
for (n = sector->touching_thinglist; n; n = n->m_thinglist_next) // go through list
{
if (n->visited)
continue;
n->visited = true; // mark thing as processed
if (n->m_thing->flags & MF_NOBLOCKMAP) //jff 4/7/98 don't do these
continue;
if (!PIT_ChangeSector(n->m_thing, realcrush, crunch) && !realcrush) // process it
return false;
break; // exit and start over
}
} while (n); // repeat from scratch until all things left are marked valid
return true;
}
static boolean P_CheckSectorFFloors(sector_t *sector, boolean realcrush, boolean crunch)
{
sector_t *sec;
size_t i;
if (!sector->numattached)
return true;
for (i = 0; i < sector->numattached; i++)
{
sec = &sectors[sector->attached[i]];
for (n = sec->touching_thinglist; n; n = n->m_thinglist_next)
n->visited = false;
sec->moved = true;
@ -4396,45 +4430,25 @@ static boolean P_CheckSectorHelper(sector_t *sector, boolean realcrush, boolean
if (!sector->attachedsolid[i])
continue;
do
{
for (n = sec->touching_thinglist; n; n = n->m_thinglist_next)
if (!n->visited)
{
n->visited = true;
if (!(n->m_thing->flags & MF_NOBLOCKMAP))
{
if (!PIT_ChangeSector(n->m_thing, realcrush, crunch) && !realcrush)
if (!P_CheckTouchingThinglist(sec, realcrush, crunch))
return false;
}
break;
}
} while (n);
}
return true;
}
static boolean P_CheckSectorHelper(sector_t *sector, boolean realcrush, boolean crunch)
{
if (!P_CheckSectorPolyObjects(sector, realcrush, crunch))
return false;
if (!P_CheckSectorFFloors(sector, realcrush, crunch))
return false;
// Mark all things invalid
sector->moved = true;
for (n = sector->touching_thinglist; n; n = n->m_thinglist_next)
n->visited = false;
do
{
for (n = sector->touching_thinglist; n; n = n->m_thinglist_next) // go through list
if (!n->visited) // unprocessed thing found
{
n->visited = true; // mark thing as processed
if (!(n->m_thing->flags & MF_NOBLOCKMAP)) //jff 4/7/98 don't do these
{
if (!PIT_ChangeSector(n->m_thing, realcrush, crunch) && !realcrush) // process it
return false;
}
break; // exit and start over
}
} while (n); // repeat from scratch until all things left are marked valid
return true;
return P_CheckTouchingThinglist(sector, realcrush, crunch);
}
//