Example #1
0
        public void Trace()
        {
            Engine.AddTextMessage(string.Format("Tracing packet 0x{0:X2} '{1}' of length {2} ( 0x{2:X} )", this.m_Command, this.m_Name, this.m_Count));
            StreamWriter tw = new StreamWriter("PacketTrace.log", true);

            if (this.m_Count < 0x10)
            {
                tw.WriteLine("Packet Server->Client '{0}' ( {1} bytes )", this.m_ReturnName, this.m_Count);
            }
            else
            {
                tw.WriteLine("Packet Server->Client '{0}' ( {1} [0x{1:X}] bytes )", this.m_ReturnName, this.m_Count);
            }
            tw.WriteLine();
            Network.Log(tw, this.m_Data, this.m_Start, this.m_Count);
            tw.WriteLine();
            tw.Flush();
            tw.Close();
        }
Example #2
0
 public static void Slice()
 {
     if (m_Socket != null)
     {
         try
         {
             if ((DateTime.Now > (m_LastQuery + m_QueryDelay)) && (!Query() || !Query2()))
             {
                 Disconnect();
             }
             else if ((DateTime.Now > (m_LastPost + m_PostDelay)) && !Post())
             {
                 Disconnect();
             }
             else if (m_Socket.Available > 0)
             {
                 int num = m_Socket.Receive(m_Buffer, 0, m_Buffer.Length - m_Offset, SocketFlags.None);
                 if (num <= 0)
                 {
                     Disconnect();
                 }
                 else
                 {
                     m_Offset += num;
                 }
                 while (m_Offset >= 0x18)
                 {
                     int count = ((m_Buffer[8] | (m_Buffer[9] << 8)) | (m_Buffer[10] << 0x10)) | (m_Buffer[11] << 0x18);
                     if (m_Offset < count)
                     {
                         return;
                     }
                     if (count == 0)
                     {
                         m_Offset = 0;
                         return;
                     }
                     m_Offset -= count;
                     byte[] dst = new byte[count];
                     Buffer.BlockCopy(m_Buffer, 0, dst, 0, count);
                     Buffer.BlockCopy(m_Buffer, count, m_Buffer, 0, m_Offset);
                     if (count >= 0x18)
                     {
                         m_Log = false;
                         if (dst[20] == 0)
                         {
                             DoPositions(new UOAMPacketReader(dst));
                         }
                         else if (dst[20] == 1)
                         {
                             DoChat(new UOAMPacketReader(dst));
                         }
                         else
                         {
                             m_Log = true;
                         }
                         if (m_Log)
                         {
                             Network.Log(dst, null);
                         }
                     }
                 }
             }
         }
         catch
         {
             Disconnect();
         }
     }
 }