Ejemplo n.º 1
0
 /// <summary>
 ///     Creates a task which represent an individual patch operation
 /// </summary>
 /// <param name="clientProfile"></param>
 /// <param name="patchInfo"></param>
 /// <param name="officialPatchInfo"></param>
 /// <param name="patcherContext"></param>
 public PatchTask(PatcherContext patcherContext, IClientProfile clientProfile, PatchInfo patchInfo, OfficialPatchInfo officialPatchInfo)
 {
     _patcherContext   = patcherContext;
     _clientProfile    = clientProfile;
     PatchInfo         = patchInfo;
     OfficialPatchInfo = officialPatchInfo;
 }
Ejemplo n.º 2
0
 /// <summary>
 ///     Creates a download queue but does not initialize it
 /// </summary>
 /// <param name="patcherContext"></param>
 /// <param name="patchInfos"></param>
 /// <param name="officialPatchInfo"></param>
 public DownloadQueue(PatcherContext patcherContext, IClientProfile clientProfile, List <PatchInfo> patchInfos, OfficialPatchInfo officialPatchInfo)
 {
     _patcherContext    = patcherContext;
     _clientProfile     = clientProfile;
     _patchInfos        = patchInfos;
     _patchTasks        = new List <PatchTask>();
     _officialPatchInfo = officialPatchInfo;
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
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);
        }