Exemplo n.º 1
0
        protected override FileIndexEntry3D[] ReadEntries()
        {

            List<FileIndexEntry3D> entries = new List<FileIndexEntry3D>();

            int length = (int)((new FileInfo(idxPath).Length / 3) / 4);

            using (FileStream index = new FileStream(idxPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryReader bin = new BinaryReader(index);

                int count = (int)(index.Length / 12);

                for (int i = 0; i < count && i < length; ++i)
                {
                    FileIndexEntry3D entry = new FileIndexEntry3D
                    {
                        lookup = bin.ReadInt32(),
                        length = bin.ReadInt32(),
                        extra = bin.ReadInt32()
                    };

                    entries.Add(entry);
                }

                for (int i = count; i < length; ++i)
                {
                    FileIndexEntry3D entry = new FileIndexEntry3D
                    {
                        lookup = -1,
                        length = -1,
                        extra = -1
                    };

                    entries.Add(entry);
                }
            }

            FileIndexEntry5D[] patches = VerData.Patches;

            for (int i = 0; i < patches.Length; ++i)
            {
                FileIndexEntry5D patch = patches[i];

                if (patch.file == patchFile && patch.index >= 0 && patch.index < entries.Count)
                {
                    FileIndexEntry3D entry = entries.ElementAt(patch.index);
                    entry.lookup = patch.lookup;
                    entry.length = patch.length | (1 << 31);
                    entry.extra = patch.extra;
                }
            }

            return entries.ToArray();
        }
Exemplo n.º 2
0
        protected override FileIndexEntry3D[] ReadEntries()
        {
            List <FileIndexEntry3D> entries = new List <FileIndexEntry3D>();

            int length = (int)((new FileInfo(idxPath).Length / 3) / 4);

            using (FileStream index = new FileStream(idxPath, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryReader bin = new BinaryReader(index);

                int count = (int)(index.Length / 12);

                for (int i = 0; i < count && i < length; ++i)
                {
                    FileIndexEntry3D entry = new FileIndexEntry3D
                    {
                        lookup = bin.ReadInt32(),
                        length = bin.ReadInt32(),
                        extra  = bin.ReadInt32()
                    };

                    entries.Add(entry);
                }

                for (int i = count; i < length; ++i)
                {
                    FileIndexEntry3D entry = new FileIndexEntry3D
                    {
                        lookup = -1,
                        length = -1,
                        extra  = -1
                    };

                    entries.Add(entry);
                }
            }

            FileIndexEntry5D[] patches = VerData.Patches;

            for (int i = 0; i < patches.Length; ++i)
            {
                FileIndexEntry5D patch = patches[i];

                if (patch.file == patchFile && patch.index >= 0 && patch.index < entries.Count)
                {
                    FileIndexEntry3D entry = entries.ElementAt(patch.index);
                    entry.lookup = patch.lookup;
                    entry.length = patch.length | (1 << 31);
                    entry.extra  = patch.extra;
                }
            }

            return(entries.ToArray());
        }
Exemplo n.º 3
0
        public BinaryFileReader Seek(int index, out int length, out int extra, out bool patched)
        {
            if (Stream == null)
            {
                m_Stream = new FileStream(DataPath, FileMode.Open, FileAccess.Read, FileShare.Read);
            }

            if (index < 0 || index >= m_Index.Length)
            {
                length  = extra = 0;
                patched = false;
                return(null);
            }

            FileIndexEntry3D e = m_Index[index];

            if (e.lookup < 0)
            {
                length  = extra = 0;
                patched = false;
                return(null);
            }

            length = e.length & 0x7FFFFFFF;
            extra  = e.extra;

            if ((e.length & 0xFF000000) != 0)
            {
                patched = true;

                VerData.Stream.Seek(e.lookup, SeekOrigin.Begin);
                return(new BinaryFileReader(new BinaryReader(VerData.Stream)));
            }
            else if (m_Stream == null)
            {
                length  = extra = 0;
                patched = false;
                return(null);
            }

            patched = false;

            m_Stream.Position = e.lookup;
            return(new BinaryFileReader(new BinaryReader(m_Stream)));
        }