Beispiel #1
0
        public void SerializeLoad_BeforeFlags(FAssetRegistryArchive Ar, FAssetRegistryVersionType version, FDependsNode[] a)
        {
            Identifier = new FAssetIdentifier(Ar);

            var numHard        = Ar.Read <int>();
            var numSoft        = Ar.Read <int>();
            var numName        = Ar.Read <int>();
            var numSoftManage  = Ar.Read <int>();
            var numHardManage  = version >= FAssetRegistryVersionType.AddedHardManage ? Ar.Read <int>() : 0;
            var numReferencers = Ar.Read <int>();

            PackageDependencies = new List <FDependsNode>(numHard + numSoft);
            NameDependencies    = new List <FDependsNode>(numName);
            ManageDependencies  = new List <FDependsNode>(numSoftManage + numHardManage);
            Referencers         = new List <FDependsNode>(numReferencers);

            void SerializeNodeArray(int num, ref List <FDependsNode> dependencies)
            {
                for (var i = 0; i < num; i++)
                {
                    var index = Ar.Read <int>();
                    if (index < 0 || index >= a.Length)
                    {
                        throw new ParserException("");
                    }
                    var dependsNodes = a[index];
                    dependencies.Add(dependsNodes);
                }
            }

            SerializeNodeArray(numHard, ref PackageDependencies);
            SerializeNodeArray(numSoft, ref PackageDependencies);
            SerializeNodeArray(numName, ref NameDependencies);
            SerializeNodeArray(numSoftManage, ref ManageDependencies);
            SerializeNodeArray(numHardManage, ref ManageDependencies);
            SerializeNodeArray(numReferencers, ref Referencers);
        }
Beispiel #2
0
        public void SerializeLoad_BeforeFlags(FAssetRegistryArchive Ar, FAssetRegistryVersionType version, FDependsNode[] preallocatedDependsNodeDataBuffer)
        {
            Identifier = new FAssetIdentifier(Ar);

            var numHard        = Ar.Read <int>();
            var numSoft        = Ar.Read <int>();
            var numName        = Ar.Read <int>();
            var numSoftManage  = Ar.Read <int>();
            var numHardManage  = version >= FAssetRegistryVersionType.AddedHardManage ? Ar.Read <int>() : 0;
            var numReferencers = Ar.Read <int>();

            PackageDependencies = new List <FDependsNode>(numHard + numSoft);
            NameDependencies    = new List <FDependsNode>(numName);
            ManageDependencies  = new List <FDependsNode>(numSoftManage + numHardManage);
            Referencers         = new List <FDependsNode>(numReferencers);

            void SerializeNodeArray(int num, ref List <FDependsNode> outNodes)
            {
                for (var dependencyIndex = 0; dependencyIndex < num; ++dependencyIndex)
                {
                    var index = Ar.Read <int>();
                    if (index < 0 || index >= preallocatedDependsNodeDataBuffer.Length)
                    {
                        throw new ParserException($"Index {index} doesn't exist in 'PreallocatedDependsNodeDataBuffers'");
                    }
                    var dependsNode = preallocatedDependsNodeDataBuffer[index];
                    outNodes.Add(dependsNode);
                }
            }

            SerializeNodeArray(numHard, ref PackageDependencies);
            SerializeNodeArray(numSoft, ref PackageDependencies);
            SerializeNodeArray(numName, ref NameDependencies);
            SerializeNodeArray(numSoftManage, ref ManageDependencies);
            SerializeNodeArray(numHardManage, ref ManageDependencies);
            SerializeNodeArray(numReferencers, ref Referencers);
        }
Beispiel #3
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);
        }
Beispiel #4
0
        public void SerializeLoad(FAssetRegistryArchive Ar, FDependsNode[] preallocatedDependsNodeDataBuffer)
        {
            Identifier = new FAssetIdentifier(Ar);

            void ReadDependencies(ref List <FDependsNode> outDependencies, ref BitArray?outFlagBits, int flagSetWidth)
            {
                var sortIndexes         = new List <int>();
                var pointerDependencies = new List <FDependsNode>();

                var inDependencies  = Ar.ReadArray <int>();
                var numDependencies = inDependencies.Length;
                var numFlagBits     = flagSetWidth * numDependencies;
                var numFlagWords    = numFlagBits.DivideAndRoundUp(32);
                var inFlagBits      = numFlagWords != 0 ? new BitArray(Ar.ReadArray <int>(numFlagWords)) : new BitArray(0);

                foreach (var serializeIndex in inDependencies)
                {
                    if (serializeIndex < 0 || preallocatedDependsNodeDataBuffer.Length <= serializeIndex)
                    {
                        throw new ParserException($"Index {serializeIndex} doesn't exist in 'PreallocatedDependsNodeDataBuffers'");
                    }
                    var dependsNode = preallocatedDependsNodeDataBuffer[serializeIndex];
                    pointerDependencies.Add(dependsNode);
                }

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

                sortIndexes.Sort((a, b) => pointerDependencies[a]._index - pointerDependencies[b]._index);

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

                outFlagBits = new BitArray(numFlagBits);
                for (var writeIndex = 0; writeIndex < numDependencies; writeIndex++)
                {
                    var readIndex = sortIndexes[writeIndex];
                    outFlagBits.SetRangeFromRange(writeIndex * flagSetWidth, flagSetWidth, inFlagBits, readIndex * flagSetWidth);
                }
            }

            void ReadDependenciesNoFlags(ref List <FDependsNode> outDependencies)
            {
                var sortIndexes         = new List <int>();
                var pointerDependencies = new List <FDependsNode>();

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

                foreach (var serializeIndex in inDependencies)
                {
                    if (serializeIndex < 0 || preallocatedDependsNodeDataBuffer.Length <= serializeIndex)
                    {
                        throw new ParserException($"Index {serializeIndex} doesn't exist in 'PreallocatedDependsNodeDataBuffers'");
                    }
                    var dependsNode = preallocatedDependsNodeDataBuffer[serializeIndex];
                    pointerDependencies.Add(dependsNode);
                }

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

                sortIndexes.Sort((a, b) => pointerDependencies[a]._index - pointerDependencies[b]._index);

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

            ReadDependencies(ref PackageDependencies, ref PackageFlags, PackageFlagSetWidth);
            ReadDependenciesNoFlags(ref NameDependencies);
            ReadDependencies(ref ManageDependencies, ref ManageFlags, ManageFlagSetWidth);
            ReadDependenciesNoFlags(ref Referencers);
        }