Advertisement
Guest User

Untitled

a guest
Aug 13th, 2016
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.60 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Conquer_Online_Server.Client;
  6. using Conquer_Online_Server.Network.GamePackets;
  7. using Conquer_Online_Server.Game;
  8. using System.Collections.Concurrent;
  9. using Conquer_Online_Server.Interfaces;
  10. using Conquer_Online_Server.Network;
  11. using System.IO;
  12. using Conquer_Online_Server.Game.ConquerStructures;
  13.  
  14. namespace Conquer_Online_Server.WebServer
  15. {
  16. public partial class TransferPlayer
  17. {
  18. public TransferPlayer()
  19. {
  20.  
  21. }
  22. public void Deserialize(byte[] buffer)
  23. {
  24. packet = buffer;
  25. }
  26. public byte[] packet;
  27. public uint UID
  28. {
  29. get
  30. {
  31. return BitConverter.ToUInt32(packet, 78) + Server.Key;
  32. }
  33. }
  34. public string FromServer
  35. {
  36. get
  37. {
  38. return PacketHandler.ReadString(packet, 161, packet[160]);
  39. }
  40. }
  41. public string Name
  42. {
  43. get
  44. {
  45. // return "Tra_" + Key;
  46. return PacketHandler.ReadString(packet, 181, packet[180]);
  47. }
  48. }
  49. public uint Money
  50. {
  51. get
  52. {
  53. return BitConverter.ToUInt32(packet, 6);
  54. }
  55. }
  56. public uint Cpc { get { return BitConverter.ToUInt32(packet, 10); } }
  57. public uint Class { get { return BitConverter.ToUInt16(packet, 14); } }
  58. public uint SecoundClass { get { return BitConverter.ToUInt16(packet, 16); } }
  59. public uint FirstClass { get { return BitConverter.ToUInt16(packet, 18); } }
  60. public uint Reborn { get { return BitConverter.ToUInt32(packet, 22); } }
  61. public uint Haire { get { return BitConverter.ToUInt32(packet, 30); } }
  62. public uint Body { get { return BitConverter.ToUInt32(packet, 34); } }
  63. public uint Level { get { return BitConverter.ToUInt32(packet, 38); } }
  64. public uint Str { get { return BitConverter.ToUInt32(packet, 42); } }
  65. public uint Agi { get { return BitConverter.ToUInt32(packet, 46); } }
  66. public uint Spi { get { return BitConverter.ToUInt32(packet, 50); } }
  67. public uint Vit { get { return BitConverter.ToUInt32(packet, 54); } }
  68. public uint Atr { get { return BitConverter.ToUInt32(packet, 58); } }
  69. public uint Face { get { return BitConverter.ToUInt32(packet, 62); } }
  70. public uint QuizPoints { get { return BitConverter.ToUInt32(packet, 66); } }
  71. public uint Vip { get { return BitConverter.ToUInt32(packet, 70); } }
  72. public uint Study { get { return BitConverter.ToUInt32(packet, 74); } }
  73. public ulong NobilityInformation { get { return BitConverter.ToUInt64(packet, 82); } }
  74. public NobilityRank NobilityRank { get { return (NobilityRank)packet[90]; } }
  75.  
  76. public ushort GuildID { get { return BitConverter.ToUInt16(packet, 100); } }
  77. public ushort GuildRank { get { return BitConverter.ToUInt16(packet, 102); } }
  78. public string GuildName { get { return PacketHandler.ReadString(packet, 104, 16); } }
  79. public string GuildLeaderName { get { return PacketHandler.ReadString(packet, 120, 16); } }
  80.  
  81. public uint UnionID { get { return BitConverter.ToUInt32(packet, 23004); } }
  82. public string UnionName { get { return PacketHandler.ReadString(packet, 23008, 16); } }
  83. public byte UnionRank { get { return packet[23024]; } }
  84. public byte UnionType { get { return packet[23025]; } }
  85. public uint UnionTitle { get { return BitConverter.ToUInt32(packet, 23026); } }
  86. public uint UnionExploits { get { return BitConverter.ToUInt32(packet, 23030); } }
  87.  
  88. public Database.AccountTable.AccountState State
  89. {
  90. get
  91. {
  92. return (Database.AccountTable.AccountState)packet[23999];
  93. }
  94. }
  95. public string username
  96. {
  97. get
  98. {
  99. return PacketHandler.ReadString(packet, 24001, packet[24000]);
  100. }
  101. }
  102. public string password
  103. {
  104. get
  105. {
  106. return PacketHandler.ReadString(packet, 24017, packet[24016]);
  107. }
  108. }
  109. public string ip
  110. {
  111. get
  112. {
  113. return PacketHandler.ReadString(packet, 24033, packet[24032]);
  114. }
  115. }
  116. public string Jiang
  117. {
  118. get
  119. {
  120. return Program.GetString(packet, 20004, BitConverter.ToUInt16(packet, 20000)).Replace("\0", "");
  121. }
  122. }
  123. public SafeDictionary<ushort, Interfaces.IProf> Proficiencies = new SafeDictionary<ushort, Interfaces.IProf>();
  124. public SafeDictionary<ushort, Interfaces.ISkill> Spells = new SafeDictionary<ushort, Interfaces.ISkill>();
  125. public Dictionary<uint, Network.GamePackets.ConquerItem> Items = new Dictionary<uint, Network.GamePackets.ConquerItem>();
  126. public List<ChiPowerStructure> ChiPowers = new List<ChiPowerStructure>();
  127. public MaTrix.Inner.InnerPower InnerPower;
  128. public WebServer.Client.TranServer Server;
  129. public void Clone(ref Conquer_Online_Server.Client.GameState client)
  130. {
  131. var Player = this;
  132. client.ReadyToPlay();
  133. client.TransferedPlayer = true;
  134. client.Account = new Database.AccountTable(null);
  135. client.Account.State = State;
  136. client.Account.Username = username;
  137. client.Account.Password = password;
  138. client.Account.IP = ip;
  139. var mainid = Player.UID - Server.Key;
  140. client.Account.EntityID = Player.UID;
  141.  
  142.  
  143. if (mainid == 0)
  144. {
  145. client.Socket.OverrideTiming = true;
  146. client.Send(new Message("Sorry You Can't Login", "ALLUSERS", System.Drawing.Color.Orange, Network.GamePackets.Message.Dialog));
  147. return;
  148. }
  149. if (Kernel.DisconnectPool.ContainsKey(mainid))
  150. {
  151. client.Send(new Message("Please try again after a minute!", "ALLUSERS", System.Drawing.Color.Orange, Network.GamePackets.Message.Dialog));
  152. return;
  153. }
  154.  
  155. client.Entity = new Game.Entity(Game.EntityFlag.Player, false);
  156. client.Entity.Name = Player.Name;
  157. client.Entity.Spouse = "None";
  158. client.Entity.UID = Player.UID;
  159. client.Entity.Money = Player.Money;
  160. client.Entity.MyFlowers = new Game.Features.Flowers(client.Entity.UID, client.Entity.Name);
  161. client.Entity.Owner = client;
  162. client.Entity.MyAchievement = new Game.Achievement(client.Entity);
  163. client.Entity.Titles = new ConcurrentDictionary<TitlePacket.Titles, DateTime>();
  164. client.ElitePKStats = new ElitePK.FighterStats(client.Entity.UID, client.Entity.Name, client.Entity.Mesh);
  165. client.Entity.ConquerPoints = Player.Cpc;
  166. client.Entity.Class = (byte)Player.Class;
  167. client.Entity.SecondRebornClass = (byte)Player.SecoundClass;
  168. client.Entity.FirstRebornClass = (byte)Player.FirstClass;
  169. client.Entity.Reborn = (byte)Player.Reborn;
  170. client.Entity.HairStyle = (ushort)Player.Haire;
  171. client.Entity.Body = (ushort)Player.Body;
  172. client.Entity.Level = (byte)Player.Level;
  173. client.Entity.Strength = (ushort)Player.Str;
  174. client.Entity.Agility = (ushort)Player.Agi;
  175. client.Entity.Spirit = (ushort)Player.Spi;
  176. client.Entity.Vitality = (ushort)Player.Vit;
  177. client.Entity.Atributes = (ushort)Player.Atr;
  178. client.Entity.Face = (ushort)Player.Face;
  179. client.Entity.QuizPoints = (ushort)Player.QuizPoints;
  180. client.Entity.VIPLevel = (byte)Player.Vip;
  181. if (client.Entity.SubClasses != null)
  182. client.Entity.SubClasses.StudyPoints = (ushort)Player.Study;
  183.  
  184.  
  185. client.Variables = new VariableVault();
  186. client.Friends = new SafeDictionary<uint, Game.ConquerStructures.Society.Friend>();
  187. client.Enemy = new SafeDictionary<uint, Game.ConquerStructures.Society.Enemy>();
  188. client.ChiPowers = new List<ChiPowerStructure>();
  189. if (ChiPowers != null)
  190. client.ChiPowers = ChiPowers;
  191. client.ChiData = new Conquer_Online_Server.Database.ChiTable.ChiData() { UID = client.Entity.UID, Name = client.Entity.Name, Powers = client.ChiPowers };
  192.  
  193. client.NobilityInformation = new Conquer_Online_Server.Game.ConquerStructures.NobilityInformation();
  194. client.NobilityInformation.EntityUID = client.Entity.UID;
  195. client.NobilityInformation.Name = client.Entity.Name;
  196. client.NobilityInformation.Donation = NobilityInformation;
  197. client.Entity.NobilityRank = client.NobilityInformation.Rank = NobilityRank;
  198. client.NobilityInformation.Position = -1;
  199. client.NobilityInformation.Gender = 1;
  200. client.NobilityInformation.Mesh = client.Entity.Mesh;
  201. if (client.Entity.Body % 10 >= 3)
  202. client.NobilityInformation.Gender = 0;
  203.  
  204.  
  205. client.TeamArenaStatistic = new Conquer_Online_Server.Network.GamePackets.TeamArenaStatistic(true);
  206. client.TeamArenaStatistic.EntityID = client.Entity.UID;
  207. client.TeamArenaStatistic.Name = client.Entity.Name;
  208. client.TeamArenaStatistic.Level = client.Entity.Level;
  209. client.TeamArenaStatistic.Class = client.Entity.Class;
  210. client.TeamArenaStatistic.Model = client.Entity.Mesh;
  211. client.TeamArenaStatistic.Status = Network.GamePackets.TeamArenaStatistic.NotSignedUp;
  212.  
  213. client.ArenaStatistic = new Conquer_Online_Server.Network.GamePackets.ArenaStatistic(true);
  214. client.ArenaStatistic.EntityID = client.Entity.UID;
  215. client.ArenaStatistic.Name = client.Entity.Name;
  216. client.ArenaStatistic.Level = client.Entity.Level;
  217. client.ArenaStatistic.Class = client.Entity.Class;
  218. client.ArenaStatistic.Model = client.Entity.Mesh;
  219. client.ArenaStatistic.LastArenaPointFill = DateTime.Now;
  220. client.ArenaStatistic.Status = Network.GamePackets.ArenaStatistic.NotSignedUp;
  221.  
  222. //client.ChampionStats = new Conquer_Online_Server.Network.GamePackets.ChampionStatistic(true);
  223. //client.ChampionStats.UID = client.Entity.UID;
  224. //client.ChampionStats.Name = client.Entity.Name;
  225. //client.ChampionStats.Level = client.Entity.Level;
  226. //client.ChampionStats.Class = client.Entity.Class;
  227. //client.ChampionStats.Model = client.Entity.Mesh;
  228. //client.ChampionStats.Points = 0;
  229. //client.ChampionStats.LastReset = DateTime.Now;
  230.  
  231. if (GuildID != 0 && GuildName != "")
  232. {
  233. client.Guild = new Game.ConquerStructures.Society.Guild(GuildLeaderName);
  234. client.Guild.ID = (GuildID + Server.Key);
  235. client.Guild.Name = GuildName;
  236.  
  237. client.AsMember = new Game.ConquerStructures.Society.Guild.Member(client.Guild.ID);
  238. client.AsMember.Name = client.Entity.Name;
  239. client.AsMember.ID = client.Entity.UID;
  240. client.AsMember.Level = client.Entity.Level;
  241. client.AsMember.Spouse = client.Entity.Spouse;
  242. client.AsMember.Rank = (Game.Enums.GuildMemberRank)GuildRank;
  243.  
  244. client.Guild.Members.Add(client.Entity.UID, client.AsMember);
  245.  
  246. client.Entity.GuildID = (ushort)(GuildID + Server.Key);
  247. client.Entity.GuildRank = GuildRank;
  248. client.Guild.SendGuild(client);
  249. client.Guild.SendName(client);
  250. }
  251. client.Entity.AshesofAnger = packet[23041] == 1 ? true : false;
  252. client.Entity.ScrambleforJustice = packet[23042] == 1 ? true : false;
  253. client.Entity.ThunderStrike = packet[23043] == 1 ? true : false;
  254. client.Entity.CrystalBounty = packet[23044] == 1 ? true : false;
  255. client.Entity.BeastOfLegend = packet[23045] == 1 ? true : false;
  256.  
  257. client.Entity.StrikePoints = System.BitConverter.ToUInt32(packet, 23046);
  258. client.Entity.BeastOfLegendKilling = System.BitConverter.ToUInt32(packet, 23050);
  259. client.Entity.AshesofAngerKilling = System.BitConverter.ToUInt32(packet, 23054);
  260. client.Entity.CrystalBountyKilling = System.BitConverter.ToUInt32(packet, 23058);
  261. client.Entity.ScrambleforJusticeKilling = System.BitConverter.ToUInt32(packet, 23062);
  262. client.Entity.GoldBricks = System.BitConverter.ToUInt32(packet, 23066);
  263. if (UnionID != 0 && UnionName != "")
  264. {
  265. client.Union = new Game.ConquerStructures.Union(client, this.UnionName, this.UnionID+ Server.Key);
  266. client.UnionID = this.UnionID + Server.Key;
  267. client.UnionName = this.UnionName;
  268. client.UnionExploits = this.UnionExploits;
  269. client.UnionRank = this.UnionRank;
  270. client.UnionType = this.UnionType;
  271. client.Send(Game.ConquerStructures.Union.SendOverheadLeagueInfo2(client));
  272. }
  273. if (Jiang != "")
  274. {
  275. client.Entity.MyJiang = new Game.JiangHu(0);
  276. client.Entity.MyJiang.Load(Jiang);
  277. }
  278. if (InnerPower != null)
  279. {
  280. InnerPower.UID = client.Entity.UID;
  281. InnerPower.Name = client.Entity.Name;
  282. client.Entity.InnerPower = InnerPower;
  283. }
  284.  
  285. client.Entity.FullyLoaded = true;
  286. client.ClaimableItem = new SafeDictionary<uint, DetainedItem>();
  287. client.DeatinedItem = new SafeDictionary<uint, DetainedItem>();
  288. client.Spells = new SafeDictionary<ushort, ISkill>();
  289. client.Proficiencies = new SafeDictionary<ushort, IProf>();
  290. client.Partners = new SafeDictionary<uint, Game.ConquerStructures.Society.TradePartner>();
  291. client.Apprentices = new SafeDictionary<uint, Game.ConquerStructures.Society.Apprentice>();
  292.  
  293. if (Player.Proficiencies.Count > 0)
  294. client.Proficiencies = Player.Proficiencies;
  295.  
  296. if (Player.Spells.Count > 0)
  297. client.Spells = Player.Spells;
  298.  
  299. if (Player.Items.Count > 0)
  300. {
  301. foreach (var item in Player.Items.Values)
  302. {
  303. item.UID = item.UID + Server.Key;
  304. if (item.Purification.Available)
  305. {
  306. var ps = item.Purification;
  307. ps.ItemUID = item.UID;
  308. item.Purification = ps;
  309. }
  310. if (item.ExtraEffect.Available)
  311. {
  312. var ps = item.ExtraEffect;
  313. ps.ItemUID = item.UID;
  314. item.ExtraEffect = ps;
  315. }
  316. if (item.Inscribed)
  317. {
  318. int arsenalRealPosition = PacketHandler.ArsenalPosition(item.ID);
  319. if ((item.ID % 10) >= 8 && !item.Inscribed)
  320. {
  321. if (client.Entity.GuildID != 0 && client.Guild != null && client.Guild.Arsenals[arsenalRealPosition].Unlocked)
  322. {
  323. item.Inscribed = true;
  324. item.Mode = Game.Enums.ItemMode.Update;
  325. item.Send(client);
  326. var Arsenal = client.Guild.Arsenals[arsenalRealPosition];
  327. Arsenal.AddItem(item, client);
  328. client.Guild.SaveArsenal();
  329. }
  330. }
  331.  
  332. }
  333. if (item.InWardRobe)
  334. {
  335. client.WardRobe.Load(item);
  336. continue;
  337. }
  338. switch (item.Position)
  339. {
  340. case 0: client.Inventory.Add(item, Game.Enums.ItemUse.None); break;
  341. default:
  342. if (item.Position > 40) { client.Inventory.Add(item, Game.Enums.ItemUse.None); break; }
  343. //if (item.InWardRobe)
  344. //{
  345. // client.WardRobe.Load(item);
  346. // break;
  347. //}
  348. if (client.Equipment.Free((byte)item.Position))
  349. client.Equipment.Add(item, Game.Enums.ItemUse.None);
  350. else
  351. {
  352. if (client.Inventory.Count < 40)
  353. {
  354. item.Position = 0;
  355. client.Inventory.Add(item, Game.Enums.ItemUse.None);
  356. if (client.Warehouses[Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.Market].Count < 20)
  357. client.Warehouses[Conquer_Online_Server.Game.ConquerStructures.Warehouse.WarehouseID.Market].Add(item);
  358.  
  359. }
  360. }
  361. break;
  362. }
  363. //client.WardRobe.Equip(client.WardRobe.MyGarment.UID, ConquerItem.Garment);
  364. //client.WardRobe.Equip(client.WardRobe.MySteedArmor.UID, ConquerItem.SteedArmor);
  365. }
  366. }
  367.  
  368. Conquer_Online_Server.Client.GameState aClient = null;
  369. if (Kernel.GamePool.TryGetValue(client.Account.EntityID, out aClient))
  370. aClient.Disconnect();
  371. Kernel.GamePool.Remove(client.Account.EntityID);
  372. Kernel.GamePool.Add(client.Account.EntityID, client);
  373.  
  374.  
  375. // client.Send(new Message("ANSWER_OK", "ALLUSERS", System.Drawing.Color.Orange, Message.Dialog));
  376. Program.World.Register(client);
  377. Kernel.GamePool[client.Account.EntityID] = client;
  378.  
  379. Kernel.TransferPool.Remove(client.Account.EntityID);
  380. // client.Send(new CharacterInfo(client));
  381. string IP = client.IP;
  382. if (!client.LoggedIn)
  383. Console.WriteLine("[TransferdPlayer]" + client.Entity.Name + " has logged on! Ip:[" + client.Account.IP + "]");
  384.  
  385. client.LoggedIn = true;
  386. client.Action = 2;
  387. client.Entity.ServerID = Server.ID;
  388. client.Entity.CUID = mainid;
  389. // client.Entity.UID = (uint.MaxValue - client.Entity.UID);
  390. byte[] tets = new byte[16 + 8];
  391. Writer.Ushort(16, 0, tets);
  392. Writer.Ushort(2501, 2, tets);
  393. Writer.Uint(client.Entity.CUID, 8, tets);
  394. Writer.Uint(client.Entity.UID, 12, tets);
  395. client.Send(tets);
  396.  
  397. _String str = new _String(true);
  398. str.Type = 61;
  399. str.Texts.Add(Constants.ServerName);
  400. client.Send(str);
  401.  
  402. client.Send(new Data(true) { UID = client.Entity.UID, ID = Network.GamePackets.Data.ChangePKMode, dwParam = (uint)Enums.PKMode.CS });
  403.  
  404. if (client.Guild != null)
  405. client.Guild.SendGuild(client);
  406.  
  407. }
  408. }
  409. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement