Example #1
0
        public void CheckForUpdates(HashWebClient.RemoteFileInfo mods)
        {
            if (_isChecking)
                return;

            _lastModsJsonLoc = mods;
            _isChecking = true;

            new Thread(() =>
            {
                try
                {
                    string modsFileName = ModsMeta.GetFileName();
                    ModsMeta modsInfo = null;

                    HashWebClient.DownloadWithStatusDots(mods, modsFileName, DayZeroLauncherUpdater.STATUS_CHECKINGFORUPDATES,
                        newStatus => { Status = newStatus; },
                        (wc, fileInfo, destPath) => { modsInfo = ModsMeta.LoadFromFile(modsFileName); });

                    if (modsInfo != null)
                    {
                        Status = DayZeroLauncherUpdater.STATUS_CHECKINGFORUPDATES;
                        Thread.Sleep(100);

                        try
                        {
                            ModsMeta.ModInfo theMod =
                                modsInfo.Mods.Where(x => x.Version.Equals(modsInfo.LatestModVersion, StringComparison.OrdinalIgnoreCase))
                                    .Single();
                            SetLatestModVersion(theMod);

                            string currVersion = CalculatedGameSettings.Current.ModContentVersion;
                            if (!theMod.Version.Equals(currVersion, StringComparison.OrdinalIgnoreCase))
                            {
                                Status = DayZeroLauncherUpdater.STATUS_OUTOFDATE;

                                //this lets them seed/repair version they already have if it's not discontinued
                                ModsMeta.ModInfo currMod =
                                    modsInfo.Mods.SingleOrDefault(x => x.Version.Equals(currVersion, StringComparison.OrdinalIgnoreCase));
                                if (currMod != null)
                                    DownloadSpecificVersion(currMod, false);
                                else //try getting it from file cache (necessary for switching branches)
                                    DownloadLocalVersion(currVersion, false);
                            }
                            else
                            {
                                Status = DayZeroLauncherUpdater.STATUS_UPTODATE;
                                DownloadLatestVersion(false);
                            }
                        }
                        catch (Exception)
                        {
                            Status = "Could not determine revision";
                        }
                    }
                }
                finally
                {
                    _isChecking = false;
                }
            }).Start();
        }
Example #2
0
        public void CheckForUpdates(HashWebClient.RemoteFileInfo patches)
        {
            if (_isChecking)
                return;

            _lastPatchesJsonLoc = patches;
            _isChecking = true;

            Status = DayZeroLauncherUpdater.STATUS_CHECKINGFORUPDATES;
            new Thread(() =>
            {
                try
                {
                    string patchesFileName = PatchesMeta.GetFileName();
                    PatchesMeta patchInfo = null;

                    HashWebClient.DownloadWithStatusDots(patches, patchesFileName, DayZeroLauncherUpdater.STATUS_CHECKINGFORUPDATES,
                        newStatus => { Status = newStatus; },
                        (wc, fileInfo, destPath) => { patchInfo = PatchesMeta.LoadFromFile(patchesFileName); });

                    if (patchInfo != null)
                    {
                        Status = DayZeroLauncherUpdater.STATUS_CHECKINGFORUPDATES;
                        Thread.Sleep(100);

                        try
                        {
                            PatchesMeta.PatchInfo thePatch = patchInfo.Updates.Where(x => x.Version == patchInfo.LatestRevision).Single();
                            SetLatestServerVersion(thePatch);

                            Status = VersionMismatch ? (DayZeroLauncherUpdater.STATUS_OUTOFDATE) : (DayZeroLauncherUpdater.STATUS_UPTODATE);
                        }
                        catch (Exception)
                        {
                            Status = "Could not determine revision";
                        }
                    }
                }
                finally
                {
                    _isChecking = false;
                }
            }).Start();
        }