mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
added checks to allow opening maps with missing sidedefs, sectors or vertices (in these cases, the element requiring the missing element will be removed from the map during loading)
This commit is contained in:
parent
3370d90bd0
commit
2aedd732d3
3 changed files with 176 additions and 79 deletions
|
@ -272,43 +272,78 @@ namespace CodeImp.DoomBuilder.IO
|
||||||
if(int.TryParse(f.Key, out fnum)) stringflags[f.Key] = ((flags & fnum) == fnum);
|
if(int.TryParse(f.Key, out fnum)) stringflags[f.Key] = ((flags & fnum) == fnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new item
|
// Create new linedef
|
||||||
l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
|
if(vertexlink.ContainsKey(v1) && vertexlink.ContainsKey(v2))
|
||||||
l.Update(stringflags, 0, tag, action, new int[Linedef.NUM_ARGS]);
|
|
||||||
l.UpdateCache();
|
|
||||||
|
|
||||||
// Line has a front side?
|
|
||||||
if(s1 != ushort.MaxValue)
|
|
||||||
{
|
{
|
||||||
// Read front sidedef
|
l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
|
||||||
sidedefsmem.Seek(s1 * 30, SeekOrigin.Begin);
|
l.Update(stringflags, 0, tag, action, new int[Linedef.NUM_ARGS]);
|
||||||
offsetx = readside.ReadInt16();
|
l.UpdateCache();
|
||||||
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
|
// Line has a front side?
|
||||||
s = map.CreateSidedef(l, true, sectorlink[sc]);
|
if(s1 != ushort.MaxValue)
|
||||||
s.Update(offsetx, offsety, thigh, tmid, tlow);
|
{
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
// Create front sidedef
|
||||||
|
if(sectorlink.ContainsKey(sc))
|
||||||
|
{
|
||||||
|
s = map.CreateSidedef(l, true, sectorlink[sc]);
|
||||||
|
s.Update(offsetx, offsety, thigh, tmid, tlow);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
General.WriteLogLine("WARNING: Sidedef references invalid sector " + sc + "! Sidedef has been removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
General.WriteLogLine("WARNING: Linedef references invalid sidedef! Sidedef has been removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Line has a back side?
|
||||||
|
if(s2 != ushort.MaxValue)
|
||||||
|
{
|
||||||
|
// 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.WriteLogLine("WARNING: Sidedef references invalid sector " + sc + "! Sidedef has been removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
General.WriteLogLine("WARNING: Linedef references invalid sidedef! Sidedef has been removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// Line has a back side?
|
|
||||||
if(s2 != ushort.MaxValue)
|
|
||||||
{
|
{
|
||||||
// Read back sidedef
|
General.WriteLogLine("WARNING: Linedef references one or more invalid vertices! Linedef has been removed.");
|
||||||
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
|
|
||||||
s = map.CreateSidedef(l, false, sectorlink[sc]);
|
|
||||||
s.Update(offsetx, offsety, thigh, tmid, tlow);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,43 +287,78 @@ namespace CodeImp.DoomBuilder.IO
|
||||||
if(int.TryParse(f.Key, out fnum)) stringflags[f.Key] = ((flags & fnum) == fnum);
|
if(int.TryParse(f.Key, out fnum)) stringflags[f.Key] = ((flags & fnum) == fnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new item
|
// Create new linedef
|
||||||
l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
|
if(vertexlink.ContainsKey(v1) && vertexlink.ContainsKey(v2))
|
||||||
l.Update(stringflags, (flags & manager.Config.LinedefActivationsFilter), 0, action, args);
|
|
||||||
l.UpdateCache();
|
|
||||||
|
|
||||||
// Line has a front side?
|
|
||||||
if(s1 != ushort.MaxValue)
|
|
||||||
{
|
{
|
||||||
// Read front sidedef
|
l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
|
||||||
sidedefsmem.Seek(s1 * 30, SeekOrigin.Begin);
|
l.Update(stringflags, (flags & manager.Config.LinedefActivationsFilter), 0, action, args);
|
||||||
offsetx = readside.ReadInt16();
|
l.UpdateCache();
|
||||||
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
|
// Line has a front side?
|
||||||
s = map.CreateSidedef(l, true, sectorlink[sc]);
|
if(s1 != ushort.MaxValue)
|
||||||
s.Update(offsetx, offsety, thigh, tmid, tlow);
|
{
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
// Create front sidedef
|
||||||
|
if(sectorlink.ContainsKey(sc))
|
||||||
|
{
|
||||||
|
s = map.CreateSidedef(l, true, sectorlink[sc]);
|
||||||
|
s.Update(offsetx, offsety, thigh, tmid, tlow);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
General.WriteLogLine("WARNING: Sidedef references invalid sector " + sc + "! Sidedef has been removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
General.WriteLogLine("WARNING: Linedef references invalid sidedef! Sidedef has been removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Line has a back side?
|
||||||
|
if(s2 != ushort.MaxValue)
|
||||||
|
{
|
||||||
|
// 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.WriteLogLine("WARNING: Sidedef references invalid sector " + sc + "! Sidedef has been removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
General.WriteLogLine("WARNING: Linedef references invalid sidedef! Sidedef has been removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// Line has a back side?
|
|
||||||
if(s2 != ushort.MaxValue)
|
|
||||||
{
|
{
|
||||||
// Read back sidedef
|
General.WriteLogLine("WARNING: Linedef references one or more invalid vertices! Linedef has been removed.");
|
||||||
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
|
|
||||||
s = map.CreateSidedef(l, false, sectorlink[sc]);
|
|
||||||
s.Update(offsetx, offsety, thigh, tmid, tlow);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,17 +232,37 @@ namespace CodeImp.DoomBuilder.IO
|
||||||
foreach(LinedefActivateInfo activate in General.Map.Config.LinedefActivates)
|
foreach(LinedefActivateInfo activate in General.Map.Config.LinedefActivates)
|
||||||
stringflags[activate.Key] = GetCollectionEntry<bool>(lc, activate.Key, false, false);
|
stringflags[activate.Key] = GetCollectionEntry<bool>(lc, activate.Key, false, false);
|
||||||
|
|
||||||
// Create new item
|
// Create new linedef
|
||||||
Linedef l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
|
if(vertexlink.ContainsKey(v1) && vertexlink.ContainsKey(v2))
|
||||||
l.Update(stringflags, 0, tag, special, args);
|
{
|
||||||
l.UpdateCache();
|
Linedef l = map.CreateLinedef(vertexlink[v1], vertexlink[v2]);
|
||||||
|
l.Update(stringflags, 0, tag, special, args);
|
||||||
|
l.UpdateCache();
|
||||||
|
|
||||||
// Custom fields
|
// Custom fields
|
||||||
ReadCustomFields(lc, l, "linedef");
|
ReadCustomFields(lc, l, "linedef");
|
||||||
|
|
||||||
// Read sidedefs and connect them to the line
|
// Read sidedefs and connect them to the line
|
||||||
if(s1 > -1) ReadSidedef(map, sidescolls[s1], l, true, sectorlink);
|
if(s1 > -1)
|
||||||
if(s2 > -1) ReadSidedef(map, sidescolls[s2], l, false, sectorlink);
|
{
|
||||||
|
if(s1 < sidescolls.Count)
|
||||||
|
ReadSidedef(map, sidescolls[s1], l, true, sectorlink);
|
||||||
|
else
|
||||||
|
General.WriteLogLine("WARNING: Linedef references invalid sidedef! Sidedef has been removed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(s2 > -1)
|
||||||
|
{
|
||||||
|
if(s2 < sidescolls.Count)
|
||||||
|
ReadSidedef(map, sidescolls[s2], l, false, sectorlink);
|
||||||
|
else
|
||||||
|
General.WriteLogLine("WARNING: Linedef references invalid sidedef! Sidedef has been removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
General.WriteLogLine("WARNING: Linedef references one or more invalid vertices! Linedef has been removed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,11 +279,18 @@ namespace CodeImp.DoomBuilder.IO
|
||||||
int sector = GetCollectionEntry<int>(sc, "sector", true, 0);
|
int sector = GetCollectionEntry<int>(sc, "sector", true, 0);
|
||||||
|
|
||||||
// Create sidedef
|
// Create sidedef
|
||||||
Sidedef s = map.CreateSidedef(ld, front, sectorlink[sector]);
|
if(sectorlink.ContainsKey(sector))
|
||||||
s.Update(offsetx, offsety, thigh, tmid, tlow);
|
{
|
||||||
|
Sidedef s = map.CreateSidedef(ld, front, sectorlink[sector]);
|
||||||
|
s.Update(offsetx, offsety, thigh, tmid, tlow);
|
||||||
|
|
||||||
// Custom fields
|
// Custom fields
|
||||||
ReadCustomFields(sc, s, "sidedef");
|
ReadCustomFields(sc, s, "sidedef");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
General.WriteLogLine("WARNING: Sidedef references invalid sector " + sector + "! Sidedef has been removed.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This reads the sectors
|
// This reads the sectors
|
||||||
|
|
Loading…
Reference in a new issue