- made MoveAttached, MoveCeiling and MoveFloor members of sector_t instead of DMover.

- call MoveFloor and MoveCeiling directly in FS's floorheight and ceilingheight functions and remove the dummy thinkers it had to use before.
This commit is contained in:
Christoph Oelckers 2016-04-08 14:18:46 +02:00
commit 8535a973cf
9 changed files with 119 additions and 159 deletions

View file

@ -133,17 +133,17 @@ DMovingCeiling::DMovingCeiling (sector_t *sector)
interpolation = sector->SetInterpolation(sector_t::CeilingMove, true);
}
bool DMover::MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed)
bool sector_t::MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed)
{
if (!P_Scroll3dMidtex(m_Sector, crush, move, !!floorOrCeiling) && resetfailed)
if (!P_Scroll3dMidtex(this, crush, move, !!floorOrCeiling) && resetfailed)
{
P_Scroll3dMidtex(m_Sector, crush, -move, !!floorOrCeiling);
P_Scroll3dMidtex(this, crush, -move, !!floorOrCeiling);
return false;
}
if (!P_MoveLinkedSectors(m_Sector, crush, move, !!floorOrCeiling) && resetfailed)
if (!P_MoveLinkedSectors(this, crush, move, !!floorOrCeiling) && resetfailed)
{
P_MoveLinkedSectors(m_Sector, crush, -move, !!floorOrCeiling);
P_Scroll3dMidtex(m_Sector, crush, -move, !!floorOrCeiling);
P_MoveLinkedSectors(this, crush, -move, !!floorOrCeiling);
P_Scroll3dMidtex(this, crush, -move, !!floorOrCeiling);
return false;
}
return true;
@ -155,7 +155,7 @@ bool DMover::MoveAttached(int crush, double move, int floorOrCeiling, bool reset
// (Use -1 to prevent it from trying to crush)
// dest is the desired d value for the plane
//
EMoveResult DMover::MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush)
EMoveResult sector_t::MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush)
{
bool flag;
double lastpos;
@ -163,30 +163,30 @@ EMoveResult DMover::MoveFloor(double speed, double dest, int crush, int directio
double move;
//double destheight; //jff 02/04/98 used to keep floors/ceilings
// from moving thru each other
lastpos = m_Sector->floorplane.fD();
lastpos = floorplane.fD();
switch (direction)
{
case -1:
// DOWN
movedest = m_Sector->floorplane.GetChangedHeight(-speed);
movedest = floorplane.GetChangedHeight(-speed);
if (movedest >= dest)
{
move = m_Sector->floorplane.HeightDiff(lastpos, dest);
move = floorplane.HeightDiff(lastpos, dest);
if (!MoveAttached(crush, move, 0, true)) return EMoveResult::crushed;
m_Sector->floorplane.setD(dest);
flag = P_ChangeSector(m_Sector, crush, move, 0, false);
floorplane.setD(dest);
flag = P_ChangeSector(this, crush, move, 0, false);
if (flag)
{
m_Sector->floorplane.setD(lastpos);
P_ChangeSector(m_Sector, crush, -move, 0, true);
floorplane.setD(lastpos);
P_ChangeSector(this, crush, -move, 0, true);
MoveAttached(crush, -move, 0, false);
}
else
{
m_Sector->ChangePlaneTexZ(sector_t::floor, move);
m_Sector->AdjustFloorClip();
ChangePlaneTexZ(sector_t::floor, move);
AdjustFloorClip();
}
return EMoveResult::pastdest;
}
@ -194,20 +194,20 @@ EMoveResult DMover::MoveFloor(double speed, double dest, int crush, int directio
{
if (!MoveAttached(crush, -speed, 0, true)) return EMoveResult::crushed;
m_Sector->floorplane.setD(movedest);
floorplane.setD(movedest);
flag = P_ChangeSector(m_Sector, crush, -speed, 0, false);
flag = P_ChangeSector(this, crush, -speed, 0, false);
if (flag)
{
m_Sector->floorplane.setD(lastpos);
P_ChangeSector(m_Sector, crush, speed, 0, true);
floorplane.setD(lastpos);
P_ChangeSector(this, crush, speed, 0, true);
MoveAttached(crush, speed, 0, false);
return EMoveResult::crushed;
}
else
{
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff(lastpos));
m_Sector->AdjustFloorClip();
ChangePlaneTexZ(sector_t::floor, floorplane.HeightDiff(lastpos));
AdjustFloorClip();
}
}
break;
@ -216,34 +216,34 @@ EMoveResult DMover::MoveFloor(double speed, double dest, int crush, int directio
// UP
// jff 02/04/98 keep floor from moving thru ceilings
// [RH] not so easy with arbitrary planes
//destheight = (dest < m_Sector->ceilingheight) ? dest : m_Sector->ceilingheight;
if (!m_Sector->ceilingplane.isSlope() && !m_Sector->floorplane.isSlope() &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && -dest > m_Sector->ceilingplane.fD()))
//destheight = (dest < ceilingheight) ? dest : ceilingheight;
if (!ceilingplane.isSlope() && !floorplane.isSlope() &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && -dest > ceilingplane.fD()))
{
dest = -m_Sector->ceilingplane.fD();
dest = -ceilingplane.fD();
}
movedest = m_Sector->floorplane.GetChangedHeight(speed);
movedest = floorplane.GetChangedHeight(speed);
if (movedest <= dest)
{
move = m_Sector->floorplane.HeightDiff(lastpos, dest);
move = floorplane.HeightDiff(lastpos, dest);
if (!MoveAttached(crush, move, 0, true)) return EMoveResult::crushed;
m_Sector->floorplane.setD(dest);
floorplane.setD(dest);
flag = P_ChangeSector(m_Sector, crush, move, 0, false);
flag = P_ChangeSector(this, crush, move, 0, false);
if (flag)
{
m_Sector->floorplane.setD(lastpos);
P_ChangeSector(m_Sector, crush, -move, 0, true);
floorplane.setD(lastpos);
P_ChangeSector(this, crush, -move, 0, true);
MoveAttached(crush, -move, 0, false);
}
else
{
m_Sector->ChangePlaneTexZ(sector_t::floor, move);
m_Sector->AdjustFloorClip();
ChangePlaneTexZ(sector_t::floor, move);
AdjustFloorClip();
}
return EMoveResult::pastdest;
}
@ -251,32 +251,32 @@ EMoveResult DMover::MoveFloor(double speed, double dest, int crush, int directio
{
if (!MoveAttached(crush, speed, 0, true)) return EMoveResult::crushed;
m_Sector->floorplane.setD(movedest);
floorplane.setD(movedest);
// COULD GET CRUSHED
flag = P_ChangeSector(m_Sector, crush, speed, 0, false);
flag = P_ChangeSector(this, crush, speed, 0, false);
if (flag)
{
if (crush >= 0 && !hexencrush)
{
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff(lastpos));
m_Sector->AdjustFloorClip();
ChangePlaneTexZ(sector_t::floor, floorplane.HeightDiff(lastpos));
AdjustFloorClip();
return EMoveResult::crushed;
}
m_Sector->floorplane.setD(lastpos);
P_ChangeSector(m_Sector, crush, -speed, 0, true);
floorplane.setD(lastpos);
P_ChangeSector(this, crush, -speed, 0, true);
MoveAttached(crush, -speed, 0, false);
return EMoveResult::crushed;
}
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff(lastpos));
m_Sector->AdjustFloorClip();
ChangePlaneTexZ(sector_t::floor, floorplane.HeightDiff(lastpos));
AdjustFloorClip();
}
break;
}
return EMoveResult::ok;
}
EMoveResult DMover::MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush)
EMoveResult sector_t::MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush)
{
bool flag;
double lastpos;
@ -285,38 +285,38 @@ EMoveResult DMover::MoveCeiling(double speed, double dest, int crush, int direct
//double destheight; //jff 02/04/98 used to keep floors/ceilings
// from moving thru each other
lastpos = m_Sector->ceilingplane.fD();
lastpos = ceilingplane.fD();
switch (direction)
{
case -1:
// DOWN
// jff 02/04/98 keep ceiling from moving thru floors
// [RH] not so easy with arbitrary planes
//destheight = (dest > m_Sector->floorheight) ? dest : m_Sector->floorheight;
if (!m_Sector->ceilingplane.isSlope() && !m_Sector->floorplane.isSlope() &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && dest < -m_Sector->floorplane.fD()))
//destheight = (dest > floorheight) ? dest : floorheight;
if (!ceilingplane.isSlope() && !floorplane.isSlope() &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && dest < -floorplane.fD()))
{
dest = -m_Sector->floorplane.fD();
dest = -floorplane.fD();
}
movedest = m_Sector->ceilingplane.GetChangedHeight (-speed);
movedest = ceilingplane.GetChangedHeight (-speed);
if (movedest <= dest)
{
move = m_Sector->ceilingplane.HeightDiff (lastpos, dest);
move = ceilingplane.HeightDiff (lastpos, dest);
if (!MoveAttached(crush, move, 1, true)) return EMoveResult::crushed;
m_Sector->ceilingplane.setD(dest);
flag = P_ChangeSector (m_Sector, crush, move, 1, false);
ceilingplane.setD(dest);
flag = P_ChangeSector (this, crush, move, 1, false);
if (flag)
{
m_Sector->ceilingplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, -move, 1, true);
ceilingplane.setD(lastpos);
P_ChangeSector (this, crush, -move, 1, true);
MoveAttached(crush, -move, 1, false);
}
else
{
m_Sector->ChangePlaneTexZ(sector_t::ceiling, move);
ChangePlaneTexZ(sector_t::ceiling, move);
}
return EMoveResult::pastdest;
}
@ -324,47 +324,47 @@ EMoveResult DMover::MoveCeiling(double speed, double dest, int crush, int direct
{
if (!MoveAttached(crush, -speed, 1, true)) return EMoveResult::crushed;
m_Sector->ceilingplane.setD(movedest);
ceilingplane.setD(movedest);
// COULD GET CRUSHED
flag = P_ChangeSector (m_Sector, crush, -speed, 1, false);
flag = P_ChangeSector (this, crush, -speed, 1, false);
if (flag)
{
if (crush >= 0 && !hexencrush)
{
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
ChangePlaneTexZ(sector_t::ceiling, ceilingplane.HeightDiff (lastpos));
return EMoveResult::crushed;
}
m_Sector->ceilingplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, speed, 1, true);
ceilingplane.setD(lastpos);
P_ChangeSector (this, crush, speed, 1, true);
MoveAttached(crush, speed, 1, false);
return EMoveResult::crushed;
}
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
ChangePlaneTexZ(sector_t::ceiling, ceilingplane.HeightDiff (lastpos));
}
break;
case 1:
// UP
movedest = m_Sector->ceilingplane.GetChangedHeight (speed);
movedest = ceilingplane.GetChangedHeight (speed);
if (movedest >= dest)
{
move = m_Sector->ceilingplane.HeightDiff (lastpos, dest);
move = ceilingplane.HeightDiff (lastpos, dest);
if (!MoveAttached(crush, move, 1, true)) return EMoveResult::crushed;
m_Sector->ceilingplane.setD(dest);
ceilingplane.setD(dest);
flag = P_ChangeSector (m_Sector, crush, move, 1, false);
flag = P_ChangeSector (this, crush, move, 1, false);
if (flag)
{
m_Sector->ceilingplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, move, 1, true);
ceilingplane.setD(lastpos);
P_ChangeSector (this, crush, move, 1, true);
MoveAttached(crush, move, 1, false);
}
else
{
m_Sector->ChangePlaneTexZ(sector_t::ceiling, move);
ChangePlaneTexZ(sector_t::ceiling, move);
}
return EMoveResult::pastdest;
}
@ -372,17 +372,17 @@ EMoveResult DMover::MoveCeiling(double speed, double dest, int crush, int direct
{
if (!MoveAttached(crush, speed, 1, true)) return EMoveResult::crushed;
m_Sector->ceilingplane.setD(movedest);
ceilingplane.setD(movedest);
flag = P_ChangeSector (m_Sector, crush, speed, 1, false);
flag = P_ChangeSector (this, crush, speed, 1, false);
if (flag)
{
m_Sector->ceilingplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, -speed, 1, true);
ceilingplane.setD(lastpos);
P_ChangeSector (this, crush, -speed, 1, true);
MoveAttached(crush, -speed, 1, false);
return EMoveResult::crushed;
}
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
ChangePlaneTexZ(sector_t::ceiling, ceilingplane.HeightDiff (lastpos));
}
break;
}