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
103
src/p_map.c
103
src/p_map.c
|
@ -1808,7 +1808,7 @@ static boolean PIT_CheckLine(line_t *ld)
|
||||||
{
|
{
|
||||||
tmceilingz = opentop;
|
tmceilingz = opentop;
|
||||||
ceilingline = ld;
|
ceilingline = ld;
|
||||||
tmceilingrover = NULL;
|
tmceilingrover = openceilingrover;
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
tmceilingslope = opentopslope;
|
tmceilingslope = opentopslope;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1817,7 +1817,7 @@ static boolean PIT_CheckLine(line_t *ld)
|
||||||
if (openbottom > tmfloorz)
|
if (openbottom > tmfloorz)
|
||||||
{
|
{
|
||||||
tmfloorz = openbottom;
|
tmfloorz = openbottom;
|
||||||
tmfloorrover = NULL;
|
tmfloorrover = openfloorrover;
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
tmfloorslope = openbottomslope;
|
tmfloorslope = openbottomslope;
|
||||||
#endif
|
#endif
|
||||||
|
@ -2089,6 +2089,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
tmfloorslope = NULL;
|
tmfloorslope = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
tmfloorrover = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (polybottom < tmceilingz && abs(delta1) >= abs(delta2)) {
|
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
|
#ifdef ESLOPE
|
||||||
tmceilingslope = NULL;
|
tmceilingslope = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
tmceilingrover = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plink = (polymaplink_t *)(plink->link.next);
|
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)
|
boolean P_CheckSector(sector_t *sector, boolean crunch)
|
||||||
{
|
{
|
||||||
msecnode_t *n;
|
msecnode_t *n;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
nofit = false;
|
nofit = false;
|
||||||
crushchange = crunch;
|
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.
|
// 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)
|
if (sector->numattached)
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
sector_t *sec;
|
sector_t *sec;
|
||||||
for (i = 0; i < sector->numattached; i++)
|
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
|
} while (n); // repeat from scratch until all things left are marked valid
|
||||||
|
|
||||||
// Nothing blocked us, so lets crush for real!
|
// 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)
|
if (sector->numattached)
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
sector_t *sec;
|
sector_t *sec;
|
||||||
for (i = 0; i < sector->numattached; i++)
|
for (i = 0; i < sector->numattached; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -311,6 +311,7 @@ fixed_t opentop, openbottom, openrange, lowfloor, highceiling;
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
pslope_t *opentopslope, *openbottomslope;
|
pslope_t *opentopslope, *openbottomslope;
|
||||||
#endif
|
#endif
|
||||||
|
ffloor_t *openfloorrover, *openceilingrover;
|
||||||
|
|
||||||
// P_CameraLineOpening
|
// P_CameraLineOpening
|
||||||
// P_LineOpening, but for camera
|
// P_LineOpening, but for camera
|
||||||
|
@ -517,6 +518,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
||||||
I_Assert(front != NULL);
|
I_Assert(front != NULL);
|
||||||
I_Assert(back != NULL);
|
I_Assert(back != NULL);
|
||||||
|
|
||||||
|
openfloorrover = openceilingrover = NULL;
|
||||||
|
|
||||||
{ // Set open and high/low values here
|
{ // Set open and high/low values here
|
||||||
fixed_t frontheight, backheight;
|
fixed_t frontheight, backheight;
|
||||||
|
|
||||||
|
@ -641,6 +644,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
||||||
pslope_t *ceilingslope = opentopslope;
|
pslope_t *ceilingslope = opentopslope;
|
||||||
pslope_t *floorslope = openbottomslope;
|
pslope_t *floorslope = openbottomslope;
|
||||||
#endif
|
#endif
|
||||||
|
ffloor_t *floorrover = NULL;
|
||||||
|
ffloor_t *ceilingrover = NULL;
|
||||||
|
|
||||||
// Check for frontsector's fake floors
|
// Check for frontsector's fake floors
|
||||||
for (rover = front->ffloors; rover; rover = rover->next)
|
for (rover = front->ffloors; rover; rover = rover->next)
|
||||||
|
@ -668,6 +673,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
ceilingslope = *rover->b_slope;
|
ceilingslope = *rover->b_slope;
|
||||||
#endif
|
#endif
|
||||||
|
ceilingrover = rover;
|
||||||
}
|
}
|
||||||
else if (bottomheight < highestceiling)
|
else if (bottomheight < highestceiling)
|
||||||
highestceiling = bottomheight;
|
highestceiling = bottomheight;
|
||||||
|
@ -680,6 +686,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
floorslope = *rover->t_slope;
|
floorslope = *rover->t_slope;
|
||||||
#endif
|
#endif
|
||||||
|
floorrover = rover;
|
||||||
}
|
}
|
||||||
else if (topheight > lowestfloor)
|
else if (topheight > lowestfloor)
|
||||||
lowestfloor = topheight;
|
lowestfloor = topheight;
|
||||||
|
@ -712,6 +719,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
ceilingslope = *rover->b_slope;
|
ceilingslope = *rover->b_slope;
|
||||||
#endif
|
#endif
|
||||||
|
ceilingrover = rover;
|
||||||
}
|
}
|
||||||
else if (bottomheight < highestceiling)
|
else if (bottomheight < highestceiling)
|
||||||
highestceiling = bottomheight;
|
highestceiling = bottomheight;
|
||||||
|
@ -724,6 +732,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
floorslope = *rover->t_slope;
|
floorslope = *rover->t_slope;
|
||||||
#endif
|
#endif
|
||||||
|
floorrover = rover;
|
||||||
}
|
}
|
||||||
else if (topheight > lowestfloor)
|
else if (topheight > lowestfloor)
|
||||||
lowestfloor = topheight;
|
lowestfloor = topheight;
|
||||||
|
@ -743,6 +752,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
ceilingslope = NULL;
|
ceilingslope = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
ceilingrover = NULL;
|
||||||
}
|
}
|
||||||
else if (polysec->floorheight < highestceiling && delta1 >= delta2)
|
else if (polysec->floorheight < highestceiling && delta1 >= delta2)
|
||||||
highestceiling = polysec->floorheight;
|
highestceiling = polysec->floorheight;
|
||||||
|
@ -752,6 +762,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
floorslope = NULL;
|
floorslope = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
floorrover = NULL;
|
||||||
}
|
}
|
||||||
else if (polysec->ceilingheight > lowestfloor && delta1 < delta2)
|
else if (polysec->ceilingheight > lowestfloor && delta1 < delta2)
|
||||||
lowestfloor = polysec->ceilingheight;
|
lowestfloor = polysec->ceilingheight;
|
||||||
|
@ -765,6 +776,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
openbottomslope = floorslope;
|
openbottomslope = floorslope;
|
||||||
#endif
|
#endif
|
||||||
|
openfloorrover = floorrover;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lowestceiling < opentop) {
|
if (lowestceiling < opentop) {
|
||||||
|
@ -772,6 +784,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
opentopslope = ceilingslope;
|
opentopslope = ceilingslope;
|
||||||
#endif
|
#endif
|
||||||
|
openceilingrover = ceilingrover;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lowestfloor > lowfloor)
|
if (lowestfloor > lowfloor)
|
||||||
|
|
|
@ -58,6 +58,7 @@ extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling;
|
||||||
#ifdef ESLOPE
|
#ifdef ESLOPE
|
||||||
extern pslope_t *opentopslope, *openbottomslope;
|
extern pslope_t *opentopslope, *openbottomslope;
|
||||||
#endif
|
#endif
|
||||||
|
extern ffloor_t *openfloorrover, *openceilingrover;
|
||||||
|
|
||||||
void P_LineOpening(line_t *plinedef, mobj_t *mobj);
|
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->floorheight = target->z - amtz;
|
||||||
po->lines[0]->backsector->ceilingheight = target->z + amtz;
|
po->lines[0]->backsector->ceilingheight = target->z + amtz;
|
||||||
// Sal: Remember to check your sectors!
|
// 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));
|
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage));
|
||||||
// Apply action to mirroring polyobjects as well
|
// Apply action to mirroring polyobjects as well
|
||||||
start = 0;
|
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->floorheight += diffz; // move up/down by same amount as the parent did
|
||||||
po->lines[0]->backsector->ceilingheight += diffz;
|
po->lines[0]->backsector->ceilingheight += diffz;
|
||||||
// Sal: Remember to check your sectors!
|
// 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));
|
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->floorheight += momz;
|
||||||
po->lines[0]->backsector->ceilingheight += momz;
|
po->lines[0]->backsector->ceilingheight += momz;
|
||||||
// Sal: Remember to check your sectors!
|
// Sal: Remember to check your sectors!
|
||||||
P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); // frontsector is NEEDED for crushing
|
// Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap
|
||||||
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); // backsector may not be necessary, but just in case
|
// 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
|
// Apply action to mirroring polyobjects as well
|
||||||
start = 0;
|
start = 0;
|
||||||
|
@ -2065,7 +2068,8 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
||||||
po->lines[0]->backsector->floorheight += momz;
|
po->lines[0]->backsector->floorheight += momz;
|
||||||
po->lines[0]->backsector->ceilingheight += momz;
|
po->lines[0]->backsector->ceilingheight += momz;
|
||||||
// Sal: Remember to check your sectors!
|
// 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));
|
P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue