Пример #1
0
 public static void BuildPacketHeader <T>(ref MPacketHeader pHeader, ushort userId)
 {
     pHeader.Size      = (ushort)(Marshal.SizeOf(typeof(T)));
     pHeader.ClientId  = userId;
     pHeader.Key       = PacketSecurity.GetHashByte();
     pHeader.TimeStamp = PacketSecurity.GetTimeStamp();
 }
Пример #2
0
        /// <summary>
        /// Creates a empty ready-to-use copy of a given implementation of IGamePacket.
        /// </summary>
        public static T GetEmptyValid <T>(ushort opcode) where T : IGamePacket
        {
            MPacketHeader validHeader = new MPacketHeader();
            T             packet      = W2Marshal.CreateEmpty <T>();

            // Set the default values to the packet header.
            validHeader.Size      = (ushort)Marshal.SizeOf(packet);
            validHeader.Opcode    = opcode;
            validHeader.Key       = PacketSecurity.GetHashByte();
            validHeader.TimeStamp = PacketSecurity.GetTimeStamp();

            packet.Header = validHeader;

            return(packet);
        }