mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-03-22 02:42:20 +00:00
Merge branch 'snaptoground-fix' into 'master'
Snap to ground fix Closes #165 See merge request STJr/SRB2Internal!274
This commit is contained in:
commit
97072d9faa
4 changed files with 122 additions and 9 deletions
103
src/p_map.c
103
src/p_map.c
|
@ -1808,7 +1808,7 @@ static boolean PIT_CheckLine(line_t *ld)
|
|||
{
|
||||
tmceilingz = opentop;
|
||||
ceilingline = ld;
|
||||
tmceilingrover = NULL;
|
||||
tmceilingrover = openceilingrover;
|
||||
#ifdef ESLOPE
|
||||
tmceilingslope = opentopslope;
|
||||
#endif
|
||||
|
@ -1817,7 +1817,7 @@ static boolean PIT_CheckLine(line_t *ld)
|
|||
if (openbottom > tmfloorz)
|
||||
{
|
||||
tmfloorz = openbottom;
|
||||
tmfloorrover = NULL;
|
||||
tmfloorrover = openfloorrover;
|
||||
#ifdef ESLOPE
|
||||
tmfloorslope = openbottomslope;
|
||||
#endif
|
||||
|
@ -2089,6 +2089,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
|
|||
#ifdef ESLOPE
|
||||
tmfloorslope = NULL;
|
||||
#endif
|
||||
tmfloorrover = NULL;
|
||||
}
|
||||
|
||||
if (polybottom < tmceilingz && abs(delta1) >= abs(delta2)) {
|
||||
|
@ -2096,6 +2097,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
|
|||
#ifdef ESLOPE
|
||||
tmceilingslope = NULL;
|
||||
#endif
|
||||
tmceilingrover = NULL;
|
||||
}
|
||||
}
|
||||
plink = (polymaplink_t *)(plink->link.next);
|
||||
|
@ -4085,6 +4087,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush)
|
|||
boolean P_CheckSector(sector_t *sector, boolean crunch)
|
||||
{
|
||||
msecnode_t *n;
|
||||
size_t i;
|
||||
|
||||
nofit = false;
|
||||
crushchange = crunch;
|
||||
|
@ -4099,9 +4102,57 @@ boolean P_CheckSector(sector_t *sector, boolean crunch)
|
|||
|
||||
|
||||
// First, let's see if anything will keep it from crushing.
|
||||
|
||||
// Sal: This stupid function chain is required to fix polyobjects not being able to crush.
|
||||
// Monster Iestyn: don't use P_CheckSector actually just look for objects in the blockmap instead
|
||||
validcount++;
|
||||
|
||||
for (i = 0; i < sector->linecount; i++)
|
||||
{
|
||||
if (sector->lines[i]->polyobj)
|
||||
{
|
||||
polyobj_t *po = sector->lines[i]->polyobj;
|
||||
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;
|
||||
po->validcount = validcount;
|
||||
|
||||
for (y = po->blockbox[BOXBOTTOM]; y <= po->blockbox[BOXTOP]; ++y)
|
||||
{
|
||||
for (x = po->blockbox[BOXLEFT]; x <= po->blockbox[BOXRIGHT]; ++x)
|
||||
{
|
||||
mobj_t *mo;
|
||||
|
||||
if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight)
|
||||
continue;
|
||||
|
||||
mo = blocklinks[y * bmapwidth + x];
|
||||
|
||||
for (; mo; mo = mo->bnext)
|
||||
{
|
||||
// Monster Iestyn: do we need to check if a mobj has already been checked? ...probably not I suspect
|
||||
|
||||
if (!P_MobjTouchingPolyobj(po, mo))
|
||||
continue;
|
||||
|
||||
if (!PIT_ChangeSector(mo, false))
|
||||
{
|
||||
nofit = true;
|
||||
return nofit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sector->numattached)
|
||||
{
|
||||
size_t i;
|
||||
sector_t *sec;
|
||||
for (i = 0; i < sector->numattached; i++)
|
||||
{
|
||||
|
@ -4161,9 +4212,53 @@ boolean P_CheckSector(sector_t *sector, boolean crunch)
|
|||
} while (n); // repeat from scratch until all things left are marked valid
|
||||
|
||||
// Nothing blocked us, so lets crush for real!
|
||||
|
||||
// Sal: This stupid function chain is required to fix polyobjects not being able to crush.
|
||||
// Monster Iestyn: don't use P_CheckSector actually just look for objects in the blockmap instead
|
||||
validcount++;
|
||||
|
||||
for (i = 0; i < sector->linecount; i++)
|
||||
{
|
||||
if (sector->lines[i]->polyobj)
|
||||
{
|
||||
polyobj_t *po = sector->lines[i]->polyobj;
|
||||
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;
|
||||
po->validcount = validcount;
|
||||
|
||||
for (y = po->blockbox[BOXBOTTOM]; y <= po->blockbox[BOXTOP]; ++y)
|
||||
{
|
||||
for (x = po->blockbox[BOXLEFT]; x <= po->blockbox[BOXRIGHT]; ++x)
|
||||
{
|
||||
mobj_t *mo;
|
||||
|
||||
if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight)
|
||||
continue;
|
||||
|
||||
mo = blocklinks[y * bmapwidth + x];
|
||||
|
||||
for (; mo; mo = mo->bnext)
|
||||
{
|
||||
// Monster Iestyn: do we need to check if a mobj has already been checked? ...probably not I suspect
|
||||
|
||||
if (!P_MobjTouchingPolyobj(po, mo))
|
||||
continue;
|
||||
|
||||
PIT_ChangeSector(mo, true);
|
||||
return nofit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sector->numattached)
|
||||
{
|
||||
size_t i;
|
||||
sector_t *sec;
|
||||
for (i = 0; i < sector->numattached; i++)
|
||||
{
|
||||
|
|
|
@ -311,6 +311,7 @@ fixed_t opentop, openbottom, openrange, lowfloor, highceiling;
|
|||
#ifdef ESLOPE
|
||||
pslope_t *opentopslope, *openbottomslope;
|
||||
#endif
|
||||
ffloor_t *openfloorrover, *openceilingrover;
|
||||
|
||||
// P_CameraLineOpening
|
||||
// P_LineOpening, but for camera
|
||||
|
@ -517,6 +518,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
|||
I_Assert(front != NULL);
|
||||
I_Assert(back != NULL);
|
||||
|
||||
openfloorrover = openceilingrover = NULL;
|
||||
|
||||
{ // Set open and high/low values here
|
||||
fixed_t frontheight, backheight;
|
||||
|
||||
|
@ -641,6 +644,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
|||
pslope_t *ceilingslope = opentopslope;
|
||||
pslope_t *floorslope = openbottomslope;
|
||||
#endif
|
||||
ffloor_t *floorrover = NULL;
|
||||
ffloor_t *ceilingrover = NULL;
|
||||
|
||||
// Check for frontsector's fake floors
|
||||
for (rover = front->ffloors; rover; rover = rover->next)
|
||||
|
@ -668,6 +673,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
|||
#ifdef ESLOPE
|
||||
ceilingslope = *rover->b_slope;
|
||||
#endif
|
||||
ceilingrover = rover;
|
||||
}
|
||||
else if (bottomheight < highestceiling)
|
||||
highestceiling = bottomheight;
|
||||
|
@ -680,6 +686,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
|||
#ifdef ESLOPE
|
||||
floorslope = *rover->t_slope;
|
||||
#endif
|
||||
floorrover = rover;
|
||||
}
|
||||
else if (topheight > lowestfloor)
|
||||
lowestfloor = topheight;
|
||||
|
@ -712,6 +719,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
|||
#ifdef ESLOPE
|
||||
ceilingslope = *rover->b_slope;
|
||||
#endif
|
||||
ceilingrover = rover;
|
||||
}
|
||||
else if (bottomheight < highestceiling)
|
||||
highestceiling = bottomheight;
|
||||
|
@ -724,6 +732,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
|||
#ifdef ESLOPE
|
||||
floorslope = *rover->t_slope;
|
||||
#endif
|
||||
floorrover = rover;
|
||||
}
|
||||
else if (topheight > lowestfloor)
|
||||
lowestfloor = topheight;
|
||||
|
@ -743,6 +752,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
|||
#ifdef ESLOPE
|
||||
ceilingslope = NULL;
|
||||
#endif
|
||||
ceilingrover = NULL;
|
||||
}
|
||||
else if (polysec->floorheight < highestceiling && delta1 >= delta2)
|
||||
highestceiling = polysec->floorheight;
|
||||
|
@ -752,6 +762,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
|||
#ifdef ESLOPE
|
||||
floorslope = NULL;
|
||||
#endif
|
||||
floorrover = NULL;
|
||||
}
|
||||
else if (polysec->ceilingheight > lowestfloor && delta1 < delta2)
|
||||
lowestfloor = polysec->ceilingheight;
|
||||
|
@ -765,6 +776,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
|||
#ifdef ESLOPE
|
||||
openbottomslope = floorslope;
|
||||
#endif
|
||||
openfloorrover = floorrover;
|
||||
}
|
||||
|
||||
if (lowestceiling < opentop) {
|
||||
|
@ -772,6 +784,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
|||
#ifdef ESLOPE
|
||||
opentopslope = ceilingslope;
|
||||
#endif
|
||||
openceilingrover = ceilingrover;
|
||||
}
|
||||
|
||||
if (lowestfloor > lowfloor)
|
||||
|
|
|
@ -58,6 +58,7 @@ extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling;
|
|||
#ifdef ESLOPE
|
||||
extern pslope_t *opentopslope, *openbottomslope;
|
||||
#endif
|
||||
extern ffloor_t *openfloorrover, *openceilingrover;
|
||||
|
||||
void P_LineOpening(line_t *plinedef, mobj_t *mobj);
|
||||
|
||||
|
|
|
@ -1873,7 +1873,8 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
|||
po->lines[0]->backsector->floorheight = target->z - amtz;
|
||||
po->lines[0]->backsector->ceilingheight = target->z + amtz;
|
||||
// Sal: Remember to check your sectors!
|
||||
P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage));
|
||||
// Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap
|
||||
// updating objects in the front one too just added teleporting to ground bugs
|
||||
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage));
|
||||
// Apply action to mirroring polyobjects as well
|
||||
start = 0;
|
||||
|
@ -1887,7 +1888,8 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
|||
po->lines[0]->backsector->floorheight += diffz; // move up/down by same amount as the parent did
|
||||
po->lines[0]->backsector->ceilingheight += diffz;
|
||||
// Sal: Remember to check your sectors!
|
||||
P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage));
|
||||
// Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap
|
||||
// updating objects in the front one too just added teleporting to ground bugs
|
||||
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage));
|
||||
}
|
||||
|
||||
|
@ -2050,8 +2052,9 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
|||
po->lines[0]->backsector->floorheight += momz;
|
||||
po->lines[0]->backsector->ceilingheight += momz;
|
||||
// Sal: Remember to check your sectors!
|
||||
P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); // frontsector is NEEDED for crushing
|
||||
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); // backsector may not be necessary, but just in case
|
||||
// Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap
|
||||
// updating objects in the front one too just added teleporting to ground bugs
|
||||
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage));
|
||||
|
||||
// Apply action to mirroring polyobjects as well
|
||||
start = 0;
|
||||
|
@ -2065,7 +2068,8 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
|||
po->lines[0]->backsector->floorheight += momz;
|
||||
po->lines[0]->backsector->ceilingheight += momz;
|
||||
// Sal: Remember to check your sectors!
|
||||
P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage));
|
||||
// Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap
|
||||
// updating objects in the front one too just added teleporting to ground bugs
|
||||
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue