From d45e71ce213e7baf2916adc0c7a9f6de606988d0 Mon Sep 17 00:00:00 2001 From: MaxED Date: Sun, 22 May 2016 21:22:42 +0000 Subject: [PATCH] Fixed, Script Editor: in some cases the editor was unable to restore saved script file settings. Fixed, Drag Linedefs, Drag Vertices, Edit Selection modes: in some cases sidedefs were incorrectly removed when modifying a closed section of a multi-part sector. Fixed, Drag Linedefs, Drag Vertices, Drag Sectors, Edit Selection modes: in some cases sidedef textures were not adjusted after applying the modes, leaving middle textures on double-sided lines. --- Source/Core/Geometry/Tools.cs | 37 ++++++++++++++++++- Source/Core/Map/MapOptions.cs | 25 ++++++++----- .../ClassicModes/DragLinedefsMode.cs | 7 ++-- .../ClassicModes/DragSectorsMode.cs | 7 ++-- .../ClassicModes/DragVerticesMode.cs | 7 ++-- .../ClassicModes/EditSelectionMode.cs | 7 ++-- 6 files changed, 67 insertions(+), 23 deletions(-) diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index c1dfac5..140833b 100644 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -2489,6 +2489,9 @@ namespace CodeImp.DoomBuilder.Geometry { if(side.Sector != nearest) sidesectorref[side] = nearest; // This side will be reattached in phase 2 else sidesectorref.Remove(side); // This side is already attached where it needs to be + + // Store + adjustedsides.Add(side); } else { @@ -2574,9 +2577,41 @@ namespace CodeImp.DoomBuilder.Geometry { List sectorsides = FindPotentialSectorAt(line, front); if(sectorsides == null) return null; + Sector result = null; + + // Special case: if sectorsides match sidestoexclude and all sidestoexclude reference the same sector, return that sector + if(sidestoexclude.Count > 2 && sectorsides.Count == sidestoexclude.Count) + { + bool allsidesmatch = true; + + // Check if all sidestoexclude reference the same sector... + foreach(Sidedef s in sidestoexclude) + { + if(result == null) result = s.Sector; + else if(result != s.Sector) + { + allsidesmatch = false; + break; + } + } + + // Check if sidestoexclude match sectorsides... + if(allsidesmatch) + { + HashSet sectorsidesset = new HashSet(); + foreach(LinedefSide ls in sectorsides) + { + sectorsidesset.Add(ls.Front ? ls.Line.Front : ls.Line.Back); + } + + allsidesmatch = sectorsidesset.SetEquals(sidestoexclude); + } + + // Sides are already where they need to be + if(allsidesmatch) return result; + } // Filter outersides from the list, proceed only if all sectorsides reference the same sector - Sector result = null; foreach(LinedefSide sectorside in sectorsides) { Sidedef target = (sectorside.Front ? sectorside.Line.Front : sectorside.Line.Back); diff --git a/Source/Core/Map/MapOptions.cs b/Source/Core/Map/MapOptions.cs index 3e107da..b78a8ca 100644 --- a/Source/Core/Map/MapOptions.cs +++ b/Source/Core/Map/MapOptions.cs @@ -438,16 +438,21 @@ namespace CodeImp.DoomBuilder.Map { ScriptDocumentSettings settings = new ScriptDocumentSettings { FoldLevels = new Dictionary>() }; - // Copy information from Configuration to ScriptDocumentSaveSettings - if (scfinfo.Contains("filename") && (scfinfo["filename"] is string)) settings.Filename = (string)scfinfo["filename"]; - if (scfinfo.Contains("hash") && (scfinfo["hash"] is long)) settings.Hash = (long)scfinfo["hash"]; - if (scfinfo.Contains("caretposition") && (scfinfo["caretposition"] is int)) settings.CaretPosition = (int)scfinfo["caretposition"]; - if (scfinfo.Contains("firstvisibleline") && (scfinfo["firstvisibleline"] is int)) settings.FirstVisibleLine = (int)scfinfo["firstvisibleline"]; - if (scfinfo.Contains("activetab") && (scfinfo["activetab"] is bool)) settings.IsActiveTab = (bool)scfinfo["activetab"]; - if (scfinfo.Contains("foldlevels") && (scfinfo["foldlevels"] is string)) - { - // 1:12,13,14;2:21,43,36 - string foldstr = (string)scfinfo["foldlevels"]; + // Copy information from Configuration to ScriptDocumentSaveSettings + if(scfinfo.Contains("filename") && (scfinfo["filename"] is string)) settings.Filename = (string)scfinfo["filename"]; + if(scfinfo.Contains("hash")) + { + // Configuration will parse the value as int if it's inside int type bounds. + if(scfinfo["hash"] is int) settings.Hash = (int)scfinfo["hash"]; + else if(scfinfo["hash"] is long) settings.Hash = (long)scfinfo["hash"]; + } + if(scfinfo.Contains("caretposition") && (scfinfo["caretposition"] is int)) settings.CaretPosition = (int)scfinfo["caretposition"]; + if(scfinfo.Contains("firstvisibleline") && (scfinfo["firstvisibleline"] is int)) settings.FirstVisibleLine = (int)scfinfo["firstvisibleline"]; + if(scfinfo.Contains("activetab") && (scfinfo["activetab"] is bool)) settings.IsActiveTab = (bool)scfinfo["activetab"]; + if(scfinfo.Contains("foldlevels") && (scfinfo["foldlevels"] is string)) + { + // 1:12,13,14;2:21,43,36 + string foldstr = (string)scfinfo["foldlevels"]; // Convert string to dictionary if (!string.IsNullOrEmpty(foldstr)) diff --git a/Source/Plugins/BuilderModes/ClassicModes/DragLinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DragLinedefsMode.cs index 05ca6cc..8448171 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/DragLinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DragLinedefsMode.cs @@ -129,16 +129,17 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd. Reattach/add/remove outer sidedefs HashSet adjustedsides = Tools.AdjustOuterSidedefs(toadjust, changedlines); + //mxd. Split outer sectors + Tools.SplitOuterSectors(changedlines); + //mxd. Remove unneeded textures foreach(Sidedef side in adjustedsides) { + if(side.IsDisposed) continue; side.RemoveUnneededTextures(true, true, true); if(side.Other != null) side.Other.RemoveUnneededTextures(true, true, true); } - //mxd. Split outer sectors - Tools.SplitOuterSectors(changedlines); - // If only a single linedef was selected, deselect it now if(selectedlines.Count == 1) General.Map.Map.ClearSelectedLinedefs(); } diff --git a/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs index 9557851..33a59e6 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs @@ -132,16 +132,17 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd. Process outer sidedefs HashSet adjustedsides = Tools.AdjustOuterSidedefs(toadjust, changedlines); + //mxd. Split outer sectors + Tools.SplitOuterSectors(changedlines); + //mxd. Remove unneeded textures foreach(Sidedef side in adjustedsides) { + if(side.IsDisposed) continue; side.RemoveUnneededTextures(true, true, true); if(side.Other != null) side.Other.RemoveUnneededTextures(true, true, true); } - //mxd. Split outer sectors - Tools.SplitOuterSectors(changedlines); - // If only a single sector was selected, deselect it now if(selectedsectors.Count == 1) { diff --git a/Source/Plugins/BuilderModes/ClassicModes/DragVerticesMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DragVerticesMode.cs index f204d56..66e31d8 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/DragVerticesMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DragVerticesMode.cs @@ -123,16 +123,17 @@ namespace CodeImp.DoomBuilder.BuilderModes // Reattach/add/remove outer sidedefs HashSet adjustedsides = Tools.AdjustOuterSidedefs(toadjust, changedlines); + // Split outer sectors + Tools.SplitOuterSectors(changedlines); + // Remove unneeded textures foreach(Sidedef side in adjustedsides) { + if(side.IsDisposed) continue; side.RemoveUnneededTextures(true, true, true); if(side.Other != null) side.Other.RemoveUnneededTextures(true, true, true); } - // Split outer sectors - Tools.SplitOuterSectors(changedlines); - // Additional verts may've been created if(selectedverts.Count > 1) { diff --git a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs index 023ac5e..a3c2527 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/EditSelectionMode.cs @@ -1658,15 +1658,16 @@ namespace CodeImp.DoomBuilder.BuilderModes // Change floor/ceiling height? if(!pasting) AdjustSectorsHeight(affectedsectors, heightadjustmode, oldoutsidefloorheight, oldoutsideceilingheight); + // Split outer sectors + Tools.SplitOuterSectors(changedlines); + // Remove unneeded textures (needs to be done AFTER adjusting floor/ceiling height) foreach(Sidedef side in adjustedsides) { + if(side.IsDisposed) continue; side.RemoveUnneededTextures(true, true, true); if(side.Other != null) side.Other.RemoveUnneededTextures(true, true, true); } - - // Split outer sectors - Tools.SplitOuterSectors(changedlines); } // Update cached values