Beispiel #1
0
    public static void ProcessPlayerSerializedData(CNetworkPlayer _cPlayer, byte[] _baData)
    {
        // Create packet stream
        CNetworkStream cStream = new CNetworkStream(_baData);

        // Ignore timestamp packet id
        cStream.IgnoreBytes(1);

        // Retrieve latency
        ulong ulLatency = RakNet.RakNet.GetTime() - cStream.ReadULong();

        // Ignmore serialized data packet id
        cStream.IgnoreBytes(1);

        // Iterate through the packet data
        while (cStream.HasUnreadData &&
               cStream.NumUnreadBits > 18)
        {
            // Extract the target identifier
            byte bTargetIdentifier = cStream.ReadByte();

            // Extract the size of the data
            ushort usBitSize  = cStream.ReadBits <ushort>(10);
            ushort usByteSize = (ushort)((float)usBitSize / 8.0f);

            // Extract the data
            byte[] baData = new byte[usByteSize];
            cStream.BitStream.ReadBits(baData, usBitSize);

            // Create stream for the control
            CNetworkStream cTargetStream = new CNetworkStream();
            cTargetStream.WriteBits(baData, usBitSize);

            // Have the target process its data
            s_mThrottledSerializeTargets[bTargetIdentifier].nUnserializeMethod(_cPlayer, cTargetStream);
        }
    }
Beispiel #2
0
	public static void ProcessPlayerSerializedData(CNetworkPlayer _cPlayer, byte[] _baData)
	{
		// Create packet stream
		CNetworkStream cStream = new CNetworkStream(_baData);
        
        // Ignore timestamp packet id
		cStream.IgnoreBytes(1);

		// Retrieve latency
		ulong ulLatency = RakNet.RakNet.GetTime() - cStream.ReadULong();

        // Ignmore serialized data packet id
		cStream.IgnoreBytes(1);

		// Iterate through the packet data
		while (cStream.HasUnreadData &&
               cStream.NumUnreadBits > 18)
		{
			// Extract the target identifier
			byte bTargetIdentifier = cStream.ReadByte();

			// Extract the size of the data
            ushort usBitSize = cStream.ReadBits<ushort>(10);
            ushort usByteSize = (ushort)((float)usBitSize / 8.0f);

			// Extract the data
            byte[] baData = new byte[usByteSize];
            cStream.BitStream.ReadBits(baData, usBitSize);

			// Create stream for the control
			CNetworkStream cTargetStream = new CNetworkStream();
            cTargetStream.WriteBits(baData, usBitSize);

			// Have the target process its data
			s_mThrottledSerializeTargets[bTargetIdentifier].nUnserializeMethod(_cPlayer, cTargetStream);
		}
	}