Example #1
0
        public void ReadUpdateMask(Packet packet, int bitSizeCount = 32)
        {
            var newSize = packet.ReadBits(bitSizeCount);

            Resize(newSize);
            var rawMask = new int[(newSize + 31) / 32];

            if (newSize > 32)
            {
                if (packet.HasUnreadBitsInBuffer())
                {
                    for (var i = 0; i < newSize / 32; ++i)
                    {
                        rawMask[i] = (int)packet.ReadBits(32);
                    }
                }
                else
                {
                    for (var i = 0; i < newSize / 32; ++i)
                    {
                        rawMask[i] = packet.ReadInt32();
                    }
                }
            }
            if ((newSize % 32) != 0)
            {
                rawMask[newSize / 32] = (int)packet.ReadBits((int)newSize % 32);
            }

            UpdateMask = new BitArray(rawMask);
        }