Exemplo n.º 1
0
        public void SerializeLoad(FAssetRegistryArchive Ar, Func <int, FDependsNode?> GetNodeFromSerializeIndex)
        {
            Identifier = new FAssetIdentifier(Ar);

            void ReadDependencies(ref List <FDependsNode> dependencies, ref BitArray outFlagBits, int flagSetWidth)
            {
                var      numFlagBits         = 0;
                BitArray inFlagBits          = null;
                var      sortIndexes         = new List <int>();
                var      pointerDependencies = new List <FDependsNode>();

                var inDependencies  = Ar.ReadArray <int>();
                var numDependencies = inDependencies.Length;

                if (outFlagBits != null)
                {
                    numFlagBits = flagSetWidth * numDependencies;
                    var numFlagWords = (numFlagBits + 32u - 1u) / 32u;
                    inFlagBits = new BitArray(Ar.ReadBytes(Convert.ToInt32(numFlagWords)));
                }

                foreach (var serializeIndex in inDependencies)
                {
                    var dependsNode = GetNodeFromSerializeIndex(serializeIndex);
                    if (dependsNode == null)
                    {
                        throw new ParserException($"Index {serializeIndex} doesn't exist in 'PreallocatedDependsNodeDataBuffers'");
                    }
                    pointerDependencies.Add(dependsNode);
                }

                for (var i = 0; i < numDependencies; i++)
                {
                    sortIndexes.Add(i);
                }

                dependencies = new List <FDependsNode>(numDependencies);
                foreach (var index in sortIndexes)
                {
                    dependencies.Add(pointerDependencies[index]);
                }

                if (outFlagBits != null)
                {
                    outFlagBits = new BitArray(numFlagBits);
                    for (var i = 0; i < numDependencies; i++)
                    {
                        var readIndex = sortIndexes[i];
                        var start     = i * flagSetWidth;
                        for (var j = 0; j < start + flagSetWidth; j++) // oof
                        {
                            outFlagBits.Set(j, inFlagBits.Get(readIndex * flagSetWidth + j));
                        }
                    }
                }
            }

            BitArray myNameIsNull = null;

            ReadDependencies(ref PackageDependencies, ref PackageFlags, _packageFlagSetWidth);
            ReadDependencies(ref NameDependencies, ref myNameIsNull, 0);
            ReadDependencies(ref ManageDependencies, ref ManageFlags, _manageFlagSetWidth);
            ReadDependencies(ref Referencers, ref myNameIsNull, 0);
        }
Exemplo n.º 2
0
 public FMD5Hash(FAssetRegistryArchive Ar)
 {
     Hash = Ar.Read <uint>() != 0 ? Ar.ReadBytes(16) : null;
 }