mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-24 19:52:08 +00:00
P_PlayerZMovement: Move PolyObject handling code into its own function
This commit is contained in:
parent
29192eff9a
commit
a67c8786ae
1 changed files with 52 additions and 59 deletions
111
src/p_mobj.c
111
src/p_mobj.c
|
@ -2835,6 +2835,57 @@ static void P_CheckMarioBlocks(mobj_t *mo)
|
|||
}
|
||||
}
|
||||
|
||||
// Check if we're on a polyobject that triggers a linedef executor.
|
||||
static boolean P_PlayerPolyObjectZMovement(mobj_t *mo)
|
||||
{
|
||||
msecnode_t *node;
|
||||
boolean stopmovecut = false;
|
||||
|
||||
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
|
||||
{
|
||||
sector_t *sec = node->m_sector;
|
||||
subsector_t *newsubsec;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < numsubsectors; i++)
|
||||
{
|
||||
polyobj_t *po;
|
||||
sector_t *polysec;
|
||||
newsubsec = &subsectors[i];
|
||||
|
||||
if (newsubsec->sector != sec)
|
||||
continue;
|
||||
|
||||
for (po = newsubsec->polyList; po; po = (polyobj_t *)(po->link.next))
|
||||
{
|
||||
if (!(po->flags & POF_SOLID))
|
||||
continue;
|
||||
|
||||
if (!P_MobjInsidePolyobj(po, mo))
|
||||
continue;
|
||||
|
||||
polysec = po->lines[0]->backsector;
|
||||
|
||||
// Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red
|
||||
if ((mo->z == polysec->ceilingheight || mo->z + mo->height == polysec->floorheight) && po->thinker)
|
||||
stopmovecut = true;
|
||||
|
||||
if (!(po->flags & POF_LDEXEC))
|
||||
continue;
|
||||
|
||||
if (mo->z != polysec->ceilingheight)
|
||||
continue;
|
||||
|
||||
// We're landing on a PO, so check for a linedef executor.
|
||||
// Trigger tags are 32000 + the PO's ID number.
|
||||
P_LinedefExecute((INT16)(32000 + po->id), mo, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stopmovecut;
|
||||
}
|
||||
|
||||
static void P_PlayerZMovement(mobj_t *mo)
|
||||
{
|
||||
boolean onground;
|
||||
|
@ -2931,66 +2982,8 @@ static void P_PlayerZMovement(mobj_t *mo)
|
|||
|
||||
mo->eflags |= MFE_JUSTHITFLOOR; // Spin Attack
|
||||
|
||||
if (!P_PlayerPolyObjectZMovement(mo))
|
||||
{
|
||||
// Check if we're on a polyobject
|
||||
// that triggers a linedef executor.
|
||||
msecnode_t *node;
|
||||
boolean stopmovecut = false;
|
||||
|
||||
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
|
||||
{
|
||||
sector_t *sec = node->m_sector;
|
||||
subsector_t *newsubsec;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < numsubsectors; i++)
|
||||
{
|
||||
newsubsec = &subsectors[i];
|
||||
|
||||
if (newsubsec->sector != sec)
|
||||
continue;
|
||||
|
||||
if (newsubsec->polyList)
|
||||
{
|
||||
polyobj_t *po = newsubsec->polyList;
|
||||
sector_t *polysec;
|
||||
|
||||
while(po)
|
||||
{
|
||||
if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID))
|
||||
{
|
||||
po = (polyobj_t *)(po->link.next);
|
||||
continue;
|
||||
}
|
||||
|
||||
// We're inside it! Yess...
|
||||
polysec = po->lines[0]->backsector;
|
||||
|
||||
// Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red
|
||||
if ((mo->z == polysec->ceilingheight || mo->z+mo->height == polysec->floorheight) && po->thinker)
|
||||
stopmovecut = true;
|
||||
|
||||
if (!(po->flags & POF_LDEXEC))
|
||||
{
|
||||
po = (polyobj_t *)(po->link.next);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mo->z == polysec->ceilingheight)
|
||||
{
|
||||
// We're landing on a PO, so check for
|
||||
// a linedef executor.
|
||||
// Trigger tags are 32000 + the PO's ID number.
|
||||
P_LinedefExecute((INT16)(32000 + po->id), mo, NULL);
|
||||
}
|
||||
|
||||
po = (polyobj_t *)(po->link.next);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!stopmovecut)
|
||||
// Cut momentum in half when you hit the ground and
|
||||
// aren't pressing any controls.
|
||||
if (!(mo->player->cmd.forwardmove || mo->player->cmd.sidemove) && !mo->player->cmomx && !mo->player->cmomy && !(mo->player->pflags & PF_SPINNING))
|
||||
|
|
Loading…
Reference in a new issue