From f0adc71f9b1db56b0b38dcf2b2eafe0f3020a71d Mon Sep 17 00:00:00 2001
From: spherallic <spherallic@gmail.com>
Date: Wed, 7 Sep 2022 23:11:02 +0200
Subject: [PATCH] Add flag to invert current gravity to gravity flip executor

---
 extras/conf/SRB2-22.cfg                      |  3 ++-
 extras/conf/udb/Includes/SRB222_linedefs.cfg | 14 ++++++++++++--
 src/p_setup.c                                |  1 +
 src/p_spec.c                                 |  4 +++-
 4 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg
index 969f645f3f..79ed8ff444 100644
--- a/extras/conf/SRB2-22.cfg
+++ b/extras/conf/SRB2-22.cfg
@@ -2315,6 +2315,7 @@ linedeftypes
 			title = "Enable/Disable Gravity Flip";
 			prefix = "(433)";
 			flags8text = "[3] Set delay by backside sector";
+			flags32text = "[5] Invert current gravity";
 			flags64text = "[6] Return to normal";
 		}
 
@@ -6949,7 +6950,7 @@ thingtypes
 	{
 		color = 10; // Green
 		title = "Tutorial";
-		
+
 		799
 		{
 			title = "Tutorial Plant";
diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg
index fff9edf109..6da66ae211 100644
--- a/extras/conf/udb/Includes/SRB222_linedefs.cfg
+++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg
@@ -2593,7 +2593,7 @@ udmf
 				}
 			}
 		}
-		
+
 		190
 		{
 			title = "Rising";
@@ -4157,7 +4157,7 @@ udmf
 			prefix = "(433)";
 			arg0
 			{
-				title = "Gravity";
+				title = "Set gravity";
 				type = 11;
 				enum
 				{
@@ -4165,6 +4165,16 @@ udmf
 					1 = "Normal";
 				}
 			}
+			arg1
+			{
+				title = "Invert current gravity";
+				type = 11;
+				enum
+				{
+					0 = "No";
+					1 = "Yes";
+				}
+			}
 		}
 
 		434
diff --git a/src/p_setup.c b/src/p_setup.c
index 146d5d3023..50c5ae2a34 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -5164,6 +5164,7 @@ static void P_ConvertBinaryLinedefTypes(void)
 			break;
 		case 433: //Enable/disable gravity flip
 			lines[i].args[0] = !!(lines[i].flags & ML_NOCLIMB);
+			lines[i].args[1] = !!(lines[i].flags & ML_SKEWTD);
 			break;
 		case 434: //Award power-up
 			if (sides[lines[i].sidenum[0]].text)
diff --git a/src/p_spec.c b/src/p_spec.c
index 78878de1da..03ed298e89 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -2773,7 +2773,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
 			break;
 
 		case 433: // Flip/flop gravity. Works on pushables, too!
-			if (line->args[0])
+			if (line->args[1])
+				mo->flags2 ^= MF2_OBJECTFLIP;
+			else if (line->args[0])
 				mo->flags2 &= ~MF2_OBJECTFLIP;
 			else
 				mo->flags2 |= MF2_OBJECTFLIP;
-- 
GitLab