mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- took EResult out of DMover and made it an enum class.
This commit is contained in:
parent
fb2234396c
commit
e505bfd7a3
9 changed files with 57 additions and 56 deletions
|
@ -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
|
||||
//
|
||||
DMover::EResult DMover::MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush)
|
||||
EMoveResult DMover::MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush)
|
||||
{
|
||||
bool flag;
|
||||
double lastpos;
|
||||
|
@ -173,7 +173,7 @@ DMover::EResult DMover::MoveFloor(double speed, double dest, int crush, int dire
|
|||
{
|
||||
move = m_Sector->floorplane.HeightDiff(lastpos, dest);
|
||||
|
||||
if (!MoveAttached(crush, move, 0, true)) return crushed;
|
||||
if (!MoveAttached(crush, move, 0, true)) return EMoveResult::crushed;
|
||||
|
||||
m_Sector->floorplane.setD(dest);
|
||||
flag = P_ChangeSector(m_Sector, crush, move, 0, false);
|
||||
|
@ -188,11 +188,11 @@ DMover::EResult DMover::MoveFloor(double speed, double dest, int crush, int dire
|
|||
m_Sector->ChangePlaneTexZ(sector_t::floor, move);
|
||||
m_Sector->AdjustFloorClip();
|
||||
}
|
||||
return pastdest;
|
||||
return EMoveResult::pastdest;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!MoveAttached(crush, -speed, 0, true)) return crushed;
|
||||
if (!MoveAttached(crush, -speed, 0, true)) return EMoveResult::crushed;
|
||||
|
||||
m_Sector->floorplane.setD(movedest);
|
||||
|
||||
|
@ -202,7 +202,7 @@ DMover::EResult DMover::MoveFloor(double speed, double dest, int crush, int dire
|
|||
m_Sector->floorplane.setD(lastpos);
|
||||
P_ChangeSector(m_Sector, crush, speed, 0, true);
|
||||
MoveAttached(crush, speed, 0, false);
|
||||
return crushed;
|
||||
return EMoveResult::crushed;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -229,7 +229,7 @@ DMover::EResult DMover::MoveFloor(double speed, double dest, int crush, int dire
|
|||
{
|
||||
move = m_Sector->floorplane.HeightDiff(lastpos, dest);
|
||||
|
||||
if (!MoveAttached(crush, move, 0, true)) return crushed;
|
||||
if (!MoveAttached(crush, move, 0, true)) return EMoveResult::crushed;
|
||||
|
||||
m_Sector->floorplane.setD(dest);
|
||||
|
||||
|
@ -245,11 +245,11 @@ DMover::EResult DMover::MoveFloor(double speed, double dest, int crush, int dire
|
|||
m_Sector->ChangePlaneTexZ(sector_t::floor, move);
|
||||
m_Sector->AdjustFloorClip();
|
||||
}
|
||||
return pastdest;
|
||||
return EMoveResult::pastdest;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!MoveAttached(crush, speed, 0, true)) return crushed;
|
||||
if (!MoveAttached(crush, speed, 0, true)) return EMoveResult::crushed;
|
||||
|
||||
m_Sector->floorplane.setD(movedest);
|
||||
|
||||
|
@ -261,22 +261,22 @@ DMover::EResult DMover::MoveFloor(double speed, double dest, int crush, int dire
|
|||
{
|
||||
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff(lastpos));
|
||||
m_Sector->AdjustFloorClip();
|
||||
return crushed;
|
||||
return EMoveResult::crushed;
|
||||
}
|
||||
m_Sector->floorplane.setD(lastpos);
|
||||
P_ChangeSector(m_Sector, crush, -speed, 0, true);
|
||||
MoveAttached(crush, -speed, 0, false);
|
||||
return crushed;
|
||||
return EMoveResult::crushed;
|
||||
}
|
||||
m_Sector->ChangePlaneTexZ(sector_t::floor, m_Sector->floorplane.HeightDiff(lastpos));
|
||||
m_Sector->AdjustFloorClip();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ok;
|
||||
return EMoveResult::ok;
|
||||
}
|
||||
|
||||
DMover::EResult DMover::MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush)
|
||||
EMoveResult DMover::MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush)
|
||||
{
|
||||
bool flag;
|
||||
double lastpos;
|
||||
|
@ -303,7 +303,7 @@ DMover::EResult DMover::MoveCeiling(double speed, double dest, int crush, int di
|
|||
{
|
||||
move = m_Sector->ceilingplane.HeightDiff (lastpos, dest);
|
||||
|
||||
if (!MoveAttached(crush, move, 1, true)) return crushed;
|
||||
if (!MoveAttached(crush, move, 1, true)) return EMoveResult::crushed;
|
||||
|
||||
m_Sector->ceilingplane.setD(dest);
|
||||
flag = P_ChangeSector (m_Sector, crush, move, 1, false);
|
||||
|
@ -318,11 +318,11 @@ DMover::EResult DMover::MoveCeiling(double speed, double dest, int crush, int di
|
|||
{
|
||||
m_Sector->ChangePlaneTexZ(sector_t::ceiling, move);
|
||||
}
|
||||
return pastdest;
|
||||
return EMoveResult::pastdest;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!MoveAttached(crush, -speed, 1, true)) return crushed;
|
||||
if (!MoveAttached(crush, -speed, 1, true)) return EMoveResult::crushed;
|
||||
|
||||
m_Sector->ceilingplane.setD(movedest);
|
||||
|
||||
|
@ -333,12 +333,12 @@ DMover::EResult DMover::MoveCeiling(double speed, double dest, int crush, int di
|
|||
if (crush >= 0 && !hexencrush)
|
||||
{
|
||||
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
|
||||
return crushed;
|
||||
return EMoveResult::crushed;
|
||||
}
|
||||
m_Sector->ceilingplane.setD(lastpos);
|
||||
P_ChangeSector (m_Sector, crush, speed, 1, true);
|
||||
MoveAttached(crush, speed, 1, false);
|
||||
return crushed;
|
||||
return EMoveResult::crushed;
|
||||
}
|
||||
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ DMover::EResult DMover::MoveCeiling(double speed, double dest, int crush, int di
|
|||
{
|
||||
move = m_Sector->ceilingplane.HeightDiff (lastpos, dest);
|
||||
|
||||
if (!MoveAttached(crush, move, 1, true)) return crushed;
|
||||
if (!MoveAttached(crush, move, 1, true)) return EMoveResult::crushed;
|
||||
|
||||
m_Sector->ceilingplane.setD(dest);
|
||||
|
||||
|
@ -366,11 +366,11 @@ DMover::EResult DMover::MoveCeiling(double speed, double dest, int crush, int di
|
|||
{
|
||||
m_Sector->ChangePlaneTexZ(sector_t::ceiling, move);
|
||||
}
|
||||
return pastdest;
|
||||
return EMoveResult::pastdest;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!MoveAttached(crush, speed, 1, true)) return crushed;
|
||||
if (!MoveAttached(crush, speed, 1, true)) return EMoveResult::crushed;
|
||||
|
||||
m_Sector->ceilingplane.setD(movedest);
|
||||
|
||||
|
@ -380,11 +380,11 @@ DMover::EResult DMover::MoveCeiling(double speed, double dest, int crush, int di
|
|||
m_Sector->ceilingplane.setD(lastpos);
|
||||
P_ChangeSector (m_Sector, crush, -speed, 1, true);
|
||||
MoveAttached(crush, -speed, 1, false);
|
||||
return crushed;
|
||||
return EMoveResult::crushed;
|
||||
}
|
||||
m_Sector->ChangePlaneTexZ(sector_t::ceiling, m_Sector->ceilingplane.HeightDiff (lastpos));
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ok;
|
||||
return EMoveResult::ok;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ class DMover : public DSectorEffect
|
|||
public:
|
||||
DMover (sector_t *sector);
|
||||
protected:
|
||||
enum EResult { ok, crushed, pastdest };
|
||||
TObjPtr<DInterpolation> interpolation;
|
||||
private:
|
||||
bool MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed);
|
||||
|
@ -36,15 +35,15 @@ protected:
|
|||
void Serialize (FArchive &arc);
|
||||
void Destroy();
|
||||
void StopInterpolation(bool force = false);
|
||||
EResult MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush);
|
||||
EResult MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush);
|
||||
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 EResult MoveFloor(double speed, double dest, int direction)
|
||||
inline EMoveResult MoveFloor(double speed, double dest, int direction)
|
||||
{
|
||||
return MoveFloor(speed, dest, -1, direction, false);
|
||||
}
|
||||
|
||||
inline EResult MoveCeiling(double speed, double dest, int direction)
|
||||
inline EMoveResult MoveCeiling(double speed, double dest, int direction)
|
||||
{
|
||||
return MoveCeiling(speed, dest, -1, direction, false);
|
||||
}
|
||||
|
|
|
@ -1545,7 +1545,7 @@ public:
|
|||
|
||||
bool Move(double speed, double dest, int crush, int direction)
|
||||
{
|
||||
bool res = DMover::crushed != MoveFloor(speed, dest, crush, direction, false);
|
||||
bool res = EMoveResult::crushed != MoveFloor(speed, dest, crush, direction, false);
|
||||
Destroy();
|
||||
m_Sector->floordata=NULL;
|
||||
StopInterpolation(true);
|
||||
|
@ -1694,7 +1694,7 @@ public:
|
|||
|
||||
bool Move(double speed, double dest, int crush, int direction)
|
||||
{
|
||||
bool res = DMover::crushed != MoveCeiling(speed, dest, crush, direction, false);
|
||||
bool res = EMoveResult::crushed != MoveCeiling(speed, dest, crush, direction, false);
|
||||
Destroy();
|
||||
m_Sector->ceilingdata=NULL;
|
||||
StopInterpolation (true);
|
||||
|
|
|
@ -127,7 +127,7 @@ void DCeiling::PlayCeilingSound ()
|
|||
|
||||
void DCeiling::Tick ()
|
||||
{
|
||||
EResult res;
|
||||
EMoveResult res;
|
||||
|
||||
switch (m_Direction)
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ void DCeiling::Tick ()
|
|||
// UP
|
||||
res = MoveCeiling (m_Speed, m_TopHeight, m_Direction);
|
||||
|
||||
if (res == pastdest)
|
||||
if (res == EMoveResult::pastdest)
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
|
@ -169,7 +169,7 @@ void DCeiling::Tick ()
|
|||
// DOWN
|
||||
res = MoveCeiling (m_Speed, m_BottomHeight, m_Crush, m_Direction, m_CrushMode == ECrushMode::crushHexen);
|
||||
|
||||
if (res == pastdest)
|
||||
if (res == EMoveResult::pastdest)
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
|
@ -198,7 +198,7 @@ void DCeiling::Tick ()
|
|||
}
|
||||
else // ( res != pastdest )
|
||||
{
|
||||
if (res == crushed)
|
||||
if (res == EMoveResult::crushed)
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
|
|
|
@ -80,7 +80,7 @@ void DDoor::Serialize (FArchive &arc)
|
|||
|
||||
void DDoor::Tick ()
|
||||
{
|
||||
EResult res;
|
||||
EMoveResult res;
|
||||
|
||||
// Adjust bottom height - but only if there isn't an active lift attached to the floor.
|
||||
if (m_Sector->floorplane.fD() != m_OldFloorDist)
|
||||
|
@ -146,7 +146,7 @@ void DDoor::Tick ()
|
|||
(m_Sector->ceilingplane.fD() + m_Sector->floorplane.fD()) / (m_TopDist + m_Sector->floorplane.fD()));
|
||||
}
|
||||
|
||||
if (res == pastdest)
|
||||
if (res == EMoveResult::pastdest)
|
||||
{
|
||||
SN_StopSequence (m_Sector, CHAN_CEILING);
|
||||
switch (m_Type)
|
||||
|
@ -166,7 +166,7 @@ void DDoor::Tick ()
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (res == crushed)
|
||||
else if (res == EMoveResult::crushed)
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
|
@ -192,7 +192,7 @@ void DDoor::Tick ()
|
|||
(m_Sector->ceilingplane.fD() + m_Sector->floorplane.fD()) / (m_TopDist + m_Sector->floorplane.fD()));
|
||||
}
|
||||
|
||||
if (res == pastdest)
|
||||
if (res == EMoveResult::pastdest)
|
||||
{
|
||||
SN_StopSequence (m_Sector, CHAN_CEILING);
|
||||
switch (m_Type)
|
||||
|
@ -212,7 +212,7 @@ void DDoor::Tick ()
|
|||
break;
|
||||
}
|
||||
}
|
||||
else if (res == crushed)
|
||||
else if (res == EMoveResult::crushed)
|
||||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
|
@ -560,7 +560,7 @@ bool DAnimatedDoor::StartClosing ()
|
|||
}
|
||||
|
||||
double topdist = m_Sector->ceilingplane.fD();
|
||||
if (MoveCeiling (2048., m_BotDist, 0, -1, false) == crushed)
|
||||
if (MoveCeiling (2048., m_BotDist, 0, -1, false) == EMoveResult::crushed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ void DFloor::Serialize (FArchive &arc)
|
|||
|
||||
void DFloor::Tick ()
|
||||
{
|
||||
EResult res;
|
||||
EMoveResult res;
|
||||
|
||||
// [RH] Handle resetting stairs
|
||||
if (m_Type == buildStair || m_Type == waitStair)
|
||||
|
@ -146,7 +146,7 @@ void DFloor::Tick ()
|
|||
|
||||
res = MoveFloor (m_Speed, m_FloorDestDist, m_Crush, m_Direction, m_Hexencrush);
|
||||
|
||||
if (res == pastdest)
|
||||
if (res == EMoveResult::pastdest)
|
||||
{
|
||||
SN_StopSequence (m_Sector, CHAN_FLOOR);
|
||||
|
||||
|
@ -898,7 +898,7 @@ void DElevator::Destroy()
|
|||
|
||||
void DElevator::Tick ()
|
||||
{
|
||||
EResult res;
|
||||
EMoveResult res;
|
||||
|
||||
double oldfloor, oldceiling;
|
||||
|
||||
|
@ -908,10 +908,10 @@ void DElevator::Tick ()
|
|||
if (m_Direction < 0) // moving down
|
||||
{
|
||||
res = MoveFloor (m_Speed, m_FloorDestDist, m_Direction);
|
||||
if (res == ok || res == pastdest)
|
||||
if (res == EMoveResult::ok || res == EMoveResult::pastdest)
|
||||
{
|
||||
res = MoveCeiling (m_Speed, m_CeilingDestDist, m_Direction);
|
||||
if (res == crushed)
|
||||
if (res == EMoveResult::crushed)
|
||||
{
|
||||
MoveFloor (m_Speed, oldfloor, -m_Direction);
|
||||
}
|
||||
|
@ -920,17 +920,17 @@ void DElevator::Tick ()
|
|||
else // up
|
||||
{
|
||||
res = MoveCeiling (m_Speed, m_CeilingDestDist, m_Direction);
|
||||
if (res == ok || res == pastdest)
|
||||
if (res == EMoveResult::ok || res == EMoveResult::pastdest)
|
||||
{
|
||||
res = MoveFloor (m_Speed, m_FloorDestDist, m_Direction);
|
||||
if (res == crushed)
|
||||
if (res == EMoveResult::crushed)
|
||||
{
|
||||
MoveCeiling (m_Speed, oldceiling, -m_Direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (res == pastdest) // if destination height acheived
|
||||
if (res == EMoveResult::pastdest) // if destination height acheived
|
||||
{
|
||||
// make floor stop sound
|
||||
SN_StopSequence (m_Sector, CHAN_FLOOR);
|
||||
|
|
|
@ -88,7 +88,7 @@ void DPillar::Serialize (FArchive &arc)
|
|||
|
||||
void DPillar::Tick ()
|
||||
{
|
||||
int r, s;
|
||||
EMoveResult r, s;
|
||||
double oldfloor, oldceiling;
|
||||
|
||||
oldfloor = m_Sector->floorplane.fD();
|
||||
|
@ -105,18 +105,18 @@ void DPillar::Tick ()
|
|||
s = MoveCeiling (m_CeilingSpeed, m_CeilingTarget, m_Crush, 1, m_Hexencrush);
|
||||
}
|
||||
|
||||
if (r == pastdest && s == pastdest)
|
||||
if (r == EMoveResult::pastdest && s == EMoveResult::pastdest)
|
||||
{
|
||||
SN_StopSequence (m_Sector, CHAN_FLOOR);
|
||||
Destroy ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (r == crushed)
|
||||
if (r == EMoveResult::crushed)
|
||||
{
|
||||
MoveFloor (m_FloorSpeed, oldfloor, -1, -1, m_Hexencrush);
|
||||
}
|
||||
if (s == crushed)
|
||||
if (s == EMoveResult::crushed)
|
||||
{
|
||||
MoveCeiling (m_CeilingSpeed, oldceiling, -1, 1, m_Hexencrush);
|
||||
}
|
||||
|
|
|
@ -94,20 +94,20 @@ void DPlat::PlayPlatSound (const char *sound)
|
|||
//
|
||||
void DPlat::Tick ()
|
||||
{
|
||||
EResult res;
|
||||
EMoveResult res;
|
||||
|
||||
switch (m_Status)
|
||||
{
|
||||
case up:
|
||||
res = MoveFloor (m_Speed, m_High, m_Crush, 1, false);
|
||||
|
||||
if (res == crushed && (m_Crush == -1))
|
||||
if (res == EMoveResult::crushed && (m_Crush == -1))
|
||||
{
|
||||
m_Count = m_Wait;
|
||||
m_Status = down;
|
||||
PlayPlatSound ("Platform");
|
||||
}
|
||||
else if (res == pastdest)
|
||||
else if (res == EMoveResult::pastdest)
|
||||
{
|
||||
SN_StopSequence (m_Sector, CHAN_FLOOR);
|
||||
if (m_Type != platToggle)
|
||||
|
@ -146,7 +146,7 @@ void DPlat::Tick ()
|
|||
case down:
|
||||
res = MoveFloor (m_Speed, m_Low, -1, -1, false);
|
||||
|
||||
if (res == pastdest)
|
||||
if (res == EMoveResult::pastdest)
|
||||
{
|
||||
SN_StopSequence (m_Sector, CHAN_FLOOR);
|
||||
// if not an instant toggle, start waiting
|
||||
|
@ -172,7 +172,7 @@ void DPlat::Tick ()
|
|||
m_Status = in_stasis; //for reactivation of toggle
|
||||
}
|
||||
}
|
||||
else if (res == crushed && m_Crush < 0 && m_Type != platToggle)
|
||||
else if (res == EMoveResult::crushed && m_Crush < 0 && m_Type != platToggle)
|
||||
{
|
||||
m_Status = up;
|
||||
m_Count = m_Wait;
|
||||
|
|
|
@ -616,6 +616,8 @@ struct secspecial_t
|
|||
|
||||
FArchive &operator<< (FArchive &arc, secspecial_t &p);
|
||||
|
||||
enum class EMoveResult { ok, crushed, pastdest };
|
||||
|
||||
struct sector_t
|
||||
{
|
||||
// Member functions
|
||||
|
|
Loading…
Reference in a new issue