예제 #1
0
        public static CASCConfig LoadLocalStorageConfig(string basePath)
        {
            var config = new CASCConfig {
                OnlineMode = false, BasePath = basePath
            };

            config.GameType = CASCGame.DetectLocalGame(basePath);

            if (config.GameType == CASCGameType.Agent || config.GameType == CASCGameType.Hearthstone)
            {
                throw new Exception("Local mode not supported for this game!");
            }

            string buildInfoPath = Path.Combine(basePath, ".build.info");

            using (Stream buildInfoStream = new FileStream(buildInfoPath, FileMode.Open))
            {
                config._BuildInfo = VerBarConfig.ReadVerBarConfig(buildInfoStream);
            }

            Dictionary <string, string> bi = null;

            for (int i = 0; i < config._BuildInfo.Count; ++i)
            {
                if (config._BuildInfo[i]["Active"] == "1")
                {
                    bi = config._BuildInfo[i];
                    break;
                }
            }

            if (bi == null)
            {
                throw new Exception("Can't find active BuildInfoEntry");
            }

            string dataFolder = CASCGame.GetDataFolder(config.GameType);

            config.ActiveBuild = 0;

            config._Builds = new List <KeyValueConfig>();

            string buildKey     = bi["BuildKey"];
            string buildCfgPath = Path.Combine(basePath, dataFolder, "config", buildKey.Substring(0, 2), buildKey.Substring(2, 2), buildKey);

            using (Stream stream = new FileStream(buildCfgPath, FileMode.Open))
            {
                config._Builds.Add(KeyValueConfig.ReadKeyValueConfig(stream));
            }

            string cdnKey     = bi["CDNKey"];
            string cdnCfgPath = Path.Combine(basePath, dataFolder, "config", cdnKey.Substring(0, 2), cdnKey.Substring(2, 2), cdnKey);

            using (Stream stream = new FileStream(cdnCfgPath, FileMode.Open))
            {
                config._CDNConfig = KeyValueConfig.ReadKeyValueConfig(stream);
            }

            return(config);
        }
예제 #2
0
        public static VerBarConfig ReadVerBarConfig(TextReader reader)
        {
            var result = new VerBarConfig();

            int lineNum = 0;

            string[] fields = null;

            string line;

            while ((line = reader.ReadLine()) != null)
            {
                if (string.IsNullOrWhiteSpace(line) || line.StartsWith("#")) // skip empty lines and comments
                {
                    continue;
                }

                string[] tokens = line.Split(new char[] { '|' });

                if (lineNum == 0) // keys
                {
                    fields = new string[tokens.Length];

                    for (int i = 0; i < tokens.Length; ++i)
                    {
                        fields[i] = tokens[i].Split(new char[] { '!' })[0].Replace(" ", "");
                    }
                }
                else // values
                {
                    result.Data.Add(new Dictionary <string, string>());

                    for (int i = 0; i < tokens.Length; ++i)
                    {
                        result.Data[lineNum - 1].Add(fields[i], tokens[i]);
                    }
                }

                lineNum++;
            }

            return(result);
        }
예제 #3
0
파일: CASCConfig.cs 프로젝트: aeo24/WoWMap
        public static VerBarConfig ReadVerBarConfig(TextReader reader)
        {
            var result = new VerBarConfig();
            string line;

            int lineNum = 0;

            string[] fields = null;

            while ((line = reader.ReadLine()) != null)
            {
                if (string.IsNullOrWhiteSpace(line) || line.StartsWith("#")) // skip empty lines and comments
                    continue;

                string[] tokens = line.Split(new char[] { '|' });

                if (lineNum == 0) // keys
                {
                    fields = new string[tokens.Length];

                    for (int i = 0; i < tokens.Length; ++i)
                    {
                        fields[i] = tokens[i].Split(new char[] { '!' })[0].Replace(" ", "");
                    }
                }
                else // values
                {
                    result.Data.Add(new Dictionary<string, string>());

                    for (int i = 0; i < tokens.Length; ++i)
                    {
                        result.Data[lineNum - 1].Add(fields[i], tokens[i]);
                    }
                }

                lineNum++;
            }

            return result;
        }
예제 #4
0
        public static void Load(bool online)
        {
            string wowPath = Properties.Settings.Default.WowPath;

            if (online)
            {
                using (var cdnsStream = CDNHandler.OpenFileDirect("http://us.patch.battle.net/wow_beta/cdns"))
                    _CDNData = new VerBarConfig(cdnsStream);

                using (var versionsStream = CDNHandler.OpenFileDirect("http://us.patch.battle.net/wow_beta/versions"))
                    _VersionsData = new VerBarConfig(versionsStream);

                string buildKey = _VersionsData["BuildConfig"][0];
                using (Stream buildConfigStream = CDNHandler.OpenConfigFileDirect(buildKey))
                    _BuildConfig = new KeyValueConfig(buildConfigStream);

                string cdnKey = _VersionsData["CDNConfig"][0];
                using (Stream CDNConfigStream = CDNHandler.OpenConfigFileDirect(cdnKey))
                    _CDNConfig = new KeyValueConfig(CDNConfigStream);
            }
            else
            {
                string buildInfoPath = Path.Combine(wowPath, ".build.info");

                using (Stream buildInfoStream = new FileStream(buildInfoPath, FileMode.Open))
                    _BuildInfo = new VerBarConfig(buildInfoStream);

                string buildKey     = _BuildInfo["Build Key"][0];
                string buildCfgPath = Path.Combine(wowPath, "Data\\config\\", buildKey.Substring(0, 2), buildKey.Substring(2, 2), buildKey);
                using (Stream buildConfigStream = new FileStream(buildCfgPath, FileMode.Open))
                    _BuildConfig = new KeyValueConfig(buildConfigStream);

                string cdnKey     = _BuildInfo["CDN Key"][0];
                string cdnCfgPath = Path.Combine(wowPath, "Data\\config\\", cdnKey.Substring(0, 2), cdnKey.Substring(2, 2), cdnKey);
                using (Stream CDNConfigStream = new FileStream(cdnCfgPath, FileMode.Open))
                    _CDNConfig = new KeyValueConfig(CDNConfigStream);
            }
        }
예제 #5
0
        public static void Load(bool online)
        {
            string wowPath = Properties.Settings.Default.WowPath;

            if (online)
            {
                using (var cdnsStream = CDNHandler.OpenFileDirect("http://us.patch.battle.net/wow_beta/cdns"))
                    _CDNData = new VerBarConfig(cdnsStream);

                using (var versionsStream = CDNHandler.OpenFileDirect("http://us.patch.battle.net/wow_beta/versions"))
                    _VersionsData = new VerBarConfig(versionsStream);

                string buildKey = _VersionsData["BuildConfig"][0];
                using (Stream buildConfigStream = CDNHandler.OpenConfigFileDirect(buildKey))
                    _BuildConfig = new KeyValueConfig(buildConfigStream);

                string cdnKey = _VersionsData["CDNConfig"][0];
                using (Stream CDNConfigStream = CDNHandler.OpenConfigFileDirect(cdnKey))
                    _CDNConfig = new KeyValueConfig(CDNConfigStream);
            }
            else
            {
                string buildInfoPath = Path.Combine(wowPath, ".build.info");

                using (Stream buildInfoStream = new FileStream(buildInfoPath, FileMode.Open))
                    _BuildInfo = new VerBarConfig(buildInfoStream);

                string buildKey = _BuildInfo["Build Key"][0];
                string buildCfgPath = Path.Combine(wowPath, "Data\\config\\", buildKey.Substring(0, 2), buildKey.Substring(2, 2), buildKey);
                using (Stream buildConfigStream = new FileStream(buildCfgPath, FileMode.Open))
                    _BuildConfig = new KeyValueConfig(buildConfigStream);

                string cdnKey = _BuildInfo["CDN Key"][0];
                string cdnCfgPath = Path.Combine(wowPath, "Data\\config\\", cdnKey.Substring(0, 2), cdnKey.Substring(2, 2), cdnKey);
                using (Stream CDNConfigStream = new FileStream(cdnCfgPath, FileMode.Open))
                    _CDNConfig = new KeyValueConfig(CDNConfigStream);
            }
        }
예제 #6
0
        public static CASCConfig LoadOnlineStorageConfig(string product, string region, bool useCurrentBuild = false)
        {
            var config = new CASCConfig {
                OnlineMode = true
            };

            config.Region  = region;
            config.Product = product;

            using (var cdnsStream = CDNIndexHandler.OpenFileDirect(string.Format("http://us.patch.battle.net/{0}/cdns", product)))
            {
                config._CDNData = VerBarConfig.ReadVerBarConfig(cdnsStream);
            }

            using (var versionsStream = CDNIndexHandler.OpenFileDirect(string.Format("http://us.patch.battle.net/{0}/versions", product)))
            {
                config._VersionsData = VerBarConfig.ReadVerBarConfig(versionsStream);
            }

            int versionIndex = 0;

            for (int i = 0; i < config._VersionsData.Count; ++i)
            {
                if (config._VersionsData[i]["Region"] == region)
                {
                    versionIndex = i;
                    break;
                }
            }

            config.GameType = CASCGame.DetectOnlineGame(product);

            string cdnKey = config._VersionsData[versionIndex]["CDNConfig"];

            using (Stream stream = CDNIndexHandler.OpenConfigFileDirect(config, cdnKey))
            {
                config._CDNConfig = KeyValueConfig.ReadKeyValueConfig(stream);
            }

            config.ActiveBuild = 0;

            config._Builds = new List <KeyValueConfig>();

            for (int i = 0; i < config._CDNConfig["builds"].Count; i++)
            {
                try
                {
                    using (Stream stream = CDNIndexHandler.OpenConfigFileDirect(config, config._CDNConfig["builds"][i]))
                    {
                        var cfg = KeyValueConfig.ReadKeyValueConfig(stream);
                        config._Builds.Add(cfg);
                    }
                }
                catch
                {
                }
            }

            if (useCurrentBuild)
            {
                string buildKey = config._VersionsData[versionIndex]["BuildConfig"];

                int buildIndex = config._CDNConfig["builds"].IndexOf(buildKey);

                if (buildIndex != -1)
                {
                    config.ActiveBuild = buildIndex;
                }
            }

            return(config);
        }
예제 #7
0
        public static CASCConfig LoadOnlineStorageConfig(string product, string region, bool useCurrentBuild = false)
        {
            var config = new CASCConfig {
                OnlineMode = true
            };

            config.Region  = region;
            config.Product = product;

            using (var cdnsStream = CDNIndexHandler.OpenFileDirect(string.Format("http://us.patch.battle.net:1119/{0}/cdns", product)))
            {
                config._CDNData = VerBarConfig.ReadVerBarConfig(cdnsStream);
            }

            using (var versionsStream = CDNIndexHandler.OpenFileDirect(string.Format("http://us.patch.battle.net:1119/{0}/versions", product)))
            {
                config._VersionsData = VerBarConfig.ReadVerBarConfig(versionsStream);
            }

            for (int i = 0; i < config._VersionsData.Count; ++i)
            {
                if (config._VersionsData[i]["Region"] == region)
                {
                    config._versionsIndex = i;
                    break;
                }
            }

            config.GameType = CASCGame.DetectOnlineGame(product);

            string cdnKey = config._VersionsData[config._versionsIndex]["CDNConfig"].ToLower();

            //string cdnKey = "d583ee15a02b81cc494aeeef8d195059";
            //string cdnKey = "8c4ac7ab2f96ab75dab58448ffd07842";
            using (Stream stream = CDNIndexHandler.OpenConfigFileDirect(config, cdnKey))
            {
                config._CDNConfig = KeyValueConfig.ReadKeyValueConfig(stream);
            }

            config.ActiveBuild = 0;

            config._Builds = new List <KeyValueConfig>();

            if (config._CDNConfig["builds"] != null)
            {
                for (int i = 0; i < config._CDNConfig["builds"].Count; i++)
                {
                    try
                    {
                        using (Stream stream = CDNIndexHandler.OpenConfigFileDirect(config, config._CDNConfig["builds"][i]))
                        {
                            var cfg = KeyValueConfig.ReadKeyValueConfig(stream);
                            config._Builds.Add(cfg);
                        }
                    }
                    catch
                    {
                    }
                }

                if (useCurrentBuild)
                {
                    string curBuildKey = config._VersionsData[config._versionsIndex]["BuildConfig"];

                    int buildIndex = config._CDNConfig["builds"].IndexOf(curBuildKey);

                    if (buildIndex != -1)
                    {
                        config.ActiveBuild = buildIndex;
                    }
                }
            }

            string buildKey = config._VersionsData[config._versionsIndex]["BuildConfig"].ToLower();

            //string buildKey = "2e1db4da3a538cd52521b73040bdb162";
            //string buildKey = "f639eab0a11d5b7a9099bc188badaa2e";
            using (Stream stream = CDNIndexHandler.OpenConfigFileDirect(config, buildKey))
            {
                var cfg = KeyValueConfig.ReadKeyValueConfig(stream);
                config._Builds.Add(cfg);
            }

            return(config);
        }