From 79c3197de2c40bb8f91582cebceda46f736ec6f2 Mon Sep 17 00:00:00 2001
From: MascaraSnake <jonassauer27@gmail.com>
Date: Tue, 28 Dec 2021 16:38:52 +0100
Subject: [PATCH] Adapt various thing types for UDMF

---
 extras/conf/udb/Includes/SRB222_things.cfg | 135 +++++++++++++++++++++
 src/p_inter.c                              |   2 +-
 src/p_mobj.c                               |  45 +++++--
 src/p_setup.c                              |  57 +++++++++
 src/p_spec.h                               |   7 ++
 5 files changed, 236 insertions(+), 10 deletions(-)

diff --git a/extras/conf/udb/Includes/SRB222_things.cfg b/extras/conf/udb/Includes/SRB222_things.cfg
index 649ddd647c..02d90eacfe 100644
--- a/extras/conf/udb/Includes/SRB222_things.cfg
+++ b/extras/conf/udb/Includes/SRB222_things.cfg
@@ -4265,6 +4265,12 @@ udmf
 		width = 24;
 		height = 24;
 		sprite = "RINGA0";
+		arg0
+		{
+			title = "Float?";
+			type = 11;
+			enum = "yesno";
+		}
 
 		300
 		{
@@ -4380,6 +4386,12 @@ udmf
 			sprite = "TOKEA0";
 			width = 16;
 			height = 32;
+			arg0
+			{
+				title = "Float?";
+				type = 11;
+				enum = "yesno";
+			}
 		}
 		313
 		{
@@ -4420,11 +4432,23 @@ udmf
 		{
 			title = "Emerald Hunt Location";
 			sprite = "SHRDA0";
+			arg0
+			{
+				title = "Float?";
+				type = 11;
+				enum = "yesno";
+			}
 		}
 		321
 		{
 			title = "Match Chaos Emerald Spawn";
 			sprite = "CEMGA0";
+			arg0
+			{
+				title = "Float?";
+				type = 11;
+				enum = "yesno";
+			}
 		}
 		322
 		{
@@ -4432,6 +4456,12 @@ udmf
 			sprite = "EMBMA0";
 			width = 16;
 			height = 30;
+			arg0
+			{
+				title = "Float?";
+				type = 11;
+				enum = "yesno";
+			}
 		}
 	}
 
@@ -4661,6 +4691,12 @@ udmf
 			{
 				title = "Order";
 			}
+			arg1
+			{
+				title = "Respawn at center?";
+				type = 11;
+				enum = "noyes";
+			}
 		}
 		520
 		{
@@ -4668,6 +4704,12 @@ udmf
 			sprite = "SPHRD0";
 			width = 16;
 			height = 24;
+			arg0
+			{
+				title = "Float?";
+				type = 11;
+				enum = "yesno";
+			}
 		}
 		521
 		{
@@ -4675,6 +4717,12 @@ udmf
 			sprite = "SPIKA0";
 			width = 12;
 			height = 8;
+			arg0
+			{
+				title = "Float?";
+				type = 11;
+				enum = "yesno";
+			}
 		}
 		522
 		{
@@ -4791,6 +4839,12 @@ udmf
 			title = "Gas Jet";
 			sprite = "STEMD0";
 			width = 32;
+			arg0
+			{
+				title = "Play sound?";
+				type = 11;
+				enum = "noyes";
+			}
 		}
 		542
 		{
@@ -4889,6 +4943,12 @@ udmf
 			sprite = "SSWYD2D8";
 			width = 16;
 			height = 32;
+			arg0
+			{
+				title = "Float?";
+				type = 11;
+				enum = "yesno";
+			}
 		}
 		559
 		{
@@ -4897,6 +4957,12 @@ udmf
 			sprite = "SSWRD2D8";
 			width = 16;
 			height = 32;
+			arg0
+			{
+				title = "Float?";
+				type = 11;
+				enum = "yesno";
+			}
 		}
 		560
 		{
@@ -4905,6 +4971,12 @@ udmf
 			sprite = "SSWBD2D8";
 			width = 16;
 			height = 32;
+			arg0
+			{
+				title = "Float?";
+				type = 11;
+				enum = "yesno";
+			}
 		}
 		1134
 		{
@@ -4927,6 +4999,12 @@ udmf
 			sprite = "BSTYA0";
 			width = 28;
 			height = 2;
+			arg0
+			{
+				title = "Force spin?";
+				type = 11;
+				enum = "noyes";
+			}
 		}
 		545
 		{
@@ -4935,6 +5013,12 @@ udmf
 			sprite = "BSTRA0";
 			width = 28;
 			height = 2;
+			arg0
+			{
+				title = "Force spin?";
+				type = 11;
+				enum = "noyes";
+			}
 		}
 	}
 
@@ -5572,6 +5656,12 @@ udmf
 				type = 11;
 				enum = "pushablebehavior";
 			}
+			arg1
+			{
+				title = "Solid gold?";
+				type = 11;
+				enum = "noyes";
+			}
 		}
 		1103
 		{
@@ -6049,6 +6139,17 @@ udmf
 			sprite = "EGR1A1";
 			width = 20;
 			height = 72;
+			arg0
+			{
+				title = "Movement";
+				type = 11;
+				enum
+				{
+					0 = "None";
+					1 = "Right";
+					2 = "Left";
+				}
+			}
 		}
 		1128
 		{
@@ -6265,6 +6366,12 @@ udmf
 			sprite = "SALDARAL";
 			width = 96;
 			height = 160;
+			arg0
+			{
+				title = "Allow non-minecart players?";
+				type = 11;
+				enum = "noyes";
+			}
 		}
 		1222
 		{
@@ -6293,6 +6400,16 @@ udmf
 			sprite = "internal:zoom";
 			width = 8;
 			height = 16;
+			arg0
+			{
+				title = "Type";
+				type = 11;
+				enum
+				{
+					0 = "Disable";
+					1 = "Enable";
+				}
+			}
 		}
 		1230
 		{
@@ -6391,6 +6508,12 @@ udmf
 			sprite = "PUMIA1A5";
 			width = 30;
 			height = 60;
+			arg0
+			{
+				title = "Buoyant?";
+				type = 11;
+				enum = "yesno";
+			}
 		}
 		1306
 		{
@@ -6939,6 +7062,12 @@ udmf
 			sprite = "SPHRA0";
 			width = 16;
 			height = 24;
+			arg0
+			{
+				title = "Float?";
+				type = 11;
+				enum = "yesno";
+			}
 		}
 		1707
 		{
@@ -7051,6 +7180,12 @@ udmf
 			sprite = "COINA0";
 			width = 16;
 			height = 24;
+			arg0
+			{
+				title = "Float?";
+				type = 11;
+				enum = "yesno";
+			}
 		}
 		1801
 		{
diff --git a/src/p_inter.c b/src/p_inter.c
index 9a3562fc88..028ac0ef37 100644
--- a/src/p_inter.c
+++ b/src/p_inter.c
@@ -1437,7 +1437,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
 // Misc touchables //
 // *************** //
 		case MT_STARPOST:
-			P_TouchStarPost(special, player, special->spawnpoint && (special->spawnpoint->options & MTF_OBJECTSPECIAL));
+			P_TouchStarPost(special, player, special->spawnpoint && special->spawnpoint->args[1]);
 			return;
 
 		case MT_FAKEMOBILE:
diff --git a/src/p_mobj.c b/src/p_mobj.c
index 4fe3e02ac4..fa3bba57a8 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -8590,9 +8590,9 @@ static boolean P_EggRobo1Think(mobj_t *mobj)
 	{
 		fixed_t basex = mobj->cusval, basey = mobj->cvmem;
 
-		if (mobj->spawnpoint && mobj->spawnpoint->options & (MTF_AMBUSH|MTF_OBJECTSPECIAL))
+		if (mobj->spawnpoint && mobj->spawnpoint->args[0] != TMED_NONE)
 		{
-			angle_t sideang = mobj->movedir + ((mobj->spawnpoint->options & MTF_AMBUSH) ? ANGLE_90 : -ANGLE_90);
+			angle_t sideang = mobj->movedir + ((mobj->spawnpoint->args[0] == TMED_LEFT) ? ANGLE_90 : -ANGLE_90);
 			fixed_t oscillate = FixedMul(FINESINE(((leveltime * ANG1) >> (ANGLETOFINESHIFT + 2)) & FINEMASK), 250*mobj->scale);
 			basex += P_ReturnThrustX(mobj, sideang, oscillate);
 			basey += P_ReturnThrustY(mobj, sideang, oscillate);
@@ -11775,14 +11775,14 @@ fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mt
 			dz = 288*FRACUNIT;
 		break;
 
-	// Horizontal springs, may float additional units with MTF_AMBUSH.
+	// Horizontal springs, float additional units unless args[0] is set.
 	case MT_YELLOWHORIZ:
 	case MT_REDHORIZ:
 	case MT_BLUEHORIZ:
-		offset += mthing->options & MTF_AMBUSH ? 16*FRACUNIT : 0;
+		offset += mthing->args[0] ? 0 : 16*FRACUNIT;
 		break;
 
-	// Ring-like items, may float additional units with MTF_AMBUSH.
+	// Ring-like items, float additional units unless args[0] is set.
 	case MT_SPIKEBALL:
 	case MT_EMERHUNT:
 	case MT_EMERALDSPAWN:
@@ -11796,13 +11796,13 @@ fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mt
 	case MT_BOMBSPHERE:
 	case MT_NIGHTSCHIP:
 	case MT_NIGHTSSTAR:
-		offset += mthing->options & MTF_AMBUSH ? 24*FRACUNIT : 0;
+		offset += mthing->args[0] ? 0 : 24*FRACUNIT;
 		break;
 
 	// Remaining objects.
 	default:
 		if (P_WeaponOrPanel(mobjtype))
-			offset += mthing->options & MTF_AMBUSH ? 24*FRACUNIT : 0;
+			offset += mthing->args[0] ? 0 : 24*FRACUNIT;
 	}
 
 	if (!(dz + offset)) // Snap to the surfaces when there's no offset set.
@@ -12717,7 +12717,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
 		break;
 	}
 	case MT_EGGSTATUE:
-		if (mthing->options & MTF_EXTRA)
+		if (mthing->args[1])
 		{
 			mobj->color = SKINCOLOR_GOLD;
 			mobj->colorized = true;
@@ -13096,6 +13096,22 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
 		if (mthing->args[1])
 			mobj->flags2 |= MF2_AMBUSH;
 		break;
+	case MT_STEAM:
+		if (mthing->args[0])
+			mobj->flags2 |= MF2_AMBUSH;
+		break;
+	case MT_SALOONDOORCENTER:
+		if (mthing->args[0])
+			mobj->flags2 |= MF2_AMBUSH;
+		break;
+	case MT_MINECARTSWITCHPOINT:
+		if (mthing->args[0])
+			mobj->flags2 |= MF2_AMBUSH;
+		break;
+	case MT_ROLLOUTSPAWN:
+		if (mthing->args[0])
+			mobj->flags2 |= MF2_AMBUSH;
+		break;
 	default:
 		break;
 	}
@@ -13136,6 +13152,12 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
 				break;
 		}
 	}
+	if (mobj->flags & MF_SPRING && mobj->info->painchance == 3)
+	{
+		if (mthing->args[0])
+			mobj->flags2 |= MF2_AMBUSH;
+	}
+
 
 	return true;
 }
@@ -13171,7 +13193,12 @@ static void P_SetAmbush(mobj_t *mobj)
 		mobj->type != MT_CACOLANTERN &&
 		mobj->type != MT_PIAN &&
 		mobj->type != MT_EGGGUARD &&
-		mobj->type != MT_STARPOST)
+		mobj->type != MT_STEAM &&
+		mobj->type != MT_SALOONDOORCENTER &&
+		mobj->type != MT_MINECARTSWITCHPOINT &&
+		mobj->type != MT_ROLLOUTSPAWN &&
+		mobj->type != MT_STARPOST &&
+		!(mobj->flags & MF_SPRING && mobj->info->painchance == 3))
 		mobj->flags2 |= MF2_AMBUSH;
 }
 
diff --git a/src/p_setup.c b/src/p_setup.c
index de6eb1c931..c267167fed 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -4914,6 +4914,8 @@ static void P_ConvertBinaryMap(void)
 				else
 					mapthings[i].args[0] = TMP_NORMAL;
 			}
+			if (mobjinfo[mobjtype].flags & MF_SPRING && mobjinfo[mobjtype].painchance == 3)
+				mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH);
 		}
 
 		if (mapthings[i].type >= 1 && mapthings[i].type <= 35) //Player starts
@@ -4996,6 +4998,32 @@ static void P_ConvertBinaryMap(void)
 		case 294: //Fang waypoint
 			mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH);
 			break;
+		case 300: //Ring
+		case 301: //Bounce ring
+		case 302: //Rail ring
+		case 303: //Infinity ring
+		case 304: //Automatic ring
+		case 305: //Explosion ring
+		case 306: //Scatter ring
+		case 307: //Grenade ring
+		case 308: //Red team ring
+		case 309: //Blue team ring
+		case 312: //Emerald token
+		case 320: //Emerald hunt location
+		case 321: //Match chaos emerald spawn
+		case 322: //Emblem
+		case 330: //Bounce ring panel
+		case 331: //Rail ring panel
+		case 332: //Automatic ring panel
+		case 333: //Explosion ring panel
+		case 334: //Scatter ring panel
+		case 335: //Grenade ring panel
+		case 520: //Bomb sphere
+		case 521: //Spikeball
+		case 1706: //Blue sphere
+		case 1800: //Coin
+			mapthings[i].args[0] = !(mapthings[i].options & MTF_AMBUSH);
+			break;
 		case 500: //Air bubble patch
 			mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH);
 			break;
@@ -5009,6 +5037,7 @@ static void P_ConvertBinaryMap(void)
 			else
 				// Old behavior if Parameter is 0; add 360 to the angle for each consecutive star post.
 				mapthings[i].args[0] = (mapthings[i].angle/360);
+			mapthings[i].args[1] = !!(mapthings[i].options & MTF_OBJECTSPECIAL);
 			break;
 		case 522: //Wall spike
 			if (mapthings[i].options & MTF_OBJECTSPECIAL)
@@ -5039,6 +5068,9 @@ static void P_ConvertBinaryMap(void)
 			if (mapthings[i].options & MTF_AMBUSH)
 				mapthings[i].args[1] |= TMF_NODISTANCECHECK;
 			break;
+		case 541: //Gas jet
+			mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH);
+			break;
 		case 543: //Balloon
 			if (mapthings[i].angle > 0)
 				P_WriteConstant(((mapthings[i].angle - 1) % (numskincolors - 1)) + 1, &mapthings[i].stringargs[0]);
@@ -5052,6 +5084,11 @@ static void P_ConvertBinaryMap(void)
 			if (mapthings[i].options & MTF_AMBUSH)
 				mapthings[i].args[0] |= TMDS_ROTATEEXTRA;
 			break;
+		case 558: //Horizontal yellow spring
+		case 559: //Horizontal red spring
+		case 560: //Horizontal blue spring
+			mapthings[i].args[0] = !(mapthings[i].options & MTF_AMBUSH);
+			break;
 		case 700: //Water ambience A
 		case 701: //Water ambience A
 		case 702: //Water ambience A
@@ -5174,6 +5211,9 @@ static void P_ConvertBinaryMap(void)
 		case 1011: //Stalagmite (DSZ2)
 			mapthings[i].args[0] = !!(mapthings[i].options & MTF_OBJECTSPECIAL);
 			break;
+		case 1102: //Eggman Statue
+			mapthings[i].args[1] = !!(mapthings[i].options & MTF_EXTRA);
+			break;
 		case 1104: //Mace spawnpoint
 		case 1105: //Chain with maces spawnpoint
 		case 1106: //Chained spring spawnpoint
@@ -5238,6 +5278,14 @@ static void P_ConvertBinaryMap(void)
 			if (mapthings[i].options & MTF_EXTRA)
 				mapthings[i].args[0] |= TMFH_CORONA;
 			break;
+		case 1127: //Spectator EggRobo
+			if (mapthings[i].options & MTF_AMBUSH)
+				mapthings[i].args[0] = TMED_LEFT;
+			else if (mapthings[i].options & MTF_OBJECTSPECIAL)
+				mapthings[i].args[0] = TMED_RIGHT;
+			else
+				mapthings[i].args[0] = TMED_NONE;
+			break;
 		case 1200: //Tumbleweed (Big)
 		case 1201: //Tumbleweed (Small)
 			mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH);
@@ -5259,6 +5307,12 @@ static void P_ConvertBinaryMap(void)
 			P_WriteConstant(MT_ROCKCRUMBLE1 + (sides[lines[j].sidenum[0]].rowoffset >> FRACBITS), &mapthings[i].stringargs[0]);
 			break;
 		}
+		case 1221: //Minecart saloon door
+			mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH);
+			break;
+		case 1229: //Minecart switch point
+			mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH);
+			break;
 		case 1300: //Flame jet (horizontal)
 		case 1301: //Flame jet (vertical)
 			mapthings[i].args[0] = (mapthings[i].angle >> 13)*TICRATE/2;
@@ -5269,6 +5323,9 @@ static void P_ConvertBinaryMap(void)
 			mapthings[i].args[0] = mapthings[i].angle;
 			mapthings[i].args[1] = !!(mapthings[i].options & MTF_AMBUSH);
 			break;
+		case 1305: //Rollout Rock
+			mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH);
+			break;
 		case 1700: //Axis
 			mapthings[i].args[2] = mapthings[i].angle & 16383;
 			mapthings[i].args[3] = !!(mapthings[i].angle & 16384);
diff --git a/src/p_spec.h b/src/p_spec.h
index 2203769034..0fc7c6ee10 100644
--- a/src/p_spec.h
+++ b/src/p_spec.h
@@ -96,6 +96,13 @@ typedef enum
 	TMP_CLASSIC   = 3,
 } textmappushabletype_t;
 
+typedef enum
+{
+	TMED_NONE  = 0,
+	TMED_RIGHT = 1,
+	TMED_LEFT  = 2,
+} textmapeggrobodirection_t;
+
 //FOF flags
 typedef enum
 {
-- 
GitLab