Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.65 KB | None | 0 0
  1. // * Created By The-Great
  2. // * Copyright © 2015-2016
  3. // * ! Reflect ! - Project
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8.  
  9. namespace Reflect.Network.GamePackets
  10. {
  11. public unsafe class GenericRanking : Writer, Interfaces.IPacket
  12. {
  13. public const uint
  14. Ranking = 1,
  15. QueryCount = 2,
  16. InformationRequest = 5;
  17. public const uint
  18. RoseFairy = 30000002,
  19. LilyFairy = 30000102,
  20. OrchidFairy = 30000202,
  21. TulipFairy = 30000302,
  22. Kiss = 30000402,
  23. Love = 30000502,
  24. Tins = 30000602,
  25. Jade = 30000702,
  26. Chi = 60000000,
  27. InnerPower = 70000000,
  28. DragonChi = 60000001,
  29. PhoenixChi = 60000002,
  30. TigerChi = 60000003,
  31. TurtleChi = 60000004,
  32. Prestige = 80000000;
  33. byte[] Buffer;
  34. int current;
  35. public GenericRanking(bool Create, uint entries = 1)
  36. {
  37. if (Create)
  38. {
  39. //Old
  40. //Buffer = new byte[32 + entries * 72];
  41. //WriteUInt16((ushort)(24 + entries * 72), 0, Buffer);
  42. //
  43. Buffer = new byte[32 + entries * 80];
  44. WriteUInt16((ushort)(24 + entries * 80), 0, Buffer);
  45. WriteUInt16(1151, 2, Buffer);
  46. }
  47. }
  48. public void Append(uint rank, uint amount, uint uid, string name)
  49. {
  50. //int offset = current * 72 + 24;//Old
  51. //if (offset + 72 <= Buffer.Length)//Old
  52. int offset = current * 80 + 24;
  53. if (offset + 80 <= Buffer.Length)
  54. {
  55. current++;
  56. Count = (uint)current;
  57. WriteUInt32(rank, offset, Buffer); offset += 8;
  58. WriteUInt32(amount, offset, Buffer); offset += 8;
  59. WriteUInt32(uid, offset, Buffer); offset += 4;
  60. WriteUInt32(uid, offset, Buffer); offset += 4;
  61. WriteString(name, offset, Buffer); offset += 16;
  62. WriteString(name, offset, Buffer); offset += 16;
  63. }
  64. }
  65. public void Deserialize(byte[] _buffer)
  66. {
  67. Buffer = _buffer;
  68. if (Count == 0)
  69. {
  70. //byte[] buffer = new byte[88 + 16];//Old
  71. byte[] buffer = new byte[104 + 8];
  72. Buffer.CopyTo(buffer, 0);
  73. //WriteUInt16(80 + 16, 0, buffer);Old
  74. WriteUInt16(80 + 16, 0, buffer);
  75. Buffer = buffer;
  76. }
  77. }
  78. public uint Mode
  79. {
  80. get { return BitConverter.ToUInt32(Buffer, 4); }
  81. set { WriteUInt32(value, 4, Buffer); }
  82. }
  83. public uint RankingType
  84. {
  85. get { return BitConverter.ToUInt32(Buffer, 8); }
  86. set { WriteUInt32(value, 8, Buffer); }
  87. }
  88. public ushort RegisteredCount
  89. {
  90. get { return BitConverter.ToUInt16(Buffer, 12); }
  91. set { WriteUInt16(value, 12, Buffer); }
  92. }
  93. public ushort Page
  94. {
  95. get { return BitConverter.ToUInt16(Buffer, 14); }
  96. set { WriteUInt16(value, 14, Buffer); }
  97. }
  98. public uint Count
  99. {
  100. get { return BitConverter.ToUInt32(Buffer, 16); }
  101. set { WriteUInt32(value, 16, Buffer); }
  102. }
  103. public void Reset()
  104. {
  105. current = 0;
  106. }
  107. public void Send(Client.GameState client)
  108. {
  109. client.Send(Buffer);
  110. }
  111. public byte[] ToArray()
  112. {
  113. return Buffer;
  114. }
  115. public void Append(uint rank, uint amount, uint uid, string name, byte level = 0, byte Class = 0, uint mesh = 0)
  116. {
  117. //int offset = current * 72 + 24;//Old
  118. //if (offset + 72 <= Buffer.Length)//Old
  119. int offset = current * 80 + 24;
  120. if (offset + 80 <= Buffer.Length)
  121. {
  122. current++;
  123. Count = (uint)current;
  124. WriteUInt32(rank, offset, Buffer); offset += 8;
  125. WriteUInt32(amount, offset, Buffer); offset += 8;
  126. WriteUInt32(uid, offset, Buffer); offset += 4;
  127. WriteUInt32(uid, offset, Buffer); offset += 4;
  128. WriteString(name, offset, Buffer); offset += 16;
  129. WriteString(name, offset, Buffer); offset += 16;
  130. WriteUInt32(level, offset, Buffer); offset += 4;
  131. WriteUInt32(Class, offset, Buffer); offset += 4;
  132. WriteUInt32(mesh, offset, Buffer); offset += 8;
  133. }
  134. }
  135. public void Append(uint amount, uint uid, string name, byte level = 0, byte Class = 0, uint mesh = 0)
  136. {
  137. //int offset = current * 72 + 24;//Old
  138. //if (offset + 72 <= Buffer.Length)//Old
  139. int offset = current * 80 + 24;
  140. if (offset + 80 <= Buffer.Length)
  141. {
  142. current++;
  143. WriteUInt64(1, offset, Buffer); offset += 8;
  144. WriteUInt64(amount, offset, Buffer); offset += 8;
  145. WriteUInt32(80000000 + (uint)(current - 1), offset, Buffer); offset += 4;
  146. WriteUInt32(uid, offset, Buffer); offset += 4;
  147. WriteString(name, offset, Buffer); offset += 16;
  148. WriteString(name, offset, Buffer); offset += 16;
  149. WriteUInt32(level, offset, Buffer); offset += 4;
  150. WriteUInt32(Class, offset, Buffer); offset += 4;
  151. WriteUInt64(mesh, offset, Buffer); offset += 8;
  152. }
  153. }
  154. }
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement