From 2318db0b1a6d0aad0215792f60b8e1456b531e7f Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <c.oelckers@zdoom.fake>
Date: Fri, 23 Sep 2016 22:03:44 +0200
Subject: [PATCH] - let DWaggleBase use the interpolation pointer of its parent
 instead of defining its own one. - do not call checking code for loading
 savegames when writing them in ACS module serializer.

---
 src/p_acs.cpp   |  9 ++++++---
 src/p_floor.cpp | 16 ++++------------
 src/p_spec.h    |  1 -
 3 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/src/p_acs.cpp b/src/p_acs.cpp
index 3bd7218b3..fefe5cd8f 100644
--- a/src/p_acs.cpp
+++ b/src/p_acs.cpp
@@ -1614,10 +1614,13 @@ void FBehavior::StaticSerializeModuleStates (FSerializer &arc)
 
 	if (arc.BeginArray("acsmodules"))
 	{
-		int modnum = arc.ArraySize();
-		if (modnum != StaticModules.Size())
+		if (arc.isReading())
 		{
-			I_Error("Level was saved with a different number of ACS modules. (Have %d, save has %d)", StaticModules.Size(), modnum);
+			int modnum = arc.ArraySize();
+			if (modnum != StaticModules.Size())
+			{
+				I_Error("Level was saved with a different number of ACS modules. (Have %d, save has %d)", StaticModules.Size(), modnum);
+			}
 		}
 
 		for (modnum = 0; modnum < StaticModules.Size(); ++modnum)
diff --git a/src/p_floor.cpp b/src/p_floor.cpp
index db4887ab8..8d09ea2d5 100644
--- a/src/p_floor.cpp
+++ b/src/p_floor.cpp
@@ -1103,9 +1103,7 @@ bool EV_DoChange (line_t *line, EChange changetype, int tag)
 //
 //==========================================================================
 
-IMPLEMENT_POINTY_CLASS (DWaggleBase)
-	DECLARE_POINTER(m_Interpolation)
-END_POINTERS
+IMPLEMENT_CLASS (DWaggleBase)
 
 IMPLEMENT_CLASS (DFloorWaggle)
 IMPLEMENT_CLASS (DCeilingWaggle)
@@ -1124,8 +1122,7 @@ void DWaggleBase::Serialize(FSerializer &arc)
 		("scale", m_Scale)
 		("scaledelta", m_ScaleDelta)
 		("ticker", m_Ticker)
-		("state", m_State)
-		("interpolation", m_Interpolation);
+		("state", m_State);
 }
 
 //==========================================================================
@@ -1145,11 +1142,6 @@ DWaggleBase::DWaggleBase (sector_t *sec)
 
 void DWaggleBase::Destroy()
 {
-	if (m_Interpolation != NULL)
-	{
-		m_Interpolation->DelRef();
-		m_Interpolation = NULL;
-	}
 	Super::Destroy();
 }
 
@@ -1244,7 +1236,7 @@ DFloorWaggle::DFloorWaggle (sector_t *sec)
 	: Super (sec)
 {
 	sec->floordata = this;
-	m_Interpolation = sec->SetInterpolation(sector_t::FloorMove, true);
+	interpolation = sec->SetInterpolation(sector_t::FloorMove, true);
 }
 
 void DFloorWaggle::Tick ()
@@ -1266,7 +1258,7 @@ DCeilingWaggle::DCeilingWaggle (sector_t *sec)
 	: Super (sec)
 {
 	sec->ceilingdata = this;
-	m_Interpolation = sec->SetInterpolation(sector_t::CeilingMove, true);
+	interpolation = sec->SetInterpolation(sector_t::CeilingMove, true);
 }
 
 void DCeilingWaggle::Tick ()
diff --git a/src/p_spec.h b/src/p_spec.h
index 23237bb15..41d47c721 100644
--- a/src/p_spec.h
+++ b/src/p_spec.h
@@ -612,7 +612,6 @@ protected:
 	double m_ScaleDelta;
 	int m_Ticker;
 	int m_State;
-	TObjPtr<DInterpolation> m_Interpolation;
 
 	friend bool EV_StartWaggle (int tag, line_t *line, int height, int speed,
 		int offset, int timer, bool ceiling);