Beispiel #1
0
            internal ChunkEntryList(int requestedApiVersion, EventHandler handler, Stream s, TGIBlock[] chunks, RCOLIndexEntry[] index)
                : base(null, -1)
            {
                elementHandler = handler;

                BinaryReader r = new BinaryReader(s);

                for (int i = 0; i < index.Length; i++)
                {
                    s.Position = index[i].Position;
                    byte[]       data = r.ReadBytes(index[i].Length);
                    MemoryStream ms   = new MemoryStream();
                    ms.Write(data, 0, data.Length);
                    ms.Position = 0;

                    this.Add(new ChunkEntry(0, elementHandler, chunks[i], GenericRCOLResourceHandler.RCOLDealer(requestedApiVersion, elementHandler, chunks[i].ResourceType, ms)));
                }

                this.handler = handler;
            }
Beispiel #2
0
        void Parse(Stream s)
        {
            BinaryReader r = new BinaryReader(s);

            version      = r.ReadUInt32();
            publicChunks = r.ReadInt32();
            unused       = r.ReadUInt32();
            int countResources = r.ReadInt32();
            int countChunks    = r.ReadInt32();

            TGIBlock[] chunks = new TGIBlock[countChunks];
            for (int i = 0; i < countChunks; i++)
            {
                chunks[i] = new TGIBlock(0, OnResourceChanged, "ITG", s);
            }
            resources = new CountedTGIBlockList(OnResourceChanged, "ITG", countResources, s);

            RCOLIndexEntry[] index = new RCOLIndexEntry[countChunks];
            for (int i = 0; i < countChunks; i++)
            {
                index[i].Position = r.ReadUInt32(); index[i].Length = r.ReadInt32();
            }
            if (countChunks == 1)
            {
                index[0].Position = 0x2c + (uint)countResources * 16;
                index[0].Length   = (int)(s.Length - index[0].Position);
                if (chunks[0].ResourceType == 0)
                {
                    string tag = new string(r.ReadChars(4));
                    chunks[0].ResourceType = GenericRCOLResourceHandler.RCOLTypesForTag(tag).FirstOrDefault();
                }
            }

            blockList = new ChunkEntryList(requestedApiVersion, OnResourceChanged, s, chunks, index)
            {
                ParentTGIBlocks = resources,
            };
        }