Esempio n. 1
0
        private void Regrresion(string dir)
        {
            var    entries = Directory.GetFiles(dir);
            string find    = null;

            if ((find = Array.Find(entries, x => x.EndsWith("steam.inf") && File.Exists(x))) != null)
            {
                SourceGame sg = SourceGame.Initialize(dir);
                if (sg != null)
                {
                    Console.WriteLine(sg.Game);
                    Console.WriteLine(sg.ClientAppID);
                    Console.WriteLine(sg.ServerAppID);
                    Console.WriteLine(sg.ServerVersion);
                    Console.WriteLine(sg.NeedUpdate);
                }
            }
            else
            {
                foreach (var d in Directory.GetDirectories(dir))
                {
                    if (!d.Equals(".") && !d.Equals("..") && !d.Equals("..."))
                    {
                        Regrresion(d);
                    }
                }
            }
        }
Esempio n. 2
0
 public static string GetSteamStoreHeaderImage(SourceGame sg)
 {
     return(String.Format("https://steamcdn-a.akamaihd.net/steam/apps/{0}/header.jpg", sg.ClientAppID));
 }
Esempio n. 3
0
        public static SourceGame Initialize(string directory)
        {
            var infofile = Path.Combine(directory, "steam.inf");

            if (Directory.Exists(directory) && File.Exists(infofile))
            {
                int    v_sv    = 0;
                int    appid_c = 0;
                int    appid_s = 0;
                string name    = null;

                var line = File.ReadAllLines(infofile);
                if (line.Length > 0)
                {
                    foreach (var t in line)
                    {
                        var split = t.Split('=');
                        if (split.Length == 2)
                        {
                            switch (split[0].ToLower())
                            {
                            case "appid":
                                appid_c = int.Parse(split[1]);
                                break;

                            case "serverappid":
                                appid_s = int.Parse(split[1]);
                                break;

                            case "serverversion":
                                v_sv = int.Parse(split[1]);
                                break;

                            case "productname":
                                name = split[1];
                                break;
                            }
                        }
                    }
                }
                if (v_sv != 0 && appid_c != 0 && appid_s != 0 && name != null)
                {
                    using (var wc = new WebClient())
                    {
                        try
                        {
                            var content = wc.DownloadString(String.Format(VERSION_CHECK_URL, appid_c));

                            XmlDocument doc = new XmlDocument();
                            doc.LoadXml(content);

                            if (doc.DocumentElement["deploy_version"] != null)
                            {
                                var game = new SourceGame();

                                game.NeedUpdate    = int.Parse(doc.DocumentElement["deploy_version"].InnerText) != v_sv;
                                game.ServerVersion = v_sv;
                                game.ClientAppID   = appid_c;
                                game.ServerAppID   = appid_s;
                                game.Game          = name;
                                game.BaseDir       = Path.GetFullPath(directory);

                                return(game);
                            }
                        }
                        catch
                        {
                            return(null);
                        }
                    }
                }
            }
            return(null);
        }