- changed handling of one-time, one-way door polyobjects to be more efficient.

The old code kept the dead thinker, resulting in constant deletion and recreation of the subsector links and PolyBSP because the interpolation kept running.
Changed it so that the thinker is destroyed and the polyobject gets blocked by setting a new flag.
This commit is contained in:
Christoph Oelckers 2016-04-17 01:24:07 +02:00
parent 7ac0cfbbb9
commit 6a27267500
4 changed files with 24 additions and 7 deletions

View file

@ -540,6 +540,14 @@ void P_SerializePolyobjs (FArchive &arc)
for(i = 0, po = polyobjs; i < po_NumPolyobjs; i++, po++)
{
arc << po->tag << po->Angle << po->StartSpot.pos << po->interpolation;
if (SaveVersion >= 4537)
{
arc << po->bBlocked;
}
else
{
po->bBlocked = false;
}
}
}
else

View file

@ -421,12 +421,13 @@ bool EV_RotatePoly (line_t *line, int polyNum, int speed, int byteAngle,
while ((poly = it.NextMirror()) != NULL)
{
if (poly->specialdata != NULL && !overRide)
if ((poly->specialdata != NULL || poly->bBlocked) && !overRide)
{ // poly is already in motion
break;
}
pe = new DRotatePoly(poly->tag);
poly->specialdata = pe;
poly->bBlocked = false;
if (byteAngle != 0)
{
if (byteAngle == 255)
@ -501,12 +502,13 @@ bool EV_MovePoly (line_t *line, int polyNum, double speed, DAngle angle,
while ((poly = it.NextMirror()) != NULL)
{
if (poly->specialdata != NULL && !overRide)
if ((poly->specialdata != NULL || poly->bBlocked) && !overRide)
{ // poly is already in motion
break;
}
pe = new DMovePoly(poly->tag);
poly->specialdata = pe;
poly->bBlocked = false;
pe->m_Dist = dist; // Distance
pe->m_Speed = speed;
pe->m_Angle = angle;
@ -581,12 +583,13 @@ bool EV_MovePolyTo(line_t *line, int polyNum, double speed, const DVector2 &targ
distlen = dist.MakeUnit();
while ((poly = it.NextMirror()) != NULL)
{
if (poly->specialdata != NULL && !overRide)
if ((poly->specialdata != NULL || poly->bBlocked) && !overRide)
{ // poly is already in motion
break;
}
pe = new DMovePolyTo(poly->tag);
poly->specialdata = pe;
poly->bBlocked = false;
pe->m_Dist = distlen;
pe->m_Speed = speed;
pe->m_Speedv = dist * speed;
@ -630,7 +633,7 @@ void DPolyDoor::Tick ()
if (m_Dist <= 0)
{
SN_StopSequence (poly);
if (!m_Close)
if (!m_Close && m_WaitTics >= 0)
{
m_Dist = m_TotalDist;
m_Close = true;
@ -640,6 +643,9 @@ void DPolyDoor::Tick ()
}
else
{
// if set to wait infinitely, Hexen kept the dead thinker to block the polyobject from getting activated again but that causes some problems
// with the subsectorlinks and the interpolation. Better delete the thinker and use a different means to block it.
if (!m_Close) poly->bBlocked = true;
Destroy ();
}
}
@ -669,7 +675,7 @@ void DPolyDoor::Tick ()
if (m_Dist <= 0)
{
SN_StopSequence (poly);
if (!m_Close)
if (!m_Close && m_WaitTics >= 0)
{
m_Dist = m_TotalDist;
m_Close = true;
@ -678,6 +684,7 @@ void DPolyDoor::Tick ()
}
else
{
if (!m_Close) poly->bBlocked = true;
Destroy ();
}
}
@ -724,7 +731,7 @@ bool EV_OpenPolyDoor(line_t *line, int polyNum, double speed, DAngle angle, int
while ((poly = it.NextMirror()) != NULL)
{
if (poly->specialdata != NULL)
if ((poly->specialdata != NULL || poly->bBlocked))
{ // poly is already moving
break;
}
@ -815,6 +822,7 @@ FPolyObj::FPolyObj()
bHurtOnTouch = false;
seqType = 0;
Size = 0;
bBlocked = false;
subsectorlinks = NULL;
specialdata = NULL;
interpolation = NULL;

View file

@ -62,6 +62,7 @@ struct FPolyObj
int validcount;
int crush; // should the polyobj attempt to crush mobjs?
bool bHurtOnTouch; // should the polyobj hurt anything it touches?
bool bBlocked;
int seqType;
double Size; // polyobj size (area of POLY_AREAUNIT == size of FRACUNIT)
FPolyNode *subsectorlinks;

View file

@ -76,7 +76,7 @@ const char *GetVersionString();
// Use 4500 as the base git save version, since it's higher than the
// SVN revision ever got.
#define SAVEVER 4536
#define SAVEVER 4537
#define SAVEVERSTRINGIFY2(x) #x
#define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x)