From c6dd658aa861c9fc2bfe794a94e835af8d5c8d98 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Thu, 6 Jun 2013 20:08:56 +0000 Subject: [PATCH] - Fixed: Polyobjs that rotated faster than their distance would overshoot on their first tic and continue spinning until the next time around because the check for moving too fast was only done after the polyobject had been rotated once. - Reduced the potential for overflow when setting up the speed of a rotating polyobj. SVN r4332 (trunk) --- src/po_man.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/po_man.cpp b/src/po_man.cpp index 1464f3ee5..289e06016 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -382,24 +382,24 @@ void DRotatePoly::Tick () FPolyObj *poly = PO_GetPolyobj (m_PolyObj); if (poly == NULL) return; + // Don't let non-perpetual polyobjs overshoot their targets. + if (m_Dist != -1 && (unsigned int)m_Dist < (unsigned int)abs(m_Speed)) + { + m_Speed = m_Speed < 0 ? -m_Dist : m_Dist; + } + if (poly->RotatePolyobj (m_Speed)) { - unsigned int absSpeed = abs (m_Speed); - if (m_Dist == -1) { // perpetual polyobj return; } - m_Dist -= absSpeed; + m_Dist -= abs(m_Speed); if (m_Dist == 0) { SN_StopSequence (poly); Destroy (); } - else if ((unsigned int)m_Dist < absSpeed) - { - m_Speed = m_Dist * (m_Speed < 0 ? -1 : 1); - } } } @@ -446,7 +446,7 @@ bool EV_RotatePoly (line_t *line, int polyNum, int speed, int byteAngle, { pe->m_Dist = ANGLE_MAX-1; } - pe->m_Speed = (speed*direction*(ANGLE_90/64))>>3; + pe->m_Speed = speed*direction*(ANGLE_90/(64<<3)); SN_StartSequence (poly, poly->seqType, SEQ_DOOR, 0); direction = -direction; // Reverse the direction }