Наследование: SERIParameter
Пример #1
0
        static SERIParameter ParseSERIArray(BinaryReader Reader,
                                            uint StringTableOffset,
                                            uint StringPointersOffset,
                                            uint ValuesOffset,
                                            string Name)
        {
            char   ArrayDataType = Reader.ReadChar();
            byte   Padding       = Reader.ReadByte();
            ushort ArrayLength   = Reader.ReadUInt16();

            ushort[] Pointers = new ushort[ArrayLength];
            for (int i = 0; i < Pointers.Length; i++)
            {
                Pointers[i] = Reader.ReadUInt16();
            }

            switch (ArrayDataType)
            {
            case 's':      //Of String
                string[] StringArray = new string[ArrayLength];

                for (int i = 0; i < Pointers.Length; i++)
                {
                    string ItemName = ReadNullTerminatedString(Reader, StringTableOffset + Pointers[i]);
                    StringArray[i] = ItemName;
                }

                return(new StringArray(Name, StringArray));

            case 'i':     //Of Integer
                switch (Name)
                {
                case "texi":
                case "model":
                case "cloth":
                case "list":
                    string[] NameArray = new string[ArrayLength];

                    for (int i = 0; i < Pointers.Length; i++)
                    {
                        Reader.BaseStream.Seek(ValuesOffset + Pointers[i], SeekOrigin.Begin);
                        Reader.BaseStream.Seek(StringPointersOffset + (Reader.ReadUInt32() - 1) * 4, SeekOrigin.Begin);
                        string ItemName = ReadNullTerminatedString(Reader, StringTableOffset + Reader.ReadUInt32());
                        NameArray[i] = ItemName;
                    }

                    return(new StringArray(Name, NameArray));

                default:
                    int[] IntArray = new int[ArrayLength];

                    for (int i = 0; i < Pointers.Length; i++)
                    {
                        Reader.BaseStream.Seek(ValuesOffset + Pointers[i], SeekOrigin.Begin);
                        IntArray[i] = Reader.ReadInt32();
                    }

                    return(new IntegerArray(Name, IntArray));
                }

            case 'b':     //Of Boolean
                bool[] BooleanArray = new bool[ArrayLength];

                for (int i = 0; i < Pointers.Length; i++)
                {
                    Reader.BaseStream.Seek(ValuesOffset + Pointers[i], SeekOrigin.Begin);
                    BooleanArray[i] = Reader.ReadByte() == 1;
                }

                return(new BooleanArray(Name, BooleanArray));

            case 'f':     //Of Float
                float[] FloatArray = new float[ArrayLength];

                for (int i = 0; i < Pointers.Length; i++)
                {
                    Reader.BaseStream.Seek(ValuesOffset + Pointers[i], SeekOrigin.Begin);
                    FloatArray[i] = Reader.ReadSingle();
                }

                return(new FloatArray(Name, FloatArray));

            case 'h':     //Of Array
                SERIParameter[] NestedArray = new SERIParameter[ArrayLength];

                for (int i = 0; i < Pointers.Length; i++)
                {
                    Reader.BaseStream.Seek(ValuesOffset + Pointers[i], SeekOrigin.Begin);
                    ushort          Count            = Reader.ReadUInt16();
                    long            TypesTableOffset = ValuesOffset + Pointers[i] + 2 + Count * 4;
                    SERIParameter[] Arrays           = new SERIParameter[Count];
                    for (int Index = 0; Index < Count; Index++)
                    {
                        Reader.BaseStream.Seek(ValuesOffset + Pointers[i] + 2 + Index * 4, SeekOrigin.Begin);
                        ushort NameOffset  = Reader.ReadUInt16();
                        ushort ValueOffset = Reader.ReadUInt16();
                        string ArrayName   = ReadNullTerminatedString(Reader, StringTableOffset + NameOffset);

                        Reader.BaseStream.Seek(TypesTableOffset + Index, SeekOrigin.Begin);
                        char ValueType = Reader.ReadChar();

                        Arrays[Index] = ParseSERI(Reader,
                                                  StringTableOffset,
                                                  StringPointersOffset,
                                                  ValuesOffset,
                                                  ValueOffset,
                                                  ValueType,
                                                  ArrayName);
                    }

                    NestedArray[i] = new NestedArray(null, Arrays);
                }

                return(new NestedArray(Name, NestedArray));
            }

            return(null);
        }
Пример #2
0
        static SERIParameter ParseSERIArray(BinaryReader Reader, 
            uint StringTableOffset,
            uint StringPointersOffset, 
            uint ValuesOffset,
            string Name)
        {
            char ArrayDataType = Reader.ReadChar();
            byte Padding = Reader.ReadByte();
            ushort ArrayLength = Reader.ReadUInt16();
            ushort[] Pointers = new ushort[ArrayLength];
            for (int i = 0; i < Pointers.Length; i++) Pointers[i] = Reader.ReadUInt16();

            switch (ArrayDataType)
            {
                case 's':  //Of String
                    string[] StringArray = new string[ArrayLength];

                    for (int i = 0; i < Pointers.Length; i++)
                    {
                        string ItemName = ReadNullTerminatedString(Reader, StringTableOffset + Pointers[i]);
                        StringArray[i] = ItemName;
                    }

                    return new StringArray(Name, StringArray);
                case 'i': //Of Integer
                    switch (Name)
                    {
                        case "texi":
                        case "model":
                        case "cloth":
                        case "list":
                            string[] NameArray = new string[ArrayLength];

                            for (int i = 0; i < Pointers.Length; i++)
                            {
                                Reader.BaseStream.Seek(ValuesOffset + Pointers[i], SeekOrigin.Begin);
                                Reader.BaseStream.Seek(StringPointersOffset + (Reader.ReadUInt32() - 1) * 4, SeekOrigin.Begin);
                                string ItemName = ReadNullTerminatedString(Reader, StringTableOffset + Reader.ReadUInt32());
                                NameArray[i] = ItemName;
                            }

                            return new StringArray(Name, NameArray);
                        default:
                            int[] IntArray = new int[ArrayLength];

                            for (int i = 0; i < Pointers.Length; i++)
                            {
                                Reader.BaseStream.Seek(ValuesOffset + Pointers[i], SeekOrigin.Begin);
                                IntArray[i] = Reader.ReadInt32();
                            }

                            return new IntegerArray(Name, IntArray);
                    }
                case 'b': //Of Boolean
                    bool[] BooleanArray = new bool[ArrayLength];

                    for (int i = 0; i < Pointers.Length; i++)
                    {
                        Reader.BaseStream.Seek(ValuesOffset + Pointers[i], SeekOrigin.Begin);
                        BooleanArray[i] = Reader.ReadByte() == 1;
                    }

                    return new BooleanArray(Name, BooleanArray);
                case 'f': //Of Float
                    float[] FloatArray = new float[ArrayLength];

                    for (int i = 0; i < Pointers.Length; i++)
                    {
                        Reader.BaseStream.Seek(ValuesOffset + Pointers[i], SeekOrigin.Begin);
                        FloatArray[i] = Reader.ReadSingle();
                    }

                    return new FloatArray(Name, FloatArray);
                case 'h': //Of Array
                    SERIParameter[] NestedArray = new SERIParameter[ArrayLength];

                    for (int i = 0; i < Pointers.Length; i++)
                    {
                        Reader.BaseStream.Seek(ValuesOffset + Pointers[i], SeekOrigin.Begin);
                        ushort Count = Reader.ReadUInt16();
                        long TypesTableOffset = ValuesOffset + Pointers[i] + 2 + Count * 4;
                        SERIParameter[] Arrays = new SERIParameter[Count];
                        for (int Index = 0; Index < Count; Index++)
                        {
                            Reader.BaseStream.Seek(ValuesOffset + Pointers[i] + 2 + Index * 4, SeekOrigin.Begin);
                            ushort NameOffset = Reader.ReadUInt16();
                            ushort ValueOffset = Reader.ReadUInt16();
                            string ArrayName = ReadNullTerminatedString(Reader, StringTableOffset + NameOffset);

                            Reader.BaseStream.Seek(TypesTableOffset + Index, SeekOrigin.Begin);
                            char ValueType = Reader.ReadChar();

                            Arrays[Index] = ParseSERI(Reader,
                                StringTableOffset,
                                StringPointersOffset,
                                ValuesOffset,
                                ValueOffset,
                                ValueType,
                                ArrayName);
                        }

                        NestedArray[i] = new NestedArray(null, Arrays);
                    }

                    return new NestedArray(Name, NestedArray);
            }

            return null;
        }