Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Runtime.InteropServices;
- namespace RappelzPlayers
- {
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- public class TS_MESSAGE
- {
- public uint size;
- public ushort id;
- public byte msg_check_sum;
- public void SetChecksum()
- {
- msg_check_sum += (byte)(size & 0xFF);
- msg_check_sum += (byte)((size >> 8) & 0xFF);
- msg_check_sum += (byte)((size >> 16) & 0xFF);
- msg_check_sum += (byte)((size >> 24) & 0xFF);
- msg_check_sum += (byte)(id & 0xFF);
- msg_check_sum += (byte)((id >> 8) & 0xFF);
- }
- public byte GetChecksum(int id, int size)
- {
- byte value = 0;
- value += (byte)(size & 0xFF);
- value += (byte)((size >> 8) & 0xFF);
- value += (byte)((size >> 16) & 0xFF);
- value += (byte)((size >> 24) & 0xFF);
- value += (byte)(id & 0xFF);
- value += (byte)((id >> 8) & 0xFF);
- return value;
- }
- }
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- public class TS_CA_VERSION : TS_MESSAGE
- {
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
- public string szVersion;
- }
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- public class TS_AC_RESULT : TS_MESSAGE
- {
- public ushort request_message_id;
- public ushort result;
- public uint value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement