示例#1
0
        private void MessageClientData()
        {
            if (demo.Perspective == Demo.Perspectives.Hltv)
            {
                return;
            }

            if (!demo.ConvertNetworkProtocol() || demo.IsBetaSteam())
            {
                parser.MessageClientData();
                return;
            }

            // read message
            Int32 messageStartOffset = parser.BitBuffer.CurrentByte;

            if (demo.NetworkProtocol <= 43)
            {
                parser.BitBuffer.Endian = BitBuffer.EndianType.Big;
            }

            BitWriter bitWriter = new BitWriter();
            HalfLifeDeltaStructure clientDataStructure = parser.GetDeltaStructure("clientdata_t");
            HalfLifeDeltaStructure weaponDataStructure = parser.GetDeltaStructure("weapon_data_t");

            Boolean deltaSequence = parser.BitBuffer.ReadBoolean();

            bitWriter.WriteBoolean(deltaSequence);

            UInt32 deltaSequenceNumber = 0;

            if (deltaSequence)
            {
                deltaSequenceNumber = parser.BitBuffer.ReadUnsignedBits(8);
                bitWriter.WriteUnsignedBits(deltaSequenceNumber, 8);
            }

            HalfLifeDelta clientData = clientDataStructure.CreateDelta();

            Byte[] clientDataBitmaskBytes;
            clientDataStructure.ReadDelta(parser.BitBuffer, clientData, out clientDataBitmaskBytes);
            clientDataStructure.WriteDelta(bitWriter, clientData, clientDataBitmaskBytes);

            while (parser.BitBuffer.ReadBoolean())
            {
                bitWriter.WriteBoolean(true);

                if (demo.NetworkProtocol < 47 && !demo.IsBetaSteam())
                {
                    bitWriter.WriteUnsignedBits(parser.BitBuffer.ReadUnsignedBits(5), 6);
                }
                else
                {
                    bitWriter.WriteUnsignedBits(parser.BitBuffer.ReadUnsignedBits(6), 6);
                }

                HalfLifeDelta weaponData = weaponDataStructure.CreateDelta();
                Byte[]        bitmaskBytes;
                weaponDataStructure.ReadDelta(parser.BitBuffer, weaponData, out bitmaskBytes);
                weaponDataStructure.WriteDelta(bitWriter, weaponData, bitmaskBytes);
            }

            bitWriter.WriteBoolean(false);

            parser.BitBuffer.SkipRemainingBits();
            parser.BitBuffer.Endian = BitBuffer.EndianType.Little;

            // insert new message
            ReWriteMessage(messageStartOffset, bitWriter.Data);
        }