コード例 #1
0
        /// <summary>
        /// Creates new instance by copying the given packet. MaxCapacity == gamePacketToCopy.Length
        /// </summary>
        /// <param name="toCopy">GamePacket to copy</param>
        public BytePacket(BytePacket toCopy)
        {
            int length = toCopy.Data.Length;

            Data = new byte[length];
            ByteManipulator.Write <byte>(toCopy.Data, 0, Data, 0, length);
            CurrentLength = toCopy.CurrentLength;
            CurrentSeek   = toCopy.CurrentSeek;
        }
コード例 #2
0
        /// <summary>
        /// Copies n elements from internal buffer of the given gamepacket starting from its seek position to the current instance. Elements copied are equal to the minimum between the packet to (copy current length - seek pos), the space effectively available starting from vopy seek pos and the space available in the current instance buffer.
        /// </summary>
        /// <param name="toCopy">gamepacket to copy from</param>
        /// <returns>effective number of elements copied successfully</returns>
        public int Copy(BytePacket toCopy)
        {
            int v1             = Data.Length - CurrentSeek;
            int v2             = toCopy.CurrentLength - toCopy.CurrentSeek;
            int v3             = toCopy.Data.Length - toCopy.CurrentSeek;
            int elementsCopied = v1 > v2 ? v2 : (v3 > v1 ? v1 : v3);

            WriteByteData(toCopy, elementsCopied);
            return(elementsCopied);
        }
コード例 #3
0
 /// <summary>
 /// Reads the internal buffer into the given array
 /// </summary>
 /// <param name="buffer">buffer on which the internal buffer elements will be written. Buffer Seek will not be moved</param>
 /// <param name="lengthToRead">number of bytes to read</param>
 public void ReadByteData(BytePacket buffer, int lengthToRead)
 {
     ReadByteData(buffer.Data, buffer.CurrentSeek, lengthToRead);
     buffer.CurrentSeek   += lengthToRead;
     buffer.CurrentLength += lengthToRead;
 }
コード例 #4
0
 /// <summary>
 /// Reads the internal buffer into the given array
 /// </summary>
 /// <param name="buffer">buffer on which the internal buffer elements will be written. Buffer Seek will not be moved</param>
 /// <param name="bufferOffset">buffer offset</param>
 /// <param name="dataOffset">internal buffer offset</param>
 /// <param name="lengthToRead">number of bytes to read</param>
 public void ReadByteData(BytePacket buffer, int bufferOffset, int dataOffset, int lengthToRead)
 {
     CurrentSeek        = dataOffset;
     buffer.CurrentSeek = bufferOffset;
     ReadByteData(buffer, lengthToRead);
 }
コード例 #5
0
 /// <summary>
 /// Writes the given byte array into the internal buffer
 /// </summary>
 /// <param name="buffer">buffer from which elements will be written on the internal buffer. Buffer Seek will not be moved</param>
 /// <param name="lengthToWrite">number of bytes to write</param>
 public void WriteByteData(BytePacket buffer, int lengthToWrite)
 {
     WriteByteData(buffer.Data, buffer.CurrentSeek, lengthToWrite);
     buffer.CurrentSeek += lengthToWrite;
 }
コード例 #6
0
 /// <summary>
 /// Writes the given byte array into the internal buffer
 /// </summary>
 /// <param name="buffer">buffer from which elements will be written on the internal buffer. Buffer Seek will not be moved</param>
 /// <param name="bufferOffset">buffer offset</param>
 /// <param name="dataOffset">internal buffer offset</param>
 /// <param name="lengthToWrite">number of bytes to write</param>
 public void WriteByteData(BytePacket buffer, int bufferOffset, int dataOffset, int lengthToWrite)
 {
     CurrentSeek        = dataOffset;
     buffer.CurrentSeek = bufferOffset;
     WriteByteData(buffer, lengthToWrite);
 }