예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SplitIdent"/> class.
 /// </summary>
 /// <param name="si">The si.</param>
 /// <remarks></remarks>
 public SplitIdent(SplitIdent si)
 {
     inchunknumber         = si.inchunknumber;
     this.pointstotagname  = si.pointstotagname;
     this.pointstoTagIndex = si.pointstoTagIndex;
     this.pointstotagtype  = si.pointstotagtype;
     this.child            = si.child;
     this.description      = si.description;
     this.intag            = si.intag;
     this.intagname        = si.intagname;
     this.intagtype        = si.intagtype;
     this.mapOffset        = si.mapOffset;
     this.offset           = si.offset;
     this.parent           = si.parent;
     this.sibling          = si.sibling;
     this.type             = si.type;
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SplitIdent"/> class.
 /// </summary>
 /// <param name="si">The si.</param>
 /// <remarks></remarks>
 public SplitIdent(SplitIdent si)
 {
     inchunknumber = si.inchunknumber;
     this.pointstotagname = si.pointstotagname;
     this.pointstoTagIndex = si.pointstoTagIndex;
     this.pointstotagtype = si.pointstotagtype;
     this.child = si.child;
     this.description = si.description;
     this.intag = si.intag;
     this.intagname = si.intagname;
     this.intagtype = si.intagtype;
     this.mapOffset = si.mapOffset;
     this.offset = si.offset;
     this.parent = si.parent;
     this.sibling = si.sibling;
     this.type = si.type;
 }
예제 #3
0
        /// <summary>
        /// The cycle elements.
        /// </summary>
        /// <param name="reflex">The reflex.</param>
        /// <param name="elements">The elements.</param>
        /// <param name="meta">The meta.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="map">The map.</param>
        /// <param name="TagIndex">The TagIndex.</param>
        /// <param name="magic">The magic.</param>
        /// <remarks></remarks>
        private void CycleElements(
            ref SplitReflexive reflex, object[] elements, ref Meta meta, int offset, Map map, int TagIndex, int magic)
        {
            for (int x = 0; x < reflex.chunkcount; x++)
            {
                SplitReflexive chunkreflexive = new SplitReflexive();
                map.BR.BaseStream.Position = reflex.realtranslation + (x * reflex.chunksize);
                chunkreflexive.MS = new MemoryStream(reflex.chunksize);
                chunkreflexive.MS.Write(map.BR.ReadBytes(reflex.chunksize), 0, reflex.chunksize);
                chunkreflexive.chunksize = reflex.chunksize;
                chunkreflexive.splitReflexiveType = SplitReflexive.SplitReflexiveType.Chunk;

                reflex.Chunks.Add(chunkreflexive);

                for (int xx = 0; xx < elements.Length; xx++)
                {
                    IFPIO.BaseObject tempbase = (IFPIO.BaseObject)elements[xx];

                    switch (tempbase.ObjectType)
                    {
                        case IFPIO.ObjectEnum.Struct:
                            IFPIO.Reflexive tempreflex = (IFPIO.Reflexive)tempbase;

                            SplitReflexive r = new SplitReflexive();
                            map.BR.BaseStream.Position = offset + tempreflex.offset + (x * reflex.chunksize);
                            r.mapOffset = (int)map.BR.BaseStream.Position;
                            r.chunkcount = map.BR.ReadInt32();
                            if (r.chunkcount == 0)
                            {
                                continue;
                            }

                            r.chunksize = tempreflex.chunkSize;
                            r.translation = map.BR.ReadInt32() - magic;
                            r.pointstoTagIndex = map.Functions.ForMeta.FindMetaByOffset(r.translation);
                            r.description = tempreflex.name;
                            if (r.pointstoTagIndex == -1)
                            {
                                continue;
                            }

                            // r.parent = reflex.description;// parentname;
                            r.realtranslation = r.translation;
                            r.realTagIndex = r.pointstoTagIndex;

                            r.label = tempreflex.label;

                            r.pointstoTagIndex = meta.TagIndex;
                            r.pointstotagtype = meta.type;
                            r.pointstotagname = meta.name;
                            r.offset = tempreflex.offset;
                            r.intag = meta.TagIndex;
                            r.intagtype = meta.type;
                            r.intagname = meta.name;
                            r.translation -= map.MetaInfo.Offset[r.realTagIndex];

                            r.inchunknumber = x;
                            r.splitReflexiveType = SplitReflexive.SplitReflexiveType.Container;
                            r.Chunks = new List<SplitReflexive>();
                            CycleElements(
                                ref r, tempreflex.items, ref meta, r.realtranslation, map, r.pointstoTagIndex, magic);
                            reflex.Chunks[x].ChunkResources.Add(r);
                            meta.reflexivecount++;

                            break;
                        case IFPIO.ObjectEnum.Ident:
                            IFPIO.Ident tempident = (IFPIO.Ident)tempbase;
                            SplitIdent i = new SplitIdent();
                            map.BR.BaseStream.Position = offset + tempident.offset + (x * reflex.chunksize);
                            i.mapOffset = (int)map.BR.BaseStream.Position;
                            i.ident = map.BR.ReadInt32();
                            if (i.ident != -1)
                            {
                                try
                                {
                                    i.pointstoTagIndex = map.Functions.ForMeta.FindMetaByID(i.ident);
                                    i.pointstotagtype = map.MetaInfo.TagType[i.pointstoTagIndex];
                                    i.pointstotagname = map.FileNames.Name[i.pointstoTagIndex];
                                }
                                catch
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                continue;
                            }

                            i.mapOffset = offset + tempident.offset + (x * reflex.chunksize);

                            i.offset = tempident.offset;
                            i.inchunknumber = x;
                            i.intag = TagIndex;
                            i.intagtype = map.MetaInfo.TagType[i.intag];
                            i.intagname = map.FileNames.Name[i.intag];
                            i.description = tempident.name;

                            reflex.Chunks[x].ChunkResources.Add(i);
                            break;
                        case IFPIO.ObjectEnum.StringID:
                            IFPIO.SID tempstringid = (IFPIO.SID)tempbase;
                            SplitString si = new SplitString();
                            map.BR.BaseStream.Position = offset + tempstringid.offset + (x * reflex.chunksize);
                            si.mapOffset = (int)map.BR.BaseStream.Position;
                            si.id = map.BR.ReadUInt16();
                            if (si.id == 0 | si.id >= map.MapHeader.scriptReferenceCount)
                            {
                                continue;
                            }

                            map.BR.ReadByte();
                            int temp = map.BR.ReadByte();
                            if (temp != map.Strings.Length[si.id])
                            {
                                continue;
                            }

                            si.mapOffset = offset + tempstringid.offset + (x * reflex.chunksize);
                            si.offset = si.mapOffset - map.MetaInfo.Offset[TagIndex];

                            si.offset = tempstringid.offset;
                            si.inchunknumber = x;
                            si.name = map.Strings.Name[si.id];
                            si.intag = TagIndex;
                            si.intagtype = map.MetaInfo.TagType[si.intag];
                            si.intagname = map.FileNames.Name[si.intag];
                            si.description = tempstringid.name;
                            reflex.Chunks[x].ChunkResources.Add(si);
                            break;
                    }
                }
            }

            return;
        }
예제 #4
0
        /// <summary>
        /// The cycle elements.
        /// </summary>
        /// <param name="reflex">The reflex.</param>
        /// <param name="elements">The elements.</param>
        /// <param name="meta">The meta.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="map">The map.</param>
        /// <param name="TagIndex">The TagIndex.</param>
        /// <param name="magic">The magic.</param>
        /// <remarks></remarks>
        private void CycleElements(
            ref SplitReflexive reflex, object[] elements, ref Meta meta, int offset, Map map, int TagIndex, int magic)
        {
            for (int x = 0; x < reflex.chunkcount; x++)
            {
                SplitReflexive chunkreflexive = new SplitReflexive();
                map.BR.BaseStream.Position = reflex.realtranslation + (x * reflex.chunksize);
                chunkreflexive.MS          = new MemoryStream(reflex.chunksize);
                chunkreflexive.MS.Write(map.BR.ReadBytes(reflex.chunksize), 0, reflex.chunksize);
                chunkreflexive.chunksize          = reflex.chunksize;
                chunkreflexive.splitReflexiveType = SplitReflexive.SplitReflexiveType.Chunk;

                reflex.Chunks.Add(chunkreflexive);

                for (int xx = 0; xx < elements.Length; xx++)
                {
                    IFPIO.BaseObject tempbase = (IFPIO.BaseObject)elements[xx];

                    switch (tempbase.ObjectType)
                    {
                    case IFPIO.ObjectEnum.Struct:
                        IFPIO.Reflexive tempreflex = (IFPIO.Reflexive)tempbase;

                        SplitReflexive r = new SplitReflexive();
                        map.BR.BaseStream.Position = offset + tempreflex.offset + (x * reflex.chunksize);
                        r.mapOffset  = (int)map.BR.BaseStream.Position;
                        r.chunkcount = map.BR.ReadInt32();
                        if (r.chunkcount == 0)
                        {
                            continue;
                        }

                        r.chunksize        = tempreflex.chunkSize;
                        r.translation      = map.BR.ReadInt32() - magic;
                        r.pointstoTagIndex = map.Functions.ForMeta.FindMetaByOffset(r.translation);
                        r.description      = tempreflex.name;
                        if (r.pointstoTagIndex == -1)
                        {
                            continue;
                        }

                        // r.parent = reflex.description;// parentname;
                        r.realtranslation = r.translation;
                        r.realTagIndex    = r.pointstoTagIndex;

                        r.label = tempreflex.label;

                        r.pointstoTagIndex = meta.TagIndex;
                        r.pointstotagtype  = meta.type;
                        r.pointstotagname  = meta.name;
                        r.offset           = tempreflex.offset;
                        r.intag            = meta.TagIndex;
                        r.intagtype        = meta.type;
                        r.intagname        = meta.name;
                        r.translation     -= map.MetaInfo.Offset[r.realTagIndex];

                        r.inchunknumber      = x;
                        r.splitReflexiveType = SplitReflexive.SplitReflexiveType.Container;
                        r.Chunks             = new List <SplitReflexive>();
                        CycleElements(
                            ref r, tempreflex.items, ref meta, r.realtranslation, map, r.pointstoTagIndex, magic);
                        reflex.Chunks[x].ChunkResources.Add(r);
                        meta.reflexivecount++;

                        break;

                    case IFPIO.ObjectEnum.Ident:
                        IFPIO.Ident tempident = (IFPIO.Ident)tempbase;
                        SplitIdent  i         = new SplitIdent();
                        map.BR.BaseStream.Position = offset + tempident.offset + (x * reflex.chunksize);
                        i.mapOffset = (int)map.BR.BaseStream.Position;
                        i.ident     = map.BR.ReadInt32();
                        if (i.ident != -1)
                        {
                            try
                            {
                                i.pointstoTagIndex = map.Functions.ForMeta.FindMetaByID(i.ident);
                                i.pointstotagtype  = map.MetaInfo.TagType[i.pointstoTagIndex];
                                i.pointstotagname  = map.FileNames.Name[i.pointstoTagIndex];
                            }
                            catch
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }

                        i.mapOffset = offset + tempident.offset + (x * reflex.chunksize);

                        i.offset        = tempident.offset;
                        i.inchunknumber = x;
                        i.intag         = TagIndex;
                        i.intagtype     = map.MetaInfo.TagType[i.intag];
                        i.intagname     = map.FileNames.Name[i.intag];
                        i.description   = tempident.name;

                        reflex.Chunks[x].ChunkResources.Add(i);
                        break;

                    case IFPIO.ObjectEnum.StringID:
                        IFPIO.SID   tempstringid = (IFPIO.SID)tempbase;
                        SplitString si           = new SplitString();
                        map.BR.BaseStream.Position = offset + tempstringid.offset + (x * reflex.chunksize);
                        si.mapOffset = (int)map.BR.BaseStream.Position;
                        si.id        = map.BR.ReadUInt16();
                        if (si.id == 0 | si.id >= map.MapHeader.scriptReferenceCount)
                        {
                            continue;
                        }

                        map.BR.ReadByte();
                        int temp = map.BR.ReadByte();
                        if (temp != map.Strings.Length[si.id])
                        {
                            continue;
                        }

                        si.mapOffset = offset + tempstringid.offset + (x * reflex.chunksize);
                        si.offset    = si.mapOffset - map.MetaInfo.Offset[TagIndex];

                        si.offset        = tempstringid.offset;
                        si.inchunknumber = x;
                        si.name          = map.Strings.Name[si.id];
                        si.intag         = TagIndex;
                        si.intagtype     = map.MetaInfo.TagType[si.intag];
                        si.intagname     = map.FileNames.Name[si.intag];
                        si.description   = tempstringid.name;
                        reflex.Chunks[x].ChunkResources.Add(si);
                        break;
                    }
                }
            }

            return;
        }