/// <summary> /// Open a file from Encoding Key /// </summary> /// <param name="key">The Long Encoding Key</param> /// <returns>Loaded file</returns> public Stream OpenEKey(CKey key) // ekey = value of ckey in encoding table { Stream stream = default; if (CreateArgs.Mode == ClientCreateArgs.InstallMode.CASC) { stream = ContainerHandler?.OpenEKey(key.AsEKey()); } if (stream != null || !CreateArgs.Online) { return(stream == null ? null : new BLTEStream(this, stream)); } stream = NetHandle.OpenData(key); if (stream == null) { return(null); } var ms = new MemoryStream(); stream.CopyTo(ms); ms.Position = 0; return(new BLTEStream(this, ms)); }
/// <summary> /// Open a file from Encoding Key /// </summary> /// <param name="key">The Long Encoding Key</param> /// <returns>Loaded file</returns> public Stream?OpenEKey(CKey key) // ekey = value of ckey in encoding table { if (ContainerHandler != null) { try { var cascBlte = OpenEKey(key.AsEKey()); if (cascBlte != null) { return(cascBlte); } } catch (Exception e) { if (!CreateArgs.Online) { throw; } Logger.Warn("CASC", $"Unable to open {key.ToHexString()} from CASC. Will try to download. Exception: {e}"); } } if (!CreateArgs.Online) { return(null); } Stream?netMemStream = null; if (m_cdnIdx !.CDNIndexData.TryGetValue(key, out var cdnIdx)) { netMemStream = m_cdnIdx.OpenDataFile(cdnIdx); } if (netMemStream == null) { netMemStream = NetHandle !.OpenData(key); } if (netMemStream == null) { return(null); } return(new BLTEStream(this, netMemStream)); }