From 2d5061e81f91807ebe054790719c1ce8be7fb482 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 28 Sep 2016 11:58:12 +0200 Subject: [PATCH] - fixed: DScroller did not initialize m_LastHeight in all situations. This caused a problem with the serializer because RapidJSON aborts the write of a floating point value if it is invalid. - ensure that floats are always written out. If the actual value causes an error (i.e. INF or NaN), write a 0 to guarantee proper formatting. --- src/p_scroll.cpp | 2 ++ src/serializer.cpp | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/p_scroll.cpp b/src/p_scroll.cpp index 2c7333a21..f2ece8b3d 100644 --- a/src/p_scroll.cpp +++ b/src/p_scroll.cpp @@ -259,6 +259,7 @@ DScroller::DScroller (EScroll type, double dx, double dy, m_Accel = accel; m_Parts = scrollpos; m_vdx = m_vdy = 0; + m_LastHeight = 0; if ((m_Control = control) != -1) m_LastHeight = sectors[control].CenterFloor () + sectors[control].CenterCeiling (); @@ -342,6 +343,7 @@ DScroller::DScroller (double dx, double dy, const line_t *l, m_vdx = m_vdy = 0; m_Accel = accel; m_Parts = scrollpos; + m_LastHeight = 0; if ((m_Control = control) != -1) m_LastHeight = sectors[control].CenterFloor() + sectors[control].CenterCeiling(); m_Affectee = int(l->sidedef[0] - sides); diff --git a/src/serializer.cpp b/src/serializer.cpp index 445a3b22b..47e096b7b 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -215,8 +215,14 @@ struct FWriter void Double(double k) { - if (mWriter1) mWriter1->Double(k); - else if (mWriter2) mWriter2->Double(k); + if (mWriter1) + { + if (!mWriter1->Double(k)) mWriter1->Double(0); + } + else if (mWriter2) + { + if (!mWriter2->Double(k)) mWriter2->Double(0); + } } };