Exemple #1
0
        /// <summary>
        /// Opens an existing TACT container and loads the Root and Encoding files
        /// </summary>
        /// <param name="directory"></param>
        /// <param name="product"></param>
        /// <param name="locale"></param>
        public void Open(string directory, string product, Locale locale)
        {
            ConfigContainer = new Configs.ConfigContainer(product, locale);
            ConfigContainer.OpenLocal(directory);

            if (uint.TryParse(ConfigContainer?.VersionsFile?.GetValue("BuildId", locale), out uint build))
            {
                Build = build;
            }

            ApplyVersionSpecificSettings(build);

            IndexContainer = new Indices.IndexContainer();
            IndexContainer.Open(directory);

            if (!ConfigContainer.EncodingEKey.IsEmpty)
            {
                EncodingFile = new Encoding.EncodingFile(BaseDirectory, ConfigContainer.EncodingEKey);

                // Open RootFile
                if (ConfigContainer.RootCKey.Value != null && EncodingFile.TryGetCKeyEntry(ConfigContainer.RootCKey, out var rootEKey))
                {
                    RootFile = new Root.RootFile(BaseDirectory, rootEKey.EKey);
                }

                // Open InstallFile
                if (ConfigContainer.InstallCKey.Value != null && EncodingFile.TryGetCKeyEntry(ConfigContainer.InstallCKey, out var installEKey))
                {
                    InstallFile = new Install.InstallFile(BaseDirectory, installEKey.EKey);
                }

                // Open DownloadFile
                if (ConfigContainer.DownloadCKey.Value != null && EncodingFile.TryGetCKeyEntry(ConfigContainer.DownloadCKey, out var downloadEKey))
                {
                    DownloadFile = new Download.DownloadFile(BaseDirectory, downloadEKey.EKey);
                }

                // Open DownloadSizeFile
                if (ConfigContainer.DownloadSizeCKey.Value != null && EncodingFile.TryGetCKeyEntry(ConfigContainer.DownloadSizeCKey, out var downloadSizeEKey))
                {
                    DownloadSizeFile = new Download.DownloadSizeFile(BaseDirectory, downloadSizeEKey.EKey);
                }
            }

            // Open PatchFile
            if (ConfigContainer.PatchEKey.Value != null)
            {
                PatchFile = new Patch.PatchFile(BaseDirectory, ConfigContainer.PatchEKey);
            }

            ApplyVersionSpecificSettings(Build);
        }
Exemple #2
0
        private void ApplyVersionSpecificSettings(uint build)
        {
            if (build > 24473)
            {
                DownloadFile.DownloadHeader.Version = 2;
            }

            if (build > 27547)
            {
                DownloadFile.DownloadHeader.Version = 3;
                DownloadSizeFile = new Download.DownloadSizeFile();
            }

            if (build >= 30080)
            {
                RootFile.RootHeader.Version = 2;
            }
        }
Exemple #3
0
        /// <summary>
        /// Streams an existing TACT container from an external CDN
        /// </summary>
        /// <param name="product"></param>
        /// <param name="locale"></param>
        public void OpenRemote(string product, Locale locale)
        {
            ManifestContainer = new Configs.ManifestContainer(product, locale);

            ConfigContainer = new Configs.ConfigContainer();
            ConfigContainer.OpenRemote(ManifestContainer);

            if (uint.TryParse(ManifestContainer?.VersionsFile?.GetValue("BuildId", locale), out uint build))
            {
                Build = build;
            }

            // stream Indicies
            IndexContainer = new Indices.IndexContainer();
            IndexContainer.OpenRemote(ConfigContainer, ManifestContainer, true);

            var cdnClient = new CDNClient(ManifestContainer);

            if (ConfigContainer.EncodingEKey.Value != null)
            {
                // Stream EncodingFile
                EncodingFile = new Encoding.EncodingFile(cdnClient, ConfigContainer.EncodingEKey);

                // Stream RootFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.RootCKey, out var entry))
                {
                    RootFile = new Root.RootFile(cdnClient, entry.EKeys[0]);
                }

                // Stream InstallFile
                if (ConfigContainer.InstallEKey.Value != null)
                {
                    InstallFile = new Install.InstallFile(cdnClient, ConfigContainer.InstallEKey);
                }
                else if (EncodingFile.TryGetCKeyEntry(ConfigContainer.InstallCKey, out entry))
                {
                    InstallFile = new Install.InstallFile(cdnClient, entry.EKeys[0]);
                }

                // Stream DownloadFile
                if (ConfigContainer.DownloadEKey.Value != null)
                {
                    DownloadFile = new Download.DownloadFile(cdnClient, ConfigContainer.DownloadEKey);
                }
                else if (EncodingFile.TryGetCKeyEntry(ConfigContainer.DownloadCKey, out entry))
                {
                    DownloadFile = new Download.DownloadFile(cdnClient, entry.EKeys[0]);
                }

                // Stream DownloadSizeFile
                if (ConfigContainer.DownloadSizeEKey.Value != null)
                {
                    DownloadSizeFile = new Download.DownloadSizeFile(cdnClient, ConfigContainer.DownloadSizeEKey);
                }
                else if (EncodingFile.TryGetCKeyEntry(ConfigContainer.DownloadSizeCKey, out entry))
                {
                    DownloadSizeFile = new Download.DownloadSizeFile(cdnClient, entry.EKeys[0]);
                }
            }

            // Stream PatchFile
            if (ConfigContainer.PatchEKey.Value != null)
            {
                PatchFile = new Patch.PatchFile(cdnClient, ConfigContainer.PatchEKey);
            }
        }