Пример #1
0
        /// <summary>
        /// Get the detailed game client version from manifest
        /// </summary>
        /// <param name="m"></param>
        /// <returns>Patch number (for example 5.23.0.239)</returns>
        public static string GetClientVersion(ReleaseManifest m)
        {
            var t  = m.Files.Where(p => p.name.EndsWith(".exe"));
            var t2 = t.Select(p => p.name);

            string tmpName     = Path.GetTempFileName();
            string fileVersion = t.ElementAt(1).release;



            if (t2.Contains("League of Legends.exe"))
            {
                try
                {
                    byte[] data;
                    using (WebClient wc = new WebClient())
                    {
                        data = wc.DownloadData($"{Program.API_BASE}/projects/{m.BranchName}/releases/{fileVersion}/files/League of Legends.exe.compressed");
                    }

                    using (MemoryStream ms = new MemoryStream(data))
                    {
                        DecompressFile(ms, tmpName);
                    }

                    string ret = GetClientReleaseDescription(tmpName);
                    File.Delete(tmpName);
                    return(ret);
                }
                catch { }
            }


            throw new Exception();
        }
Пример #2
0
        /// <summary>
        /// Get the detailed game client version from manifest
        /// </summary>
        /// <param name="m"></param>
        /// <returns>Patch number (for example 5.23.0.239)</returns>
        public static string GetClientVersion(ReleaseManifest m)
        {
            var t = m.Files.Where(p => p.name.EndsWith(".exe"));
            var t2 = t.Select(p => p.name);

            string tmpName = Path.GetTempFileName();
            string fileVersion = t.ElementAt(1).release;

            if (t2.Contains("League of Legends.exe"))
            {

                try
                {
                    byte[] data;
                    using (WebClient wc = new WebClient())
                    {
                        data = wc.DownloadData($"{Program.API_BASE}/projects/{m.BranchName}/releases/{fileVersion}/files/League of Legends.exe.compressed");

                    }

                    using (MemoryStream ms = new MemoryStream(data))
                    {
                        DecompressFile(ms, tmpName);
                    }

                    string ret = GetClientReleaseDescription(tmpName);
                    File.Delete(tmpName);
                    return ret;
                }
                catch { }
            }

            throw new Exception();
        }
Пример #3
0
        public ReleaseManifest GetReleaseManifest()
        {
            byte[] data;
            using (WebClient wc = new WebClient())
            {
                data = wc.DownloadData($"{Program.API_BASE}projects/{this.Name}/releases/{this.Version}/releasemanifest");
            }

            var m = new ReleaseManifest();

            using (MemoryStream ms = new MemoryStream(data))
            {
                m.BranchName = this.Name;

                m.MagicHeaderInt = GetInt(ms);
                m.FileType = GetInt(ms);
                m.ItemCount = GetInt(ms);
                m.ReleaseVersion = GetInt(ms);
                m.ReleaseName = GetReleaseName(m.ReleaseVersion);

                DirectoryMetaData[] directoryMetaDatas = new DirectoryMetaData[GetInt(ms)];

                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    directoryMetaDatas[i] = new DirectoryMetaData(GetInt(ms),
                            GetInt(ms),
                            GetInt(ms),
                            GetInt(ms),
                            GetInt(ms));
                }

                FileMetaData[] fileMetaDatas = new FileMetaData[GetInt(ms)];
                for (int i = 0; i < fileMetaDatas.Length; i++)
                {
                    fileMetaDatas[i] = new FileMetaData(GetInt(ms),
                            GetInt(ms),
                            GetBytes(ms, 16),
                            GetInt(ms),
                            GetInt(ms),
                            GetInt(ms),
                            GetInt(ms),
                            GetInt(ms));
                }
                String[] strs = new String[GetInt(ms)];
                int datasize = GetInt(ms); // ignored

                int c;
                int idx = 0;
                StringBuilder sb = new StringBuilder();
                while ((c = ms.ReadByte()) != -1)
                {
                    if (c == '\0')
                    {
                        strs[idx] = sb.ToString();
                        sb = new StringBuilder();
                        idx++;
                        continue;
                    }
                    sb.Append((char)c);
                }
                //assert(component.equals(strs[strs.length - 1]));

                // creating proper objects
                m.Directories = new Directory[directoryMetaDatas.Length];
                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    m.Directories[i] = new Directory(strs[directoryMetaDatas[i].nameindex]);
                }
                // linking subdirectories
                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    int start = directoryMetaDatas[i].subdirFirstIndex;
                    if (start == i) start++;
                    m.Directories[i].subdirs = new Directory[directoryMetaDatas[i].nsubdirs];

                    for (int j = 0; j < directoryMetaDatas[i].nsubdirs; j++)
                    {
                        m.Directories[i].subdirs[j] = m.Directories[start + j];
                        m.Directories[start + j].path = m.Directories[i].path + m.Directories[start + j].path;
                    }
                }
                m.Files = new ManifestFile[fileMetaDatas.Length];
                for (int i = 0; i < fileMetaDatas.Length; i++)
                {
                    FileMetaData meta = fileMetaDatas[i];
                    m.Files[i] = new ManifestFile(GetReleaseName(meta.release),
                            meta.release,
                            strs[meta.nameindex],
                            meta.checksum, meta.sizeCompressed,
                            meta.fileType, meta.sizeUncompressed,
                            meta.unknownInt3, meta.unknownInt4);
                }
                // linking files to directories
                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    int start = directoryMetaDatas[i].firstfileIndex;
                    m.Directories[i].files = new ManifestFile[directoryMetaDatas[i].fileCount];

                    for (int j = 0; j < directoryMetaDatas[i].fileCount; j++)
                    {
                        m.Directories[i].files[j] = m.Files[start + j];
                        m.Files[start + j].path = m.Directories[i].path;
                    }
                }
                m.FileDictionary = new Dictionary<string, ManifestFile>();
                foreach (ManifestFile fi in m.Files)
                {
                    m.FileDictionary[fi.path + fi.name] =  fi;
                }
            }

        

            return m;

            

        }
Пример #4
0
        public static void UpdateFile(string realm, string region, bool forceAll = false)
        {
            string _realm = Realm, _region = Region;

            Realm  = realm;
            Region = region;
            string        fileName = $"map_{Realm}_{Region}.txt";
            List <string> versions = Utils.GetSolutionVersions("lol_game_client_sln"), toDownload = new List <string>(versions), i;
            Dictionary <string, string> output = new Dictionary <string, string>();

            if (!forceAll && File.Exists(fileName))
            {
                using (StreamReader sr = new StreamReader(fileName))
                {
                    string   str;
                    string[] split;
                    while ((str = sr.ReadLine()) != null)
                    {
                        split = str.Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
                        toDownload.Remove(split[0]);
                        output.Add(split[0], split[1]);
                    }
                }
            }

            Console.WriteLine($"Updating {toDownload.Count} items for {region}@{realm}");



            while (toDownload.Count > 0)
            {
                int all = toDownload.Count, ok = 0;
                i = new List <string>(toDownload);
                toDownload.Clear();
                Parallel.ForEach(i, new ParallelOptions()
                {
                    MaxDegreeOfParallelism = 4
                }, version =>
                {
                    try
                    {
                        Console.Title      = $"Left {all - ok}";
                        SolutionManifest m = new SolutionManifest("lol_game_client_sln", version);
                        ReleaseManifest rm = m.Projects[0].GetReleaseManifest();
                        string v           = Utils.GetClientVersion(rm) + $" ({m.Projects[0].Version})";
                        GC.Collect();
                        lock (output)
                        {
                            output.Add(version, v);
                        }
                        Interlocked.Increment(ref ok);
                        Log(string.Format("{0} -> {1}", version, v));
                    }
                    catch
                    {
                        Console.WriteLine("Retrying {0}..", version);
                        lock (toDownload) { toDownload.Add(version); }
                    }
                });
            }

            using (StreamWriter sw = new StreamWriter(fileName, false))
            {
                foreach (string v in versions)
                {
                    sw.WriteLine($"{v} -> {output[v]}");
                }
            }

            File.Copy(fileName, $@"..\..\..\..\output\{fileName}", true);

            Realm  = _realm;
            Region = _region;
        }
Пример #5
0
        public ReleaseManifest GetReleaseManifest()
        {
            byte[] data;
            using (WebClient wc = new WebClient())
            {
                data = wc.DownloadData($"{Program.API_BASE}projects/{this.Name}/releases/{this.Version}/releasemanifest");
            }

            var m = new ReleaseManifest();

            using (MemoryStream ms = new MemoryStream(data))
            {
                m.BranchName = this.Name;

                m.MagicHeaderInt = GetInt(ms);
                m.FileType       = GetInt(ms);
                m.ItemCount      = GetInt(ms);
                m.ReleaseVersion = GetInt(ms);
                m.ReleaseName    = GetReleaseName(m.ReleaseVersion);

                DirectoryMetaData[] directoryMetaDatas = new DirectoryMetaData[GetInt(ms)];

                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    directoryMetaDatas[i] = new DirectoryMetaData(GetInt(ms),
                                                                  GetInt(ms),
                                                                  GetInt(ms),
                                                                  GetInt(ms),
                                                                  GetInt(ms));
                }

                FileMetaData[] fileMetaDatas = new FileMetaData[GetInt(ms)];
                for (int i = 0; i < fileMetaDatas.Length; i++)
                {
                    fileMetaDatas[i] = new FileMetaData(GetInt(ms),
                                                        GetInt(ms),
                                                        GetBytes(ms, 16),
                                                        GetInt(ms),
                                                        GetInt(ms),
                                                        GetInt(ms),
                                                        GetInt(ms),
                                                        GetInt(ms));
                }
                String[] strs     = new String[GetInt(ms)];
                int      datasize = GetInt(ms); // ignored

                int           c;
                int           idx = 0;
                StringBuilder sb  = new StringBuilder();
                while ((c = ms.ReadByte()) != -1)
                {
                    if (c == '\0')
                    {
                        strs[idx] = sb.ToString();
                        sb        = new StringBuilder();
                        idx++;
                        continue;
                    }
                    sb.Append((char)c);
                }
                //assert(component.equals(strs[strs.length - 1]));

                // creating proper objects
                m.Directories = new Directory[directoryMetaDatas.Length];
                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    m.Directories[i] = new Directory(strs[directoryMetaDatas[i].nameindex]);
                }
                // linking subdirectories
                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    int start = directoryMetaDatas[i].subdirFirstIndex;
                    if (start == i)
                    {
                        start++;
                    }
                    m.Directories[i].subdirs = new Directory[directoryMetaDatas[i].nsubdirs];

                    for (int j = 0; j < directoryMetaDatas[i].nsubdirs; j++)
                    {
                        m.Directories[i].subdirs[j]   = m.Directories[start + j];
                        m.Directories[start + j].path = m.Directories[i].path + m.Directories[start + j].path;
                    }
                }
                m.Files = new ManifestFile[fileMetaDatas.Length];
                for (int i = 0; i < fileMetaDatas.Length; i++)
                {
                    FileMetaData meta = fileMetaDatas[i];
                    m.Files[i] = new ManifestFile(GetReleaseName(meta.release),
                                                  meta.release,
                                                  strs[meta.nameindex],
                                                  meta.checksum, meta.sizeCompressed,
                                                  meta.fileType, meta.sizeUncompressed,
                                                  meta.unknownInt3, meta.unknownInt4);
                }
                // linking files to directories
                for (int i = 0; i < directoryMetaDatas.Length; i++)
                {
                    int start = directoryMetaDatas[i].firstfileIndex;
                    m.Directories[i].files = new ManifestFile[directoryMetaDatas[i].fileCount];

                    for (int j = 0; j < directoryMetaDatas[i].fileCount; j++)
                    {
                        m.Directories[i].files[j] = m.Files[start + j];
                        m.Files[start + j].path   = m.Directories[i].path;
                    }
                }
                m.FileDictionary = new Dictionary <string, ManifestFile>();
                foreach (ManifestFile fi in m.Files)
                {
                    m.FileDictionary[fi.path + fi.name] = fi;
                }
            }



            return(m);
        }