Esempio n. 1
0
        public Array_Structure AddWrapperArray(MetaWrapper[] items)
        {
            if ((items == null) || (items.Length == 0))
            {
                return(new Array_Structure());
            }

            var sa = new Array_Structure();

            sa.Count1 = (ushort)items.Length;
            sa.Count2 = sa.Count1;
            for (int i = 0; i < items.Length; i++)
            {
                var item  = items[i];
                var meptr = item.Save(this);
                if (i == 0)
                {
                    MetaBuilderPointer mbp = new MetaBuilderPointer();
                    mbp.BlockID = meptr.BlockID;
                    mbp.Offset  = meptr.Offset;
                    sa.Pointer  = mbp.Pointer;
                }
            }
            return(sa);
        }
Esempio n. 2
0
        public MetaBuilderPointer AddString(string str)
        {
            str = str ?? "";
            MetaBuilderBlock block = EnsureBlock(MetaName.STRING);

            byte[] data    = Encoding.ASCII.GetBytes(str);
            int    datalen = data.Length;
            int    newlen  = datalen;
            int    lenrem  = newlen % 16;

            if (lenrem != 0)  //need to pad the data length up to multiple of 16.
            {
                newlen += (16 - lenrem);
            }
            byte[] newdata = new byte[newlen];
            Buffer.BlockCopy(data, 0, newdata, 0, datalen);
            int offs             = block.TotalSize;
            int idx              = block.AddItem(newdata);
            MetaBuilderPointer r = new MetaBuilderPointer();

            r.BlockID = block.Index + 1;
            r.Offset  = offs;    // (idx * data.Length);
            r.Length  = datalen; //actual length of string.
            return(r);
        }
Esempio n. 3
0
 public Array_uint(MetaBuilderPointer ptr)
 {
     Pointer = ptr.Pointer;
     Unk0    = 0;
     Count1  = (ushort)ptr.Length;
     Count2  = Count1;
     Unk1    = 0;
 }
Esempio n. 4
0
        public MetaBuilderPointer AddItem(MetaName type, byte[] data)
        {
            MetaBuilderBlock block = EnsureBlock(type);
            int brem = data.Length % 16;

            if (brem > 0)
            {
                int    newlen  = data.Length - brem + 16;
                byte[] newdata = new byte[newlen];
                Buffer.BlockCopy(data, 0, newdata, 0, data.Length);
                data = newdata; //make sure item size is multiple of 16... so pointers don't need sub offsets!
            }
            int idx = block.AddItem(data);
            MetaBuilderPointer r = new MetaBuilderPointer();

            r.BlockID = block.Index + 1;
            r.Offset  = (idx * data.Length);
            r.Length  = data.Length;
            return(r);
        }
Esempio n. 5
0
        public MetaBuilderPointer AddItemArray(MetaName type, byte[] data, int length)
        {
            MetaBuilderBlock block = EnsureBlock(type);
            int datalen            = data.Length;
            int newlen             = datalen;
            int lenrem             = newlen % 16;

            if (lenrem != 0)
            {
                newlen += (16 - lenrem);
            }
            byte[] newdata = new byte[newlen];
            Buffer.BlockCopy(data, 0, newdata, 0, datalen);
            int offs             = block.TotalSize;
            int idx              = block.AddItem(newdata);
            MetaBuilderPointer r = new MetaBuilderPointer();

            r.BlockID = block.Index + 1;
            r.Offset  = offs; //(idx * data.Length);;
            r.Length  = length;
            return(r);
        }