From 536e355cdf9242daf5cffc566a36763546d47fa5 Mon Sep 17 00:00:00 2001
From: MascaraSnake <jonassauer27@gmail.com>
Date: Sat, 16 May 2020 09:49:30 +0200
Subject: [PATCH] polywaypointdata_t: Turn reverse and continuous into flags

---
 src/p_polyobj.c | 10 ++++------
 src/p_polyobj.h |  9 +++++++--
 src/p_spec.c    |  8 ++++++--
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/p_polyobj.c b/src/p_polyobj.c
index 557055c92a..9958b19c91 100644
--- a/src/p_polyobj.c
+++ b/src/p_polyobj.c
@@ -2154,11 +2154,12 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
 	// set fields
 	th->polyObjNum = pwdata->polyObjNum;
 	th->speed = pwdata->speed;
-	th->sequence = pwdata->sequence; // Used to specify sequence #
-	th->direction = pwdata->reverse ? -1 : 1;
+	th->sequence = pwdata->sequence;
+	th->direction = (pwdata->flags & PWF_REVERSE) ? -1 : 1;
 
 	th->returnbehavior = pwdata->returnbehavior;
-	th->continuous = pwdata->continuous;
+	if (pwdata->flags & PWF_LOOP)
+		th->continuous = true;
 	th->stophere = false;
 
 	// Find the first waypoint we need to use
@@ -2172,11 +2173,8 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
 		return false;
 	}
 
-	// Set pointnum
 	th->pointnum = first->health;
 
-	// We don't deal with the mirror crap here, we'll
-	// handle that in the T_Thinker function.
 	return true;
 }
 
diff --git a/src/p_polyobj.h b/src/p_polyobj.h
index cfed15ffe4..8037c545f2 100644
--- a/src/p_polyobj.h
+++ b/src/p_polyobj.h
@@ -254,14 +254,19 @@ typedef struct polymovedata_s
 	UINT8 overRide;     // if true, will override any action on the object
 } polymovedata_t;
 
+typedef enum
+{
+	PWF_REVERSE = 1,    // Move through waypoints in reverse order
+	PWF_LOOP    = 1<<1, // Loop movement (used with PWR_WRAP or PWR_COMEBACK)
+} polywaypointflags_e;
+
 typedef struct polywaypointdata_s
 {
 	INT32 polyObjNum;     // numeric id of polyobject to affect
 	INT32 sequence;       // waypoint sequence #
 	fixed_t speed;        // linear speed
-	UINT8 reverse;        // if true, will go in reverse waypoint order
 	UINT8 returnbehavior; // behavior after reaching the last waypoint
-	UINT8 continuous;     // continuously move - used with PWR_WRAP or PWR_COMEBACK
+	UINT8 flags;          // PWF_ flags
 } polywaypointdata_t;
 
 // polyobject door types
diff --git a/src/p_spec.c b/src/p_spec.c
index 99657aab99..f592e8edd5 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -1276,7 +1276,6 @@ static boolean PolyWaypoint(line_t *line)
 	pwd.polyObjNum = line->tag;
 	pwd.speed      = sides[line->sidenum[0]].textureoffset / 8;
 	pwd.sequence   = sides[line->sidenum[0]].rowoffset >> FRACBITS; // Sequence #
-	pwd.reverse    = (line->flags & ML_EFFECT1) == ML_EFFECT1; // Reverse?
 
 	// Behavior after reaching the last waypoint?
 	if (line->flags & ML_EFFECT3)
@@ -1286,7 +1285,12 @@ static boolean PolyWaypoint(line_t *line)
 	else
 		pwd.returnbehavior = PWR_STOP; // Stop
 
-	pwd.continuous = (line->flags & ML_EFFECT4) == ML_EFFECT4; // Continuously move - used with PWR_WRAP or PWR_COMEBACK
+	// Flags
+	pwd.flags = 0;
+	if (line->flags & ML_EFFECT1)
+		pwd.flags |= PWF_REVERSE;
+	if (line->flags & ML_EFFECT4)
+		pwd.flags |= PWF_LOOP;
 
 	return EV_DoPolyObjWaypoint(&pwd);
 }
-- 
GitLab