private static string[] LoadPatchNames() { var reader = new BinaryReader(DoomApplication.Instance.FileSystem.Read("PNAMES")); var count = reader.ReadInt32(); var names = new string[count]; for (var i = 0; i < names.Length; i++) { names[i] = DoomInterop.ToString(reader.ReadBytes(8), 0, 8); } return(names); }
private void AddFile(string fileName) { names.Add(Path.GetFileNameWithoutExtension(fileName).ToLower()); var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read); streams.Add(stream); string identification; int lumpCount; int lumpInfoTableOffset; { var data = new byte[12]; if (stream.Read(data, 0, data.Length) != data.Length) { throw new Exception("Failed to read the WAD file."); } identification = DoomInterop.ToString(data, 0, 4); lumpCount = BitConverter.ToInt32(data, 4); lumpInfoTableOffset = BitConverter.ToInt32(data, 8); if (identification != "IWAD" && identification != "PWAD") { throw new Exception("The file is not a WAD file."); } } { var data = new byte[LumpInfo.DataSize * lumpCount]; stream.Seek(lumpInfoTableOffset, SeekOrigin.Begin); if (stream.Read(data, 0, data.Length) != data.Length) { throw new Exception("Failed to read the WAD file."); } for (var i = 0; i < lumpCount; i++) { var offset = LumpInfo.DataSize * i; var lumpInfo = new LumpInfo( DoomInterop.ToString(data, offset + 8, 8), stream, BitConverter.ToInt32(data, offset), BitConverter.ToInt32(data, offset + 4)); lumpInfos.Add(lumpInfo); } } }
public static Texture FromData(byte[] data, int offset, Patch[] patchLookup) { var name = DoomInterop.ToString(data, offset, 8); var masked = BitConverter.ToInt32(data, offset + 8); var width = BitConverter.ToInt16(data, offset + 12); var height = BitConverter.ToInt16(data, offset + 14); var patchCount = BitConverter.ToInt16(data, offset + 20); var patches = new TexturePatch[patchCount]; for (var i = 0; i < patchCount; i++) { var patchOffset = offset + 22 + TexturePatch.DataSize * i; patches[i] = TexturePatch.FromData(data, patchOffset, patchLookup); } return(new Texture(name, masked != 0, width, height, patches)); }
public static SideDef FromData(byte[] data, int offset, TextureLookup textures, Sector[] sectors) { var textureOffset = BitConverter.ToInt16(data, offset); var rowOffset = BitConverter.ToInt16(data, offset + 2); var topTextureName = DoomInterop.ToString(data, offset + 4, 8); var bottomTextureName = DoomInterop.ToString(data, offset + 12, 8); var middleTextureName = DoomInterop.ToString(data, offset + 20, 8); var sectorNum = BitConverter.ToInt16(data, offset + 28); return(new SideDef( Fixed.FromInt(textureOffset), Fixed.FromInt(rowOffset), textures.GetNumber(topTextureName), textures.GetNumber(bottomTextureName), textures.GetNumber(middleTextureName), sectorNum != -1 ? sectors[sectorNum] : null )); }
private void ReadSlots() { this.slots = new string[SaveSlots.slotCount]; var buffer = new byte[SaveSlots.descriptionSize]; for (var i = 0; i < this.slots.Length; i++) { var path = "doomsav" + i + ".dsg"; if (DoomApplication.Instance.FileSystem.Exists(path)) { using (var reader = DoomApplication.Instance.FileSystem.Read(path)) { reader.Read(buffer, 0, buffer.Length); this.slots[i] = DoomInterop.ToString(buffer, 0, buffer.Length); } } } }
public static Sector FromData(byte[] data, int offset, int number, FlatLookup flats) { var floorHeight = BitConverter.ToInt16(data, offset); var ceilingHeight = BitConverter.ToInt16(data, offset + 2); var floorFlatName = DoomInterop.ToString(data, offset + 4, 8); var ceilingFlatName = DoomInterop.ToString(data, offset + 12, 8); var lightLevel = BitConverter.ToInt16(data, offset + 20); var special = BitConverter.ToInt16(data, offset + 22); var tag = BitConverter.ToInt16(data, offset + 24); return(new Sector( number, Fixed.FromInt(floorHeight), Fixed.FromInt(ceilingHeight), flats.GetNumber(floorFlatName), flats.GetNumber(ceilingFlatName), lightLevel, (SectorSpecial)special, tag )); }
public static string GetName(byte[] data, int offset) { return(DoomInterop.ToString(data, offset, 8)); }
private string ReadVersion() { return(DoomInterop.ToString(this.reader.ReadBytes(SaveAndLoad.versionSize), 0, SaveAndLoad.versionSize)); }