示例#1
0
        // gets information about the existing 01.dat archive
        internal static GameData RebuildGameData(bool copyBackup = false)
        {
            if (Directory.Exists(GameArchiveDir)) Directory.Delete(GameArchiveDir, true);
            ExtractGameArchive();

            if (!Directory.Exists(GameArchiveDir)) return null;

            GameData buildData = new GameData();

            // Extract game archive and load data
            QarFile gameQarXml = new QarFile();
            gameQarXml.LoadFromFile(GameArchiveXmlPath);

            // Load currently installed mods
            Settings oSet = new Settings();
            oSet.LoadSettings();

            foreach (QarEntry gameQarEntry in gameQarXml.QarEntries)
            {
                buildData.GameQarEntries.Add(new ModQarEntry() { FilePath = gameQarEntry.FilePath, Compressed = gameQarEntry.Compressed, Hash = gameQarEntry.Hash });
            }

            buildData.GameFpkEntries = BuildFpkList(GameArchiveDir);

            // recurse through all installed mods
            foreach (ModEntry mod in oSet.ModEntries)
            {
                // check all files in mod against qar archive
                foreach (ModFpkEntry modFpkFile in mod.ModFpkEntries)
                {
                    buildData.GameFpkEntries.RemoveAll(entry => entry.FilePath == modFpkFile.FilePath && entry.FpkFile == modFpkFile.FpkFile);
                }
                foreach (ModQarEntry modQarFile in mod.ModQarEntries)
                {
                    buildData.GameQarEntries.RemoveAll(entry => entry.FilePath == modQarFile.FilePath);
                }
            }

            if(copyBackup)
            {
                foreach (ModFpkEntry fpkEntry in buildData.GameFpkEntries)
                {
                    string fpkDir = Tools.ToWinPath(fpkEntry.FpkFile.Replace(".", "_"));
                    backupMan.AddFile(GameArchiveDir + fpkDir + Tools.ToWinPath(fpkEntry.FilePath), fpkEntry.FilePath, fpkEntry.FpkFile);
                }

                foreach (ModQarEntry qarEntry in buildData.GameQarEntries)
                {
                    backupMan.AddFile(GameArchiveDir + Tools.ToWinPath(qarEntry.FilePath), Tools.ToQarPath(qarEntry.FilePath));
                }
                backupMan.Save();
            }

            DeleteGameArchive();

            return buildData;
        }
        // gets information about the existing 01.dat archive
        internal static GameData RebuildGameData()
        {
            if (Directory.Exists(GameArchiveDir)) Directory.Delete(GameArchiveDir, true);
            ExtractGameArchive();

            if (!Directory.Exists(GameArchiveDir)) return null;

            GameData buildData = new GameData();

            // Extract game archive and load data
            QarFile gameQarXml = new QarFile();
            gameQarXml.LoadFromFile(GameArchiveXmlPath);

            // Load currently installed mods
            Settings oSet = new Settings();
            oSet.LoadSettings();

            foreach (QarEntry gameQarEntry in gameQarXml.QarEntries)
            {
                buildData.GameQarEntries.Add(new ModQarEntry() { FilePath = gameQarEntry.FilePath, Compressed = gameQarEntry.Compressed, Hash = gameQarEntry.Hash });
            }

            buildData.GameFpkEntries = BuildFpkList(GameArchiveDir);

            // recurse through all installed mods
            foreach (ModEntry mod in oSet.ModEntries)
            {
                // check all files in mod against qar archive
                foreach (ModFpkEntry modFpkFile in mod.ModFpkEntries)
                {
                    buildData.GameFpkEntries.RemoveAll(entry => entry.FilePath == modFpkFile.FilePath && entry.FpkFile == modFpkFile.FpkFile);
                }
                foreach (ModQarEntry modQarFile in mod.ModQarEntries)
                {
                    buildData.GameQarEntries.RemoveAll(entry => entry.FilePath == modQarFile.FilePath);
                }
            }

            Directory.Delete(GameArchiveDir, true);
            File.Delete(GameArchiveXmlPath);

            return buildData;
        }