Beispiel #1
0
        private void ReadClassMember5(EndianStream stream, ClassStruct classStruct, List <ClassMember> members, long stringPosition)
        {
            ushort num0    = stream.ReadUInt16();
            byte   level   = stream.ReadByte();
            bool   isArray = stream.ReadBoolean();

            string memberType = ReadClassType(stream, stringPosition);
            string memberName = ReadClassType(stream, stringPosition);

            int size  = stream.ReadInt32();
            int index = stream.ReadInt32();
            int flag  = stream.ReadInt32();

            if (index == 0)
            {
                classStruct.BaseType = memberType;
                classStruct.BaseName = memberName;
            }
            else
            {
                ClassMember member = new ClassMember();
                member.Level   = level;
                member.Type    = memberType;
                member.Name    = memberName;
                member.Size    = size;
                member.Index   = index;
                member.IsArray = isArray;
                member.Num0    = num0;
                member.Flag    = flag;
                members.Add(member);
            }
        }
Beispiel #2
0
        private void AddClassStruct(ClassStruct classStruct)
        {
            int classID = classStruct.ClassID;

            if (m_classStructs.ContainsKey(classID))
            {
#warning TODO: unknown behaviour. why does asset contains same files with same ID?
                if (Version.IsEqual(2017, 1, 0, VersionType.Patch, 5))
                {
                    return;
                }
                throw new Exception($"Asset file {Name} already contains class struct with class id {classID}");
            }
            m_classStructs.Add(classID, classStruct);
        }
Beispiel #3
0
        private void ReadBase(EndianStream stream)
        {
            ClassStruct classStruct = new ClassStruct();

            classStruct.ClassID  = stream.ReadInt32();
            classStruct.BaseType = stream.ReadStringZeroTerm();
            classStruct.BaseName = stream.ReadStringZeroTerm();

            List <ClassMember> members = new List <ClassMember>();

            stream.BaseStream.Position += 20;
            int memberCount = stream.ReadInt32();

            for (int i = 0; i < memberCount; i++)
            {
                ReadClassMember(stream, members, 0);
            }
            classStruct.Members = members.ToArray();

            AddClassStruct(classStruct);
        }
Beispiel #4
0
        private void ReadBase5(EndianStream stream)
        {
            int classID = stream.ReadInt32();

            if (IsReadSubClass)
            {
                // same class ID with different subclasses coored several times but we need unique class ID
                // so create unique class ID and store corresponding class ID

                stream.BaseStream.Position++;

                int uniqueClassID;
                int subClassID = stream.ReadInt16();
                if (subClassID == -1)
                {
                    // no subclass. that meen that class ID is unique by itself
                    uniqueClassID = classID;
                }
                else if (subClassID >= 0)
                {
                    // ordinal class ID should be >= 0, so we can use whole negative int range
                    uniqueClassID = -1 - subClassID;
                }
                else
                {
                    throw new Exception($"Invalid type value {subClassID} for asset file {Name}");
                }

                ClassIDMap id = new ClassIDMap(uniqueClassID, classID);
                m_classIDs.Add(id);

                if (classID == (int)ClassIDType.MonoBehaviour)
                {
                    stream.BaseStream.Position += 16;
                }
                classID = uniqueClassID;
            }
            else if (classID < 0)
            {
                stream.BaseStream.Position += 16;
            }
            stream.BaseStream.Position += 16;

            if (BaseDefinitions)
            {
                ClassStruct classStruct = new ClassStruct();
                classStruct.ClassID = classID;

                int memberCount = stream.ReadInt32();
                if (memberCount < 0)
                {
                    throw new Exception($"Invalid member count {memberCount}");
                }
                int stringSize = stream.ReadInt32();
                if (stringSize < 0)
                {
                    throw new Exception($"Invalid string size {stringSize}");
                }

                long stringPosition = stream.BaseStream.Position + memberCount * ClassMember.ClassSize;

                List <ClassMember> members = new List <ClassMember>();
                for (int i = 0; i < memberCount; i++)
                {
                    ReadClassMember5(stream, classStruct, members, stringPosition);
                }
                stream.BaseStream.Position += stringSize;
                classStruct.Members         = members.ToArray();

                AddClassStruct(classStruct);
            }
        }