Пример #1
0
        static bool InsertBoctFromBoctPacket30(string str, Boct target)
        {
            if (str.Length < 5 || str.Length % 5 != 0)
            {
                return(false);
            }

            int i = 0;

            while (i < str.Length)
            {
                uint packet = Base64Tools.ParseInt30Fast(str.Substring(i, 5));

                uint mid = BoctPacketTools.GetMaterialPart(packet);

                uint len = BoctPacketTools.GetAddressLengthPart(packet);

                var list = new List <byte>();
                for (uint j = 0; j < len; j++)
                {
                    uint pos = BoctPacketTools.GetPosition(packet, j + 1);
                    list.Add((byte)pos);
                }

                BoctTools.InsertBoct(list, target, (int)mid);

                i += 5;
            }
            return(true);
        }
 /// <summary>
 /// Dispose the region and clean up referenced boct data.
 /// </summary>
 public void Dispose(bool hard)
 {
     if (hard)
     {
         Head.ClearParent();
         Head.ClearChildren();
         Head.MaterialId  = BoctMaterial.EmptyId;
         Head.ExtensionId = BoctExtension.EmptyId;
     }
     BoctTools.ClearRegionId(Head);
     Head = null;
     CurrentState.Value = State.Disposed;
 }
        /// <summary>
        /// Convert to data.
        /// </summary>
        public RegionData ToData()
        {
            var data = new RegionData();

            data.GUID = GUID;

            data.LUID = LUID;

            var headAddress       = Head.Address;
            var headAddressLength = headAddress.Count;

            data.HeadAddress = BoctAddressTools.ToString(headAddress);

            if (Head.HasMaterial)
            {
                // If the head has material, the region is a single block.
                data.HeadMaterialId = Head.MaterialId;
            }
            else
            {
                var list = BoctTools.GetSolidBoctArray(Head);

                for (int i = 0; i < list.Length; i++)
                {
                    var b            = list[i];
                    var childAddress = b.Address;
                    // Trim headAddress from child address.
                    var localAddress = childAddress.GetRange(headAddressLength, childAddress.Count - headAddressLength);
                    data.AddressList.Add(BoctAddressTools.ToString(localAddress));
                    data.MaterialIdList.Add(b.MaterialId);
                    data.ExtensionIdList.Add(b.ExtensionId);
                }
            }

            data.HeadExtensionId = Head.ExtensionId;

            return(data);
        }