From 80637b336bcc93697e1304f4299deda285719998 Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Tue, 11 Apr 2017 22:33:04 +0100
Subject: [PATCH] Starting work, noclimb inverts direction (haven't tested if
 it actually works or not yet)

---
 src/p_floor.c |  6 ++++++
 src/p_spec.c  | 12 +++++++-----
 src/p_spec.h  |  1 +
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/p_floor.c b/src/p_floor.c
index d16c8b9ff..cefdc3d4f 100644
--- a/src/p_floor.c
+++ b/src/p_floor.c
@@ -2557,6 +2557,12 @@ void T_PlaneDisplace(planedisplace_t *pd)
 	direction = (control->floorheight > pd->last_height) ? 1 : -1;
 	diff = FixedMul(control->floorheight-pd->last_height, pd->speed);
 
+	if (pd->reverse) // reverse direction?
+	{
+		direction *= -1;
+		diff *= -1;
+	}
+
 	if (pd->type == pd_floor || pd->type == pd_both)
 		T_MovePlane(target, INT32_MAX/2, target->floorheight+diff, 0, 0, direction); // move floor
 	if (pd->type == pd_ceiling || pd->type == pd_both)
diff --git a/src/p_spec.c b/src/p_spec.c
index c327f0d13..db7b852f5 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -111,7 +111,7 @@ static void P_AddFakeFloorsByLine(size_t line, ffloortype_e ffloorflags, thinker
 static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec);
 static void Add_Friction(INT32 friction, INT32 movefactor, INT32 affectee, INT32 referrer);
 static void P_AddSpikeThinker(sector_t *sec, INT32 referrer);
-static void P_AddPlaneDisplaceThinker(INT32 type, fixed_t speed, INT32 control, INT32 affectee);
+static void P_AddPlaneDisplaceThinker(INT32 type, fixed_t speed, INT32 control, INT32 affectee, UINT8 reverse);
 
 
 //SoM: 3/7/2000: New sturcture without limits.
@@ -5176,10 +5176,11 @@ static inline void P_AddBridgeThinker(line_t *sourceline, sector_t *sec)
   * \param speed            Rate of movement relative to control sector
   * \param control          Control sector.
   * \param affectee         Target sector.
+  * \param reverse          Reverse direction?
   * \sa P_SpawnSpecials, T_PlaneDisplace
   * \author Monster Iestyn
   */
-static void P_AddPlaneDisplaceThinker(INT32 type, fixed_t speed, INT32 control, INT32 affectee)
+static void P_AddPlaneDisplaceThinker(INT32 type, fixed_t speed, INT32 control, INT32 affectee, UINT8 reverse)
 {
 	planedisplace_t *displace;
 
@@ -5193,6 +5194,7 @@ static void P_AddPlaneDisplaceThinker(INT32 type, fixed_t speed, INT32 control,
 	displace->last_height = sectors[control].floorheight;
 	displace->speed = speed;
 	displace->type = type;
+	displace->reverse = reverse;
 }
 
 /** Adds a Mario block thinker, which changes the block's texture between blank
@@ -5912,15 +5914,15 @@ void P_SpawnSpecials(INT32 fromnetsave)
 
 			case 66: // Displace floor by front sector
 				for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;)
-					P_AddPlaneDisplaceThinker(pd_floor, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s);
+					P_AddPlaneDisplaceThinker(pd_floor, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB));
 				break;
 			case 67: // Displace ceiling by front sector
 				for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;)
-					P_AddPlaneDisplaceThinker(pd_ceiling, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s);
+					P_AddPlaneDisplaceThinker(pd_ceiling, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB));
 				break;
 			case 68: // Displace both floor AND ceiling by front sector
 				for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;)
-					P_AddPlaneDisplaceThinker(pd_both, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s);
+					P_AddPlaneDisplaceThinker(pd_both, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB));
 				break;
 
 			case 100: // FOF (solid, opaque, shadows)
diff --git a/src/p_spec.h b/src/p_spec.h
index 0c77eb19f..e34b0d08e 100644
--- a/src/p_spec.h
+++ b/src/p_spec.h
@@ -458,6 +458,7 @@ typedef struct
 	INT32 control;       ///< Control sector used to control plane positions.
 	fixed_t last_height; ///< Last known height of control sector.
 	fixed_t speed;       ///< Plane movement speed.
+	UINT8 reverse;       ///< Move in reverse direction to control sector?
 	/** Types of plane displacement effects.
 	*/
 	enum