- 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
parent e505bfd7a3
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); 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; 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_MoveLinkedSectors(this, crush, -move, !!floorOrCeiling);
P_Scroll3dMidtex(m_Sector, crush, -move, !!floorOrCeiling); P_Scroll3dMidtex(this, crush, -move, !!floorOrCeiling);
return false; return false;
} }
return true; 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) // (Use -1 to prevent it from trying to crush)
// dest is the desired d value for the plane // 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; bool flag;
double lastpos; double lastpos;
@ -163,30 +163,30 @@ EMoveResult DMover::MoveFloor(double speed, double dest, int crush, int directio
double move; double move;
//double destheight; //jff 02/04/98 used to keep floors/ceilings //double destheight; //jff 02/04/98 used to keep floors/ceilings
// from moving thru each other // from moving thru each other
lastpos = m_Sector->floorplane.fD(); lastpos = floorplane.fD();
switch (direction) switch (direction)
{ {
case -1: case -1:
// DOWN // DOWN
movedest = m_Sector->floorplane.GetChangedHeight(-speed); movedest = floorplane.GetChangedHeight(-speed);
if (movedest >= dest) if (movedest >= dest)
{ {
move = m_Sector->floorplane.HeightDiff(lastpos, dest); move = floorplane.HeightDiff(lastpos, dest);
if (!MoveAttached(crush, move, 0, true)) return EMoveResult::crushed; 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) if (flag)
{ {
m_Sector->floorplane.setD(lastpos); floorplane.setD(lastpos);
P_ChangeSector(m_Sector, crush, -move, 0, true); P_ChangeSector(this, crush, -move, 0, true);
MoveAttached(crush, -move, 0, false); MoveAttached(crush, -move, 0, false);
} }
else else
{ {
m_Sector->ChangePlaneTexZ(sector_t::floor, move); ChangePlaneTexZ(sector_t::floor, move);
m_Sector->AdjustFloorClip(); AdjustFloorClip();
} }
return EMoveResult::pastdest; 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; 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) if (flag)
{ {
m_Sector->floorplane.setD(lastpos); floorplane.setD(lastpos);
P_ChangeSector(m_Sector, crush, speed, 0, true); P_ChangeSector(this, crush, speed, 0, true);
MoveAttached(crush, speed, 0, false); MoveAttached(crush, speed, 0, false);
return EMoveResult::crushed; return EMoveResult::crushed;
} }
else else
{ {
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff(lastpos)); ChangePlaneTexZ(sector_t::floor, floorplane.HeightDiff(lastpos));
m_Sector->AdjustFloorClip(); AdjustFloorClip();
} }
} }
break; break;
@ -216,34 +216,34 @@ EMoveResult DMover::MoveFloor(double speed, double dest, int crush, int directio
// UP // UP
// jff 02/04/98 keep floor from moving thru ceilings // jff 02/04/98 keep floor from moving thru ceilings
// [RH] not so easy with arbitrary planes // [RH] not so easy with arbitrary planes
//destheight = (dest < m_Sector->ceilingheight) ? dest : m_Sector->ceilingheight; //destheight = (dest < ceilingheight) ? dest : ceilingheight;
if (!m_Sector->ceilingplane.isSlope() && !m_Sector->floorplane.isSlope() && if (!ceilingplane.isSlope() && !floorplane.isSlope() &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && -dest > m_Sector->ceilingplane.fD())) (!(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) if (movedest <= dest)
{ {
move = m_Sector->floorplane.HeightDiff(lastpos, dest); move = floorplane.HeightDiff(lastpos, dest);
if (!MoveAttached(crush, move, 0, true)) return EMoveResult::crushed; 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) if (flag)
{ {
m_Sector->floorplane.setD(lastpos); floorplane.setD(lastpos);
P_ChangeSector(m_Sector, crush, -move, 0, true); P_ChangeSector(this, crush, -move, 0, true);
MoveAttached(crush, -move, 0, false); MoveAttached(crush, -move, 0, false);
} }
else else
{ {
m_Sector->ChangePlaneTexZ(sector_t::floor, move); ChangePlaneTexZ(sector_t::floor, move);
m_Sector->AdjustFloorClip(); AdjustFloorClip();
} }
return EMoveResult::pastdest; 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; if (!MoveAttached(crush, speed, 0, true)) return EMoveResult::crushed;
m_Sector->floorplane.setD(movedest); floorplane.setD(movedest);
// COULD GET CRUSHED // COULD GET CRUSHED
flag = P_ChangeSector(m_Sector, crush, speed, 0, false); flag = P_ChangeSector(this, crush, speed, 0, false);
if (flag) if (flag)
{ {
if (crush >= 0 && !hexencrush) if (crush >= 0 && !hexencrush)
{ {
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff(lastpos)); ChangePlaneTexZ(sector_t::floor, floorplane.HeightDiff(lastpos));
m_Sector->AdjustFloorClip(); AdjustFloorClip();
return EMoveResult::crushed; return EMoveResult::crushed;
} }
m_Sector->floorplane.setD(lastpos); floorplane.setD(lastpos);
P_ChangeSector(m_Sector, crush, -speed, 0, true); P_ChangeSector(this, crush, -speed, 0, true);
MoveAttached(crush, -speed, 0, false); MoveAttached(crush, -speed, 0, false);
return EMoveResult::crushed; return EMoveResult::crushed;
} }
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff(lastpos)); ChangePlaneTexZ(sector_t::floor, floorplane.HeightDiff(lastpos));
m_Sector->AdjustFloorClip(); AdjustFloorClip();
} }
break; break;
} }
return EMoveResult::ok; 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; bool flag;
double lastpos; 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 //double destheight; //jff 02/04/98 used to keep floors/ceilings
// from moving thru each other // from moving thru each other
lastpos = m_Sector->ceilingplane.fD(); lastpos = ceilingplane.fD();
switch (direction) switch (direction)
{ {
case -1: case -1:
// DOWN // DOWN
// jff 02/04/98 keep ceiling from moving thru floors // jff 02/04/98 keep ceiling from moving thru floors
// [RH] not so easy with arbitrary planes // [RH] not so easy with arbitrary planes
//destheight = (dest > m_Sector->floorheight) ? dest : m_Sector->floorheight; //destheight = (dest > floorheight) ? dest : floorheight;
if (!m_Sector->ceilingplane.isSlope() && !m_Sector->floorplane.isSlope() && if (!ceilingplane.isSlope() && !floorplane.isSlope() &&
(!(i_compatflags2 & COMPATF2_FLOORMOVE) && dest < -m_Sector->floorplane.fD())) (!(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) if (movedest <= dest)
{ {
move = m_Sector->ceilingplane.HeightDiff (lastpos, dest); move = ceilingplane.HeightDiff (lastpos, dest);
if (!MoveAttached(crush, move, 1, true)) return EMoveResult::crushed; 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) if (flag)
{ {
m_Sector->ceilingplane.setD(lastpos); ceilingplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, -move, 1, true); P_ChangeSector (this, crush, -move, 1, true);
MoveAttached(crush, -move, 1, false); MoveAttached(crush, -move, 1, false);
} }
else else
{ {
m_Sector->ChangePlaneTexZ(sector_t::ceiling, move); ChangePlaneTexZ(sector_t::ceiling, move);
} }
return EMoveResult::pastdest; 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; if (!MoveAttached(crush, -speed, 1, true)) return EMoveResult::crushed;
m_Sector->ceilingplane.setD(movedest); ceilingplane.setD(movedest);
// COULD GET CRUSHED // COULD GET CRUSHED
flag = P_ChangeSector (m_Sector, crush, -speed, 1, false); flag = P_ChangeSector (this, crush, -speed, 1, false);
if (flag) if (flag)
{ {
if (crush >= 0 && !hexencrush) 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; return EMoveResult::crushed;
} }
m_Sector->ceilingplane.setD(lastpos); ceilingplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, speed, 1, true); P_ChangeSector (this, crush, speed, 1, true);
MoveAttached(crush, speed, 1, false); MoveAttached(crush, speed, 1, false);
return EMoveResult::crushed; return EMoveResult::crushed;
} }
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos)); ChangePlaneTexZ(sector_t::ceiling, ceilingplane.HeightDiff (lastpos));
} }
break; break;
case 1: case 1:
// UP // UP
movedest = m_Sector->ceilingplane.GetChangedHeight (speed); movedest = ceilingplane.GetChangedHeight (speed);
if (movedest >= dest) if (movedest >= dest)
{ {
move = m_Sector->ceilingplane.HeightDiff (lastpos, dest); move = ceilingplane.HeightDiff (lastpos, dest);
if (!MoveAttached(crush, move, 1, true)) return EMoveResult::crushed; 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) if (flag)
{ {
m_Sector->ceilingplane.setD(lastpos); ceilingplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, move, 1, true); P_ChangeSector (this, crush, move, 1, true);
MoveAttached(crush, move, 1, false); MoveAttached(crush, move, 1, false);
} }
else else
{ {
m_Sector->ChangePlaneTexZ(sector_t::ceiling, move); ChangePlaneTexZ(sector_t::ceiling, move);
} }
return EMoveResult::pastdest; 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; 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) if (flag)
{ {
m_Sector->ceilingplane.setD(lastpos); ceilingplane.setD(lastpos);
P_ChangeSector (m_Sector, crush, -speed, 1, true); P_ChangeSector (this, crush, -speed, 1, true);
MoveAttached(crush, -speed, 1, false); MoveAttached(crush, -speed, 1, false);
return EMoveResult::crushed; return EMoveResult::crushed;
} }
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos)); ChangePlaneTexZ(sector_t::ceiling, ceilingplane.HeightDiff (lastpos));
} }
break; break;
} }

View file

@ -29,25 +29,11 @@ public:
protected: protected:
TObjPtr<DInterpolation> interpolation; TObjPtr<DInterpolation> interpolation;
private: private:
bool MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed);
protected: protected:
DMover (); DMover ();
void Serialize (FArchive &arc); void Serialize (FArchive &arc);
void Destroy(); void Destroy();
void StopInterpolation(bool force = false); void StopInterpolation(bool force = false);
EMoveResult MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush);
EMoveResult MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush);
inline EMoveResult MoveFloor(double speed, double dest, int direction)
{
return MoveFloor(speed, dest, -1, direction, false);
}
inline EMoveResult MoveCeiling(double speed, double dest, int direction)
{
return MoveCeiling(speed, dest, -1, direction, false);
}
}; };
class DMovingFloor : public DMover class DMovingFloor : public DMover

View file

@ -1535,26 +1535,6 @@ void FParser::SF_StartSectorSound(void)
} }
} }
/************* Sector functions ***************/
class DFloorChanger : public DFloor
{
public:
DFloorChanger(sector_t * sec)
: DFloor(sec) {}
bool Move(double speed, double dest, int crush, int direction)
{
bool res = EMoveResult::crushed != MoveFloor(speed, dest, crush, direction, false);
Destroy();
m_Sector->floordata=NULL;
StopInterpolation(true);
m_Sector=NULL;
return res;
}
};
//========================================================================== //==========================================================================
// //
// //
@ -1588,12 +1568,12 @@ void FParser::SF_FloorHeight(void)
{ {
if (sectors[i].floordata) continue; // don't move floors that are active! if (sectors[i].floordata) continue; // don't move floors that are active!
DFloorChanger * f = new DFloorChanger(&sectors[i]); if (sectors[i].MoveFloor(
if (!f->Move(
fabs(dest - sectors[i].CenterFloor()), fabs(dest - sectors[i].CenterFloor()),
sectors[i].floorplane.PointToDist (sectors[i].centerspot, dest), sectors[i].floorplane.PointToDist (sectors[i].centerspot, dest),
crush? 10:-1, crush? 10:-1,
(dest > sectors[i].CenterFloor()) ? 1 : -1)) (dest > sectors[i].CenterFloor()) ? 1 : -1,
false) != EMoveResult::crushed)
{ {
returnval = 0; returnval = 0;
} }
@ -1686,29 +1666,6 @@ void FParser::SF_MoveFloor(void)
// //
//========================================================================== //==========================================================================
class DCeilingChanger : public DCeiling
{
public:
DCeilingChanger(sector_t * sec)
: DCeiling(sec) {}
bool Move(double speed, double dest, int crush, int direction)
{
bool res = EMoveResult::crushed != MoveCeiling(speed, dest, crush, direction, false);
Destroy();
m_Sector->ceilingdata=NULL;
StopInterpolation (true);
m_Sector=NULL;
return res;
}
};
//==========================================================================
//
//
//
//==========================================================================
// ceiling height of sector // ceiling height of sector
void FParser::SF_CeilingHeight(void) void FParser::SF_CeilingHeight(void)
{ {
@ -1735,12 +1692,12 @@ void FParser::SF_CeilingHeight(void)
{ {
if (sectors[i].ceilingdata) continue; // don't move ceilings that are active! if (sectors[i].ceilingdata) continue; // don't move ceilings that are active!
DCeilingChanger * c = new DCeilingChanger(&sectors[i]); if (sectors[i].MoveCeiling(
if (!c->Move(
fabs(dest - sectors[i].CenterCeiling()), fabs(dest - sectors[i].CenterCeiling()),
sectors[i].ceilingplane.PointToDist (sectors[i].centerspot, dest), sectors[i].ceilingplane.PointToDist (sectors[i].centerspot, dest),
crush? 10:-1, crush? 10:-1,
(dest > sectors[i].CenterCeiling()) ? 1 : -1)) (dest > sectors[i].CenterCeiling()) ? 1 : -1,
false) != EMoveResult::crushed)
{ {
returnval = 0; returnval = 0;
} }

View file

@ -136,7 +136,7 @@ void DCeiling::Tick ()
break; break;
case 1: case 1:
// UP // UP
res = MoveCeiling (m_Speed, m_TopHeight, m_Direction); res = m_Sector->MoveCeiling (m_Speed, m_TopHeight, m_Direction);
if (res == EMoveResult::pastdest) if (res == EMoveResult::pastdest)
{ {
@ -167,7 +167,7 @@ void DCeiling::Tick ()
case -1: case -1:
// DOWN // DOWN
res = MoveCeiling (m_Speed, m_BottomHeight, m_Crush, m_Direction, m_CrushMode == ECrushMode::crushHexen); res = m_Sector->MoveCeiling (m_Speed, m_BottomHeight, m_Crush, m_Direction, m_CrushMode == ECrushMode::crushHexen);
if (res == EMoveResult::pastdest) if (res == EMoveResult::pastdest)
{ {

View file

@ -137,7 +137,7 @@ void DDoor::Tick ()
case -1: case -1:
// DOWN // DOWN
res = MoveCeiling (m_Speed, m_BotDist, -1, m_Direction, false); res = m_Sector->MoveCeiling (m_Speed, m_BotDist, -1, m_Direction, false);
// killough 10/98: implement gradual lighting effects // killough 10/98: implement gradual lighting effects
if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.fD()) if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.fD())
@ -183,7 +183,7 @@ void DDoor::Tick ()
case 1: case 1:
// UP // UP
res = MoveCeiling (m_Speed, m_TopDist, -1, m_Direction, false); res = m_Sector->MoveCeiling (m_Speed, m_TopDist, -1, m_Direction, false);
// killough 10/98: implement gradual lighting effects // killough 10/98: implement gradual lighting effects
if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.fD()) if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.fD())
@ -560,12 +560,12 @@ bool DAnimatedDoor::StartClosing ()
} }
double topdist = m_Sector->ceilingplane.fD(); double topdist = m_Sector->ceilingplane.fD();
if (MoveCeiling (2048., m_BotDist, 0, -1, false) == EMoveResult::crushed) if (m_Sector->MoveCeiling (2048., m_BotDist, 0, -1, false) == EMoveResult::crushed)
{ {
return false; return false;
} }
MoveCeiling (2048., topdist, 1); m_Sector->MoveCeiling (2048., topdist, 1);
m_Line1->flags |= ML_BLOCKING; m_Line1->flags |= ML_BLOCKING;
m_Line2->flags |= ML_BLOCKING; m_Line2->flags |= ML_BLOCKING;
@ -650,7 +650,7 @@ void DAnimatedDoor::Tick ()
if (--m_Frame < 0) if (--m_Frame < 0)
{ {
// IF DOOR IS DONE CLOSING... // IF DOOR IS DONE CLOSING...
MoveCeiling (2048., m_BotDist, -1); m_Sector->MoveCeiling (2048., m_BotDist, -1);
m_Sector->ceilingdata = NULL; m_Sector->ceilingdata = NULL;
Destroy (); Destroy ();
// Unset blocking flags on lines that didn't start with them. Since the // Unset blocking flags on lines that didn't start with them. Since the
@ -734,7 +734,7 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay,
m_Line1->flags |= ML_BLOCKING; m_Line1->flags |= ML_BLOCKING;
m_Line2->flags |= ML_BLOCKING; m_Line2->flags |= ML_BLOCKING;
m_BotDist = m_Sector->ceilingplane.fD(); m_BotDist = m_Sector->ceilingplane.fD();
MoveCeiling (2048., topdist, 1); m_Sector->MoveCeiling (2048., topdist, 1);
if (m_DoorAnim->OpenSound != NAME_None) if (m_DoorAnim->OpenSound != NAME_None)
{ {
SN_StartSequence (m_Sector, CHAN_INTERIOR, m_DoorAnim->OpenSound, 1); SN_StartSequence (m_Sector, CHAN_INTERIOR, m_DoorAnim->OpenSound, 1);

View file

@ -144,7 +144,7 @@ void DFloor::Tick ()
if (m_Type == waitStair) if (m_Type == waitStair)
return; return;
res = MoveFloor (m_Speed, m_FloorDestDist, m_Crush, m_Direction, m_Hexencrush); res = m_Sector->MoveFloor (m_Speed, m_FloorDestDist, m_Crush, m_Direction, m_Hexencrush);
if (res == EMoveResult::pastdest) if (res == EMoveResult::pastdest)
{ {
@ -907,25 +907,25 @@ void DElevator::Tick ()
if (m_Direction < 0) // moving down if (m_Direction < 0) // moving down
{ {
res = MoveFloor (m_Speed, m_FloorDestDist, m_Direction); res = m_Sector->MoveFloor (m_Speed, m_FloorDestDist, m_Direction);
if (res == EMoveResult::ok || res == EMoveResult::pastdest) if (res == EMoveResult::ok || res == EMoveResult::pastdest)
{ {
res = MoveCeiling (m_Speed, m_CeilingDestDist, m_Direction); res = m_Sector->MoveCeiling (m_Speed, m_CeilingDestDist, m_Direction);
if (res == EMoveResult::crushed) if (res == EMoveResult::crushed)
{ {
MoveFloor (m_Speed, oldfloor, -m_Direction); m_Sector->MoveFloor (m_Speed, oldfloor, -m_Direction);
} }
} }
} }
else // up else // up
{ {
res = MoveCeiling (m_Speed, m_CeilingDestDist, m_Direction); res = m_Sector->MoveCeiling (m_Speed, m_CeilingDestDist, m_Direction);
if (res == EMoveResult::ok || res == EMoveResult::pastdest) if (res == EMoveResult::ok || res == EMoveResult::pastdest)
{ {
res = MoveFloor (m_Speed, m_FloorDestDist, m_Direction); res = m_Sector->MoveFloor (m_Speed, m_FloorDestDist, m_Direction);
if (res == EMoveResult::crushed) if (res == EMoveResult::crushed)
{ {
MoveCeiling (m_Speed, oldceiling, -m_Direction); m_Sector->MoveCeiling (m_Speed, oldceiling, -m_Direction);
} }
} }
} }

View file

@ -96,13 +96,13 @@ void DPillar::Tick ()
if (m_Type == pillarBuild) if (m_Type == pillarBuild)
{ {
r = MoveFloor (m_FloorSpeed, m_FloorTarget, m_Crush, 1, m_Hexencrush); r = m_Sector->MoveFloor (m_FloorSpeed, m_FloorTarget, m_Crush, 1, m_Hexencrush);
s = MoveCeiling (m_CeilingSpeed, m_CeilingTarget, m_Crush, -1, m_Hexencrush); s = m_Sector->MoveCeiling (m_CeilingSpeed, m_CeilingTarget, m_Crush, -1, m_Hexencrush);
} }
else else
{ {
r = MoveFloor (m_FloorSpeed, m_FloorTarget, m_Crush, -1, m_Hexencrush); r = m_Sector->MoveFloor (m_FloorSpeed, m_FloorTarget, m_Crush, -1, m_Hexencrush);
s = MoveCeiling (m_CeilingSpeed, m_CeilingTarget, m_Crush, 1, m_Hexencrush); s = m_Sector->MoveCeiling (m_CeilingSpeed, m_CeilingTarget, m_Crush, 1, m_Hexencrush);
} }
if (r == EMoveResult::pastdest && s == EMoveResult::pastdest) if (r == EMoveResult::pastdest && s == EMoveResult::pastdest)
@ -114,11 +114,11 @@ void DPillar::Tick ()
{ {
if (r == EMoveResult::crushed) if (r == EMoveResult::crushed)
{ {
MoveFloor (m_FloorSpeed, oldfloor, -1, -1, m_Hexencrush); m_Sector->MoveFloor (m_FloorSpeed, oldfloor, -1, -1, m_Hexencrush);
} }
if (s == EMoveResult::crushed) if (s == EMoveResult::crushed)
{ {
MoveCeiling (m_CeilingSpeed, oldceiling, -1, 1, m_Hexencrush); m_Sector->MoveCeiling (m_CeilingSpeed, oldceiling, -1, 1, m_Hexencrush);
} }
} }
} }

View file

@ -99,7 +99,7 @@ void DPlat::Tick ()
switch (m_Status) switch (m_Status)
{ {
case up: case up:
res = MoveFloor (m_Speed, m_High, m_Crush, 1, false); res = m_Sector->MoveFloor (m_Speed, m_High, m_Crush, 1, false);
if (res == EMoveResult::crushed && (m_Crush == -1)) if (res == EMoveResult::crushed && (m_Crush == -1))
{ {
@ -144,7 +144,7 @@ void DPlat::Tick ()
break; break;
case down: case down:
res = MoveFloor (m_Speed, m_Low, -1, -1, false); res = m_Sector->MoveFloor (m_Speed, m_Low, -1, -1, false);
if (res == EMoveResult::pastdest) if (res == EMoveResult::pastdest)
{ {

View file

@ -621,6 +621,23 @@ enum class EMoveResult { ok, crushed, pastdest };
struct sector_t struct sector_t
{ {
// Member functions // Member functions
private:
bool MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed);
public:
EMoveResult MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush);
EMoveResult MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush);
inline EMoveResult MoveFloor(double speed, double dest, int direction)
{
return MoveFloor(speed, dest, -1, direction, false);
}
inline EMoveResult MoveCeiling(double speed, double dest, int direction)
{
return MoveCeiling(speed, dest, -1, direction, false);
}
bool IsLinked(sector_t *other, bool ceiling) const; bool IsLinked(sector_t *other, bool ceiling) const;
double FindLowestFloorSurrounding(vertex_t **v) const; double FindLowestFloorSurrounding(vertex_t **v) const;
double FindHighestFloorSurrounding(vertex_t **v) const; double FindHighestFloorSurrounding(vertex_t **v) const;