Example #1
0
 /// <summary>
 ///     Creates a new instance of PatcherDownloader that accepts a PatchSequence
 /// </summary>
 /// <param name="patchSequence">PatchSequence representing a collection of patches</param>
 /// <param name="officialPatchInfo"></param>
 /// <param name="clientProfile"></param>
 public PatchDownloader(PatcherContext patcherContext, PatchSequence patchSequence, OfficialPatchInfo officialPatchInfo, IClientProfile clientProfile)
 {
     Patches            = new List <PatchInfo>();
     _patcherContext    = patcherContext;
     _officialPatchInfo = officialPatchInfo;
     _clientProfile     = clientProfile;
     Patches.AddRange(patchSequence.Patches);
 }
Example #2
0
        public override async Task <bool> CheckForUpdates()
        {
            if (ClientProfile == null)
            {
                return(false);
            }
            if (ServerProfile == null)
            {
                return(false);
            }

            // Should never hit, earlier logic shouldn't even call the function
            if (!ServerProfile.IsOfficial)
            {
                return(false);
            }

            if (ClientProfile.Localization != ClientLocalization.Japan &&
                ClientProfile.Localization != ClientLocalization.JapanHangame)
            {
                return(false);
            }

            PatcherContext.SetPatcherState(true);

            PatcherContext.UpdateMainProgress("Checking for updates...", "", 0, true, true);

            _officialPatchInfo = OfficialPatchInfo.Parse(MabiVersion.Versions
                                                         .Find(version => version.Name == ClientProfile.Localization).PatchUrl);

            if (int.TryParse(_officialPatchInfo["main_version"], out var versionConverted))
            {
                _remoteVersion = versionConverted;
            }

            if (_currentVersion == _remoteVersion)
            {
                PatcherContext.SetPatcherState(false);
                PatcherContext.UpdateMainProgress("", "", 0, false, false);
                return(false);
            }

            try
            {
                await Task.Run(() => _patchSequence = FindPatchSequence());
            }
            catch (PatchSequenceNotFoundException ex)
            {
                Log.Exception(ex);
                PatcherContext.SetPatcherState(false);
                PatcherContext.UpdateMainProgress("", "", 0, false, false);
                return(false);
            }

            PatcherContext.SetPatcherState(false);
            PatcherContext.UpdateMainProgress("", "", 0, false, false);
            return(true);
        }