- cleaned up ceiling creation and moved the Create function out of the DCeiling class.

- did the same for floors so that FraggleScript no longer needs access to the thinkers themselves.
This commit is contained in:
Christoph Oelckers 2016-04-09 12:07:34 +02:00
parent caae61de4c
commit bc7e159be0
5 changed files with 287 additions and 318 deletions

View file

@ -26,6 +26,7 @@ class DMover : public DSectorEffect
HAS_OBJECT_POINTERS HAS_OBJECT_POINTERS
public: public:
DMover (sector_t *sector); DMover (sector_t *sector);
void StopInterpolation(bool force = false);
protected: protected:
TObjPtr<DInterpolation> interpolation; TObjPtr<DInterpolation> interpolation;
private: private:
@ -33,7 +34,6 @@ protected:
DMover (); DMover ();
void Serialize (FArchive &arc); void Serialize (FArchive &arc);
void Destroy(); void Destroy();
void StopInterpolation(bool force = false);
}; };
class DMovingFloor : public DMover class DMovingFloor : public DMover

View file

@ -1596,35 +1596,6 @@ void FParser::SF_FloorHeight(void)
} }
//=============================================================================
//
//
//=============================================================================
class DMoveFloor : public DFloor
{
public:
DMoveFloor(sector_t * sec,double moveheight,int _m_Direction,int crush,double movespeed)
: DFloor(sec)
{
m_Type = floorRaiseByValue;
m_Crush = crush;
m_Speed=movespeed;
m_Direction = _m_Direction;
m_FloorDestDist = moveheight;
// Do not interpolate instant movement floors.
double movedist = fabs(-sec->floorplane.fD() - moveheight);
if (m_Speed >= movedist)
{
StopInterpolation(true);
}
StartFloorSound();
}
};
//========================================================================== //==========================================================================
// //
// //
@ -1634,7 +1605,6 @@ public:
void FParser::SF_MoveFloor(void) void FParser::SF_MoveFloor(void)
{ {
int secnum = -1; int secnum = -1;
sector_t *sec;
int tagnum, crush; int tagnum, crush;
double platspeed = 1, destheight; double platspeed = 1, destheight;
@ -1650,12 +1620,7 @@ void FParser::SF_MoveFloor(void)
FSSectorTagIterator itr(tagnum); FSSectorTagIterator itr(tagnum);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
sec = &sectors[secnum]; P_CreateFloor(&sectors[secnum], DFloor::floorMoveToValue, NULL, platspeed, destheight, crush, 0, false, false);
// Don't start a second thinker on the same floor
if (sec->floordata) continue;
new DMoveFloor(sec, sec->floorplane.PointToDist(sec->centerspot, destheight),
destheight < sec->CenterFloor() ? -1 : 1, crush, platspeed);
} }
} }
} }
@ -1729,7 +1694,6 @@ void FParser::SF_CeilingHeight(void)
void FParser::SF_MoveCeiling(void) void FParser::SF_MoveCeiling(void)
{ {
int secnum = -1; int secnum = -1;
sector_t *sec;
int tagnum; int tagnum;
double platspeed = 1, destheight; double platspeed = 1, destheight;
int crush; int crush;
@ -1747,11 +1711,7 @@ void FParser::SF_MoveCeiling(void)
FSSectorTagIterator itr(tagnum); FSSectorTagIterator itr(tagnum);
while ((secnum = itr.Next()) >= 0) while ((secnum = itr.Next()) >= 0)
{ {
sec = &sectors[secnum]; P_CreateCeiling(&sectors[secnum], DCeiling::ceilMoveToValue, NULL, tagnum, platspeed, platspeed, destheight, crush, silent | 4, 0, DCeiling::ECrushMode::crushDoom);
// Don't start a second thinker on the same floor
if (sec->ceilingdata) continue;
DCeiling::Create(sec, DCeiling::ceilMoveToValue, NULL, tagnum, platspeed, platspeed, destheight, crush, silent | 4, 0, DCeiling::ECrushMode::crushDoom);
} }
} }
} }

View file

@ -142,7 +142,7 @@ void DCeiling::Tick ()
{ {
switch (m_Type) switch (m_Type)
{ {
case ceilCrushAndRaise: case DCeiling::ceilCrushAndRaise:
m_Direction = -1; m_Direction = -1;
m_Speed = m_Speed1; m_Speed = m_Speed1;
if (!SN_IsMakingLoopingSound (m_Sector)) if (!SN_IsMakingLoopingSound (m_Sector))
@ -173,8 +173,8 @@ void DCeiling::Tick ()
{ {
switch (m_Type) switch (m_Type)
{ {
case ceilCrushAndRaise: case DCeiling::ceilCrushAndRaise:
case ceilCrushRaiseAndStay: case DCeiling::ceilCrushRaiseAndStay:
m_Speed = m_Speed2; m_Speed = m_Speed2;
m_Direction = 1; m_Direction = 1;
if (!SN_IsMakingLoopingSound (m_Sector)) if (!SN_IsMakingLoopingSound (m_Sector))
@ -202,8 +202,8 @@ void DCeiling::Tick ()
{ {
switch (m_Type) switch (m_Type)
{ {
case ceilCrushAndRaise: case DCeiling::ceilCrushAndRaise:
case ceilLowerAndCrush: case DCeiling::ceilLowerAndCrush:
if (m_CrushMode == ECrushMode::crushSlowdown) if (m_CrushMode == ECrushMode::crushSlowdown)
m_Speed = 1. / 8; m_Speed = 1. / 8;
break; break;
@ -244,9 +244,9 @@ DCeiling::DCeiling (sector_t *sec, double speed1, double speed2, int silent)
// //
//============================================================================ //============================================================================
DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag, bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag,
double speed, double speed2, double height, double speed, double speed2, double height,
int crush, int silent, int change, ECrushMode hexencrush) int crush, int silent, int change, DCeiling::ECrushMode hexencrush)
{ {
double targheight = 0; // Silence, GCC double targheight = 0; // Silence, GCC
@ -262,35 +262,35 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
switch (type) switch (type)
{ {
case ceilCrushAndRaise: case DCeiling::ceilCrushAndRaise:
case ceilCrushRaiseAndStay: case DCeiling::ceilCrushRaiseAndStay:
ceiling->m_TopHeight = sec->ceilingplane.fD(); ceiling->m_TopHeight = sec->ceilingplane.fD();
case ceilLowerAndCrush: case DCeiling::ceilLowerAndCrush:
targheight = sec->FindHighestFloorPoint (&spot); targheight = sec->FindHighestFloorPoint (&spot);
targheight += height; targheight += height;
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
break; break;
case ceilRaiseToHighest: case DCeiling::ceilRaiseToHighest:
targheight = sec->FindHighestCeilingSurrounding (&spot); targheight = sec->FindHighestCeilingSurrounding (&spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1; ceiling->m_Direction = 1;
break; break;
case ceilLowerByValue: case DCeiling::ceilLowerByValue:
targheight = sec->ceilingplane.ZatPoint (spot) - height; targheight = sec->ceilingplane.ZatPoint (spot) - height;
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
break; break;
case ceilRaiseByValue: case DCeiling::ceilRaiseByValue:
targheight = sec->ceilingplane.ZatPoint (spot) + height; targheight = sec->ceilingplane.ZatPoint (spot) + height;
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1; ceiling->m_Direction = 1;
break; break;
case ceilMoveToValue: case DCeiling::ceilMoveToValue:
{ {
double diff = height - sec->ceilingplane.ZatPoint (spot); double diff = height - sec->ceilingplane.ZatPoint (spot);
@ -308,81 +308,81 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
} }
break; break;
case ceilLowerToHighestFloor: case DCeiling::ceilLowerToHighestFloor:
targheight = sec->FindHighestFloorSurrounding (&spot); targheight = sec->FindHighestFloorSurrounding (&spot);
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
break; break;
case ceilRaiseToHighestFloor: case DCeiling::ceilRaiseToHighestFloor:
targheight = sec->FindHighestFloorSurrounding (&spot); targheight = sec->FindHighestFloorSurrounding (&spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1; ceiling->m_Direction = 1;
break; break;
case ceilLowerInstant: case DCeiling::ceilLowerInstant:
targheight = sec->ceilingplane.ZatPoint (spot) - height; targheight = sec->ceilingplane.ZatPoint (spot) - height;
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
ceiling->m_Speed = height; ceiling->m_Speed = height;
break; break;
case ceilRaiseInstant: case DCeiling::ceilRaiseInstant:
targheight = sec->ceilingplane.ZatPoint (spot) + height; targheight = sec->ceilingplane.ZatPoint (spot) + height;
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1; ceiling->m_Direction = 1;
ceiling->m_Speed = height; ceiling->m_Speed = height;
break; break;
case ceilLowerToNearest: case DCeiling::ceilLowerToNearest:
targheight = sec->FindNextLowestCeiling (&spot); targheight = sec->FindNextLowestCeiling (&spot);
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
break; break;
case ceilRaiseToNearest: case DCeiling::ceilRaiseToNearest:
targheight = sec->FindNextHighestCeiling (&spot); targheight = sec->FindNextHighestCeiling (&spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1; ceiling->m_Direction = 1;
break; break;
case ceilLowerToLowest: case DCeiling::ceilLowerToLowest:
targheight = sec->FindLowestCeilingSurrounding (&spot); targheight = sec->FindLowestCeilingSurrounding (&spot);
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
break; break;
case ceilRaiseToLowest: case DCeiling::ceilRaiseToLowest:
targheight = sec->FindLowestCeilingSurrounding (&spot); targheight = sec->FindLowestCeilingSurrounding (&spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1; ceiling->m_Direction = 1;
break; break;
case ceilLowerToFloor: case DCeiling::ceilLowerToFloor:
targheight = sec->FindHighestFloorPoint (&spot); targheight = sec->FindHighestFloorPoint (&spot);
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
break; break;
case ceilRaiseToFloor: // [RH] What's this for? case DCeiling::ceilRaiseToFloor: // [RH] What's this for?
targheight = sec->FindHighestFloorPoint (&spot); targheight = sec->FindHighestFloorPoint (&spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1; ceiling->m_Direction = 1;
break; break;
case ceilLowerToHighest: case DCeiling::ceilLowerToHighest:
targheight = sec->FindHighestCeilingSurrounding (&spot); targheight = sec->FindHighestCeilingSurrounding (&spot);
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
break; break;
case ceilLowerByTexture: case DCeiling::ceilLowerByTexture:
targheight = sec->ceilingplane.ZatPoint (spot) - sec->FindShortestUpperAround (); targheight = sec->ceilingplane.ZatPoint (spot) - sec->FindShortestUpperAround ();
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
break; break;
case ceilRaiseByTexture: case DCeiling::ceilRaiseByTexture:
targheight = sec->ceilingplane.ZatPoint (spot) + sec->FindShortestUpperAround (); targheight = sec->ceilingplane.ZatPoint (spot) + sec->FindShortestUpperAround ();
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1; ceiling->m_Direction = 1;
@ -426,9 +426,9 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
//jff 5/23/98 find model with floor at target height if target //jff 5/23/98 find model with floor at target height if target
//is a floor type //is a floor type
modelsec = (/*type == ceilRaiseToHighest ||*/ modelsec = (/*type == ceilRaiseToHighest ||*/
type == ceilRaiseToFloor || type == DCeiling::ceilRaiseToFloor ||
/*type == ceilLowerToHighest ||*/ /*type == ceilLowerToHighest ||*/
type == ceilLowerToFloor) ? type == DCeiling::ceilLowerToFloor) ?
sec->FindModelFloorSector (targheight) : sec->FindModelFloorSector (targheight) :
sec->FindModelCeilingSector (targheight); sec->FindModelCeilingSector (targheight);
if (modelsec != NULL) if (modelsec != NULL)
@ -438,14 +438,14 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
{ {
case 1: // type is zeroed case 1: // type is zeroed
ceiling->m_NewSpecial.Clear(); ceiling->m_NewSpecial.Clear();
ceiling->m_Type = genCeilingChg0; ceiling->m_Type = DCeiling::genCeilingChg0;
break; break;
case 2: // type is copied case 2: // type is copied
sec->GetSpecial(&ceiling->m_NewSpecial); sec->GetSpecial(&ceiling->m_NewSpecial);
ceiling->m_Type = genCeilingChgT; ceiling->m_Type = DCeiling::genCeilingChgT;
break; break;
case 3: // type is left alone case 3: // type is left alone
ceiling->m_Type = genCeilingChg; ceiling->m_Type = DCeiling::genCeilingChg;
break; break;
} }
} }
@ -457,21 +457,21 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
{ {
case 1: // type is zeroed case 1: // type is zeroed
ceiling->m_NewSpecial.Clear(); ceiling->m_NewSpecial.Clear();
ceiling->m_Type = genCeilingChg0; ceiling->m_Type = DCeiling::genCeilingChg0;
break; break;
case 2: // type is copied case 2: // type is copied
line->frontsector->GetSpecial(&ceiling->m_NewSpecial); line->frontsector->GetSpecial(&ceiling->m_NewSpecial);
ceiling->m_Type = genCeilingChgT; ceiling->m_Type = DCeiling::genCeilingChgT;
break; break;
case 3: // type is left alone case 3: // type is left alone
ceiling->m_Type = genCeilingChg; ceiling->m_Type = DCeiling::genCeilingChg;
break; break;
} }
} }
} }
ceiling->PlayCeilingSound (); ceiling->PlayCeilingSound ();
return ceiling; return ceiling != NULL;
} }
//============================================================================ //============================================================================
@ -502,7 +502,7 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line,
// [RH] Hack to let manual crushers be retriggerable, too // [RH] Hack to let manual crushers be retriggerable, too
tag ^= secnum | 0x1000000; tag ^= secnum | 0x1000000;
P_ActivateInStasisCeiling (tag); P_ActivateInStasisCeiling (tag);
return !!DCeiling::Create(sec, type, line, tag, speed, speed2, height, crush, silent, change, hexencrush); return P_CreateCeiling(sec, type, line, tag, speed, speed2, height, crush, silent, change, hexencrush);
} }
// Reactivate in-stasis ceilings...for certain types. // Reactivate in-stasis ceilings...for certain types.
@ -516,7 +516,7 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line,
FSectorTagIterator it(tag); FSectorTagIterator it(tag);
while ((secnum = it.Next()) >= 0) while ((secnum = it.Next()) >= 0)
{ {
rtn |= !!DCeiling::Create(&sectors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush); rtn |= P_CreateCeiling(&sectors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush);
} }
return rtn; return rtn;
} }

View file

@ -273,40 +273,28 @@ DFloor::DFloor (sector_t *sec)
//========================================================================== //==========================================================================
// //
// HANDLE FLOOR TYPES //
// [RH] Added tag, speed, height, crush, change params.
// This functions starts too many different things.
// //
//========================================================================== //==========================================================================
bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
double speed, double height, int crush, int change, bool hexencrush, bool hereticlower) double speed, double height, int crush, int change, bool hexencrush, bool hereticlower)
{ {
int secnum;
bool rtn; bool rtn;
sector_t* sec;
DFloor* floor; DFloor* floor;
double ceilingheight; double ceilingheight;
double newheight; double newheight;
vertex_t *spot, *spot2; vertex_t *spot, *spot2;
rtn = false;
// check if a manual trigger; if so do just the sector on the backside
FSectorTagIterator it(tag, line);
while ((secnum = it.Next()) >= 0)
{
sec = &sectors[secnum];
// ALREADY MOVING? IF SO, KEEP GOING... // ALREADY MOVING? IF SO, KEEP GOING...
if (sec->PlaneMoving(sector_t::floor)) if (sec->PlaneMoving(sector_t::floor))
{ {
continue; return false;
} }
// new floor thinker // new floor thinker
rtn = true; rtn = true;
floor = new DFloor (sec); floor = new DFloor(sec);
floor->m_Type = floortype; floor->m_Type = floortype;
floor->m_Crush = crush; floor->m_Crush = crush;
floor->m_Hexencrush = hexencrush; floor->m_Hexencrush = hexencrush;
@ -318,25 +306,25 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
{ {
case DFloor::floorLowerToHighest: case DFloor::floorLowerToHighest:
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->FindHighestFloorSurrounding (&spot); newheight = sec->FindHighestFloorSurrounding(&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
// [RH] DOOM's turboLower type did this. I've just extended it // [RH] DOOM's turboLower type did this. I've just extended it
// to be applicable to all LowerToHighest types. // to be applicable to all LowerToHighest types.
if (hereticlower || floor->m_FloorDestDist != sec->floorplane.fD()) if (hereticlower || floor->m_FloorDestDist != sec->floorplane.fD())
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight+height); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight + height);
break; break;
case DFloor::floorLowerToLowest: case DFloor::floorLowerToLowest:
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->FindLowestFloorSurrounding (&spot); newheight = sec->FindLowestFloorSurrounding(&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
case DFloor::floorLowerToNearest: case DFloor::floorLowerToNearest:
//jff 02/03/30 support lowering floor to next lowest floor //jff 02/03/30 support lowering floor to next lowest floor
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->FindNextLowestFloor (&spot); newheight = sec->FindNextLowestFloor(&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
case DFloor::floorLowerInstant: case DFloor::floorLowerInstant:
@ -344,7 +332,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
case DFloor::floorLowerByValue: case DFloor::floorLowerByValue:
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->CenterFloor() - height; newheight = sec->CenterFloor() - height;
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight);
break; break;
case DFloor::floorRaiseInstant: case DFloor::floorRaiseInstant:
@ -352,75 +340,75 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
case DFloor::floorRaiseByValue: case DFloor::floorRaiseByValue:
floor->m_Direction = 1; floor->m_Direction = 1;
newheight = sec->CenterFloor() + height; newheight = sec->CenterFloor() + height;
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight);
break; break;
case DFloor::floorMoveToValue: case DFloor::floorMoveToValue:
sec->FindHighestFloorPoint (&spot); sec->FindHighestFloorPoint(&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, height); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, height);
floor->m_Direction = (floor->m_FloorDestDist > sec->floorplane.fD()) ? -1 : 1; floor->m_Direction = (floor->m_FloorDestDist > sec->floorplane.fD()) ? -1 : 1;
break; break;
case DFloor::floorRaiseAndCrushDoom: case DFloor::floorRaiseAndCrushDoom:
case DFloor::floorRaiseToLowestCeiling: case DFloor::floorRaiseToLowestCeiling:
floor->m_Direction = 1; floor->m_Direction = 1;
newheight = sec->FindLowestCeilingSurrounding (&spot); newheight = sec->FindLowestCeilingSurrounding(&spot);
if (floortype == DFloor::floorRaiseAndCrushDoom) if (floortype == DFloor::floorRaiseAndCrushDoom)
newheight -= 8; newheight -= 8;
ceilingheight = sec->FindLowestCeilingPoint (&spot2); ceilingheight = sec->FindLowestCeilingPoint(&spot2);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
if (sec->floorplane.ZatPointDist (spot2, floor->m_FloorDestDist) > ceilingheight) if (sec->floorplane.ZatPointDist(spot2, floor->m_FloorDestDist) > ceilingheight)
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot2, floor->m_FloorDestDist = sec->floorplane.PointToDist(spot2,
floortype == DFloor::floorRaiseAndCrushDoom ? ceilingheight - 8 : ceilingheight); floortype == DFloor::floorRaiseAndCrushDoom ? ceilingheight - 8 : ceilingheight);
break; break;
case DFloor::floorRaiseToHighest: case DFloor::floorRaiseToHighest:
floor->m_Direction = 1; floor->m_Direction = 1;
newheight = sec->FindHighestFloorSurrounding (&spot); newheight = sec->FindHighestFloorSurrounding(&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
case DFloor::floorRaiseToNearest: case DFloor::floorRaiseToNearest:
floor->m_Direction = 1; floor->m_Direction = 1;
newheight = sec->FindNextHighestFloor (&spot); newheight = sec->FindNextHighestFloor(&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
case DFloor::floorRaiseToLowest: case DFloor::floorRaiseToLowest:
floor->m_Direction = 1; floor->m_Direction = 1;
newheight = sec->FindLowestFloorSurrounding (&spot); newheight = sec->FindLowestFloorSurrounding(&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
case DFloor::floorRaiseAndCrush: case DFloor::floorRaiseAndCrush:
floor->m_Direction = 1; floor->m_Direction = 1;
newheight = sec->FindLowestCeilingPoint (&spot) - 8; newheight = sec->FindLowestCeilingPoint(&spot) - 8;
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
case DFloor::floorRaiseToCeiling: case DFloor::floorRaiseToCeiling:
floor->m_Direction = 1; floor->m_Direction = 1;
newheight = sec->FindLowestCeilingPoint (&spot); newheight = sec->FindLowestCeilingPoint(&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
case DFloor::floorLowerToLowestCeiling: case DFloor::floorLowerToLowestCeiling:
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->FindLowestCeilingSurrounding (&spot); newheight = sec->FindLowestCeilingSurrounding(&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
case DFloor::floorLowerByTexture: case DFloor::floorLowerByTexture:
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->CenterFloor() - sec->FindShortestTextureAround (); newheight = sec->CenterFloor() - sec->FindShortestTextureAround();
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight);
break; break;
case DFloor::floorLowerToCeiling: case DFloor::floorLowerToCeiling:
// [RH] Essentially instantly raises the floor to the ceiling // [RH] Essentially instantly raises the floor to the ceiling
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->FindLowestCeilingPoint (&spot); newheight = sec->FindLowestCeilingPoint(&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
case DFloor::floorRaiseByTexture: case DFloor::floorRaiseByTexture:
@ -429,14 +417,14 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
// since the code is identical to what was here. (Oddly // since the code is identical to what was here. (Oddly
// enough, BOOM preserved the code here even though it // enough, BOOM preserved the code here even though it
// also had this function.) // also had this function.)
newheight = sec->CenterFloor() + sec->FindShortestTextureAround (); newheight = sec->CenterFloor() + sec->FindShortestTextureAround();
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight);
break; break;
case DFloor::floorRaiseAndChange: case DFloor::floorRaiseAndChange:
floor->m_Direction = 1; floor->m_Direction = 1;
newheight = sec->CenterFloor() + height; newheight = sec->CenterFloor() + height;
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight);
if (line != NULL) if (line != NULL)
{ {
FTextureID oldpic = sec->GetTexture(sector_t::floor); FTextureID oldpic = sec->GetTexture(sector_t::floor);
@ -451,8 +439,8 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
case DFloor::floorLowerAndChange: case DFloor::floorLowerAndChange:
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->FindLowestFloorSurrounding (&spot); newheight = sec->FindLowestFloorSurrounding(&spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
floor->m_Texture = sec->GetTexture(sector_t::floor); floor->m_Texture = sec->GetTexture(sector_t::floor);
// jff 1/24/98 make sure floor->m_NewSpecial gets initialized // jff 1/24/98 make sure floor->m_NewSpecial gets initialized
// in case no surrounding sector is at floordestheight // in case no surrounding sector is at floordestheight
@ -460,7 +448,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
//jff 5/23/98 use model subroutine to unify fixes and handling //jff 5/23/98 use model subroutine to unify fixes and handling
sector_t *modelsec; sector_t *modelsec;
modelsec = sec->FindModelFloorSector (newheight); modelsec = sec->FindModelFloorSector(newheight);
if (modelsec != NULL) if (modelsec != NULL)
{ {
floor->m_Texture = modelsec->GetTexture(sector_t::floor); floor->m_Texture = modelsec->GetTexture(sector_t::floor);
@ -475,8 +463,8 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
// Do not interpolate instant movement floors. // Do not interpolate instant movement floors.
bool silent = false; bool silent = false;
if ((floor->m_Direction>0 && floor->m_FloorDestDist>sec->floorplane.fD()) || // moving up but going down if ((floor->m_Direction > 0 && floor->m_FloorDestDist > sec->floorplane.fD()) || // moving up but going down
(floor->m_Direction<0 && floor->m_FloorDestDist<sec->floorplane.fD()) || // moving down but going up (floor->m_Direction < 0 && floor->m_FloorDestDist < sec->floorplane.fD()) || // moving down but going up
(floor->m_Speed >= fabs(sec->floorplane.fD() - floor->m_FloorDestDist))) // moving in one step (floor->m_Speed >= fabs(sec->floorplane.fD() - floor->m_FloorDestDist))) // moving in one step
{ {
floor->StopInterpolation(true); floor->StopInterpolation(true);
@ -486,11 +474,11 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
// switches that activate their own back side. // switches that activate their own back side.
if (!(i_compatflags & COMPATF_SILENT_INSTANT_FLOORS)) if (!(i_compatflags & COMPATF_SILENT_INSTANT_FLOORS))
{ {
if (!line || !(line->activation & (SPAC_Use|SPAC_Push)) || line->backsector!=sec) if (!line || !(line->activation & (SPAC_Use | SPAC_Push)) || line->backsector != sec)
silent = true; silent = true;
} }
} }
if (!silent) floor->StartFloorSound (); if (!silent) floor->StartFloorSound();
if (change & 3) if (change & 3)
{ {
@ -504,20 +492,42 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
floortype == DFloor::floorLowerToLowestCeiling || floortype == DFloor::floorLowerToLowestCeiling ||
floortype == DFloor::floorRaiseToCeiling || floortype == DFloor::floorRaiseToCeiling ||
floortype == DFloor::floorLowerToCeiling) ? floortype == DFloor::floorLowerToCeiling) ?
sec->FindModelCeilingSector (-floor->m_FloorDestDist) : sec->FindModelCeilingSector(-floor->m_FloorDestDist) :
sec->FindModelFloorSector (-floor->m_FloorDestDist); sec->FindModelFloorSector(-floor->m_FloorDestDist);
if (modelsec != NULL) if (modelsec != NULL)
{ {
floor->SetFloorChangeType (modelsec, change); floor->SetFloorChangeType(modelsec, change);
} }
} }
else if (line) else if (line)
{ {
// Trigger model change // Trigger model change
floor->SetFloorChangeType (line->frontsector, change); floor->SetFloorChangeType(line->frontsector, change);
} }
} }
return true;
}
//==========================================================================
//
// HANDLE FLOOR TYPES
// [RH] Added tag, speed, height, crush, change params.
// This functions starts too many different things.
//
//==========================================================================
bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag,
double speed, double height, int crush, int change, bool hexencrush, bool hereticlower)
{
int secnum;
bool rtn = false;
// check if a manual trigger; if so do just the sector on the backside
FSectorTagIterator it(tag, line);
while ((secnum = it.Next()) >= 0)
{
rtn |= P_CreateFloor(&sectors[secnum], floortype, line, speed, height, crush, change, hexencrush, hereticlower);
} }
return rtn; return rtn;
} }

View file

@ -572,10 +572,6 @@ public:
void Serialize (FArchive &arc); void Serialize (FArchive &arc);
void Tick (); void Tick ();
static DCeiling *Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag,
double speed, double speed2, double height,
int crush, int silent, int change, ECrushMode hexencrush);
protected: protected:
ECeiling m_Type; ECeiling m_Type;
double m_BottomHeight; double m_BottomHeight;
@ -601,13 +597,13 @@ protected:
private: private:
DCeiling (); DCeiling ();
friend bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag, double speed, double speed2, double height, int crush, int silent, int change, DCeiling::ECrushMode hexencrush);
friend bool EV_CeilingCrushStop (int tag); friend bool EV_CeilingCrushStop (int tag);
friend void P_ActivateInStasisCeiling (int tag); friend void P_ActivateInStasisCeiling (int tag);
}; };
bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag, double speed, double speed2, double height, int crush, int silent, int change, DCeiling::ECrushMode hexencrush);
int tag, double speed, double speed2, double height, bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, int tag, double speed, double speed2, double height, int crush, int silent, int change, DCeiling::ECrushMode hexencrush = DCeiling::ECrushMode::crushDoom);
int crush, int silent, int change, DCeiling::ECrushMode hexencrush = DCeiling::ECrushMode::crushDoom);
bool EV_CeilingCrushStop (int tag); bool EV_CeilingCrushStop (int tag);
void P_ActivateInStasisCeiling (int tag); void P_ActivateInStasisCeiling (int tag);
@ -711,6 +707,9 @@ private:
DFloor (); DFloor ();
}; };
bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
double speed, double height, int crush, int change, bool hexencrush, bool hereticlower);
bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line, bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line,
double stairsize, double speed, int delay, int reset, int igntxt, double stairsize, double speed, int delay, int reset, int igntxt,
int usespecials); int usespecials);