private static Patch CachedRead(string name, Dictionary <string, Patch> cache) { if (!cache.ContainsKey(name)) { var reader = new BinaryReader(DoomApplication.Instance.FileSystem.Read(name)); cache.Add(name, Patch.FromData(name, reader.ReadBytes((int)reader.BaseStream.Length))); } return(cache[name]); }
private static Patch[] LoadPatches() { var patchNames = TextureLookup.LoadPatchNames(); var patches = new Patch[patchNames.Length]; for (var i = 0; i < patches.Length; i++) { var name = patchNames[i]; // This check is necessary to avoid crash in DOOM1.WAD. if (!DoomApplication.Instance.FileSystem.Exists(name)) { if (name == "TFOGF0" || name == "TFOGI0") // TNT.WAD uses this sprites as patches... { name = $"SPRITES/{name}"; } else if (name == "BOSFA0") // PLUTONIA.WAD uses this sprite as patch... { name = $"SPRITES/{name}"; } else { name = $"PATCHES/{name}"; } if (!DoomApplication.Instance.FileSystem.Exists(name)) { continue; } } var reader = new BinaryReader(DoomApplication.Instance.FileSystem.Read(name)); patches[i] = Patch.FromData(name, reader.ReadBytes((int)reader.BaseStream.Length)); } return(patches); }
public static Patch FromWad(string name) { var reader = new BinaryReader(DoomApplication.Instance.FileSystem.Read(name)); return(Patch.FromData(name, reader.ReadBytes((int)reader.BaseStream.Length))); }