Ejemplo n.º 1
0
        private static UnknownStruct7[] _ReadUnknownStruct7Array(byte[] fileBytes, ref int offset, int count) // because Marshal.PtrToStructure IS SO F*****G SLOW
        {
            UnknownStruct7[] arr = new UnknownStruct7[count];

            for (int i = 0; i < count; i++)
            {
                arr[i] = new UnknownStruct7
                {
                    UnknownShort1 = StreamTools.ReadInt16(fileBytes, ref offset),
                    UnknownShort2 = StreamTools.ReadInt16(fileBytes, ref offset),
                    UnknownShort3 = StreamTools.ReadInt16(fileBytes, ref offset)
                };
            }

            return(arr);
        }
Ejemplo n.º 2
0
        private static Vector3[] _ReadVector3Array(byte[] fileBytes, ref int offset, int count) // because Marshal.PtrToStructure IS SO F*****G SLOW
        {
            Vector3[] arr = new Vector3[count];

            for (int i = 0; i < count; i++)
            {
                arr[i] = new Vector3
                {
                    X = StreamTools.ReadFloat(fileBytes, ref offset),
                    Y = StreamTools.ReadFloat(fileBytes, ref offset),
                    Z = StreamTools.ReadFloat(fileBytes, ref offset),
                };
            }

            return(arr);
        }
Ejemplo n.º 3
0
        private static UnknownStruct1[] _ReadUnknownStruct1Array(byte[] fileBytes, ref int offset, int count) // because Marshal.PtrToStructure IS SO F*****G SLOW
        {
            UnknownStruct1[] arr = new UnknownStruct1[count];

            for (int i = 0; i < count; i++)
            {
                arr[i] = new UnknownStruct1
                {
                    UnknownFloat1 = StreamTools.ReadFloat(fileBytes, ref offset),
                    UnknownFloat2 = StreamTools.ReadFloat(fileBytes, ref offset),
                    UnknownFloat3 = StreamTools.ReadFloat(fileBytes, ref offset),
                    Index         = StreamTools.ReadInt32(fileBytes, ref offset)
                };
            }

            return(arr);
        }
Ejemplo n.º 4
0
        private void _ParsePatchType(byte[] buffer)
        {
            int offset = 0;

            /* This reading/parsing stores all date merely to make it clear of the file structure.
             * Given we're not going to be using this much at all, this will do for now until we know
             * what all the unknown fields are.
             */

            // header
            PatchFileHeader fileHeader = FileTools.ByteArrayToStructure <PatchFileHeader>(buffer, ref offset);

            if (fileHeader.EndToken != Token.PatchSect)
            {
                throw new Exceptions.UnexpectedTokenException("Expected PatchSect token but got 0x" + fileHeader.EndToken.ToString("X8"));
            }

            // file searches?
            List <PatchSearch> searchSegments = new List <PatchSearch>();

            while (true)
            {
                bool isPresent = (StreamTools.ReadInt32(buffer, ref offset) != 0);
                if (!isPresent)
                {
                    break;
                }

                int characterCount = StreamTools.ReadInt32(buffer, ref offset);

                PatchSearch searchSegment = new PatchSearch
                {
                    IsPresent      = true,
                    CharacterCount = characterCount,
                    FileSearch     = StreamTools.ReadStringUnicode(buffer, ref offset, characterCount, false)
                };

                searchSegments.Add(searchSegment);
            }

            // files
            List <PatchEntryStruct> entries = new List <PatchEntryStruct>();

            while (true)
            {
                int characterCount = StreamTools.ReadInt32(buffer, ref offset);

                PatchEntryStruct entrySegment = new PatchEntryStruct
                {
                    CharacterCount = characterCount,
                    FileName       = StreamTools.ReadStringUnicode(buffer, ref offset, characterCount, false),
                    UsedInX86      = (StreamTools.ReadInt32(buffer, ref offset) != 0),
                    UsedInX64      = (StreamTools.ReadInt32(buffer, ref offset) != 0),
                    Localization   = StreamTools.ReadInt16(buffer, ref offset),
                    FileSize       = StreamTools.ReadInt64(buffer, ref offset),
                    DatOffset      = StreamTools.ReadInt64(buffer, ref offset),
                    Hash           = StreamTools.ReadInt32(buffer, ref offset),
                    HasMoreEntries = StreamTools.ReadInt32(buffer, ref offset),
                };

                entries.Add(entrySegment);

                if (entrySegment.HasMoreEntries == -1)
                {
                    break;
                }
            }

            // add files to file list (could be done in above loop, but as mentioned earlier, this parsing method is almost enitrely out of random interest
            foreach (PatchEntryStruct entry in entries)
            {
                PackFileEntry fileEntry = new PatchFileEntry(entry)
                {
                    Pack = this
                };

                Files.Add(fileEntry);
            }

            HasIntegrity = (offset == buffer.Length);
        }