Example #1
0
        public new static XML Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired,
                                          uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            XML xml = mapper.Map <XML>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            using (MemoryStream memory = new MemoryStream(rawData))
            {
                xml.TargetModule = memory.ReadString((int)memory.ReadUInt32());
                xml.Unknown8     = memory.ReadUInt8();
                xml.Path         = memory.ReadString((int)memory.ReadUInt32());

                if (xml.Path != xml.Info.SourceDataDescription)
                {
                    xml.Info.SourceDataDescription = xml.Path;
                }

                xml.Unknown16 = memory.ReadUInt16();

                if (xml.Unknown16 != 1024)
                {
                    xml.rawUnsolved = rawData;
                    return(xml);
                }

                uint   nodesCount = memory.ReadUInt32();
                byte[] valuesDb   = new byte[memory.ReadUInt32()];

                memory.Read(valuesDb, 0, valuesDb.Length);
                using (MemoryStream valuesDbStream = new MemoryStream(valuesDb))
                {
                    for (int i = 0; i < nodesCount; i++)
                    {
                        Node node = new Node();

                        uint nameOffset = memory.ReadUInt32();
                        valuesDbStream.Seek(nameOffset, SeekOrigin.Begin);
                        node.Name.Type      = valuesDbStream.ReadUInt32();
                        node.Name.Unknown32 = valuesDbStream.ReadUInt32();
                        node.Name.Value     = valuesDbStream.ReadStringDynamic();

                        uint valueOffset = memory.ReadUInt32();
                        valuesDbStream.Seek(valueOffset, SeekOrigin.Begin);
                        node.Value.Type      = valuesDbStream.ReadUInt32();
                        node.Value.Unknown32 = valuesDbStream.ReadUInt32();
                        node.Value.Value     = valuesDbStream.ReadStringDynamic();

                        node.Id = memory.ReadUInt32();

                        uint childCount = memory.ReadUInt32();
                        for (int j = 0; j < childCount; j++)
                        {
                            node.Childs.Add(memory.ReadUInt32());
                        }

                        uint attributesCount = memory.ReadUInt32();
                        for (int k = 0; k < attributesCount; k++)
                        {
                            Node.Attribute attribute = new Node.Attribute();

                            uint attributeNameOffset = memory.ReadUInt32();
                            valuesDbStream.Seek(attributeNameOffset, SeekOrigin.Begin);
                            attribute.Name.Type      = valuesDbStream.ReadUInt32();
                            attribute.Name.Unknown32 = valuesDbStream.ReadUInt32();
                            attribute.Name.Value     = valuesDbStream.ReadStringDynamic();

                            uint attributeValueOffset = memory.ReadUInt32();
                            valuesDbStream.Seek(attributeValueOffset, SeekOrigin.Begin);
                            attribute.Value.Type      = valuesDbStream.ReadUInt32();
                            attribute.Value.Unknown32 = valuesDbStream.ReadUInt32();
                            attribute.Value.Value     = valuesDbStream.ReadStringDynamic();

                            node.Attributes.Add(attribute);
                        }

                        xml._nodes.Add(node);
                    }
                }
            }
            return(xml);
        }
Example #2
0
        public new static Generic Deserialize(ResourceInfo resourceInfo, ushort version, uint slotRamRequired, uint slotVRamRequired, uint otherRamRequired, uint otherVRamRequired, ulong?nameHash, byte[] rawData, IMapper mapper)
        {
            Generic type = mapper.Map <Generic>(Resource.Deserialize(resourceInfo, version, slotRamRequired, slotVRamRequired, otherRamRequired, otherVRamRequired, nameHash, rawData, null));

            return(type);
        }