Beispiel #1
0
        public void Read(SerializedFileReader reader)
        {
            if (IsRead5Format(reader.Generation))
            {
                int nodesCount = reader.ReadInt32();
                if (nodesCount < 0)
                {
                    throw new Exception($"Invalid type tree's node count {nodesCount}");
                }

                int stringSize = reader.ReadInt32();
                if (stringSize < 0)
                {
                    throw new Exception($"Invalid type tree's string size {stringSize}");
                }

                TypeTreeNode[] nodes          = new TypeTreeNode[nodesCount];
                long           stringPosition = reader.BaseStream.Position + nodesCount * TypeTreeNode.GetNodeSize(reader.Generation);
                for (int i = 0; i < nodesCount; i++)
                {
                    TypeTreeNode node = new TypeTreeNode();
                    node.Read(reader, stringPosition);
                    nodes[i] = node;
                }
                Nodes = nodes;
                reader.BaseStream.Position += stringSize;
            }
            else
            {
                List <TypeTreeNode> nodes = new List <TypeTreeNode>();
                ReadTreeNode(reader, nodes, 0);
                Nodes = nodes.ToArray();
            }
        }
Beispiel #2
0
        public void Read(SerializedReader reader)
        {
            if (TypeTreeNode.IsFormat5(reader.Generation))
            {
                int nodesCount       = reader.ReadInt32();
                int customBufferSize = reader.ReadInt32();
                Nodes = new TypeTreeNode[nodesCount];
                for (int i = 0; i < nodesCount; i++)
                {
                    TypeTreeNode node = new TypeTreeNode();
                    node.Read(reader);
                    Nodes[i] = node;
                }
                CustomTypeBuffer = new byte[customBufferSize];
                reader.Read(CustomTypeBuffer, 0, CustomTypeBuffer.Length);

                if (HasUnknown(reader.Generation))
                {
                    Unknown = reader.ReadInt32();
                }
            }
            else
            {
                List <TypeTreeNode> nodes = new List <TypeTreeNode>();
                ReadTreeNode(reader, nodes, 0);
                Nodes = nodes.ToArray();
            }
        }
Beispiel #3
0
        private static void ReadTreeNode(SerializedFileReader reader, ICollection <TypeTreeNode> nodes, byte depth)
        {
            TypeTreeNode node = new TypeTreeNode(depth);

            node.Read(reader);
            nodes.Add(node);

            int childCount = reader.ReadInt32();

            for (int i = 0; i < childCount; i++)
            {
                ReadTreeNode(reader, nodes, (byte)(depth + 1));
            }
        }