Exemplo n.º 1
0
        private static void TraverseMap(XmlNode node, PsoBuilder pb, PsoStructureEntryInfo entry, PsoStructureInfo infos, byte[] data, PsoArrayResults arrayResults)
        {
            var mapidx1     = entry.ReferenceKey & 0x0000FFFF;
            var mapidx2     = (entry.ReferenceKey >> 16) & 0x0000FFFF;
            var mapreftype1 = infos.Entries[mapidx2];
            var mapreftype2 = infos.Entries[mapidx1];

            if (mapreftype2.ReferenceKey != 0)
            {
            }

            var xStruct = pb.AddMapNodeStructureInfo((MetaName)mapreftype2.ReferenceKey);
            var xName   = xStruct.IndexInfo.NameHash;
            var kEntry  = xStruct?.FindEntry(MetaName.Key);
            var iEntry  = xStruct?.FindEntry(MetaName.Item);

            if (kEntry.Type != PsoDataType.String)
            {
            }



            List <byte[]> nodesData = new List <byte[]>();

            foreach (XmlNode cnode in node.ChildNodes)
            {
                var kattr = cnode.Attributes["key"].Value;
                var tattr = cnode.Attributes["type"].Value;//CW invention for convenience..!
                var khash = (MetaName)(uint)GetHash(kattr);
                var thash = (MetaName)(uint)GetHash(tattr);

                byte[] strucBytes = Traverse(cnode, pb, thash);
                byte[] nodeBytes  = new byte[xStruct.StructureLength];

                TraverseStringRaw(kattr, pb, kEntry, nodeBytes); //write the key

                if (xName != (MetaName)MetaTypeName.ARRAYINFO)   // (mapreftype2.ReferenceKey != 0)
                {
                    //value struct embedded in ARRAYINFO node
                    Buffer.BlockCopy(strucBytes, 0, nodeBytes, iEntry.DataOffset, strucBytes.Length);
                }
                else
                {
                    //normal ARRAYINFO with pointer value
                    var itemptr = pb.AddItemPtr(thash, strucBytes);
                    itemptr.SwapEnd(); //big schmigg
                    var ptrbytes = MetaTypes.ConvertToBytes(itemptr);
                    Buffer.BlockCopy(ptrbytes, 0, nodeBytes, iEntry.DataOffset, ptrbytes.Length);
                }

                nodesData.Add(nodeBytes);
            }



            Write(0x1000000, data, entry.DataOffset);
            Write(0, data, entry.DataOffset + 4);

            arrayResults.Structures[entry.DataOffset + 8] = pb.AddItemArrayPtr(xName, nodesData.ToArray());  //pb.AddPointerArray(nodeptrs);
        }
Exemplo n.º 2
0
        private static Array_Structure TraverseArrayStructure(XmlNode node, PsoBuilder pb, MetaName type)
        {
            var bytes = TraverseArrayStructureRaw(node, pb, type);

            return(pb.AddItemArrayPtr(type, bytes));
        }