mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 13:01:47 +00:00
- 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:
parent
caae61de4c
commit
bc7e159be0
5 changed files with 287 additions and 318 deletions
|
@ -26,6 +26,7 @@ class DMover : public DSectorEffect
|
|||
HAS_OBJECT_POINTERS
|
||||
public:
|
||||
DMover (sector_t *sector);
|
||||
void StopInterpolation(bool force = false);
|
||||
protected:
|
||||
TObjPtr<DInterpolation> interpolation;
|
||||
private:
|
||||
|
@ -33,7 +34,6 @@ protected:
|
|||
DMover ();
|
||||
void Serialize (FArchive &arc);
|
||||
void Destroy();
|
||||
void StopInterpolation(bool force = false);
|
||||
};
|
||||
|
||||
class DMovingFloor : public DMover
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
int secnum = -1;
|
||||
sector_t *sec;
|
||||
int tagnum, crush;
|
||||
double platspeed = 1, destheight;
|
||||
|
||||
|
@ -1650,12 +1620,7 @@ void FParser::SF_MoveFloor(void)
|
|||
FSSectorTagIterator itr(tagnum);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sec = §ors[secnum];
|
||||
// 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);
|
||||
P_CreateFloor(§ors[secnum], DFloor::floorMoveToValue, NULL, platspeed, destheight, crush, 0, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1729,7 +1694,6 @@ void FParser::SF_CeilingHeight(void)
|
|||
void FParser::SF_MoveCeiling(void)
|
||||
{
|
||||
int secnum = -1;
|
||||
sector_t *sec;
|
||||
int tagnum;
|
||||
double platspeed = 1, destheight;
|
||||
int crush;
|
||||
|
@ -1747,11 +1711,7 @@ void FParser::SF_MoveCeiling(void)
|
|||
FSSectorTagIterator itr(tagnum);
|
||||
while ((secnum = itr.Next()) >= 0)
|
||||
{
|
||||
sec = §ors[secnum];
|
||||
|
||||
// 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);
|
||||
P_CreateCeiling(§ors[secnum], DCeiling::ceilMoveToValue, NULL, tagnum, platspeed, platspeed, destheight, crush, silent | 4, 0, DCeiling::ECrushMode::crushDoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ void DCeiling::Tick ()
|
|||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
case ceilCrushAndRaise:
|
||||
case DCeiling::ceilCrushAndRaise:
|
||||
m_Direction = -1;
|
||||
m_Speed = m_Speed1;
|
||||
if (!SN_IsMakingLoopingSound (m_Sector))
|
||||
|
@ -173,8 +173,8 @@ void DCeiling::Tick ()
|
|||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
case ceilCrushAndRaise:
|
||||
case ceilCrushRaiseAndStay:
|
||||
case DCeiling::ceilCrushAndRaise:
|
||||
case DCeiling::ceilCrushRaiseAndStay:
|
||||
m_Speed = m_Speed2;
|
||||
m_Direction = 1;
|
||||
if (!SN_IsMakingLoopingSound (m_Sector))
|
||||
|
@ -202,8 +202,8 @@ void DCeiling::Tick ()
|
|||
{
|
||||
switch (m_Type)
|
||||
{
|
||||
case ceilCrushAndRaise:
|
||||
case ceilLowerAndCrush:
|
||||
case DCeiling::ceilCrushAndRaise:
|
||||
case DCeiling::ceilLowerAndCrush:
|
||||
if (m_CrushMode == ECrushMode::crushSlowdown)
|
||||
m_Speed = 1. / 8;
|
||||
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,
|
||||
int crush, int silent, int change, ECrushMode hexencrush)
|
||||
int crush, int silent, int change, DCeiling::ECrushMode hexencrush)
|
||||
{
|
||||
double targheight = 0; // Silence, GCC
|
||||
|
||||
|
@ -262,35 +262,35 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
|
|||
|
||||
switch (type)
|
||||
{
|
||||
case ceilCrushAndRaise:
|
||||
case ceilCrushRaiseAndStay:
|
||||
case DCeiling::ceilCrushAndRaise:
|
||||
case DCeiling::ceilCrushRaiseAndStay:
|
||||
ceiling->m_TopHeight = sec->ceilingplane.fD();
|
||||
case ceilLowerAndCrush:
|
||||
case DCeiling::ceilLowerAndCrush:
|
||||
targheight = sec->FindHighestFloorPoint (&spot);
|
||||
targheight += height;
|
||||
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = -1;
|
||||
break;
|
||||
|
||||
case ceilRaiseToHighest:
|
||||
case DCeiling::ceilRaiseToHighest:
|
||||
targheight = sec->FindHighestCeilingSurrounding (&spot);
|
||||
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = 1;
|
||||
break;
|
||||
|
||||
case ceilLowerByValue:
|
||||
case DCeiling::ceilLowerByValue:
|
||||
targheight = sec->ceilingplane.ZatPoint (spot) - height;
|
||||
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = -1;
|
||||
break;
|
||||
|
||||
case ceilRaiseByValue:
|
||||
case DCeiling::ceilRaiseByValue:
|
||||
targheight = sec->ceilingplane.ZatPoint (spot) + height;
|
||||
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = 1;
|
||||
break;
|
||||
|
||||
case ceilMoveToValue:
|
||||
case DCeiling::ceilMoveToValue:
|
||||
{
|
||||
double diff = height - sec->ceilingplane.ZatPoint (spot);
|
||||
|
||||
|
@ -308,81 +308,81 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
|
|||
}
|
||||
break;
|
||||
|
||||
case ceilLowerToHighestFloor:
|
||||
case DCeiling::ceilLowerToHighestFloor:
|
||||
targheight = sec->FindHighestFloorSurrounding (&spot);
|
||||
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = -1;
|
||||
break;
|
||||
|
||||
case ceilRaiseToHighestFloor:
|
||||
case DCeiling::ceilRaiseToHighestFloor:
|
||||
targheight = sec->FindHighestFloorSurrounding (&spot);
|
||||
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = 1;
|
||||
break;
|
||||
|
||||
case ceilLowerInstant:
|
||||
case DCeiling::ceilLowerInstant:
|
||||
targheight = sec->ceilingplane.ZatPoint (spot) - height;
|
||||
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = -1;
|
||||
ceiling->m_Speed = height;
|
||||
break;
|
||||
|
||||
case ceilRaiseInstant:
|
||||
case DCeiling::ceilRaiseInstant:
|
||||
targheight = sec->ceilingplane.ZatPoint (spot) + height;
|
||||
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = 1;
|
||||
ceiling->m_Speed = height;
|
||||
break;
|
||||
|
||||
case ceilLowerToNearest:
|
||||
case DCeiling::ceilLowerToNearest:
|
||||
targheight = sec->FindNextLowestCeiling (&spot);
|
||||
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = -1;
|
||||
break;
|
||||
|
||||
case ceilRaiseToNearest:
|
||||
case DCeiling::ceilRaiseToNearest:
|
||||
targheight = sec->FindNextHighestCeiling (&spot);
|
||||
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = 1;
|
||||
break;
|
||||
|
||||
case ceilLowerToLowest:
|
||||
case DCeiling::ceilLowerToLowest:
|
||||
targheight = sec->FindLowestCeilingSurrounding (&spot);
|
||||
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = -1;
|
||||
break;
|
||||
|
||||
case ceilRaiseToLowest:
|
||||
case DCeiling::ceilRaiseToLowest:
|
||||
targheight = sec->FindLowestCeilingSurrounding (&spot);
|
||||
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = 1;
|
||||
break;
|
||||
|
||||
case ceilLowerToFloor:
|
||||
case DCeiling::ceilLowerToFloor:
|
||||
targheight = sec->FindHighestFloorPoint (&spot);
|
||||
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = -1;
|
||||
break;
|
||||
|
||||
case ceilRaiseToFloor: // [RH] What's this for?
|
||||
case DCeiling::ceilRaiseToFloor: // [RH] What's this for?
|
||||
targheight = sec->FindHighestFloorPoint (&spot);
|
||||
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = 1;
|
||||
break;
|
||||
|
||||
case ceilLowerToHighest:
|
||||
case DCeiling::ceilLowerToHighest:
|
||||
targheight = sec->FindHighestCeilingSurrounding (&spot);
|
||||
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = -1;
|
||||
break;
|
||||
|
||||
case ceilLowerByTexture:
|
||||
case DCeiling::ceilLowerByTexture:
|
||||
targheight = sec->ceilingplane.ZatPoint (spot) - sec->FindShortestUpperAround ();
|
||||
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
ceiling->m_Direction = -1;
|
||||
break;
|
||||
|
||||
case ceilRaiseByTexture:
|
||||
case DCeiling::ceilRaiseByTexture:
|
||||
targheight = sec->ceilingplane.ZatPoint (spot) + sec->FindShortestUpperAround ();
|
||||
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
|
||||
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
|
||||
//is a floor type
|
||||
modelsec = (/*type == ceilRaiseToHighest ||*/
|
||||
type == ceilRaiseToFloor ||
|
||||
type == DCeiling::ceilRaiseToFloor ||
|
||||
/*type == ceilLowerToHighest ||*/
|
||||
type == ceilLowerToFloor) ?
|
||||
type == DCeiling::ceilLowerToFloor) ?
|
||||
sec->FindModelFloorSector (targheight) :
|
||||
sec->FindModelCeilingSector (targheight);
|
||||
if (modelsec != NULL)
|
||||
|
@ -438,14 +438,14 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
|
|||
{
|
||||
case 1: // type is zeroed
|
||||
ceiling->m_NewSpecial.Clear();
|
||||
ceiling->m_Type = genCeilingChg0;
|
||||
ceiling->m_Type = DCeiling::genCeilingChg0;
|
||||
break;
|
||||
case 2: // type is copied
|
||||
sec->GetSpecial(&ceiling->m_NewSpecial);
|
||||
ceiling->m_Type = genCeilingChgT;
|
||||
ceiling->m_Type = DCeiling::genCeilingChgT;
|
||||
break;
|
||||
case 3: // type is left alone
|
||||
ceiling->m_Type = genCeilingChg;
|
||||
ceiling->m_Type = DCeiling::genCeilingChg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -457,21 +457,21 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line,
|
|||
{
|
||||
case 1: // type is zeroed
|
||||
ceiling->m_NewSpecial.Clear();
|
||||
ceiling->m_Type = genCeilingChg0;
|
||||
ceiling->m_Type = DCeiling::genCeilingChg0;
|
||||
break;
|
||||
case 2: // type is copied
|
||||
line->frontsector->GetSpecial(&ceiling->m_NewSpecial);
|
||||
ceiling->m_Type = genCeilingChgT;
|
||||
ceiling->m_Type = DCeiling::genCeilingChgT;
|
||||
break;
|
||||
case 3: // type is left alone
|
||||
ceiling->m_Type = genCeilingChg;
|
||||
ceiling->m_Type = DCeiling::genCeilingChg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
tag ^= secnum | 0x1000000;
|
||||
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.
|
||||
|
@ -516,7 +516,7 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line,
|
|||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
{
|
||||
rtn |= !!DCeiling::Create(§ors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush);
|
||||
rtn |= P_CreateCeiling(§ors[secnum], type, line, tag, speed, speed2, height, crush, silent, change, hexencrush);
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
|
470
src/p_floor.cpp
470
src/p_floor.cpp
|
@ -271,6 +271,244 @@ DFloor::DFloor (sector_t *sec)
|
|||
{
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
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 rtn;
|
||||
DFloor* floor;
|
||||
double ceilingheight;
|
||||
double newheight;
|
||||
vertex_t *spot, *spot2;
|
||||
|
||||
// ALREADY MOVING? IF SO, KEEP GOING...
|
||||
if (sec->PlaneMoving(sector_t::floor))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// new floor thinker
|
||||
rtn = true;
|
||||
floor = new DFloor(sec);
|
||||
floor->m_Type = floortype;
|
||||
floor->m_Crush = crush;
|
||||
floor->m_Hexencrush = hexencrush;
|
||||
floor->m_Speed = speed;
|
||||
floor->m_ResetCount = 0; // [RH]
|
||||
floor->m_OrgDist = sec->floorplane.fD(); // [RH]
|
||||
|
||||
switch (floortype)
|
||||
{
|
||||
case DFloor::floorLowerToHighest:
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->FindHighestFloorSurrounding(&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
|
||||
// [RH] DOOM's turboLower type did this. I've just extended it
|
||||
// to be applicable to all LowerToHighest types.
|
||||
if (hereticlower || floor->m_FloorDestDist != sec->floorplane.fD())
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight + height);
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerToLowest:
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->FindLowestFloorSurrounding(&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerToNearest:
|
||||
//jff 02/03/30 support lowering floor to next lowest floor
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->FindNextLowestFloor(&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerInstant:
|
||||
floor->m_Speed = height;
|
||||
case DFloor::floorLowerByValue:
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->CenterFloor() - height;
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseInstant:
|
||||
floor->m_Speed = height;
|
||||
case DFloor::floorRaiseByValue:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->CenterFloor() + height;
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorMoveToValue:
|
||||
sec->FindHighestFloorPoint(&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, height);
|
||||
floor->m_Direction = (floor->m_FloorDestDist > sec->floorplane.fD()) ? -1 : 1;
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseAndCrushDoom:
|
||||
case DFloor::floorRaiseToLowestCeiling:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->FindLowestCeilingSurrounding(&spot);
|
||||
if (floortype == DFloor::floorRaiseAndCrushDoom)
|
||||
newheight -= 8;
|
||||
ceilingheight = sec->FindLowestCeilingPoint(&spot2);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
|
||||
if (sec->floorplane.ZatPointDist(spot2, floor->m_FloorDestDist) > ceilingheight)
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot2,
|
||||
floortype == DFloor::floorRaiseAndCrushDoom ? ceilingheight - 8 : ceilingheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseToHighest:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->FindHighestFloorSurrounding(&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseToNearest:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->FindNextHighestFloor(&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseToLowest:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->FindLowestFloorSurrounding(&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseAndCrush:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->FindLowestCeilingPoint(&spot) - 8;
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseToCeiling:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->FindLowestCeilingPoint(&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerToLowestCeiling:
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->FindLowestCeilingSurrounding(&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerByTexture:
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->CenterFloor() - sec->FindShortestTextureAround();
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerToCeiling:
|
||||
// [RH] Essentially instantly raises the floor to the ceiling
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->FindLowestCeilingPoint(&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseByTexture:
|
||||
floor->m_Direction = 1;
|
||||
// [RH] Use P_FindShortestTextureAround from BOOM to do this
|
||||
// since the code is identical to what was here. (Oddly
|
||||
// enough, BOOM preserved the code here even though it
|
||||
// also had this function.)
|
||||
newheight = sec->CenterFloor() + sec->FindShortestTextureAround();
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseAndChange:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->CenterFloor() + height;
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight);
|
||||
if (line != NULL)
|
||||
{
|
||||
FTextureID oldpic = sec->GetTexture(sector_t::floor);
|
||||
sec->SetTexture(sector_t::floor, line->frontsector->GetTexture(sector_t::floor));
|
||||
sec->TransferSpecial(line->frontsector);
|
||||
}
|
||||
else
|
||||
{
|
||||
sec->ClearSpecial();
|
||||
}
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerAndChange:
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->FindLowestFloorSurrounding(&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
|
||||
floor->m_Texture = sec->GetTexture(sector_t::floor);
|
||||
// jff 1/24/98 make sure floor->m_NewSpecial gets initialized
|
||||
// in case no surrounding sector is at floordestheight
|
||||
sec->GetSpecial(&floor->m_NewSpecial);
|
||||
|
||||
//jff 5/23/98 use model subroutine to unify fixes and handling
|
||||
sector_t *modelsec;
|
||||
modelsec = sec->FindModelFloorSector(newheight);
|
||||
if (modelsec != NULL)
|
||||
{
|
||||
floor->m_Texture = modelsec->GetTexture(sector_t::floor);
|
||||
modelsec->GetSpecial(&floor->m_NewSpecial);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Do not interpolate instant movement floors.
|
||||
bool silent = false;
|
||||
|
||||
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_Speed >= fabs(sec->floorplane.fD() - floor->m_FloorDestDist))) // moving in one step
|
||||
{
|
||||
floor->StopInterpolation(true);
|
||||
|
||||
// [Graf Zahl]
|
||||
// Don't make sounds for instant movement hacks but make an exception for
|
||||
// switches that activate their own back side.
|
||||
if (!(i_compatflags & COMPATF_SILENT_INSTANT_FLOORS))
|
||||
{
|
||||
if (!line || !(line->activation & (SPAC_Use | SPAC_Push)) || line->backsector != sec)
|
||||
silent = true;
|
||||
}
|
||||
}
|
||||
if (!silent) floor->StartFloorSound();
|
||||
|
||||
if (change & 3)
|
||||
{
|
||||
// [RH] Need to do some transferring
|
||||
if (change & 4)
|
||||
{
|
||||
// Numeric model change
|
||||
sector_t *modelsec;
|
||||
|
||||
modelsec = (floortype == DFloor::floorRaiseToLowestCeiling ||
|
||||
floortype == DFloor::floorLowerToLowestCeiling ||
|
||||
floortype == DFloor::floorRaiseToCeiling ||
|
||||
floortype == DFloor::floorLowerToCeiling) ?
|
||||
sec->FindModelCeilingSector(-floor->m_FloorDestDist) :
|
||||
sec->FindModelFloorSector(-floor->m_FloorDestDist);
|
||||
|
||||
if (modelsec != NULL)
|
||||
{
|
||||
floor->SetFloorChangeType(modelsec, change);
|
||||
}
|
||||
}
|
||||
else if (line)
|
||||
{
|
||||
// Trigger model change
|
||||
floor->SetFloorChangeType(line->frontsector, change);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// HANDLE FLOOR TYPES
|
||||
|
@ -283,241 +521,13 @@ 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;
|
||||
sector_t* sec;
|
||||
DFloor* floor;
|
||||
double ceilingheight;
|
||||
double newheight;
|
||||
vertex_t *spot, *spot2;
|
||||
|
||||
rtn = false;
|
||||
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)
|
||||
{
|
||||
sec = §ors[secnum];
|
||||
// ALREADY MOVING? IF SO, KEEP GOING...
|
||||
if (sec->PlaneMoving(sector_t::floor))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// new floor thinker
|
||||
rtn = true;
|
||||
floor = new DFloor (sec);
|
||||
floor->m_Type = floortype;
|
||||
floor->m_Crush = crush;
|
||||
floor->m_Hexencrush = hexencrush;
|
||||
floor->m_Speed = speed;
|
||||
floor->m_ResetCount = 0; // [RH]
|
||||
floor->m_OrgDist = sec->floorplane.fD(); // [RH]
|
||||
|
||||
switch (floortype)
|
||||
{
|
||||
case DFloor::floorLowerToHighest:
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->FindHighestFloorSurrounding (&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
|
||||
// [RH] DOOM's turboLower type did this. I've just extended it
|
||||
// to be applicable to all LowerToHighest types.
|
||||
if (hereticlower || floor->m_FloorDestDist != sec->floorplane.fD())
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight+height);
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerToLowest:
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->FindLowestFloorSurrounding (&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerToNearest:
|
||||
//jff 02/03/30 support lowering floor to next lowest floor
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->FindNextLowestFloor (&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerInstant:
|
||||
floor->m_Speed = height;
|
||||
case DFloor::floorLowerByValue:
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->CenterFloor() - height;
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseInstant:
|
||||
floor->m_Speed = height;
|
||||
case DFloor::floorRaiseByValue:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->CenterFloor() + height;
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorMoveToValue:
|
||||
sec->FindHighestFloorPoint (&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, height);
|
||||
floor->m_Direction = (floor->m_FloorDestDist > sec->floorplane.fD()) ? -1 : 1;
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseAndCrushDoom:
|
||||
case DFloor::floorRaiseToLowestCeiling:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->FindLowestCeilingSurrounding (&spot);
|
||||
if (floortype == DFloor::floorRaiseAndCrushDoom)
|
||||
newheight -= 8;
|
||||
ceilingheight = sec->FindLowestCeilingPoint (&spot2);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
|
||||
if (sec->floorplane.ZatPointDist (spot2, floor->m_FloorDestDist) > ceilingheight)
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot2,
|
||||
floortype == DFloor::floorRaiseAndCrushDoom ? ceilingheight - 8 : ceilingheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseToHighest:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->FindHighestFloorSurrounding (&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseToNearest:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->FindNextHighestFloor (&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseToLowest:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->FindLowestFloorSurrounding (&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseAndCrush:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->FindLowestCeilingPoint (&spot) - 8;
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseToCeiling:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->FindLowestCeilingPoint (&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerToLowestCeiling:
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->FindLowestCeilingSurrounding (&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerByTexture:
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->CenterFloor() - sec->FindShortestTextureAround ();
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerToCeiling:
|
||||
// [RH] Essentially instantly raises the floor to the ceiling
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->FindLowestCeilingPoint (&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseByTexture:
|
||||
floor->m_Direction = 1;
|
||||
// [RH] Use P_FindShortestTextureAround from BOOM to do this
|
||||
// since the code is identical to what was here. (Oddly
|
||||
// enough, BOOM preserved the code here even though it
|
||||
// also had this function.)
|
||||
newheight = sec->CenterFloor() + sec->FindShortestTextureAround ();
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight);
|
||||
break;
|
||||
|
||||
case DFloor::floorRaiseAndChange:
|
||||
floor->m_Direction = 1;
|
||||
newheight = sec->CenterFloor() + height;
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight);
|
||||
if (line != NULL)
|
||||
{
|
||||
FTextureID oldpic = sec->GetTexture(sector_t::floor);
|
||||
sec->SetTexture(sector_t::floor, line->frontsector->GetTexture(sector_t::floor));
|
||||
sec->TransferSpecial(line->frontsector);
|
||||
}
|
||||
else
|
||||
{
|
||||
sec->ClearSpecial();
|
||||
}
|
||||
break;
|
||||
|
||||
case DFloor::floorLowerAndChange:
|
||||
floor->m_Direction = -1;
|
||||
newheight = sec->FindLowestFloorSurrounding (&spot);
|
||||
floor->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
|
||||
floor->m_Texture = sec->GetTexture(sector_t::floor);
|
||||
// jff 1/24/98 make sure floor->m_NewSpecial gets initialized
|
||||
// in case no surrounding sector is at floordestheight
|
||||
sec->GetSpecial(&floor->m_NewSpecial);
|
||||
|
||||
//jff 5/23/98 use model subroutine to unify fixes and handling
|
||||
sector_t *modelsec;
|
||||
modelsec = sec->FindModelFloorSector (newheight);
|
||||
if (modelsec != NULL)
|
||||
{
|
||||
floor->m_Texture = modelsec->GetTexture(sector_t::floor);
|
||||
modelsec->GetSpecial(&floor->m_NewSpecial);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Do not interpolate instant movement floors.
|
||||
bool silent = false;
|
||||
|
||||
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_Speed >= fabs(sec->floorplane.fD() - floor->m_FloorDestDist))) // moving in one step
|
||||
{
|
||||
floor->StopInterpolation(true);
|
||||
|
||||
// [Graf Zahl]
|
||||
// Don't make sounds for instant movement hacks but make an exception for
|
||||
// switches that activate their own back side.
|
||||
if (!(i_compatflags & COMPATF_SILENT_INSTANT_FLOORS))
|
||||
{
|
||||
if (!line || !(line->activation & (SPAC_Use|SPAC_Push)) || line->backsector!=sec)
|
||||
silent = true;
|
||||
}
|
||||
}
|
||||
if (!silent) floor->StartFloorSound ();
|
||||
|
||||
if (change & 3)
|
||||
{
|
||||
// [RH] Need to do some transferring
|
||||
if (change & 4)
|
||||
{
|
||||
// Numeric model change
|
||||
sector_t *modelsec;
|
||||
|
||||
modelsec = (floortype == DFloor::floorRaiseToLowestCeiling ||
|
||||
floortype == DFloor::floorLowerToLowestCeiling ||
|
||||
floortype == DFloor::floorRaiseToCeiling ||
|
||||
floortype == DFloor::floorLowerToCeiling) ?
|
||||
sec->FindModelCeilingSector (-floor->m_FloorDestDist) :
|
||||
sec->FindModelFloorSector (-floor->m_FloorDestDist);
|
||||
|
||||
if (modelsec != NULL)
|
||||
{
|
||||
floor->SetFloorChangeType (modelsec, change);
|
||||
}
|
||||
}
|
||||
else if (line)
|
||||
{
|
||||
// Trigger model change
|
||||
floor->SetFloorChangeType (line->frontsector, change);
|
||||
}
|
||||
}
|
||||
rtn |= P_CreateFloor(§ors[secnum], floortype, line, speed, height, crush, change, hexencrush, hereticlower);
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
|
13
src/p_spec.h
13
src/p_spec.h
|
@ -572,10 +572,6 @@ public:
|
|||
void Serialize (FArchive &arc);
|
||||
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:
|
||||
ECeiling m_Type;
|
||||
double m_BottomHeight;
|
||||
|
@ -601,13 +597,13 @@ protected:
|
|||
private:
|
||||
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 void P_ActivateInStasisCeiling (int tag);
|
||||
};
|
||||
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
|
||||
bool EV_CeilingCrushStop (int tag);
|
||||
void P_ActivateInStasisCeiling (int tag);
|
||||
|
@ -711,6 +707,9 @@ private:
|
|||
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,
|
||||
double stairsize, double speed, int delay, int reset, int igntxt,
|
||||
int usespecials);
|
||||
|
|
Loading…
Reference in a new issue