Exemple #1
0
        public static PendingUpdates GetPendingUpdateQueues(ClientService.ClientService service)
        {
            PendingUpdates returnValue = new PendingUpdates();

            var lobbies = ServiceHandler.Service.CheckAvailableLobbies();

            foreach (LobbyResult lobby in lobbies)
            {
                //Get autoupdate files associated with lobby
                var results = service.CheckForUpdates(lobby.LobbyId, true);

                List <FindAutoUpdateFilesResult> updateQueue = ProcessPendingUpdates(lobby, results);

                returnValue.AutoUpdateBaseAddress.Add(lobby.LobbyId, results.AutoUpdateBaseAddress);
                returnValue.AllFilesInUpdatePackage.Add(lobby.LobbyId, results.Files);
                returnValue.PendingUpdateList.Add(lobby.LobbyId, updateQueue);
            }

            return(returnValue);
        }
Exemple #2
0
        public static PendingUpdates GetPendingUpdateQueues(ClientService.ClientService service)
        {
            //Initialize Checksum class to use SHA1
            var encryption = new Encryption <SHA1>();

            PendingUpdates returnValue = new PendingUpdates();

            var lobbies = ServiceHandler.Service.CheckAvailableLobbies();

            foreach (LobbyResult lobby in lobbies)
            {
                //Get autoupdate files associated with lobby
                var results = service.CheckForUpdates(lobby.LobbyId, true);
                //var root        = AllegianceRegistry.EXEPath; //Allegiance root directory
                var    autoUpdate  = DataStore.Open("autoupdate.ds", "Ga46^#a042");
                string dataKey     = "Files_" + lobby.LobbyId;
                var    lastResults = autoUpdate[dataKey] as Dictionary <string, FindAutoUpdateFilesResult>;
                List <FindAutoUpdateFilesResult> updateQueue = new List <FindAutoUpdateFilesResult>();

                //Check files which need update
                foreach (var file in results.Files)
                {
                    DebugDetector.AssertCheckRunning();

                    string path;

                    if (string.Equals(file.Filename, GlobalSettings.ClientExecutableName) ||
                        string.Equals(file.Filename, GlobalSettings.ClientExecutablePDB))
                    {
                        path = Path.Combine(AllegianceRegistry.LobbyPath, file.Filename);
                    }
                    else
                    {
                        path = GetLobbyPath(lobby, file.Filename);
                    }

                    //Check that all files exist
                    if (!File.Exists(path))
                    {
                        Log.Write("File did not exist: " + path + ", will update.");
                        updateQueue.Add(file);
                        continue;
                    }

                    if (lastResults == null)
                    {
                        Log.Write("No prior autoupdate records, will updated: " + path);
                        updateQueue.Add(file);
                        continue;
                    }

                    //Check if we don't have a record of the file at all
                    if (!lastResults.ContainsKey(file.Filename))
                    {
                        Log.Write("No record of file in autoupdate history, will update: " + path);
                        updateQueue.Add(file);
                        continue;
                    }

                    //Check that all file versions match
                    if (lastResults.ContainsKey(file.Filename) &&
                        (file.CurrentVersion != lastResults[file.Filename].CurrentVersion))
                    {
                        Log.Write("File version mismatch, will update: " + file.Filename + ", server version: " + file.CurrentVersion + ", local version: " + lastResults[file.Filename].CurrentVersion);

                        updateQueue.Add(file);
                        continue;
                    }

                    //Compare hashes with all protected files to those on-disk
                    if (file.IsProtected)
                    {
                        var checksum = encryption.Calculate(path);
                        if (!string.Equals(file.ValidChecksum, checksum))
                        {
                            Log.Write("File checksum mismatch, will update: " + path + ", server checksum: " + file.ValidChecksum + ", local checksum: " + checksum);

                            updateQueue.Add(file);
                        }
                    }
                }

                returnValue.AutoUpdateBaseAddress.Add(lobby.LobbyId, results.AutoUpdateBaseAddress);
                returnValue.AllFilesInUpdatePackage.Add(lobby.LobbyId, results.Files);
                returnValue.PendingUpdateList.Add(lobby.LobbyId, updateQueue);
            }

            return(returnValue);
        }