Пример #1
0
        public void FullyLoad()
        {
            Log.InfoFormat("fully loading database: version='{0}', nationName='{1}'", this.Version, this.RootPath);

            if (this.IsFullyLoaded)
            {
                Log.Info("this database is already fully loaded");
                return;
            }

            //this.ReadVersion();

            this.InitializePackages();

            var scriptEntries = PackageStream.GetFileEntries(Path.Combine(RootPath, ScriptsPackageFile));


            var nationEntries = scriptEntries.Where(s => s.StartsWith(VehiclesFolderInPackage) && s.Length > VehiclesFolderInPackage.Length).Select(s => s.Substring(VehiclesFolderInPackage.Length, s.IndexOf("/", VehiclesFolderInPackage.Length, StringComparison.InvariantCulture) - VehiclesFolderInPackage.Length)).Distinct();

            foreach (var nationName in nationEntries)
            {
                if (Database.IsTechTreeFolder(nationName, scriptEntries))
                {
                    var nation = new NationalDatabase(this, nationName);
                    Log.InfoFormat("adding nation database: {0}", nation.Key);
                    this.Nations.Add(nation.Key, nation);
                }
            }

            this.LoadCommonData();

            this.LoadBenchmarkTanks();

            this.IsFullyLoaded = true;
        }
Пример #2
0
        private PackageIndexEntry[] BuildPackageIndices()
        {
            var entries = new List <PackageIndexEntry>();

            foreach (var packageFile in _client.Paths.ClientPackages)
            {
                this.LogInfo("buiding package indices for '{0}'", packageFile);

                var fileEntries = PackageStream.GetFileEntries(packageFile);
                if (fileEntries == null)
                {
                    this.LogError("non-existed or invalid package file: {0}", packageFile);
                    continue;
                }

                foreach (var filePath in fileEntries)
                {
                    entries.Add(new PackageIndexEntry(filePath.ToLower(), packageFile));
                }
            }

            return(entries.ToArray());
        }