Exemple #1
0
        private void GetDayZFiles()
        {
            var    files = new List <string>();
            string responseBody;

            if (!GameUpdater.HttpGet(_latestDownloadUrl, out responseBody))
            {
                Status = "Error getting files";
                return;
            }
            var fileMatches = Regex.Matches(responseBody, @"<a\s+href\s*=\s*(?:'|"")([^'""]+\.[^'""]{3})(?:'|"")", RegexOptions.IgnoreCase);

            foreach (Match match in fileMatches)
            {
                if (!match.Success)
                {
                    continue;
                }
                var file = match.Groups[1].Value;
                if (string.IsNullOrEmpty(file))
                {
                    continue;
                }

                files.Add(file);
            }
            _dayZFiles = files;

            ProcessNext();
        }
Exemple #2
0
        public void CheckForUpdate()
        {
            if (_isChecking)
            {
                return;
            }

            _isChecking = true;

            Status = DayZCommanderUpdater.STATUS_CHECKINGFORUPDATES;

            string  responseBody;
            Version latestVersion = null;

            new Thread(() =>
            {
                try
                {
                    Thread.Sleep(750);                                              //In case this happens so fast the UI looks like it didn't work
                    if (!GameUpdater.HttpGet(DayZListingUrl, out responseBody))
                    {
                        Status = "cdn.armafiles.com not responding";
                        return;
                    }
                    var latestCodeFileMatch = Regex.Match(responseBody,
                                                          @"<a\s+href\s*=\s*(?:'|"")(dayz_code_[^'""]+)(?:'|"")",
                                                          RegexOptions.IgnoreCase);
                    if (!latestCodeFileMatch.Success)
                    {
                        Status = "Filenames don't match expected pattern";
                        return;
                    }
                    var latestCodeFile         = latestCodeFileMatch.Groups[1].Value;
                    var latestCodeVersionMatch = Regex.Match(latestCodeFile, @"\d(?:\.\d){1,3}");
                    if (!latestCodeVersionMatch.Success)
                    {
                        Status = "Could not determine version from filenames";
                        return;
                    }
                    Version version;
                    if (Version.TryParse(latestCodeVersionMatch.Value, out version))
                    {
                        latestVersion = version;
                        if (!latestVersion.Equals(LocalMachineInfo.Current.DayZVersion))
                        {
                            Status = DayZCommanderUpdater.STATUS_OUTOFDATE;
                        }
                        else
                        {
                            Status = DayZCommanderUpdater.STATUS_UPTODATE;
                        }
                    }
                    else
                    {
                        Status = "Could not determine version from filenames";
                    }
                }
                catch (Exception ex)
                {
                    Status = "Error getting version";
                }
                finally
                {
                    _isChecking   = false;
                    LatestVersion = latestVersion;
                }
            }).Start();
        }
Exemple #3
0
        public void CheckForUpdates()
        {
            if (_isChecking)
            {
                return;
            }

            _isChecking = true;

            Status = DayZCommanderUpdater.STATUS_CHECKINGFORUPDATES;

            string responseBody;
            int?   latestRevision = null;

            new Thread(() =>
            {
                try
                {
                    Thread.Sleep(750);                                              //In case this happens so fast the UI looks like it didn't work
                    if (!GameUpdater.HttpGet(ArmaBetaListingUrl, out responseBody))
                    {
                        Status = "Arma2.com not responding";
                        return;
                    }
                    var latestBetaUrlMatch = Regex.Match(responseBody, @"Latest\s+beta\s+patch:\s*<a\s+href\s*=\s*(?:'|"")([^'""]+)(?:'|"")", RegexOptions.IgnoreCase);
                    if (!latestBetaUrlMatch.Success)
                    {
                        Status = "Latest patch url doesn't match pattern";
                        return;
                    }
                    _latestDownloadUrl          = latestBetaUrlMatch.Groups[1].Value;
                    var latestBetaRevisionMatch = Regex.Match(_latestDownloadUrl, @"(\d+)\.(?:zip|rar)", RegexOptions.IgnoreCase);
                    if (!latestBetaRevisionMatch.Success)
                    {
                        Status = "Latest patch doesn't match pattern";
                        return;
                    }
                    latestRevision = latestBetaRevisionMatch.Groups[1].Value.TryIntNullable();
                    if (latestRevision != null)
                    {
                        if (LocalMachineInfo.Current.Arma2OABetaVersion == null || LocalMachineInfo.Current.Arma2OABetaVersion.Revision != latestRevision)
                        {
                            Status = DayZCommanderUpdater.STATUS_OUTOFDATE;
                        }
                        else
                        {
                            Status = DayZCommanderUpdater.STATUS_UPTODATE;
                        }
                    }
                    else
                    {
                        Status = "Coult not determine revision";
                    }
                }
                catch (Exception ex)
                {
                    Status = "Error getting version";
                }
                finally
                {
                    _isChecking   = false;
                    LatestVersion = latestRevision;
                }
            }).Start();
        }