Ejemplo n.º 1
0
    static void CompileThrottledSerializeTargetsOutboundData(CNetworkStream _cOutboundStream)
    {
        // Create packet stream
        CNetworkStream cSerializedDataStream = new CNetworkStream();

        foreach (KeyValuePair <byte, TSerializationMethods> tEntry in s_mThrottledSerializeTargets)
        {
            tEntry.Value.nSerializeMethod(cSerializedDataStream);

            if (cSerializedDataStream.BitSize > 0)
            {
                // Write the control identifier
                _cOutboundStream.Write(tEntry.Key);

                // Write the size of the data
                _cOutboundStream.WriteBits(cSerializedDataStream.BitSize, 10);

                // Write the data
                _cOutboundStream.Write(cSerializedDataStream);

                // Clear target stream
                cSerializedDataStream.Clear();
            }
        }
    }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 3
0
    static void CompileThrottledSerializeTargetsOutboundData(CNetworkStream _cOutboundStream)
    {
        // Create packet stream
        CNetworkStream cSerializedDataStream = new CNetworkStream();

        foreach (KeyValuePair<byte, TSerializationMethods> tEntry in s_mThrottledSerializeTargets)
        {
            tEntry.Value.nSerializeMethod(cSerializedDataStream);

            if (cSerializedDataStream.BitSize > 0)
            {
                // Write the control identifier
                _cOutboundStream.Write(tEntry.Key);

                // Write the size of the data
                _cOutboundStream.WriteBits(cSerializedDataStream.BitSize, 10);

                // Write the data
                _cOutboundStream.Write(cSerializedDataStream);

                // Clear target stream
                cSerializedDataStream.Clear();
            }
        }
    }
Ejemplo n.º 4
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);
		}
	}