From 3c62e89ded0a8d889ca88b360c17516baca3625a Mon Sep 17 00:00:00 2001
From: MaxED <j.maxed@gmail.com>
Date: Fri, 24 Jun 2016 22:25:12 +0000
Subject: [PATCH] Reverted some older changes to Linedef.Join(), which were
 made for older version of "enhanced" map element merging logic and in some
 cases were causing incorrect geometry to be created when using current
 merging logic.

---
 Source/Core/Map/Linedef.cs | 60 ++++++++++----------------------------
 1 file changed, 16 insertions(+), 44 deletions(-)

diff --git a/Source/Core/Map/Linedef.cs b/Source/Core/Map/Linedef.cs
index 98dcc8a3b..7925813d9 100644
--- a/Source/Core/Map/Linedef.cs
+++ b/Source/Core/Map/Linedef.cs
@@ -1126,7 +1126,7 @@ namespace CodeImp.DoomBuilder.Map
 					if(this.front != null) this.front.AddTexturesTo(other.back);
 
 					// Change sidedefs?
-					if(back != null && !JoinChangeSidedefs(other, true, back)) return false;
+					if(!JoinChangeSidedefs(other, true, back)) return false;
 				}
 				// Compare back sectors
 				else if((otherbs != null) && (otherbs == thisbs))
@@ -1136,7 +1136,7 @@ namespace CodeImp.DoomBuilder.Map
 					if(this.back != null) this.back.AddTexturesTo(other.front);
 
 					// Change sidedefs?
-					if(front != null && !JoinChangeSidedefs(other, false, front)) return false;
+					if(!JoinChangeSidedefs(other, false, front)) return false;
 				}
 				// Compare front and back
 				else if((otherfs != null) && (otherfs == thisbs))
@@ -1146,7 +1146,7 @@ namespace CodeImp.DoomBuilder.Map
 					if(this.back != null) this.back.AddTexturesTo(other.back);
 
 					// Change sidedefs?
-					if(front != null && !JoinChangeSidedefs(other, true, front)) return false;
+					if(!JoinChangeSidedefs(other, true, front)) return false;
 				}
 				// Compare back and front
 				else if((otherbs != null) && (otherbs == thisfs))
@@ -1156,7 +1156,7 @@ namespace CodeImp.DoomBuilder.Map
 					if(this.front != null) this.front.AddTexturesTo(other.front);
 
 					// Change sidedefs?
-					if(back != null && !JoinChangeSidedefs(other, false, back)) return false;
+					if(!JoinChangeSidedefs(other, false, back)) return false;
 				}
 				else
 				{
@@ -1170,7 +1170,7 @@ namespace CodeImp.DoomBuilder.Map
 							if(this.back != null) this.back.AddTexturesTo(other.front);
 
 							// Change sidedefs?
-							if(front != null && !JoinChangeSidedefs(other, false, front)) return false;
+							if(!JoinChangeSidedefs(other, false, front)) return false;
 						}
 						else
 						{
@@ -1178,7 +1178,7 @@ namespace CodeImp.DoomBuilder.Map
 							if(this.front != null) this.front.AddTexturesTo(other.front);
 
 							// Change sidedefs?
-							if(back != null && !JoinChangeSidedefs(other, false, back)) return false;
+							if(!JoinChangeSidedefs(other, false, back)) return false;
 						}
 					}
 					// This line single sided?
@@ -1213,50 +1213,22 @@ namespace CodeImp.DoomBuilder.Map
 						// This line with its back to the other?
 						if(this.start == other.end)
 						{
-							//mxd. Attach our front to other back?
-							if(otherbs == null)
-							{
-								// Copy textures
-								if(other.back != null) other.back.AddTexturesTo(this.front);
-								if(this.back != null) this.back.AddTexturesTo(other.front);
-
-								// Change sidedefs (replace other back with our front)
-								if(front != null && !JoinChangeSidedefs(other, false, front)) return false;
-							}
-							//mxd. Attach our back to other front?
-							else if(otherfs == null)
-							{
-								// Copy textures
-								if(other.front != null) other.front.AddTexturesTo(this.back);
-								if(this.front != null) this.front.AddTexturesTo(other.back);
+							// Copy textures
+							if(other.back != null) other.back.AddTexturesTo(this.front);
+							if(this.back != null) this.back.AddTexturesTo(other.front);
 
-								// Change sidedefs (replace other back with our front)
-								if(back != null && !JoinChangeSidedefs(other, true, back)) return false;
-							}
+							// Change sidedefs
+							if(!JoinChangeSidedefs(other, false, front)) return false;
 						}
 						// Both lines face the same way
 						else
 						{
-							//mxd. Attach our back to other back?
-							if(otherbs == null)
-							{
-								// Copy textures
-								if(other.back != null) other.back.AddTexturesTo(this.back);
-								if(this.front != null) this.front.AddTexturesTo(other.front);
-
-								// Change sidedefs
-								if(back != null && !JoinChangeSidedefs(other, false, back)) return false;
-							}
-							//mxd. Attach our front to other front?
-							else if(otherfs == null)
-							{
-								// Copy textures
-								if(other.front != null) other.front.AddTexturesTo(this.front);
-								if(this.back != null) this.back.AddTexturesTo(other.back);
+							// Copy textures
+							if(other.back != null) other.back.AddTexturesTo(this.back);
+							if(this.front != null) this.front.AddTexturesTo(other.front);
 
-								// Change sidedefs
-								if(front != null && !JoinChangeSidedefs(other, true, front)) return false;
-							}
+							// Change sidedefs
+							if(!JoinChangeSidedefs(other, false, back)) return false;
 						}
 					}
 				}
-- 
GitLab