Advertisement
Aodai

packets

Apr 25th, 2020
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System.Runtime.InteropServices;
  2.  
  3. namespace RappelzPlayers
  4. {
  5.  
  6.     [StructLayout(LayoutKind.Sequential, Pack = 1)]
  7.     public class TS_MESSAGE
  8.     {
  9.         public uint size;
  10.         public ushort id;
  11.         public byte msg_check_sum;
  12.  
  13.         public void SetChecksum()
  14.         {
  15.  
  16.             msg_check_sum += (byte)(size & 0xFF);
  17.             msg_check_sum += (byte)((size >> 8) & 0xFF);
  18.             msg_check_sum += (byte)((size >> 16) & 0xFF);
  19.             msg_check_sum += (byte)((size >> 24) & 0xFF);
  20.  
  21.             msg_check_sum += (byte)(id & 0xFF);
  22.             msg_check_sum += (byte)((id >> 8) & 0xFF);
  23.         }
  24.         public byte GetChecksum(int id, int size)
  25.         {
  26.             byte value = 0;
  27.  
  28.             value += (byte)(size & 0xFF);
  29.             value += (byte)((size >> 8) & 0xFF);
  30.             value += (byte)((size >> 16) & 0xFF);
  31.             value += (byte)((size >> 24) & 0xFF);
  32.  
  33.             value += (byte)(id & 0xFF);
  34.             value += (byte)((id >> 8) & 0xFF);
  35.            
  36.             return value;
  37.         }
  38.     }
  39.  
  40.     [StructLayout(LayoutKind.Sequential, Pack = 1)]
  41.     public class TS_CA_VERSION : TS_MESSAGE
  42.     {
  43.         [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
  44.         public string szVersion;
  45.     }
  46.  
  47.     [StructLayout(LayoutKind.Sequential, Pack = 1)]
  48.     public class TS_AC_RESULT : TS_MESSAGE
  49.     {
  50.         public ushort request_message_id;
  51.         public ushort result;
  52.         public uint value;
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement