Beispiel #1
0
        /// <summary>
        /// lese die Daten aus einer TDB-Datei ein
        /// </summary>
        /// <param name="br"></param>
        public void Read(BinaryReaderWriter br)
        {
            BlockHeader blh = new BlockHeader();

            Tilemap.Clear();
            BlockHeaderTypList.Clear();

            br.Seek(0);
            blh.Read(br);
            if (blh.ID != BlockHeader.Typ.Header)
            {
                throw new Exception("Keine TDB-Datei.");
            }
            Head = new Header(blh);
            Head.ReadData(br);
            BlockHeaderTypList.Add(blh.ID);
            BlockLength.Add(blh.Length);

            do
            {
                blh.Read(br);
                BlockHeaderTypList.Add(blh.ID);
                BlockLength.Add(blh.Length);
                switch (blh.ID)
                {
                case BlockHeader.Typ.Copyright:
                    Copyright = new SegmentedCopyright(new BlockHeader(blh));
                    Copyright.ReadData(br);
                    break;

                case BlockHeader.Typ.Overviewmap:
                    Overviewmap = new OverviewMap(new BlockHeader(blh));
                    Overviewmap.ReadData(br);
                    break;

                case BlockHeader.Typ.Tilemap:
                    TileMap dm = new TileMap(new BlockHeader(blh));
                    dm.ReadData(br);
                    Tilemap.Add(dm);
                    break;

                case BlockHeader.Typ.Description:
                    Mapdescription = new Description(new BlockHeader(blh));
                    Mapdescription.ReadData(br);
                    break;

                case BlockHeader.Typ.Crc:
                    Crc = new PseudoCRC(new BlockHeader(blh));
                    Crc.ReadData(br);
                    break;

                default:   // unbekannter Block
                    br.Position += blh.Length;
                    break;
                }
            } while (br.Position < br.Length);
        }
Beispiel #2
0
 public File_TDB()
 {
     BlockHeaderTypList = new List <BlockHeader.Typ>();
     BlockLength        = new List <int>();
     Head           = new Header(new BlockHeader(BlockHeader.Typ.Header, 0));
     Copyright      = new SegmentedCopyright(new BlockHeader(BlockHeader.Typ.Copyright, 0));
     Overviewmap    = new OverviewMap(new BlockHeader(BlockHeader.Typ.Overviewmap, 0));
     Tilemap        = new List <TileMap>();
     Crc            = new PseudoCRC(new BlockHeader(BlockHeader.Typ.Crc, 0));
     Mapdescription = new Description(new BlockHeader(BlockHeader.Typ.Description, 0));
 }