From 49930185206141a5d0219ebbbf405cae88c82f0e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 31 Aug 2016 09:18:59 +0200 Subject: [PATCH] - fixed: Actor velocity requires an upper limit to prevent uncontrolled accumulation, as can happen when multiple exploding and pushable objects overlap. The value 5000 was chosen because it is high enough to not occur under regular circumstances and small enough to prevent severe slowdowns. In the old fixed point code the lack of such a check just caused random overflows. --- src/p_mobj.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 8971efe25..f5791d079 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1806,6 +1806,11 @@ double P_XYMovement (AActor *mo, DVector2 scroll) mo->Vel.X *= fac; mo->Vel.Y *= fac; } + const double VELOCITY_THRESHOLD = 5000; // don't let it move faster than this. Fixed point overflowed at 32768 but that's too much to make this safe. + if (mo->Vel.LengthSquared() >= VELOCITY_THRESHOLD*VELOCITY_THRESHOLD) + { + mo->Vel.MakeResize(VELOCITY_THRESHOLD); + } move = mo->Vel; // [RH] Carrying sectors didn't work with low speeds in BOOM. This is // because BOOM relied on the speed being fast enough to accumulate