コード例 #1
0
        public void WriteBitStream(BitStream readStream)
        {
            // Make better, preferably by reading to aligned area
            int numBits = readStream.BitLength - readStream.m_bitPosition;

            while (numBits > 0)
            {
                int   readBits = Math.Min(64, numBits);
                ulong value    = readStream.ReadUInt64(readBits);
                WriteUInt64(value, readBits);
                numBits -= readBits;
            }
        }
コード例 #2
0
 public void WriteBitStream(BitStream readStream)
 {
     // Make better, preferably by reading to aligned area
     int numBits = readStream.BitLength - readStream.m_bitPosition;
     while (numBits > 0)
     {
         int readBits = Math.Min(64, numBits);
         ulong value = readStream.ReadUInt64(readBits);
         WriteUInt64(value, readBits);
         numBits -= readBits;
     }
 }
コード例 #3
0
        public void Serialize(BitStream stream, MyClientStateBase forClient, byte packetId, int maxBitPosition)
        {
            SmallBitField dirtyFlags;
            if (stream.Writing)
            {
                var data = m_clientData[forClient];
                dirtyFlags = data.DirtyProperties;
                stream.WriteUInt64(dirtyFlags.Bits, m_properties.Count);
            }
            else
            {
                dirtyFlags.Bits = stream.ReadUInt64(m_properties.Count);
            }

            for (int i = 0; i < m_properties.Count; i++)
            {
                if (dirtyFlags[i])
                {
                    m_properties[i].Serialize(stream, false); // Received from server, don't validate
                    if (stream.Reading) // Received from server, it's no longer dirty
                        m_dirtyProperties[i] = false;
                }
            }
            if (stream.Writing && stream.BitPosition <= maxBitPosition)
            {
                var data = m_clientData[forClient];
                data.PacketId = packetId;
                data.SentProperties.Bits = data.DirtyProperties.Bits;
                data.DirtyProperties.Bits = 0;
            }
        }