public bool GetEncodingEntry(ulong hash, out EncodingEntry enc) { var rootInfos = RootHandler.GetEntries(hash); if (rootInfos.Any()) { return(EncodingHandler.GetEntry(rootInfos.First().MD5, out enc)); } if ((CASCConfig.LoadFlags & LoadFlags.Install) != 0) { var installInfos = Install.GetEntries().Where(e => Hasher.ComputeHash(e.Name) == hash && e.Tags.Any(t => t.Type == 1 && t.Name == RootHandler.Locale.ToString())); if (installInfos.Any()) { return(EncodingHandler.GetEntry(installInfos.First().MD5, out enc)); } installInfos = Install.GetEntries().Where(e => Hasher.ComputeHash(e.Name) == hash); if (installInfos.Any()) { return(EncodingHandler.GetEntry(installInfos.First().MD5, out enc)); } } enc = default(EncodingEntry); return(false); }
private CASCHandlerLite(CASCConfig config, LocaleFlags locale, BackgroundWorkerEx worker) : base(config, worker) { if (config.GameType != CASCGameType.WoW) throw new Exception("Unsupported game " + config.BuildUID); Logger.WriteLine("CASCHandlerLite: loading encoding data..."); EncodingHandler EncodingHandler; using (var _ = new PerfCounter("new EncodingHandler()")) { using (var fs = OpenEncodingFile(this)) EncodingHandler = new EncodingHandler(fs, worker); } Logger.WriteLine("CASCHandlerLite: loaded {0} encoding data", EncodingHandler.Count); Logger.WriteLine("CASCHandlerLite: loading root data..."); RootHandlerBase RootHandler; using (var _ = new PerfCounter("new RootHandler()")) { using (var fs = OpenRootFile(EncodingHandler, this)) RootHandler = new WowRootHandler(fs, worker); } Logger.WriteLine("CASCHandlerLite: loaded {0} root data", RootHandler.Count); RootHandler.SetFlags(locale, ContentFlags.None, false); RootEntry rootEntry; foreach (var entry in RootHandler.GetAllEntries()) { rootEntry = entry.Value; if ((rootEntry.Block.LocaleFlags == locale || (rootEntry.Block.LocaleFlags & locale) != LocaleFlags.None) && (rootEntry.Block.ContentFlags & ContentFlags.LowViolence) == ContentFlags.None) { var enc = EncodingHandler.GetEntry(rootEntry.MD5); if (enc != null) { if (!HashToKey.ContainsKey(entry.Key)) { HashToKey.Add(entry.Key, enc.Key); FileDataIdToHash.Add(rootEntry.FileDataId, entry.Key); } } } } RootHandler.Clear(); EncodingHandler.Clear(); RootHandler = null; EncodingHandler = null; GC.Collect(); Logger.WriteLine("CASCHandlerLite: loaded {0} files", HashToKey.Count); }
protected BinaryReader OpenRootFile(EncodingHandler enc, CASCHandlerBase casc) { if (!enc.GetEntry(casc.Config.RootMD5, out EncodingEntry encInfo)) { throw new FileNotFoundException("encoding info for root file missing!"); } //ExtractFile(encInfo.Key, ".", "root"); return(new BinaryReader(casc.OpenFile(encInfo.Key))); }
public EncodingEntry GetEncodingEntry(ulong hash) { var rootInfos = RootHandler.GetEntries(hash); if (rootInfos.Any()) { return(EncodingHandler.GetEntry(rootInfos.First().MD5)); } if ((CASCConfig.LoadFlags & LoadFlags.Install) != 0) { var installInfos = Install.GetEntries().Where(e => Hasher.ComputeHash(e.Name) == hash); if (installInfos.Any()) { return(EncodingHandler.GetEntry(installInfos.First().MD5)); } } return(null); }
protected BinaryReader OpenDownloadFile(EncodingHandler enc, CASCHandlerBase casc) { var encInfo = enc.GetEntry(casc.Config.DownloadMD5); if (encInfo == null) { throw new FileNotFoundException("encoding info for download file missing!"); } //ExtractFile(encInfo.Key, ".", "download"); return(new BinaryReader(casc.OpenFile(encInfo.Key))); }
protected static BinaryReader OpenInstallFile(EncodingHandler enc, CASCHandlerBase casc) { var encInfo = enc.GetEntry(casc.Config.InstallMD5); if (encInfo == null) { throw new FileNotFoundException("encoding info for install file missing!"); } //ExtractFile(encInfo.Key, ".", "install"); return(new BinaryReader(casc.OpenFile(encInfo.Key))); }
private CASCHandlerLite(CASCConfig config, LocaleFlags locale, BackgroundWorkerEx worker) : base(config, worker) { if (config.GameType != CASCGameType.WoW) { throw new Exception("Unsupported game " + config.BuildUID); } Logger.WriteLine("CASCHandlerLite: loading encoding data..."); EncodingHandler EncodingHandler; using (var _ = new PerfCounter("new EncodingHandler()")) { using (var fs = OpenEncodingFile(this)) EncodingHandler = new EncodingHandler(fs, worker); } Logger.WriteLine("CASCHandlerLite: loaded {0} encoding data", EncodingHandler.Count); Logger.WriteLine("CASCHandlerLite: loading root data..."); WowRootHandler RootHandler; using (var _ = new PerfCounter("new RootHandler()")) { using (var fs = OpenRootFile(EncodingHandler, this)) RootHandler = new WowRootHandler(fs, worker); } Logger.WriteLine("CASCHandlerLite: loaded {0} root data", RootHandler.Count); RootHandler.SetFlags(locale, ContentFlags.None, false); CDNIndexData = new Dictionary <MD5Hash, IndexEntry>(comparer); if (LocalIndex != null) { LocalIndexData = new Dictionary <MD5Hash, IndexEntry>(comparer); } RootEntry rootEntry; foreach (var entry in RootHandler.GetAllEntries()) { rootEntry = entry.Value; if ((rootEntry.LocaleFlags == locale || (rootEntry.LocaleFlags & locale) != LocaleFlags.None) && (rootEntry.ContentFlags & ContentFlags.LowViolence) == ContentFlags.None) { if (EncodingHandler.GetEntry(rootEntry.MD5, out EncodingEntry enc)) { if (!HashToKey.ContainsKey(entry.Key)) { HashToKey.Add(entry.Key, enc.Key); FileDataIdToHash.Add(RootHandler.GetFileDataIdByHash(entry.Key), entry.Key); if (LocalIndex != null) { IndexEntry iLocal = LocalIndex.GetIndexInfo(enc.Key); if (iLocal != null && !LocalIndexData.ContainsKey(enc.Key)) { LocalIndexData.Add(enc.Key, iLocal); } } IndexEntry iCDN = CDNIndex.GetIndexInfo(enc.Key); if (iCDN != null && !CDNIndexData.ContainsKey(enc.Key)) { CDNIndexData.Add(enc.Key, iCDN); } } } } } CDNIndex.Clear(); //CDNIndex = null; LocalIndex?.Clear(); LocalIndex = null; RootHandler.Clear(); RootHandler = null; EncodingHandler.Clear(); EncodingHandler = null; GC.Collect(); Logger.WriteLine("CASCHandlerLite: loaded {0} files", HashToKey.Count); }
private CASCHandlerLite(CASCConfig config, LocaleFlags locale, BackgroundWorkerEx worker) : base(config, worker) { if (config.GameType != CASCGameType.WoW) { throw new Exception("Unsupported game " + config.BuildUID); } Logger.WriteLine("CASCHandlerLite: loading encoding data..."); EncodingHandler EncodingHandler; using (var _ = new PerfCounter("new EncodingHandler()")) { using (var fs = OpenEncodingFile(this)) EncodingHandler = new EncodingHandler(fs, worker); } Logger.WriteLine("CASCHandlerLite: loaded {0} encoding data", EncodingHandler.Count); Logger.WriteLine("CASCHandlerLite: loading root data..."); RootHandlerBase RootHandler; using (var _ = new PerfCounter("new RootHandler()")) { using (var fs = OpenRootFile(EncodingHandler, this)) RootHandler = new WowRootHandler(fs, worker); } Logger.WriteLine("CASCHandlerLite: loaded {0} root data", RootHandler.Count); RootHandler.SetFlags(locale, ContentFlags.None, false); RootEntry rootEntry; foreach (var entry in RootHandler.GetAllEntries()) { rootEntry = entry.Value; if ((rootEntry.Block.LocaleFlags == locale || (rootEntry.Block.LocaleFlags & locale) != LocaleFlags.None) && (rootEntry.Block.ContentFlags & ContentFlags.LowViolence) == ContentFlags.None) { var enc = EncodingHandler.GetEntry(rootEntry.MD5); if (enc != null) { if (!HashToKey.ContainsKey(entry.Key)) { HashToKey.Add(entry.Key, enc.Key); FileDataIdToHash.Add(rootEntry.FileDataId, entry.Key); } } } } RootHandler.Clear(); EncodingHandler.Clear(); RootHandler = null; EncodingHandler = null; GC.Collect(); Logger.WriteLine("CASCHandlerLite: loaded {0} files", HashToKey.Count); }
private CASCHandlerLite(CASCConfig config, LocaleFlags locale, BackgroundWorkerEx worker) : base(config, worker) { if (config.GameType != CASCGameType.WoW) throw new Exception("Unsupported game " + config.BuildUID); Logger.WriteLine("CASCHandlerLite: loading encoding data..."); EncodingHandler EncodingHandler; using (var _ = new PerfCounter("new EncodingHandler()")) { using (var fs = OpenEncodingFile(this)) EncodingHandler = new EncodingHandler(fs, worker); } Logger.WriteLine("CASCHandlerLite: loaded {0} encoding data", EncodingHandler.Count); Logger.WriteLine("CASCHandlerLite: loading root data..."); WowRootHandler RootHandler; using (var _ = new PerfCounter("new RootHandler()")) { using (var fs = OpenRootFile(EncodingHandler, this)) RootHandler = new WowRootHandler(fs, worker); } Logger.WriteLine("CASCHandlerLite: loaded {0} root data", RootHandler.Count); RootHandler.SetFlags(locale, ContentFlags.None, false); CDNIndexData = new Dictionary<MD5Hash, IndexEntry>(comparer); if (LocalIndex != null) LocalIndexData = new Dictionary<MD5Hash, IndexEntry>(comparer); RootEntry rootEntry; foreach (var entry in RootHandler.GetAllEntries()) { rootEntry = entry.Value; if ((rootEntry.LocaleFlags == locale || (rootEntry.LocaleFlags & locale) != LocaleFlags.None) && (rootEntry.ContentFlags & ContentFlags.LowViolence) == ContentFlags.None) { EncodingEntry enc; if (EncodingHandler.GetEntry(rootEntry.MD5, out enc)) { if (!HashToKey.ContainsKey(entry.Key)) { HashToKey.Add(entry.Key, enc.Key); FileDataIdToHash.Add(RootHandler.GetFileDataIdByHash(entry.Key), entry.Key); if (LocalIndex != null) { IndexEntry iLocal = LocalIndex.GetIndexInfo(enc.Key); if (iLocal != null && !LocalIndexData.ContainsKey(enc.Key)) LocalIndexData.Add(enc.Key, iLocal); } IndexEntry iCDN = CDNIndex.GetIndexInfo(enc.Key); if (iCDN != null && !CDNIndexData.ContainsKey(enc.Key)) CDNIndexData.Add(enc.Key, iCDN); } } } } CDNIndex.Clear(); //CDNIndex = null; LocalIndex?.Clear(); LocalIndex = null; RootHandler.Clear(); RootHandler = null; EncodingHandler.Clear(); EncodingHandler = null; GC.Collect(); Logger.WriteLine("CASCHandlerLite: loaded {0} files", HashToKey.Count); }
protected BinaryReader OpenRootFile(EncodingHandler enc, CASCHandlerBase casc) { EncodingEntry encInfo; if (!enc.GetEntry(casc.Config.RootMD5, out encInfo)) throw new FileNotFoundException("encoding info for root file missing!"); //ExtractFile(encInfo.Key, ".", "root"); return new BinaryReader(casc.OpenFile(encInfo.Key)); }
protected BinaryReader OpenDownloadFile(EncodingHandler enc, CASCHandlerBase casc) { var encInfo = enc.GetEntry(casc.Config.DownloadMD5); if (encInfo == null) throw new FileNotFoundException("encoding info for download file missing!"); //ExtractFile(encInfo.Key, ".", "download"); return new BinaryReader(casc.OpenFile(encInfo.Key)); }
protected static BinaryReader OpenInstallFile(EncodingHandler enc, CASCHandlerBase casc) { var encInfo = enc.GetEntry(casc.Config.InstallMD5); if (encInfo == null) throw new FileNotFoundException("encoding info for install file missing!"); //ExtractFile(encInfo.Key, ".", "install"); return new BinaryReader(casc.OpenFile(encInfo.Key)); }