public DummyFlatLookup(Wad wad) { var firstFlat = wad.GetLumpNumber("F_START") + 1; var lastFlat = wad.GetLumpNumber("F_END") - 1; var count = lastFlat - firstFlat + 1; flats = new Flat[count]; nameToFlat = new Dictionary <string, Flat>(); nameToNumber = new Dictionary <string, int>(); for (var lump = firstFlat; lump <= lastFlat; lump++) { if (wad.GetLumpSize(lump) != 4096) { continue; } var number = lump - firstFlat; var name = wad.LumpInfos[lump].Name; var flat = name != "F_SKY1" ? DummyData.GetFlat() : DummyData.GetSkyFlat(); flats[number] = flat; nameToFlat[name] = flat; nameToNumber[name] = number; } skyFlatNumber = nameToNumber["F_SKY1"]; skyFlat = nameToFlat["F_SKY1"]; }
private void InitStandard(Wad wad) { try { Console.Write("Load flats: "); var firstFlat = wad.GetLumpNumber("F_START") + 1; var lastFlat = wad.GetLumpNumber("F_END") - 1; var count = lastFlat - firstFlat + 1; flats = new Flat[count]; nameToFlat = new Dictionary <string, Flat>(); nameToNumber = new Dictionary <string, int>(); for (var lump = firstFlat; lump <= lastFlat; lump++) { if (wad.GetLumpSize(lump) != 4096 && wad.GetLumpSize(lump) != 4) { continue; } var number = lump - firstFlat; var name = wad.LumpInfos[lump].Name; var flat = new Flat(name, wad.ReadLump(lump)); flats[number] = flat; nameToFlat[name] = flat; nameToNumber[name] = number; } skyFlatNumber = nameToNumber["F_SKY1"]; skyFlat = nameToFlat["F_SKY1"]; Console.WriteLine("OK (" + nameToFlat.Count + " flats)"); } catch (Exception e) { Console.WriteLine("Failed"); ExceptionDispatchInfo.Throw(e); } }
public static Sector[] FromWad(Wad wad, int lump, FlatLookup flats) { var length = wad.GetLumpSize(lump); if (length % dataSize != 0) { throw new Exception(); } var data = wad.ReadLump(lump); var count = length / dataSize; var sectors = new Sector[count];; for (var i = 0; i < count; i++) { var offset = dataSize * i; sectors[i] = FromData(data, offset, i, flats); } return(sectors); }
public static SideDef[] FromWad(Wad wad, int lump, TextureLookup textures, Sector[] sectors) { var length = wad.GetLumpSize(lump); if (length % dataSize != 0) { throw new Exception(); } var data = wad.ReadLump(lump); var count = length / dataSize; var sides = new SideDef[count];; for (var i = 0; i < count; i++) { var offset = dataSize * i; sides[i] = FromData(data, offset, textures, sectors); } return(sides); }
public static LineDef[] FromWad(Wad wad, int lump, Vertex[] vertices, SideDef[] sides) { var length = wad.GetLumpSize(lump); if (length % DataSize != 0) { throw new Exception(); } var data = wad.ReadLump(lump); var count = length / DataSize; var lines = new LineDef[count];; for (var i = 0; i < count; i++) { var offset = 14 * i; lines[i] = FromData(data, offset, vertices, sides); } return(lines); }
public static MapThing[] FromWad(Wad wad, int lump) { var length = wad.GetLumpSize(lump); if (length % DataSize != 0) { throw new Exception(); } var data = wad.ReadLump(lump); var count = length / DataSize; var things = new MapThing[count]; for (var i = 0; i < count; i++) { var offset = DataSize * i; things[i] = FromData(data, offset); } return(things); }
public static Subsector[] FromWad(Wad wad, int lump, Seg[] segs) { var length = wad.GetLumpSize(lump); if (length % Subsector.DataSize != 0) { throw new Exception(); } var data = wad.ReadLump(lump); var count = length / Subsector.DataSize; var subsectors = new Subsector[count]; for (var i = 0; i < count; i++) { var offset = Subsector.DataSize * i; subsectors[i] = Subsector.FromData(data, offset, segs); } return(subsectors); }
public static Seg[] FromWad(Wad wad, int lump, Vertex[] vertices, LineDef[] lines) { var length = wad.GetLumpSize(lump); if (length % Seg.DataSize != 0) { throw new Exception(); } var data = wad.ReadLump(lump); var count = length / Seg.DataSize; var segs = new Seg[count];; for (var i = 0; i < count; i++) { var offset = Seg.DataSize * i; segs[i] = Seg.FromData(data, offset, vertices, lines); } return(segs); }
public static Node[] FromWad(Wad wad, int lump, Subsector[] subsectors) { var length = wad.GetLumpSize(lump); if (length % Node.DataSize != 0) { throw new Exception(); } var data = wad.ReadLump(lump); var count = length / Node.DataSize; var nodes = new Node[count]; for (var i = 0; i < count; i++) { var offset = Node.DataSize * i; nodes[i] = Node.FromData(data, offset); } return(nodes); }
public static Vertex[] FromWad(Wad wad, int lump) { var length = wad.GetLumpSize(lump); if (length % DataSize != 0) { throw new Exception(); } var data = wad.ReadLump(lump); var count = length / DataSize; var vertices = new Vertex[count];; for (var i = 0; i < count; i++) { var offset = DataSize * i; vertices[i] = FromData(data, offset); } return(vertices); }
private void InitDeuTexMerge(Wad wad) { try { Console.Write("Load flats: "); var allFlats = new List <int>(); var flatZone = false; for (var lump = 0; lump < wad.LumpInfos.Count; lump++) { var name = wad.LumpInfos[lump].Name; if (flatZone) { if (name == "F_END" || name == "FF_END") { flatZone = false; } else { allFlats.Add(lump); } } else { if (name == "F_START" || name == "FF_START") { flatZone = true; } } } allFlats.Reverse(); var dupCheck = new HashSet <string>(); var distinctFlats = new List <int>(); foreach (var lump in allFlats) { if (!dupCheck.Contains(wad.LumpInfos[lump].Name)) { distinctFlats.Add(lump); dupCheck.Add(wad.LumpInfos[lump].Name); } } distinctFlats.Reverse(); flats = new Flat[distinctFlats.Count]; nameToFlat = new Dictionary <string, Flat>(); nameToNumber = new Dictionary <string, int>(); for (var number = 0; number < flats.Length; number++) { var lump = distinctFlats[number]; if (wad.GetLumpSize(lump) != 4096) { continue; } var name = wad.LumpInfos[lump].Name; var flat = new Flat(name, wad.ReadLump(lump)); flats[number] = flat; nameToFlat[name] = flat; nameToNumber[name] = number; } skyFlatNumber = nameToNumber["F_SKY1"]; skyFlat = nameToFlat["F_SKY1"]; Console.WriteLine("OK (" + nameToFlat.Count + " flats)"); } catch (Exception e) { Console.WriteLine("Failed"); ExceptionDispatchInfo.Throw(e); } }