diff --git a/Source/Core/GZBuilder/Windows/ExceptionDialog.cs b/Source/Core/GZBuilder/Windows/ExceptionDialog.cs index fdc97179..cf541ab7 100644 --- a/Source/Core/GZBuilder/Windows/ExceptionDialog.cs +++ b/Source/Core/GZBuilder/Windows/ExceptionDialog.cs @@ -38,6 +38,55 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows public void Setup() { bContinue.Enabled = !cannotContinue; + + string[] titles = { + "0x000000 at 0xFFFFFF. That's probaby bad", + "Here we go again...", + "Uh oh, you're screwed", + "All is lost!", + "Achievement unlocked: CRASH TIME!", + "OH NOES! TEH ERROR!", + "0001000001111011000000000011001101011110110111", + "Nuclear launch detected!", + "Don't send this to Microsoft", + "You. Shall. Not. Pass!!!", + "Yep, we have bugs", + "It's dangerous to go alone. Take this!", + "The operation completed successfully", + "Security Alert – Moving cursor is not as safe as you thought", + "Random error appears from north", + "ERROR: NO_ERROR", + "Epic fail", + "At least it's not BSoD...", + "User Error. Please Replace User", + "Brought to you by MaxED!", + "GZDoom Builder proudly presents:", + "You aren't expected to understand this", + "Back to the drawing board...", + "I'm sorry... :(", + "This is a horrbble day for you, and of course, the world", + "Abort, Retry, Fail?", + "You are making progress. I'm afraid that's something I cannot allow to happen", + "You are making progress. That's not OK", + "No errors found, restarting computer", + "Does Not Compute!", + "I’m sorry, Dave, I’m afraid I can’t do that", + "What's that? Chicken?", + "It can only be attributable to human error", + "It's now safe to turn off your computer", + "I've got a bad feeling about this", + "YOU CAN’T DO THAT!", + "Man the Lifeboats! Women and children first!", + "IMPOSSIBURU!!!", + "Now deleting all files. Goodbye", + "General Failure", + "Invalid Error", + "Beam me up Scotty, there’s no life out here", + "Well, you ran into something and the game is over", + "I'm good at writing bad code", + "$FUNNY_ERROR_CAPTION", + }; + this.Text = titles[new Random().Next(0, titles.Length - 1)]; } private void reportLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { diff --git a/Source/Core/Map/Sector.cs b/Source/Core/Map/Sector.cs index ea3028bd..3fe8bae5 100644 --- a/Source/Core/Map/Sector.cs +++ b/Source/Core/Map/Sector.cs @@ -490,14 +490,16 @@ namespace CodeImp.DoomBuilder.Map else if (s.Line.Start.Position.x > right) right = s.Line.Start.Position.x; if (s.Line.Start.Position.y < top) top = s.Line.Start.Position.y; else if (s.Line.Start.Position.y > bottom) bottom = s.Line.Start.Position.y; + processed.Add(s.Line.Start); } //end... - if(!processed.Contains(s.Line.Start)) { + if(!processed.Contains(s.Line.End)) { if(s.Line.End.Position.x < left) left = s.Line.End.Position.x; else if(s.Line.End.Position.x > right) right = s.Line.End.Position.x; if(s.Line.End.Position.y < top) top = s.Line.End.Position.y; else if(s.Line.End.Position.y > bottom) bottom = s.Line.End.Position.y; + processed.Add(s.Line.End); } } diff --git a/Source/Plugins/BuilderModes/BuilderModes.csproj b/Source/Plugins/BuilderModes/BuilderModes.csproj index 811f61c1..5f71a26e 100644 --- a/Source/Plugins/BuilderModes/BuilderModes.csproj +++ b/Source/Plugins/BuilderModes/BuilderModes.csproj @@ -238,6 +238,7 @@ + diff --git a/Source/Plugins/BuilderModes/ErrorChecks/CheckClosedSectors.cs b/Source/Plugins/BuilderModes/ErrorChecks/CheckClosedSectors.cs index 83854704..17497f70 100644 --- a/Source/Plugins/BuilderModes/ErrorChecks/CheckClosedSectors.cs +++ b/Source/Plugins/BuilderModes/ErrorChecks/CheckClosedSectors.cs @@ -24,7 +24,7 @@ using System.Threading; namespace CodeImp.DoomBuilder.BuilderModes { - [ErrorChecker("Check closed sectors", true, 300)] + [ErrorChecker("Check invalid sectors", true, 300)] public class CheckClosedSectors : ErrorChecker { #region ================== Constants @@ -149,6 +149,8 @@ namespace CodeImp.DoomBuilder.BuilderModes // Add report when holes have been found if(foundholes.Count > 0) SubmitResult(new ResultSectorUnclosed(s, foundholes)); + else if(s.Sidedefs.Count < 3 || s.BBox.IsEmpty) //mxd + SubmitResult(new ResultSectorInvalid(s)); // Handle thread interruption try { Thread.Sleep(0); } diff --git a/Source/Plugins/BuilderModes/ErrorChecks/ResultSectorInvalid.cs b/Source/Plugins/BuilderModes/ErrorChecks/ResultSectorInvalid.cs new file mode 100644 index 00000000..7cb4935e --- /dev/null +++ b/Source/Plugins/BuilderModes/ErrorChecks/ResultSectorInvalid.cs @@ -0,0 +1,87 @@ +#region ================== Namespaces + +using System.Collections.Generic; +using CodeImp.DoomBuilder.Geometry; +using CodeImp.DoomBuilder.Map; +using CodeImp.DoomBuilder.Rendering; + +#endregion + +namespace CodeImp.DoomBuilder.BuilderModes +{ + public class ResultSectorInvalid : ErrorResult + { + #region ================== Variables + + private readonly Sector sector; + + #endregion + + #region ================== Properties + + public override int Buttons { get { return 1; } } + public override string Button1Text { get { return "Dissolve"; } } + + #endregion + + #region ================== Constructor / Destructor + + // Constructor + public ResultSectorInvalid(Sector s) + { + // Initialize + this.sector = s; + this.viewobjects.Add(s); + this.description = "This sector has invalid geometry (it has less than 3 sidedefs or it's area is 0). This could cause problems with clipping and rendering in the game."; + } + + #endregion + + #region ================== Methods + + // This must return the string that is displayed in the listbox + public override string ToString() { + if (sector.Sidedefs != null && sector.Sidedefs.Count > 2) + return "Area of sector " + sector.Index + " is 0"; + return "Sector " + sector.Index + " has " + (sector.Sidedefs == null ? "no" : sector.Sidedefs.Count.ToString()) + " sidedefs"; + } + + // Rendering + public override void PlotSelection(IRenderer2D renderer) + { + renderer.PlotSector(sector, General.Colors.Selection); + } + + // Fix by merging with surrounding geometry/removing + public override bool Button1Click(bool batchMode) { + if(!batchMode) General.Map.UndoRedo.CreateUndo("Invalid sector correction"); + + //collect the lines + List lines = new List(); + foreach (Sidedef side in sector.Sidedefs) { + if (!lines.Contains(side.Line) && !side.Line.IsDisposed) + lines.Add(side.Line); + } + + //get rid of lines with zero length + foreach (Linedef line in lines) + if (line.Length == 0) line.Dispose(); + + if(lines.Count == 0) { + sector.Dispose(); + } else { //redraw the lines + foreach(Linedef line in lines) { + if(line.IsDisposed) continue; + DrawnVertex start = new DrawnVertex { pos = line.Start.Position, stitch = true, stitchline = true }; + DrawnVertex end = new DrawnVertex { pos = line.End.Position, stitch = true, stitchline = true }; + Tools.DrawLines(new List { start, end }); + } + } + + General.Map.Map.Update(); + return true; + } + + #endregion + } +}