コード例 #1
0
ファイル: Index2.cs プロジェクト: PikminGuts92/BFForever
        internal override void ReadData(AwesomeReader ar)
        {
            Entries.Clear();

            Version = ar.ReadInt32();
            int count = ar.ReadInt32();

            ar.BaseStream.Position += 4; // Should be 4

            for (int i = 0; i < count; i++)
            {
                Index2Entry entry = new Index2Entry();

                // 24 bytes
                entry.FilePath = ar.ReadUInt64();
                entry.Type     = ar.ReadUInt64();
                int stringCount = ar.ReadInt32(); // Usually 1 for most entries

                entry.PackageEntries = new List <Index2PackageEntry>();

                // Jumps to packages/external paths entries
                long stringOffset     = (ar.ReadInt32() - 4) + ar.BaseStream.Position;
                long previousPosition = ar.BaseStream.Position;

                for (int ii = 0; ii < stringCount; ii++)
                {
                    // 248 bytes
                    ar.BaseStream.Position = stringOffset;

                    // Reads string + null-terminated string
                    Index2PackageEntry pack = new Index2PackageEntry();
                    pack.Package          = ar.ReadUInt64();
                    pack.ExternalFilePath = ar.ReadNullString();
                    entry.PackageEntries.Add(pack);

                    stringOffset += 248;
                }

                // Returns to next entry
                ar.BaseStream.Position = previousPosition;

                // Adds to entries
                Entries.Add(entry);
            }
        }
コード例 #2
0
        private bool LoadRiffFile(string path, Index2PackageEntry packageEntry)
        {
            RiffFile rif = RiffFile.FromFile(path);

            if (rif == null)
            {
                return(false);
            }

            _tempObjects.Clear();
            _tempObjectsPackageEntry = packageEntry;

            // Loads all zobjects from riff file
            foreach (ZObject obj in rif.Objects.Where(x => !(x is StringTable)))
            {
                CreateStringTablePaths(obj.DirectoryPath); // Creates string table path
                _tempObjects.Add(obj);
            }

            return(true);
        }
コード例 #3
0
        public void UpdateIndexEntryAsPending(HKey filePath, HKey type, string physicalPath, HKey packageFilePath)
        {
            Index2Entry indexEntry = Index.Entries.FirstOrDefault(x => x.FilePath == filePath);

            if (indexEntry == null)
            {
                // Creates new entry
                indexEntry = new Index2Entry()
                {
                    FilePath = filePath,
                    Type     = type
                };

                Index.Entries.Add(indexEntry);
            }

            Index2PackageEntry packageEntry = indexEntry.PackageEntries.FirstOrDefault(x => x.Package == packageFilePath);

            if (packageEntry == null)
            {
                // Creates new entry
                packageEntry = new Index2PackageEntry()
                {
                    Package          = packageFilePath,
                    ExternalFilePath = physicalPath
                };

                // Inserts at the front
                indexEntry.PackageEntries.Insert(0, packageEntry);
            }
            else
            {
                // Updates external file path
                packageEntry.ExternalFilePath = physicalPath;
            }
        }
コード例 #4
0
 public void ClearCache()
 {
     _tempObjects.Clear();
     _tempObjectsPackageEntry = null;
 }