Ejemplo n.º 1
0
        private void VersionChecker_DownloadComplete(CDownloadFile sender)
        {
            string[] versionData = Encoding.UTF8.GetString(sender.CompleteFileData).Split('\n');

            if (versionData.Length >= 4 && (ProconUpdate == null || ProconUpdate.FileDownloading == false))
            {
                // Download file, alert or auto apply once complete with release notes.
                ProconUpdate = new CDownloadFile(versionData[2], versionData[3]);
                ProconUpdate.DownloadComplete += new CDownloadFile.DownloadFileEventDelegate(cdfPRoConUpdate_DownloadComplete);

                if (UpdateDownloading != null)
                {
                    FrostbiteConnection.RaiseEvent(UpdateDownloading.GetInvocationList(), ProconUpdate);
                }

                ProconUpdate.BeginDownload();
            }
        }
Ejemplo n.º 2
0
        private void VersionChecker_DownloadComplete(CDownloadFile sender)
        {
            string[] versionData = Encoding.UTF8.GetString(sender.CompleteFileData).Split('\n');
            GameConfigHint = false;

            if (versionData.Length >= 4 && (ProconUpdate == null || ProconUpdate.FileDownloading == false))
            {
                bool blContinueFileDownload = true;

                try {
                    if (Directory.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Updates")) == true)
                    {
                        AssemblyName proconAssemblyName = AssemblyName.GetAssemblyName(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Updates"), "PRoCon.exe"));

                        // If an update has already been downloaded but not installed..
                        if (new Version(versionData[0]).CompareTo(proconAssemblyName.Version) >= 0)
                        {
                            blContinueFileDownload = false;
                        }
                    }
                }
                catch (Exception) {
                }

                if (blContinueFileDownload == true)
                {
                    if (new Version(versionData[0]).CompareTo(Assembly.GetExecutingAssembly().GetName().Version) > 0)
                    {
                        // Download file, alert or auto apply once complete with release notes.
                        ProconUpdate = new CDownloadFile(versionData[2], versionData[3]);
                        ProconUpdate.DownloadComplete += new CDownloadFile.DownloadFileEventDelegate(cdfPRoConUpdate_DownloadComplete);

                        if (UpdateDownloading != null)
                        {
                            FrostbiteConnection.RaiseEvent(UpdateDownloading.GetInvocationList(), ProconUpdate);
                        }

                        ProconUpdate.BeginDownload();
                    }
                    else
                    {
                        if (NoVersionAvailable != null)
                        {
                            FrostbiteConnection.RaiseEvent(NoVersionAvailable.GetInvocationList());
                        }

                        lock (DownloadingLocalizationsLock) {
                            foreach (CDownloadFile cdfFile in DownloadingLocalizations)
                            {
                                cdfFile.EndDownload();
                            }

                            DownloadingLocalizations.Clear();
                        }

                        lock (DownloadingGameConfigsLock) {
                            foreach (CDownloadFile cdfFile in DownloadingGameConfigs)
                            {
                                cdfFile.EndDownload();
                            }

                            DownloadingGameConfigs.Clear();
                        }

                        for (int i = 4; i < versionData.Length; i++)
                        {
                            List <string> lstExtensibilityVersion = Packet.Wordify(versionData[i]);

                            if (lstExtensibilityVersion.Count >= 4 && System.String.Compare(lstExtensibilityVersion[0], "localization", System.StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                try {
                                    if (File.Exists(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Localization"), lstExtensibilityVersion[2])) == true)
                                    {
                                        if (System.String.Compare(lstExtensibilityVersion[1], MD5File(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Localization"), lstExtensibilityVersion[2])), System.StringComparison.OrdinalIgnoreCase) != 0)
                                        {
                                            // Download new localization file and tell options to reload it once completed.
                                            DownloadLocalizationFile(lstExtensibilityVersion[3], lstExtensibilityVersion[2]);
                                            Thread.Sleep(100); // I don't know how many languages there may be later so sleep on it to prevent spam.
                                        }
                                    }
                                    else
                                    {
                                        // Download new localization file and tell options to load it once completed.
                                        DownloadLocalizationFile(lstExtensibilityVersion[3], lstExtensibilityVersion[2]);
                                        Thread.Sleep(100);
                                    }
                                }
                                catch (Exception) {
                                }
                            }

                            // GameConfigs
                            if (lstExtensibilityVersion.Count >= 4 && System.String.Compare(lstExtensibilityVersion[0], "gameconfig", System.StringComparison.OrdinalIgnoreCase) == 0 && Application.OptionsSettings.AutoCheckGameConfigsForUpdates == true)
                            {
                                try {
                                    if (File.Exists(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs"), lstExtensibilityVersion[2])) == true)
                                    {
                                        if (System.String.Compare(lstExtensibilityVersion[1], MD5File(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs"), lstExtensibilityVersion[2])), System.StringComparison.OrdinalIgnoreCase) != 0)
                                        {
                                            // Download new GameConfig file
                                            DownloadGameConfigFile(lstExtensibilityVersion[3], lstExtensibilityVersion[2]);
                                            Thread.Sleep(100); // we don't know how many will come.
                                        }
                                    }
                                    else
                                    {
                                        // Download new GameConfig file
                                        DownloadGameConfigFile(lstExtensibilityVersion[3], lstExtensibilityVersion[2]);
                                        Thread.Sleep(100);
                                    }
                                }
                                catch (Exception) {
                                }
                            }
                        }
                    }
                }
                else
                {
                    DownloadedUnzippedComplete();
                }
            }
        }