Пример #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);
        }
Пример #2
0
 public Array_ushort(MetaBuilderPointer ptr)
 {
     Pointer = ptr.Pointer;
     Count1  = (ushort)ptr.Length;
     Count2  = Count1;
     Unk1    = 0;
 }
Пример #3
0
 public Array_Structure(MetaBuilderPointer ptr)
 {
     Pointer = ptr.Pointer;
     Unk0    = 0;
     Count1  = (ushort)ptr.Length;
     Count2  = Count1;
     Unk1    = 0;
 }
Пример #4
0
 public CharPointer(MetaBuilderPointer ptr)
 {
     Pointer = ptr.Pointer;
     Unk0    = 0;
     Count1  = (ushort)ptr.Length;
     Count2  = Count1;
     Unk1    = 0;
 }
Пример #5
0
        public MetaBuilderPointer AddString(string str)
        {
            MetaBuilderBlock block = EnsureBlock((MetaName)MetaTypeName.STRING);

            byte[] data    = Encoding.ASCII.GetBytes(str);
            int    datalen = data.Length;
            int    newlen  = datalen + 1; //include null terminator

            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. (not incl null terminator)
            return(r);
        }
Пример #6
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);
        }
Пример #7
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);
        }
Пример #8
0
        public MetaBuilderPointer AddString(string 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);
        }
Пример #9
0
        public MetaBuilderPointer AddItemArray <T>(MetaName type, T[] items) where T : struct
        {
            MetaBuilderBlock block = EnsureBlock(type);

            byte[] data    = MetaTypes.ConvertArrayToBytes(items);
            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 / 16;
            int idx              = block.AddItem(newdata);
            MetaBuilderPointer r = new MetaBuilderPointer();

            r.Block  = block.Index + 1;
            r.Offset = offs; //(idx * data.Length) / 16;
            r.Length = items.Length;
            return(r);
        }