Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Project_Terror_v2.Game.MsgServer
  7. {
  8. public unsafe class MsgUpdate
  9. {
  10. public class OnlineTraining
  11. {
  12. public const byte
  13. Show = 0,
  14. InTraining = 1,
  15. Review = 2,
  16. IncreasePoints = 3,
  17. ReceiveExperience = 4,
  18. Remove = 5;
  19. }
  20.  
  21. [Flags]
  22. public enum Flags : int
  23. {
  24. Normal = 3,//0x0,
  25. FlashingName = 0,
  26. Poisoned = 1,
  27. Invisible = 2,
  28. XPList = 4,
  29. Dead = 5,
  30. TeamLeader = 6,
  31. StarOfAccuracy = 7,
  32. MagicShield = 8,
  33. Shield = 8,
  34. Stigma = 9,
  35. Ghost = 10,
  36. FadeAway = 11,
  37. RedName = 14,
  38. BlackName = 15,
  39. ReflectMelee = 17,
  40. Superman = 18,
  41. Ball = 19,
  42. Ball2 = 20,
  43. Invisibility = 22,
  44. Cyclone = 23,
  45. Dodge = 26,
  46. Fly = 27,
  47. Intensify = 28,
  48. CastPray = 30,
  49. Praying = 31,
  50. Cursed = 32,
  51. HeavenBlessing = 33,
  52. TopGuildLeader = 34,
  53. TopDeputyLeader = 35,
  54. MonthlyPKChampion = 36,
  55. WeeklyPKChampion = 37,
  56. TopWarrior = 38,
  57. TopTrojan = 39,
  58. TopArcher = 40,
  59. TopWaterTaoist = 41,
  60. TopFireTaoist = 42,
  61. TopNinja = 43,
  62. ShurikenVortex = 46,
  63. FatalStrike = 47,
  64. Flashy = 48,
  65. Ride = 50,
  66. TopSpouse = 51,
  67. OrangeSparkle = 52,
  68. DarkSparkle = 53,
  69. FreezeSmall = 54,
  70. HeavenSparkle = 55,
  71. IncMoveSpeed = 56,
  72. GodlyShield = 57,
  73. Stun = 58,
  74. Freeze = 59,
  75. ChaosCycle = 60,
  76. Top8Weekly = 63,
  77. Top4Weekly = 64,
  78. Top2Weekly = 65,
  79. ChaintBolt = 92,
  80. AzureShield = 93,
  81. ScurvyBomb = 96,//that is use for abuse.
  82. TyrantAura = 98,
  83. FeandAura = 100,
  84. MetalAura = 102,
  85. WoodAura = 104,
  86. WaterAura = 106,
  87. FireAura = 108,
  88. EartAura = 110,
  89. SoulShackle = 111,
  90. Oblivion = 112,
  91. ShieldBlock = 113,
  92. TopMonk = 114,
  93. TopPirate = 122,
  94. PoisonStar = 119,
  95. CannonBarrage = 120,
  96. BlackbeardsRage = 121,
  97. DefensiveStance = 126,
  98. MagicDefender = 128,
  99. RemoveName = 129,
  100. PurpleBall = 131,
  101. BlueBall = 132,
  102. PathOfShadow = 145,
  103. BladeFlurry = 146,
  104. KineticSpark = 147,
  105. //AutoHunt = 148,
  106. SuperCyclone = 150,
  107.  
  108. DragonFlow = 148,//20
  109. DragonFury = 158,//30
  110. DragonCyclone = 159,//31
  111. DragonSwing = 160//32
  112. }
  113. [Flags]
  114. public enum DataType : uint
  115. {
  116. Hitpoints = 0,
  117. MaxHitpoints = 1,
  118. Mana = 2,
  119. MaxMana = 3,
  120. Money = 4,
  121. Experience = 5,
  122. PKPoints = 6,
  123. Class = 7,
  124. Stamina = 8,
  125. WHMoney = 9,
  126. Atributes = 10,
  127. Mesh = 11,
  128. Level = 12,
  129. Spirit = 13,
  130. Vitality = 14,
  131. Strength = 15,
  132. Agility = 16,
  133. HeavensBlessing = 17,
  134. DoubleExpTimer = 18,
  135. CursedTimer = 20,
  136. Reborn = 22,
  137. VirtutePoints = 23,
  138. StatusFlag = 25,
  139. HairStyle = 26,
  140. XPCircle = 27,
  141. LuckyTimeTimer = 28,
  142. ConquerPoints = 29,
  143. OnlineTraining = 31,
  144. ExtraBattlePower = 36,
  145. ArsenalBp = 37,
  146. Merchant = 38,
  147. VIPLevel = 39,
  148. QuizPoints = 40,
  149. EnlightPoints = 41,
  150. ClanShareBp = 42,
  151. GuildBattlePower = 44,
  152. Contestant = 48,
  153. AzureShield = 49,
  154. FirsRebornClass = 51,
  155. SecondRebornClass = 50,
  156. Team = 52,
  157. SoulShackle = 54,
  158. Fatigue = 55,
  159. DefensiveStance = 56,
  160. WoodResist = 60,
  161. WaterResist = 61,
  162. FireResist = 62,
  163. MetalResist = 63,
  164. EarthResist = 64,
  165. Blessed = 66,
  166. gMagicAtk = 67,
  167. gAttack = 68,
  168.  
  169. IncreaseMStrike = 60,
  170. IncreasePStrike = 59,
  171. IncreaseImunity = 61,
  172. IncreaseBreack = 62,
  173. IncreaseAntiBreack = 63,
  174. IncreaseMaxHp = 64,
  175. IncreasePAttack = 65,
  176. IncreaseMAttack = 66,
  177. IncreaseFinalPDamage = 67,
  178. IncreaseFinalMDamage = 68,
  179. IncreaseFinalPAttack = 69,
  180. IncreaseFinalMAttack = 70,
  181. ExpProtection = 73,
  182.  
  183. DragonSwing = 75,
  184. DragonFury = 74
  185.  
  186.  
  187. }
  188. private byte[] Buffer;
  189. public unsafe MsgUpdate(uint count = 1)
  190. {
  191. Buffer = new byte[40 + DataPacket.SizeOf_Data * count + 8];
  192. fixed (byte* buff = Buffer)
  193. {
  194. UpdatePacket* upd = (UpdatePacket*)buff;
  195. upd->Leng = (ushort)(40 + DataPacket.SizeOf_Data * count);
  196. upd->Type = Game.GamePackets.Update;
  197. upd->Stamp = Extensions.Time32.Now.GetHashCode();
  198. upd->Count = count;
  199. *(ulong*)(buff + (Buffer.Length - 8)) = ServerSockets.Packet.TQServer;
  200. }
  201. }
  202. public uint UID
  203. {
  204. get
  205. {
  206. fixed (byte* iUpdate = Buffer)
  207. return ((UpdatePacket*)iUpdate)->UID;
  208. }
  209. set
  210. {
  211. fixed (byte* iUpdate = Buffer)
  212. ((UpdatePacket*)iUpdate)->UID = value;
  213. }
  214. }
  215. public void Append(DataType ID, long Value, int UpdateNumber = 0)
  216. {
  217. fixed (byte* iUpdate = Buffer)
  218. {
  219. *((DataPacket*)(iUpdate + 16 + (UpdateNumber * DataPacket.SizeOf_Data))) =
  220. DataPacket.Create(ID, Value);
  221. }
  222. }
  223. public void Append(DataType ID, uint Flag,uint Time, uint Dmg, uint Level , int UpdateNumber = 0)
  224. {
  225. uint[] Value = new uint[5] { Flag, Time, Dmg, Level, 0 }; // 20 byte`s
  226. fixed (byte* iUpdate = Buffer)
  227. {
  228. *((DataPacket*)(iUpdate + 16 + (UpdateNumber * DataPacket.SizeOf_Data))) =
  229. DataPacket.Create(ID, Value);
  230. }
  231. }
  232. public void Append(DataType ID, uint[] Value, int UpdateNumber = 0)
  233. {
  234. fixed (byte* iUpdate = Buffer)
  235. {
  236. *((DataPacket*)(iUpdate + 16 + (UpdateNumber * DataPacket.SizeOf_Data))) =
  237. DataPacket.Create(ID, Value);
  238. }
  239. }
  240. public byte* GetArray()
  241. {
  242. fixed (byte* buff = Buffer)
  243. return buff;
  244. }
  245. public static implicit operator byte*(MsgUpdate big)
  246. {
  247. fixed (byte* buff = big.Buffer)
  248. return buff;
  249. }
  250. public struct DataPacket
  251. {
  252. public const byte SizeOf_Data = 28;
  253. public DataType Typ;
  254. public unsafe fixed byte Value[SizeOf_Data - 4];
  255.  
  256. public unsafe static DataPacket Create(DataType ID, long value)
  257. {
  258. DataPacket dat = new DataPacket();
  259. dat.Typ = ID;
  260. *(long*)(dat.Value) = value;
  261. return dat;
  262. }
  263. public unsafe static DataPacket Create(DataType ID, uint[] value)
  264. {
  265. DataPacket dat = new DataPacket();
  266. dat.Typ = ID;
  267. byte offset = 0;
  268. for (int x = 0; x < value.Length; x++)
  269. {
  270. *(uint*)(dat.Value + offset) = value[x];
  271. offset += 4;
  272. }
  273. return dat;
  274. }
  275. }
  276. public struct UpdatePacket
  277. {
  278. public ushort Leng;
  279. public ushort Type;
  280. public int Stamp;
  281. public uint UID;
  282. public uint Count;
  283. }
  284. }
  285.  
  286. }
  287.  
  288.  
  289.  
  290. using System;
  291. using System.Collections.Generic;
  292. using System.Linq;
  293. using System.Text;
  294.  
  295. namespace Extensions
  296. {
  297. public class BitVector32
  298. {
  299. public uint[] bits;
  300.  
  301. public int Size { get { return 32 * bits.Length; } }
  302.  
  303. public BitVector32(int BitCount)
  304. {
  305. int sections = BitCount / 32;
  306. if (BitCount % 32 != 0)
  307. sections += 1;
  308. bits = new uint[sections];
  309. }
  310.  
  311. public void Add(int index)
  312. {
  313. if (index < Size)
  314. {
  315. int idx = index / 32;
  316. uint bites = (uint)(1 << (index % 32));
  317. bits[idx] |= bites;
  318. }
  319. }
  320. public void Remove(int index)
  321. {
  322. if (index < Size)
  323. {
  324. int idx = index / 32;
  325. uint bites = (uint)(1 << (index % 32));
  326. bits[idx] &= ~bites;
  327. }
  328. }
  329. public bool Contain(int index)
  330. {
  331. if (index > Size) return false;
  332. int idx = index / 32;
  333. uint bites = (uint)(1 << (index % 32));
  334. return ((bits[idx] & bites) == bites);
  335. }
  336. public void Clear()
  337. {
  338. ushort siz = (byte)(Size / 32);
  339. for (byte x = 0; x < siz; x++)
  340. {
  341. bits[x] = 0;
  342. }
  343. }
  344. }
  345. }
  346.  
  347.  
  348. public void AddSpellFlag(Game.MsgServer.MsgUpdate.Flags Flag, int Secounds, bool RemoveOnDead, int StampSecounds = 0)
  349. {
  350. if (BitVector.ContainFlag((int)Flag))
  351. BitVector.TryRemove((int)Flag);
  352. AddFlag(Flag, Secounds, RemoveOnDead, StampSecounds);
  353. }
  354. public bool AddFlag(Game.MsgServer.MsgUpdate.Flags Flag, int Secounds, bool RemoveOnDead,int StampSecounds =0, uint showamount = 0, uint amount =0)
  355. {
  356. if (!BitVector.ContainFlag((int)Flag))
  357. {
  358. BitVector.TryAdd((int)Flag, Secounds, RemoveOnDead, StampSecounds);
  359. UpdateFlagOffset();
  360. if ((int)Flag >= 52 && (int)Flag <= 60)
  361. {
  362. unsafe
  363. {
  364. Game.MsgServer.MsgGameUpdate upd = new Game.MsgServer.MsgGameUpdate(1);
  365. upd.UID = UID;
  366. upd.Append((Game.MsgServer.MsgGameUpdate.DataType)Flag, true, showamount, (uint)Secounds, amount, 0);
  367. Send(upd);
  368. }
  369. }
  370. return true;
  371. }
  372. return false;
  373. }
  374. public bool RemoveFlag(Game.MsgServer.MsgUpdate.Flags Flag)
  375. {
  376. if (BitVector.ContainFlag((int)Flag))
  377. {
  378. BitVector.TryRemove((int)Flag);
  379. UpdateFlagOffset();
  380. if ((int)Flag >= 52 && (int)Flag <= 60)
  381. {
  382. unsafe
  383. {
  384. Game.MsgServer.MsgGameUpdate upd = new Game.MsgServer.MsgGameUpdate(1);
  385. upd.UID = UID;
  386. upd.Append((Game.MsgServer.MsgGameUpdate.DataType)Flag, false, 0, 0, 0, 0);
  387. Send(upd);
  388. }
  389. }
  390. return true;
  391. }
  392. return false;
  393. }
  394. public bool UpdateFlag(Game.MsgServer.MsgUpdate.Flags Flag, int Secounds, bool SetNewTimer, int MaxTime)
  395. {
  396. return BitVector.UpdateFlag((int)Flag, Secounds, SetNewTimer, MaxTime);
  397. }
  398. public void ClearFlags()
  399. {
  400. BitVector.GetClear();
  401. UpdateFlagOffset();
  402. }
  403. public bool ContainFlag(Game.MsgServer.MsgUpdate.Flags Flag)
  404. {
  405. return BitVector.ContainFlag((int)Flag);
  406. }
  407. public bool CheckInvokeFlag(Game.MsgServer.MsgUpdate.Flags Flag, Extensions.Time32 timer32)
  408. {
  409. return BitVector.CheckInvoke((int)Flag, timer32);
  410. }
  411. private unsafe void UpdateFlagOffset()
  412. {
  413. for (int x = 0; x < BitVector.bits.Length; x++)
  414. *(uint*)(SpawnPacket + BitVector32 + x * 4) = BitVector.bits[x];
  415. SendUpdate(BitVector.bits, Game.MsgServer.MsgUpdate.DataType.StatusFlag, true);
  416. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement