From 6a27267500c8b9017cf8454f9e6ed055700ac3bb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Apr 2016 01:24:07 +0200 Subject: [PATCH] - 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. --- src/p_saveg.cpp | 8 ++++++++ src/po_man.cpp | 20 ++++++++++++++------ src/po_man.h | 1 + src/version.h | 2 +- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 38122b977..050e4ae76 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -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 diff --git a/src/po_man.cpp b/src/po_man.cpp index b6921b0d4..f2029026d 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -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; diff --git a/src/po_man.h b/src/po_man.h index 2fbc433cf..2b9c8afef 100644 --- a/src/po_man.h +++ b/src/po_man.h @@ -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; diff --git a/src/version.h b/src/version.h index 3a79f24c7..a824525c9 100644 --- a/src/version.h +++ b/src/version.h @@ -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)