コード例 #1
0
        public void DoProcessStruct(ref TSFReader sr, ref FileStream fs, ref MemoryStream FO, uint Count, ushort uName, ref StructInfo Info, ref string[] TagList, ref string[] StringList)
        {
            long MapPosSave;

            TabReplace += (char)TabByte;
            //string InLine;// = sr.ReadLine();
            //InLine = sr.ReadLine();
            //string[] CMD = LastInline.Replace(TabReplace,"").ToLower().Trim().Split(new char[]{' '},256);
            Name    = sr.GetUName();
            Size    = sr.GetSOC();
            TagBuff = new byte[Size * Count];
            fs.Read(TagBuff, 0, TagBuff.Length);
            //FixPos(ref fs);
            long StructPosition = FO.Position;

            FO.Write(TagBuff, 0, TagBuff.Length);
            uint StartOfStruct = sr.Position;
            uint sc            = 0;
            bool ExitStruct    = false;

            bool         fuckThisShitHack = false;
            BinaryReader br = new BinaryReader(Info.BitmapsFile);
            BinaryWriter bw = new BinaryWriter(FO);

            do
            {
                do
                {
                    //InLine = "TEST";// sr.Read();
                    //sr.Read//sr.cTSF[sr.Position].CMD;   //CMD = InLine.Replace(TabReplace,"").ToLower().Trim().Split(new char[]{' '},256);
                    sr.Read();
                    switch (sr.GetCMD())
                    {
                    case TSFReader.TSFStruct:                            // 0xA0: //Struct
                        #region Structure
                        //if(fuckThisShitHack)
                        //  break;

                        uint ChildCount = GetUInt(TagBuff, (uint)(sr.GetOIP()) + (sc * Size));
                        if (sr.GetUName() == 0xffff)
                        {
                            ChildCount = 0;
                            PutUInt(ref TagBuff, (uint)(sr.GetOIP()) + (sc * Size), 0);
                        }
                        if (ChildCount != 0)
                        {
                            uint   CSOffset = GetUInt(TagBuff, (uint)(sr.GetOIP()) + 4 + (sc * Size)) - Info.TagMagic;
                            Struct Child    = new Struct();
                            fs.Seek((long)CSOffset, SeekOrigin.Begin);
                            PutUInt(ref TagBuff, (uint)(sr.GetOIP() + 4 + (sc * Size)), (uint)FO.Position - Info.TagHeaderSize);
                            Child.DoProcessStruct(ref sr, ref fs, ref FO, ChildCount, sr.GetUName(), ref Info, ref TagList, ref StringList);
                        }
                        else
                        {
                            sr.SeekAheadTo(0xA7, sr.GetUName());
                            //sr.Seek(sr.Position + 1);
                        }
                        break;

                        #endregion
                    case TSFReader.TSFBSPTagRef:                         // 0xA8: //BSPTagRef
                    case TSFReader.TSFTagRef:                            // 0xA1: //TagRef
                        #region TagRef
                        uint   StringOffset = GetUInt(TagBuff, (uint)(sr.GetOIP() + (sc * Size)) + 0x04) - Info.MapMagic;
                        ushort TagIndex     = GetUShort(TagBuff, (uint)(sr.GetOIP() + (sc * Size)) + 0x0C);
                        if (GetUInt(TagBuff, (uint)(sr.GetOIP() + (sc * Size)) + 0x04) != 0)
                        {
                            //Info.IndexItems[TagIndex].tagClass[0].Char.CopyTo(TagBuff,(long)(Val(CMD[1]) + (sc * Size)));

                            PutUInt(ref TagBuff, (sr.GetOIP() + (sc * Size)), Info.IndexItems[TagIndex].Type1);                          //.fileData.tagClass[0].UInt);
                            SwapInt(ref TagBuff, (sr.GetOIP() + (sc * Size)));
                            MapPosSave = fs.Position;
                            fs.Seek((long)StringOffset, SeekOrigin.Begin);
                            byte[] tmpstr = new byte[256];
                            fs.Read(tmpstr, 0, tmpstr.Length);
                            fs.Seek(MapPosSave, SeekOrigin.Begin);
                            uint size = 0;
                            do
                            {
                                size += 1;
                            }while (tmpstr[size] != 0);
                            byte[] OutString = new byte[size + 1];
                            uint   count     = 0;
                            do
                            {
                                OutString[count] = tmpstr[count];
                                count           += 1;
                            }while (count != size);
                            PutUInt(ref TagBuff, (uint)((sr.GetOIP() + (sc * Size)) + 0x04), (uint)FO.Position - Info.TagHeaderSize);
                            PutUInt(ref TagBuff, (uint)((sr.GetOIP() + (sc * Size)) + 0x08), (uint)OutString.Length - 1);
                            PutUInt(ref TagBuff, (uint)((sr.GetOIP() + (sc * Size)) + 0x0C), (uint)0xffffffff);
                            FO.Write(OutString, 0, OutString.Length);
                        }
                        break;

                        #endregion
                    case TSFReader.TSFInternalRaw: // 0xA3: //InternalRaw
                        #region InternalRaw
                        uint RawSize   = GetUInt(TagBuff, (uint)(sr.GetOIP() + (sc * Size)));
                        uint RawOffset = GetUInt(TagBuff, (uint)(sr.GetOIP() + 0x0c + (sc * Size))) - Info.TagMagic;
                        fs.Seek((long)RawOffset, SeekOrigin.Begin);
                        byte[] tmp = new byte[RawSize];
                        //PutUInt(ref TagBuff,(uint)(Val(CMD[2]) + (sc * Size)),(uint)(FO.Position));
                        fs.Read(tmp, 0, tmp.Length);
                        FixPos(ref fs);
                        FO.Write(tmp, 0, tmp.Length);
                        tmp = null;
                        break;

                        #endregion
                    case TSFReader.TSFBitmapRaw: // 0xA9: //Bitmapraw
                        #region BitmapRaw
                        uint   BitMapStructCount;
                        uint   BitMapStructOffset;
                        uint   TiffSize = 0;
                        byte[] tmpBMS;
                        long   sv = 0;

                        #region grenbitmap
                        if (Info.IndexItems[Info.CurrentIndex].RawTypeID != 0)
                        {
                            //Trace.WriteLine("extern ce bitmap:  " + Prometheus.Core.Compiler.Decompiler.CurrentTagName);
                            CeBitmapIndex.Read(br);
                            //meta header for bitmaps for extern ce files is actually in the bitmaps.map file
                            //so we need to get the header from there.

                            //fix the index offset, it doesn't use magic
                            int bitmap_hdr_offset = (int)CeBitmapIndex.Locator[Info.IndexItems[Info.CurrentIndex].MetaOffset + Info.TagMagic].offset;
                            Info.BitmapsFile.Position = bitmap_hdr_offset;
                            TagBuff = br.ReadBytes(TagBuff.Length);
                            PutUInt(ref TagBuff, 0x54, 0);
                            //get bitmap header(s) offset/count
                            BitMapStructCount  = GetUInt(TagBuff, 0x60);
                            BitMapStructOffset = GetUInt(TagBuff, 0x64);

                            //copy bitmap header(s) from CE shared to output tag
                            br.BaseStream.Position += (BitMapStructOffset - Size);
                            tmpBMS = new byte[BitMapStructCount * 0x30];
                            tmpBMS = br.ReadBytes(tmpBMS.Length);

                            GetUInt(TagBuff, 0x1C, ref TiffSize);

                            bw.BaseStream.Position = 0;
                            bw.Write(TagBuff);
                            bw.BaseStream.Position += (BitMapStructOffset - Size);
                            //bw.Write(tmpBMS);
                            //FO.Write(tmpBMS, (int)FO.Position, tmpBMS.Length);

                            //skip over TIFF area in output tag
                            GetUInt(TagBuff, 0x1C, ref TiffSize);
                            byte[] TiffBuffer = new byte[TiffSize];
                            bw.Write(TiffBuffer);
                            //FO.Write(TiffBuffer,0,TiffBuffer.Length);

                            //copy bitmap data from CE shared to output tag
                            uint accum = (uint)bw.BaseStream.Position;
                            for (int i = 0; i < BitMapStructCount; i++)
                            {
                                uint BitMapDataOffset = GetUInt(tmpBMS, (uint)(0x18 + (i * 0x30)));
                                uint BitMapDataSize   = GetUInt(tmpBMS, (uint)(0x1C + (i * 0x30)));
                                uint CurrentSize      = GetUInt(TagBuff, (uint)0x30);
                                PutUInt(ref TagBuff, 0x30, CurrentSize + BitMapDataSize);
                                byte[] tmpBitmapData = new byte[BitMapDataSize];
                                tmpBitmapData = br.ReadBytes((int)BitMapDataSize);
                                bw.Write(tmpBitmapData);
                                PutUInt(ref tmpBMS, (uint)(0x18 + (i * 0x30)), accum);
                                accum += BitMapDataSize;
                            }

                            //go to the image header offsets
                            //bw.BaseStream.Position = TagBuff.Length + TiffSize +
                            bw.BaseStream.Position += 0x40;
                            bw.Write(tmpBMS);
                            long eof = bw.BaseStream.Position;

                            //fix the offsets
                            bw.BaseStream.Position = 0x74;
                            bw.Write(accum);
                            bw.BaseStream.Position = eof;

                            fuckThisShitHack = true;
                            //FO.Write(tmpBitmapData, (int)FO.Position, tmpBitmapData.Length);
                        }
                        else
                        {
                            GetUInt(TagBuff, 0x1C, ref TiffSize);
                            byte[] TiffBuffer = new byte[TiffSize];
                            FO.Write(TiffBuffer, 0, TiffBuffer.Length);
                            BitMapStructCount  = GetUInt(TagBuff, 0x60);
                            BitMapStructOffset = GetUInt(TagBuff, 0x64) - Info.MapMagic;
                            sv = fs.Position;
                            fs.Seek((long)BitMapStructOffset, SeekOrigin.Begin);
                            tmpBMS = new byte[BitMapStructCount * 0x30];
                            fs.Read(tmpBMS, 0, tmpBMS.Length);

                            for (int i = 0; i < BitMapStructCount; i++)
                            {
                                uint BitMapDataOffset = GetUInt(tmpBMS, (uint)(0x18 + (i * 0x30)));
                                uint BitMapDataSize   = GetUInt(tmpBMS, (uint)(0x1C + (i * 0x30)));
                                uint CurrentSize      = GetUInt(TagBuff, (uint)0x30);
                                PutUInt(ref TagBuff, 0x30, CurrentSize + BitMapDataSize);
                                byte[] tmpBitmapData = new byte[BitMapDataSize];
                                switch (Info.MapVersion)
                                {
                                case 5:
                                    fs.Seek((long)BitMapDataOffset, SeekOrigin.Begin);
                                    fs.Read(tmpBitmapData, 0, tmpBitmapData.Length);
                                    FO.Write(tmpBitmapData, 0, tmpBitmapData.Length);
                                    break;

                                case 7:
                                    Info.BitmapsFile.Seek((long)BitMapDataOffset, SeekOrigin.Begin);
                                    Info.BitmapsFile.Read(tmpBitmapData, 0, tmpBitmapData.Length);
                                    FO.Write(tmpBitmapData, 0, tmpBitmapData.Length);
                                    break;

                                case 0x261:
                                    if (Info.IndexItems[Info.CurrentIndex].RawTypeID == 0)
                                    {
                                        fs.Seek((long)BitMapDataOffset, SeekOrigin.Begin);
                                        fs.Read(tmpBitmapData, 0, tmpBitmapData.Length);
                                        FO.Write(tmpBitmapData, 0, tmpBitmapData.Length);
                                    }
                                    else
                                    {
                                        //CE_Bitmap_File CEBF = new CE_Bitmap_File();
                                        //CEBF.HDR.Read(ref Info.BitmapsFile);
                                        //uint Current_offset = CEBF.Locator[Info.IndexItems[Info.CurrentIndex].MetaOffset].offset;
                                    }
                                    break;
                                }
                            }
                            fs.Seek(sv, SeekOrigin.Begin);
                        }
                        #endregion

                        break;

                        #endregion
                    case TSFReader.TSFSoundData:                         // 0xAA: //SoundData
                        #region SoundData
                        uint   DataSizeOffset   = sr.GetOIP();
                        uint   NormalDataOffset = sr.GetUName();
                        uint   SndDataSize      = GetUInt(TagBuff, (uint)(DataSizeOffset + (sc * Size)));
                        uint   TrueOffset       = GetUInt(TagBuff, (uint)(NormalDataOffset + 4 + (sc * Size)));
                        byte[] SoundData        = new byte[SndDataSize];
                        switch (Info.MapVersion)
                        {
                        case 5:
                            long fssv = fs.Position;
                            fs.Seek((long)TrueOffset, SeekOrigin.Begin);
                            fs.Read(SoundData, 0, SoundData.Length);
                            fs.Seek(fssv, SeekOrigin.Begin);
                            FO.Write(SoundData, 0, SoundData.Length);
                            break;

                        case 7:
                            Info.SoundsFile.Seek(TrueOffset, System.IO.SeekOrigin.Begin);
                            Info.SoundsFile.Read(SoundData, 0, SoundData.Length);
                            FO.Write(SoundData, 0, SoundData.Length);
                            SoundData = null;
                            break;
                        }
                        break;

                        #endregion
                    case TSFReader.TSFRawXModelData:                     // 0xB0: //XModelData
                        #region XModelData
                        uint   XTrueVerticesSize   = (GetUInt(TagBuff, 88 + (sc * Size))) * 32;
                        uint   XTrueIndicesSize    = (((GetUInt(TagBuff, 72 + (sc * Size))) / 3) + 1) * 6;
                        uint   XNewIndicesDataSize = (GetUInt(TagBuff, 72 + (sc * Size)) / 3) + 1;
                        uint   XTrueVerticesOffset = GetUInt(TagBuff, 100 + (sc * Size)) - Info.MapMagic;
                        uint   XSaveMapFilePos     = (uint)fs.Position;                  //MapFile.Position;
                        byte[] XModelHeader        = new byte[16];
                        fs.Seek((long)XTrueVerticesOffset, System.IO.SeekOrigin.Begin);
                        fs.Read(XModelHeader, 0, XModelHeader.Length);
                        fs.Seek(XSaveMapFilePos, System.IO.SeekOrigin.Begin);
                        XTrueVerticesOffset = GetUInt(XModelHeader, 4) - Info.MapMagic;

                        XSaveMapFilePos = (uint)fs.Position;
                        byte[] RawXModelBuffer = new byte[XTrueVerticesSize];
                        fs.Seek((long)XTrueVerticesOffset, System.IO.SeekOrigin.Begin);
                        fs.Read(RawXModelBuffer, 0, (int)XTrueVerticesSize);
                        FO.Write(RawXModelBuffer, 0, (int)XTrueVerticesSize);

                        byte[] XTestBuffer        = new byte[6];
                        uint   XTrueIndicesOffset = GetUInt(TagBuff, 80 + (sc * Size)) - Info.MapMagic;
                        RawXModelBuffer = new byte[XTrueIndicesSize];
                        fs.Seek((long)XTrueIndicesOffset, System.IO.SeekOrigin.Begin);
                        fs.Read(XModelHeader, 0, XModelHeader.Length);
                        XTrueIndicesOffset = GetUInt(XModelHeader, 0x04) - Info.MapMagic;
                        fs.Seek((long)XTrueIndicesOffset, System.IO.SeekOrigin.Begin);
                        fs.Read(RawXModelBuffer, 0, RawXModelBuffer.Length);
                        FO.Write(RawXModelBuffer, 0, RawXModelBuffer.Length);
                        fs.Read(XTestBuffer, 0, 6);
                        if (XTestBuffer[4] == 0xff)
                        {
                            FO.Write(XTestBuffer, 0, 6);
                            XTrueIndicesSize += 6;
                        }
                        break;

                        #endregion
                    case TSFReader.TSFModelData:                         // 0xAB: //Modeldata
                        #region ModelData
                        long SaveMapFilePos     = (uint)fs.Position;
                        uint TrueVerticesSize   = (GetUInt(TagBuff, (uint)(88 + (sc * Size)))) * 68;
                        uint TrueIndicesSize    = (((GetUInt(TagBuff, (uint)(72 + (sc * Size)))) / 3) + 1) * 6;
                        uint NewIndicesDataSize = (GetUInt(TagBuff, (uint)(72 + (sc * Size))) / 3) + 1;
                        uint TrueVerticesOffset = GetUInt(TagBuff, (uint)(100 + (sc * Size))) + Info.VerticesOffset;                              //80
                        uint TrueIndicesOffset  = GetUInt(TagBuff, (uint)(80 + (sc * Size))) + Info.IndicesOffset;                                //100
                        //PutUInt(ref TagBuff,GetUInt(TagBuff,(uint)(88 + (i * Size))),(uint)(32 +(i * Size)));
                        //PutUInt(ref TagBuff,NewIndicesDataSize,(uint)(56 + (i * Size)));
                        uint   CurrentStructSize = (uint)TagBuff.Length;
                        byte[] RawModelBuffer    = new byte[TrueVerticesSize];
                        fs.Seek((long)TrueVerticesOffset, System.IO.SeekOrigin.Begin);
                        fs.Read(RawModelBuffer, 0, RawModelBuffer.Length);
                        FO.Write(RawModelBuffer, 0, RawModelBuffer.Length);

                        RawModelBuffer = new byte[TrueIndicesSize];
                        fs.Seek((long)TrueIndicesOffset, System.IO.SeekOrigin.Begin);
                        fs.Read(RawModelBuffer, 0, RawModelBuffer.Length);
                        FO.Write(RawModelBuffer, 0, RawModelBuffer.Length);
                        fs.Seek(fs.Position, System.IO.SeekOrigin.Begin);
                        byte[] TestBuffer = new byte[6];
                        fs.Read(TestBuffer, 0, 6);
                        if (TestBuffer[4] == 0xff)
                        {
                            //PutUInt(StructBuffer,GetUInt(StructBuffer,56 + (StructSize * cc)) + 1,56 + (StructSize * cc));
                            FO.Write(TestBuffer, 0, TestBuffer.Length);
                            TrueIndicesSize += 6;
                        }
                        fs.Seek(SaveMapFilePos, SeekOrigin.Begin);
                        break;

                        #endregion
                    case TSFReader.TSFBSPModel:                     // 0xAC: //BSPMODEL
                        #region BSPModel
                        uint VOOffset = 0xB4;
                        uint LOOffset = 0xC8;

                        s_TrueOffset VertsTrueOffset = new s_TrueOffset();
                        s_TrueOffset LMUVTrueOffset  = new s_TrueOffset();

                        VertsTrueOffset.Read(TagBuff, VOOffset + (sc * Size), Info.TagMagic, ref fs);
                        LMUVTrueOffset.Read(TagBuff, LOOffset + (sc * Size), Info.TagMagic, ref fs);

                        uint UnCompVertsSize = VertsTrueOffset.Count * 56;
                        uint CompVertsSize   = VertsTrueOffset.Count * 32;
                        uint UnCompLMUVSize  = LMUVTrueOffset.Count * 20;
                        uint CompLMUVSize    = LMUVTrueOffset.Count * 8;

                        byte[] ba_UnCompVerts = new byte[UnCompVertsSize];
                        byte[] ba_CompVerts   = new byte[CompVertsSize];
                        byte[] ba_UnCompLMUV  = new byte[UnCompLMUVSize];
                        byte[] ba_CompLMUV    = new byte[CompLMUVSize];

                        switch (Info.MapVersion)
                        {
                        case 5:
                            long Sav_F_Pos = fs.Position;
                            fs.Seek((long)VertsTrueOffset.TrueOffset, SeekOrigin.Begin);
                            fs.Read(ba_CompVerts, 0, ba_CompVerts.Length);
                            fs.Seek((long)LMUVTrueOffset.TrueOffset, SeekOrigin.Begin);
                            fs.Read(ba_CompLMUV, 0, ba_CompLMUV.Length);
                            fs.Seek(Sav_F_Pos, SeekOrigin.Begin);
                            break;

                        case 7:
                        case 0x261:
                            fs.Read(ba_UnCompVerts, 0, ba_UnCompVerts.Length);
                            fs.Read(ba_UnCompLMUV, 0, ba_UnCompLMUV.Length);
                            break;
                        }

                        cs_UnCompVerts[] UnCompVertsBuff = new cs_UnCompVerts[VertsTrueOffset.Count];
                        cs_CompVerts[]   CompVertsBuff   = new cs_CompVerts[VertsTrueOffset.Count];
                        cs_UnCompLMUV[]  UnCompLMUV      = new cs_UnCompLMUV[LMUVTrueOffset.Count];
                        cs_CompLMUV[]    CompLMUV        = new cs_CompLMUV[LMUVTrueOffset.Count];

                        for (int vl = 0; vl < VertsTrueOffset.Count; vl++)
                        {
                            CompVertsBuff[vl]   = new cs_CompVerts();
                            UnCompVertsBuff[vl] = new cs_UnCompVerts();
                            switch (Info.MapVersion)
                            {
                            case 5:
                                CompVertsBuff[vl].Read(ba_CompVerts, (uint)vl);
                                break;

                            case 7:
                            case 0x261:
                                UnCompVertsBuff[vl].Read(ba_UnCompVerts, (uint)vl);
                                break;
                            }
                        }
                        switch (Info.MapVersion)
                        {
                        case 5:
                            DeCompressVerts(CompVertsBuff, ref UnCompVertsBuff);
                            break;

                        case 7:
                        case 0x261:
                            CompressVerts(UnCompVertsBuff, ref CompVertsBuff);
                            break;
                        }
                        for (int i = 0; i < VertsTrueOffset.Count; i++)
                        {
                            switch (Info.MapVersion)
                            {
                            case 5:
                                UnCompVertsBuff[i].Write(ref ba_UnCompVerts, (uint)i);
                                break;

                            case 7:
                            case 0x261:
                                CompVertsBuff[i].Write(ref ba_CompVerts, (uint)i);
                                break;
                            }
                        }
                        for (int i = 0; i < LMUVTrueOffset.Count; i++)
                        {
                            CompLMUV[i]   = new cs_CompLMUV();
                            UnCompLMUV[i] = new cs_UnCompLMUV();
                            switch (Info.MapVersion)
                            {
                            case 5:
                                CompLMUV[i].Read(ba_CompLMUV, (uint)i);
                                break;

                            case 7:
                            case 0x261:
                                UnCompLMUV[i].Read(ba_UnCompLMUV, (uint)i);
                                break;
                            }
                        }
                        switch (Info.MapVersion)
                        {
                        case 5:
                            DeCompressLMUV(CompLMUV, ref UnCompLMUV);
                            break;

                        case 7:
                        case 0x261:
                            CompressLMUV(UnCompLMUV, ref CompLMUV);
                            break;
                        }
                        for (int i = 0; i < LMUVTrueOffset.Count; i++)
                        {
                            switch (Info.MapVersion)
                            {
                            case 5:
                                UnCompLMUV[i].Write(ref ba_UnCompLMUV, (uint)i);
                                break;

                            case 7:
                            case 0x261:
                                CompLMUV[i].Write(ref ba_CompLMUV, (uint)i);
                                break;
                            }
                        }
                        PutUInt(ref TagBuff, 0xd8 + (sc * Size), (uint)ba_UnCompVerts.Length);

                        FO.Write(ba_UnCompVerts, 0, ba_UnCompVerts.Length);
                        FO.Write(ba_UnCompLMUV, 0, ba_UnCompLMUV.Length);
                        FO.Write(ba_CompVerts, 0, ba_CompVerts.Length);
                        FO.Write(ba_CompLMUV, 0, ba_CompLMUV.Length);
                        break;

                        #endregion
                    case TSFReader.TSFResource:                     // 0xAD: //Resource
                        #region Resource
                        ushort BitmapSoundFlag = GetUShort(TagBuff, 0x00 + (sc * Size));
                        ushort Index           = GetUShort(TagBuff, 0x02 + (sc * Size));
                        ushort ID1             = GetUShort(TagBuff, 0x04 + (sc * Size));
                        ushort ID2             = GetUShort(TagBuff, 0x06 + (sc * Size));
                        MapPosSave = fs.Position;
                        uint Offset = Info.IndexItems[ID1].OffsetToString;                         ///  fileData.stringOffset.UInt - Info.MapMagic;
                        fs.Seek((long)Offset, SeekOrigin.Begin);
                        byte[] rscstr = new byte[256];
                        fs.Read(rscstr, 0, rscstr.Length);
                        fs.Seek(MapPosSave, SeekOrigin.Begin);
                        uint rscsize = 0;
                        do
                        {
                            rscsize += 1;
                        }while (rscstr[rscsize] != 0);
                        byte[] rscOutString = new byte[rscsize + 1];
                        uint   rsccount     = 0;
                        do
                        {
                            rscOutString[rsccount] = rscstr[rsccount];
                            rsccount += 1;
                        }while (rsccount != rscsize);
                        PutUShort(ref TagBuff, (uint)(0x06 + (sc * Size)), (ushort)(rscOutString.Length - 1));
                        FO.Write(rscOutString, 0, rscOutString.Length);

                        break;

                        #endregion
                    case TSFReader.TSFEnd:                     // 0xA7: //End
                        #region StructEnd
                        if (sr.GetOIP() == Name)
                        {
                            ExitStruct = true;
                        }
                        else
                        {
                            ExitStruct = false;
                        }
                        break;
                        #endregion
                    }
                }while(ExitStruct == false);
                if (Count != 0)
                {
                    sc += 1;
                    if (sc != Count)
                    {
                        sr.Seek(StartOfStruct);
                        ExitStruct = false;
                    }
                }
            }while (sc != Count);
            long tmpPosSave = FO.Position;
            FO.Seek(StructPosition, SeekOrigin.Begin);
            FO.Write(TagBuff, 0, TagBuff.Length);
            FO.Seek(tmpPosSave, SeekOrigin.Begin);
        }