- Added check to remove zero-length linedefs when opening a map that has any

- Some minor interface polishing
This commit is contained in:
codeimp 2009-05-12 18:20:03 +00:00
parent 0dc2bed6d1
commit 5d6e077efb
6 changed files with 194 additions and 137 deletions

View file

@ -300,75 +300,83 @@ namespace CodeImp.DoomBuilder.IO
// Create new linedef
if(vertexlink.ContainsKey(v1) && vertexlink.ContainsKey(v2))
{
l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
l.Update(stringflags, 0, tag, action, new int[Linedef.NUM_ARGS]);
l.UpdateCache();
// Line has a front side?
if(s1 != ushort.MaxValue)
// Check if not zero-length
if(Vector2D.ManhattanDistance(vertexlink[v1].Position, vertexlink[v2].Position) > 0.0001f)
{
// Read front sidedef
if((s1 * 30L) <= (sidedefsmem.Length - 30L))
{
sidedefsmem.Seek(s1 * 30, SeekOrigin.Begin);
offsetx = readside.ReadInt16();
offsety = readside.ReadInt16();
thigh = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tlow = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tmid = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
sc = readside.ReadUInt16();
l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
l.Update(stringflags, 0, tag, action, new int[Linedef.NUM_ARGS]);
l.UpdateCache();
// Create front sidedef
if(sectorlink.ContainsKey(sc))
// Line has a front side?
if(s1 != ushort.MaxValue)
{
// Read front sidedef
if((s1 * 30L) <= (sidedefsmem.Length - 30L))
{
s = map.CreateSidedef(l, true, sectorlink[sc]);
s.Update(offsetx, offsety, thigh, tmid, tlow);
sidedefsmem.Seek(s1 * 30, SeekOrigin.Begin);
offsetx = readside.ReadInt16();
offsety = readside.ReadInt16();
thigh = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tlow = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tmid = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
sc = readside.ReadUInt16();
// Create front sidedef
if(sectorlink.ContainsKey(sc))
{
s = map.CreateSidedef(l, true, sectorlink[sc]);
s.Update(offsetx, offsety, thigh, tmid, tlow);
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Sidedef " + s1 + " references invalid sector " + sc + ". Sidedef has been removed.");
}
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Sidedef references invalid sector " + sc + ". Sidedef has been removed.");
General.ErrorLogger.Add(ErrorType.Warning, "Linedef references invalid sidedef " + s1 + ". Sidedef has been removed.");
}
}
else
// Line has a back side?
if(s2 != ushort.MaxValue)
{
General.ErrorLogger.Add(ErrorType.Warning, "Linedef references invalid sidedef. Sidedef has been removed.");
// Read back sidedef
if((s2 * 30L) <= (sidedefsmem.Length - 30L))
{
sidedefsmem.Seek(s2 * 30, SeekOrigin.Begin);
offsetx = readside.ReadInt16();
offsety = readside.ReadInt16();
thigh = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tlow = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tmid = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
sc = readside.ReadUInt16();
// Create back sidedef
if(sectorlink.ContainsKey(sc))
{
s = map.CreateSidedef(l, false, sectorlink[sc]);
s.Update(offsetx, offsety, thigh, tmid, tlow);
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Sidedef " + s2 + " references invalid sector " + sc + ". Sidedef has been removed.");
}
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + i + " references invalid sidedef " + s2 + ". Sidedef has been removed.");
}
}
}
// Line has a back side?
if(s2 != ushort.MaxValue)
else
{
// Read back sidedef
if((s2 * 30L) <= (sidedefsmem.Length - 30L))
{
sidedefsmem.Seek(s2 * 30, SeekOrigin.Begin);
offsetx = readside.ReadInt16();
offsety = readside.ReadInt16();
thigh = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tlow = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tmid = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
sc = readside.ReadUInt16();
// Create back sidedef
if(sectorlink.ContainsKey(sc))
{
s = map.CreateSidedef(l, false, sectorlink[sc]);
s.Update(offsetx, offsety, thigh, tmid, tlow);
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Sidedef references invalid sector " + sc + ". Sidedef has been removed.");
}
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Linedef references invalid sidedef. Sidedef has been removed.");
}
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + i + " is zero-length. Linedef has been removed.");
}
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Linedef references one or more invalid vertices. Linedef has been removed.");
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + i + " references one or more invalid vertices. Linedef has been removed.");
}
}

View file

@ -315,75 +315,83 @@ namespace CodeImp.DoomBuilder.IO
// Create new linedef
if(vertexlink.ContainsKey(v1) && vertexlink.ContainsKey(v2))
{
l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
l.Update(stringflags, (flags & manager.Config.LinedefActivationsFilter), 0, action, args);
l.UpdateCache();
// Line has a front side?
if(s1 != ushort.MaxValue)
// Check if not zero-length
if(Vector2D.ManhattanDistance(vertexlink[v1].Position, vertexlink[v2].Position) > 0.0001f)
{
// Read front sidedef
sidedefsmem.Seek(s1 * 30, SeekOrigin.Begin);
if((s1 * 30L) <= (sidedefsmem.Length - 30L))
{
offsetx = readside.ReadInt16();
offsety = readside.ReadInt16();
thigh = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tlow = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tmid = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
sc = readside.ReadUInt16();
l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
l.Update(stringflags, (flags & manager.Config.LinedefActivationsFilter), 0, action, args);
l.UpdateCache();
// Create front sidedef
if(sectorlink.ContainsKey(sc))
// Line has a front side?
if(s1 != ushort.MaxValue)
{
// Read front sidedef
sidedefsmem.Seek(s1 * 30, SeekOrigin.Begin);
if((s1 * 30L) <= (sidedefsmem.Length - 30L))
{
s = map.CreateSidedef(l, true, sectorlink[sc]);
s.Update(offsetx, offsety, thigh, tmid, tlow);
offsetx = readside.ReadInt16();
offsety = readside.ReadInt16();
thigh = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tlow = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tmid = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
sc = readside.ReadUInt16();
// Create front sidedef
if(sectorlink.ContainsKey(sc))
{
s = map.CreateSidedef(l, true, sectorlink[sc]);
s.Update(offsetx, offsety, thigh, tmid, tlow);
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Sidedef " + s1 + " references invalid sector " + sc + ". Sidedef has been removed.");
}
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Sidedef references invalid sector " + sc + ". Sidedef has been removed.");
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + i + " references invalid sidedef " + s1 + ". Sidedef has been removed.");
}
}
else
// Line has a back side?
if(s2 != ushort.MaxValue)
{
General.ErrorLogger.Add(ErrorType.Warning, "Linedef references invalid sidedef. Sidedef has been removed.");
// Read back sidedef
sidedefsmem.Seek(s2 * 30, SeekOrigin.Begin);
if((s2 * 30L) <= (sidedefsmem.Length - 30L))
{
offsetx = readside.ReadInt16();
offsety = readside.ReadInt16();
thigh = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tlow = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tmid = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
sc = readside.ReadUInt16();
// Create back sidedef
if(sectorlink.ContainsKey(sc))
{
s = map.CreateSidedef(l, false, sectorlink[sc]);
s.Update(offsetx, offsety, thigh, tmid, tlow);
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Sidedef " + s2 + " references invalid sector " + sc + ". Sidedef has been removed.");
}
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + i + " references invalid sidedef " + s2 + ". Sidedef has been removed.");
}
}
}
// Line has a back side?
if(s2 != ushort.MaxValue)
else
{
// Read back sidedef
sidedefsmem.Seek(s2 * 30, SeekOrigin.Begin);
if((s2 * 30L) <= (sidedefsmem.Length - 30L))
{
offsetx = readside.ReadInt16();
offsety = readside.ReadInt16();
thigh = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tlow = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
tmid = Lump.MakeNormalName(readside.ReadBytes(8), WAD.ENCODING);
sc = readside.ReadUInt16();
// Create back sidedef
if(sectorlink.ContainsKey(sc))
{
s = map.CreateSidedef(l, false, sectorlink[sc]);
s.Update(offsetx, offsety, thigh, tmid, tlow);
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Sidedef references invalid sector " + sc + ". Sidedef has been removed.");
}
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Linedef references invalid sidedef. Sidedef has been removed.");
}
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + i + " is zero-length. Linedef has been removed.");
}
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Linedef references one or more invalid vertices. Linedef has been removed.");
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + i + " references one or more invalid vertices. Linedef has been removed.");
}
}

View file

@ -230,33 +230,41 @@ namespace CodeImp.DoomBuilder.IO
// Create new linedef
if(vertexlink.ContainsKey(v1) && vertexlink.ContainsKey(v2))
{
Linedef l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
l.Update(stringflags, 0, tag, special, args);
l.UpdateCache();
// Custom fields
ReadCustomFields(lc, l, "linedef");
// Read sidedefs and connect them to the line
if(s1 > -1)
// Check if not zero-length
if(Vector2D.ManhattanDistance(vertexlink[v1].Position, vertexlink[v2].Position) > 0.0001f)
{
if(s1 < sidescolls.Count)
ReadSidedef(map, sidescolls[s1], l, true, sectorlink);
else
General.ErrorLogger.Add(ErrorType.Warning, "Linedef references invalid sidedef. Sidedef has been removed.");
Linedef l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
l.Update(stringflags, 0, tag, special, args);
l.UpdateCache();
// Custom fields
ReadCustomFields(lc, l, "linedef");
// Read sidedefs and connect them to the line
if(s1 > -1)
{
if(s1 < sidescolls.Count)
ReadSidedef(map, sidescolls[s1], l, true, sectorlink);
else
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + i + " references invalid front sidedef " + s1 + ". Sidedef has been removed.");
}
if(s2 > -1)
{
if(s2 < sidescolls.Count)
ReadSidedef(map, sidescolls[s2], l, false, sectorlink);
else
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + i + " references invalid back sidedef " + s1 + ". Sidedef has been removed.");
}
}
if(s2 > -1)
else
{
if(s2 < sidescolls.Count)
ReadSidedef(map, sidescolls[s2], l, false, sectorlink);
else
General.ErrorLogger.Add(ErrorType.Warning, "Linedef references invalid sidedef. Sidedef has been removed.");
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + i + " is zero-length. Linedef has been removed.");
}
}
else
{
General.ErrorLogger.Add(ErrorType.Warning, "Linedef references one or more invalid vertices. Linedef has been removed.");
General.ErrorLogger.Add(ErrorType.Warning, "Linedef " + i + " references one or more invalid vertices. Linedef has been removed.");
}
}
}

View file

@ -40,7 +40,7 @@ using System.Drawing;
namespace CodeImp.DoomBuilder.BuilderModes
{
[ErrorChecker("Check for stuck things", true, 1000)]
[ErrorChecker("Check stuck things", true, 1000)]
public class CheckStuckedThings : ErrorChecker
{
#region ================== Constants

View file

@ -50,13 +50,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.checks.Location = new System.Drawing.Point(10, 15);
this.checks.Margin = new System.Windows.Forms.Padding(1);
this.checks.Name = "checks";
this.checks.Size = new System.Drawing.Size(360, 108);
this.checks.Size = new System.Drawing.Size(360, 63);
this.checks.TabIndex = 0;
//
// buttoncheck
//
this.buttoncheck.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttoncheck.Location = new System.Drawing.Point(254, 134);
this.buttoncheck.Location = new System.Drawing.Point(254, 89);
this.buttoncheck.Margin = new System.Windows.Forms.Padding(1);
this.buttoncheck.Name = "buttoncheck";
this.buttoncheck.Size = new System.Drawing.Size(116, 25);
@ -76,7 +76,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.results.Location = new System.Drawing.Point(10, 34);
this.results.Margin = new System.Windows.Forms.Padding(1);
this.results.Name = "results";
this.results.Size = new System.Drawing.Size(360, 172);
this.results.Size = new System.Drawing.Size(360, 175);
this.results.TabIndex = 0;
this.results.SelectedIndexChanged += new System.EventHandler(this.results_SelectedIndexChanged);
//
@ -88,15 +88,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.resultspanel.Controls.Add(this.fix1);
this.resultspanel.Controls.Add(this.progress);
this.resultspanel.Controls.Add(this.results);
this.resultspanel.Location = new System.Drawing.Point(0, 170);
this.resultspanel.Location = new System.Drawing.Point(0, 124);
this.resultspanel.Name = "resultspanel";
this.resultspanel.Size = new System.Drawing.Size(383, 326);
this.resultspanel.Size = new System.Drawing.Size(383, 329);
this.resultspanel.TabIndex = 2;
//
// fix3
//
this.fix3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.fix3.Location = new System.Drawing.Point(256, 289);
this.fix3.Location = new System.Drawing.Point(256, 292);
this.fix3.Name = "fix3";
this.fix3.Size = new System.Drawing.Size(114, 26);
this.fix3.TabIndex = 3;
@ -108,7 +108,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// fix2
//
this.fix2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.fix2.Location = new System.Drawing.Point(133, 289);
this.fix2.Location = new System.Drawing.Point(133, 292);
this.fix2.Name = "fix2";
this.fix2.Size = new System.Drawing.Size(114, 26);
this.fix2.TabIndex = 2;
@ -122,7 +122,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.resultinfo.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.resultinfo.Enabled = false;
this.resultinfo.Location = new System.Drawing.Point(12, 212);
this.resultinfo.Location = new System.Drawing.Point(12, 215);
this.resultinfo.Name = "resultinfo";
this.resultinfo.Size = new System.Drawing.Size(358, 74);
this.resultinfo.TabIndex = 5;
@ -131,7 +131,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// fix1
//
this.fix1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.fix1.Location = new System.Drawing.Point(10, 289);
this.fix1.Location = new System.Drawing.Point(10, 292);
this.fix1.Name = "fix1";
this.fix1.Size = new System.Drawing.Size(114, 26);
this.fix1.TabIndex = 1;
@ -168,7 +168,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.CancelButton = this.closebutton;
this.ClientSize = new System.Drawing.Size(380, 493);
this.ClientSize = new System.Drawing.Size(380, 453);
this.Controls.Add(this.closebutton);
this.Controls.Add(this.resultspanel);
this.Controls.Add(this.buttoncheck);

View file

@ -117,4 +117,37 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="checks.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="buttoncheck.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="results.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="resultspanel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="fix3.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="fix2.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="resultinfo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="fix1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="progress.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="closebutton.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>