Beispiel #1
0
        void MergeNodes()
        {
            NodePairs nodePairs = new NodePairs();

            nodePairs.LoadPrimaryFileNodes(primaryFile.chunks);
            nodePairs.LoadSecondaryFileNodes(secondaryFile.chunks);
            nodePairs.MergeNodes();
            for (int i = 0; i < primaryFile.chunkCount; i++)
            {
                if (primaryFile.chunks[i].type == 0x0000100B)
                {
                    Chunk_Node_824 primaryFileNode     = new Chunk_Node_824(primaryFile.chunks[i].content);
                    string         primaryFileNodeName = Encoding.UTF8.GetString(primaryFileNode.name);
                    Chunk_Node_824 mergedNode          = nodePairs.GetMergedNodeByName(primaryFileNodeName);
                    if (mergedNode != null)
                    {
                        mergedNode.Serialize();
                        primaryFile.chunks[i].content = mergedNode.serialized;
                    }
                }
            }
            for (int i = 0; i < nodePairs.nodePairs.Count; i++)
            {
                NodePair pair = nodePairs.nodePairs[i];
                for (int j = 0; j < secondaryFile.chunks.Count(); j++)
                {
                    if (secondaryFile.chunks[j].chunkId == pair.secondaryFileNode.header.chunkId)
                    {
                        //change to unsupported type, not removing to prevent destorying order issues
                        secondaryFile.chunks[j].type = 0x00006666;
                    }
                }
            }
        }
Beispiel #2
0
        public void MergeNodes()
        {
            mergedNodes = new List <Chunk_Node_824>();
            nodePairs   = new List <NodePair>();
            int pairsFound = 0;

            for (int i = 0; i < primaryFileNodes.Count; i++)
            {
                string         primaryFileNodeName = Encoding.UTF8.GetString(primaryFileNodes[i].name);
                Chunk_Node_824 secondaryFileNode   = GetSecondaryFileNodeByName(primaryFileNodeName);
                if (secondaryFileNode != null)
                {
                    pairsFound++;
                    Chunk_Node_824 mergedNode = primaryFileNodes[i];
                    mergedNode.objectID = secondaryFileNode.objectID;
                    mergedNodes.Add(mergedNode);

                    NodePair nodePair = new NodePair(primaryFileNodes[i], secondaryFileNode);
                    nodePairs.Add(nodePair);
                }
            }
            if (pairsFound == 0)
            {
                Console.WriteLine("Node Pairs Not Found");
            }
        }