@ This seems to fix some geometry merging issues (mainly when pasting geometry) but it needs testing.

This commit is contained in:
codeimp 2010-08-13 12:03:25 +00:00
parent 9ec7ba38fe
commit c043d9d336

View file

@ -854,7 +854,7 @@ namespace CodeImp.DoomBuilder.Map
else else
{ {
// Compare front sectors // Compare front sectors
if(l1fs == l2fs) if((l1fs != null) && (l1fs == l2fs))
{ {
// Copy textures // Copy textures
if(other.front != null) other.front.AddTexturesTo(this.back); if(other.front != null) other.front.AddTexturesTo(this.back);
@ -864,7 +864,7 @@ namespace CodeImp.DoomBuilder.Map
JoinChangeSidedefs(other, true, back); JoinChangeSidedefs(other, true, back);
} }
// Compare back sectors // Compare back sectors
else if(l1bs == l2bs) else if((l1bs != null) && (l1bs == l2bs))
{ {
// Copy textures // Copy textures
if(other.back != null) other.back.AddTexturesTo(this.front); if(other.back != null) other.back.AddTexturesTo(this.front);
@ -874,7 +874,7 @@ namespace CodeImp.DoomBuilder.Map
JoinChangeSidedefs(other, false, front); JoinChangeSidedefs(other, false, front);
} }
// Compare front and back // Compare front and back
else if(l1fs == l2bs) else if((l1fs != null) && (l1fs == l2bs))
{ {
// Copy textures // Copy textures
if(other.front != null) other.front.AddTexturesTo(this.front); if(other.front != null) other.front.AddTexturesTo(this.front);
@ -884,7 +884,7 @@ namespace CodeImp.DoomBuilder.Map
JoinChangeSidedefs(other, true, front); JoinChangeSidedefs(other, true, front);
} }
// Compare back and front // Compare back and front
else if(l1bs == l2fs) else if((l1bs != null) && (l1bs == l2fs))
{ {
// Copy textures // Copy textures
if(other.back != null) other.back.AddTexturesTo(this.back); if(other.back != null) other.back.AddTexturesTo(this.back);
@ -919,7 +919,7 @@ namespace CodeImp.DoomBuilder.Map
} }
} }
// This line single sided? // This line single sided?
if(this.back == null) else if(this.back == null)
{ {
// Other line with its back to this? // Other line with its back to this?
if(other.start == this.end) if(other.start == this.end)
@ -985,23 +985,27 @@ namespace CodeImp.DoomBuilder.Map
} }
// This changes sidedefs (used for joining lines) // This changes sidedefs (used for joining lines)
private void JoinChangeSidedefs(Linedef other, bool front, Sidedef newside) // target: The linedef on which to remove or create a new sidedef
// front: Side on which to remove or create the sidedef (true for front side)
// newside: The side from which to copy the properties to the new sidedef.
// If this is null, no sidedef will be created (only removed)
private void JoinChangeSidedefs(Linedef target, bool front, Sidedef newside)
{ {
Sidedef sd; Sidedef sd;
// Change sidedefs // Change sidedefs
if(front) if(front)
{ {
if(other.front != null) other.front.Dispose(); if(target.front != null) target.front.Dispose();
} }
else else
{ {
if(other.back != null) other.back.Dispose(); if(target.back != null) target.back.Dispose();
} }
if(newside != null) if(newside != null)
{ {
sd = map.CreateSidedef(other, front, newside.Sector); sd = map.CreateSidedef(target, front, newside.Sector);
newside.CopyPropertiesTo(sd); newside.CopyPropertiesTo(sd);
sd.Marked = newside.Marked; sd.Marked = newside.Marked;
} }