Exemplo n.º 1
0
        public override void OnRebuild(VoidPtr address, int length, bool force)
        {
            TyDataHeader *header = (TyDataHeader *)address;

            *header = new TyDataHeader();
            header->_size = (uint)length;
            uint dataEntries = 0;

            // Calculate how many data entries there are
            foreach (TyEntryNode t in Children)
            {
                dataEntries += t.GetDataEntryCount();
            }
            header->_dataEntries = dataEntries;
            uint offset = TyDataHeader.HeaderSize;

            // Write string table
            foreach (TyEntryNode t in Children)
            {
                offset = t.WriteStrings(address, offset);
            }
            // Write each child
            foreach (TyEntryNode n in Children)
            {
                n.EntryOffset = offset;
                int size = n.OnCalculateSize(true);
                n.OnRebuild(address + offset, size, true);
                offset += (uint)size;
            }
            // Write data section
            header->_dataOffset = offset - TyDataHeader.HeaderSize;
            foreach (TyEntryNode t in Children)
            {
                offset = t.WriteData(address, offset);
            }
            // Write entries
            header->_entries = (uint)Children.Count;
            uint strOffset = 0;

            foreach (TyEntryNode t in Children)
            {
                TyEntry *entry = (TyEntry *)(address + offset);
                entry->_offset    = t.EntryOffset - TyDataHeader.HeaderSize;
                entry->_strOffset = strOffset;
                strOffset        += (uint)t.Name.UTF8Length() + 1;
                offset           += TyEntry.Size;
            }
            // Write names
            foreach (TyEntryNode t in Children)
            {
                (address + offset).WriteUTF8String(t.Name, true);
                offset += (uint)t.Name.UTF8Length() + 1;
            }

            header->_pad1 = 0;
            header->_pad2 = 0;
            header->_pad3 = 0;
            header->_pad4 = 0;
        }
Exemplo n.º 2
0
        public override void OnPopulate()
        {
            TyDataHeader *parentData = (TyDataHeader *)Parent.WorkingUncompressed.Address;
            uint          offset     = 0;

            while (offset + 100 <= WorkingUncompressed.Length)
            {
                new TySealNode().Initialize(this, WorkingUncompressed.Address + offset, 100);
                offset += 100;
            }
        }
Exemplo n.º 3
0
        public override void OnPopulate()
        {
            TyDataHeader *parentData = (TyDataHeader *)Parent.WorkingUncompressed.Address;
            uint          offset     = 0;

            while (offset + 100 <= WorkingUncompressed.Length)
            {
                //StickerEntry* e = (StickerEntry*) parentData->GetStickerEntry(Children.Count);
                new TySealNode().Initialize(this, WorkingUncompressed.Address + offset, 100);
                offset += 100;
            }
        }
Exemplo n.º 4
0
        internal static ResourceNode TryParse(DataSource source, ResourceNode parent)
        {
            VoidPtr       addr   = source.Address;
            TyDataHeader *header = (TyDataHeader *)addr;

            if (header->_size != source.Length || header->_pad1 != 0 || header->_pad2 != 0 || header->_pad3 != 0 ||
                header->_pad4 != 0 || header->_dataOffset > source.Length ||
                header->_dataOffset + header->_dataEntries * 4 > source.Length)
            {
                return(null);
            }

            return(new TyDataNode());
        }