PageRenderTime 39ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/Trunk/WorldServer/Packets/Server/System.cs

http://aioncxx.codeplex.com
C# | 235 lines | 198 code | 22 blank | 15 comment | 8 complexity | 733a4d633d2700c3fe157725fed88a79 MD5 | raw file
  1. /* Copyright (c) 2011-2012, Zetatron Consulting
  2. All rights reserved.
  3. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  4. * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  5. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  6. * Neither the name of Zetatron Consulting nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  7. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  8. */
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using AionCxxLibrary.Packets;
  14. using AionCxxLibrary.Network;
  15. using AionCxxLibrary.Utilities;
  16. using AionCxxLibrary.Enums;
  17. using System.Net;
  18. using System.Configuration;
  19. using WorldServer.Services;
  20. using WorldServer.Models;
  21. namespace WorldServer.Packets.Server
  22. {
  23. public class SPkt_CryptKey : AionServerPacket
  24. {
  25. public override void WritePacket()
  26. {
  27. WorldConnection con = (WorldConnection)Connection;
  28. int key = ((WorldCrypter)con.Crypter)._crypt.enableKey();
  29. WriteInt(key);
  30. }
  31. }
  32. public class SPkt_ServerVersion : AionServerPacket
  33. {
  34. public override void WritePacket()
  35. {
  36. WriteByte(0);
  37. WriteByte(2); // ServerID
  38. WriteInt(0x01b1b1);
  39. WriteInt(0x01b1aa);
  40. WriteInt(0);
  41. WriteInt(0x01b21a);
  42. WriteInt(0x4edf6585);
  43. WriteByte(0);
  44. WriteByte(2); // CountryCode
  45. WriteByte(0);
  46. WriteByte(1); // Server Mode
  47. WriteInt((int)Utility.DateTimeToTimestamp(DateTime.Now));
  48. WriteShort(0x15e);
  49. WriteShort(0xa01);
  50. WriteShort(0xa01);
  51. WriteShort(0x370a);
  52. WriteShort(2);
  53. WriteByte(0x14);
  54. WriteByte(1);
  55. WriteInt(0);
  56. WriteByte(1);
  57. WriteShort(0);
  58. WriteBytes(Utility.IPAddressToByteArray("188.165.229.196"));
  59. WriteShort(10241);
  60. }
  61. }
  62. public class SPkt_Login : AionServerPacket
  63. {
  64. public override void WritePacket()
  65. {
  66. WriteInt(Connection.account == null ? 1 : 0);
  67. WriteString(Connection.account == null ? "" : Connection.account.Name.ToLower());
  68. }
  69. }
  70. public class SPkt_Time : AionServerPacket
  71. {
  72. int time;
  73. public SPkt_Time(int clienttime)
  74. {
  75. time = clienttime;
  76. }
  77. public override void WritePacket()
  78. {
  79. int now = (int)Utility.CurrentMillis();
  80. WriteInt(now); // Server Time
  81. WriteInt(time); // Client Time
  82. Log.Debug("Client Time " + time + " Server " + now);
  83. }
  84. }
  85. public class SPkt_AtreiaClock : AionServerPacket
  86. {
  87. public override void WritePacket()
  88. {
  89. WriteInt((int)(Utility.DateTimeToTimestamp(DateTime.Now) / 10000));
  90. }
  91. }
  92. public class SPkt_ChooseServer : AionServerPacket
  93. {
  94. int key;
  95. public SPkt_ChooseServer(int reconnectKey)
  96. {
  97. key = reconnectKey;
  98. }
  99. public override void WritePacket()
  100. {
  101. WriteByte(0);
  102. WriteInt(key);
  103. }
  104. }
  105. public class SPkt_KeepAlive : AionServerPacket
  106. {
  107. public override void WritePacket()
  108. {
  109. WriteShort(0);
  110. }
  111. }
  112. public class SPkt_EnterWorldCheck : AionServerPacket
  113. {
  114. public override void WritePacket()
  115. {
  116. WriteInt(0);
  117. }
  118. }
  119. public class SPkt_EnterWorldAccepted : AionServerPacket
  120. {
  121. public override void WritePacket()
  122. {
  123. WriteShort(0);
  124. WriteByte(0);
  125. }
  126. }
  127. public class SPkt_ClientSettings : AionServerPacket
  128. {
  129. byte type;
  130. byte[] data;
  131. public SPkt_ClientSettings(byte type, byte[] data)
  132. {
  133. this.type = type;
  134. this.data = data;
  135. }
  136. public override void WritePacket()
  137. {
  138. WriteShort(type);
  139. WriteByte(0x1c);
  140. WriteBytes(data);
  141. }
  142. }
  143. public class SPkt_WorldQuit : AionServerPacket
  144. {
  145. bool plasticSurgery;
  146. public SPkt_WorldQuit(bool GoingToPlasticSurgery)
  147. {
  148. plasticSurgery = GoingToPlasticSurgery;
  149. }
  150. public override void WritePacket()
  151. {
  152. WriteInt(plasticSurgery ? 2 : 1);
  153. WriteByte(0);
  154. }
  155. }
  156. public class SPkt_UIQuestion : AionServerPacket
  157. {
  158. int sender;
  159. int message;
  160. object[] parameters;
  161. public SPkt_UIQuestion(int senderId, int messageId, params object[] parameters)
  162. {
  163. this.sender = senderId;
  164. this.message = messageId;
  165. this.parameters = parameters;
  166. }
  167. public override void WritePacket()
  168. {
  169. WriteInt(message);
  170. foreach (object p in parameters)
  171. {
  172. if (p is AionDescription)
  173. {
  174. WriteShort(0x24);
  175. WriteInt((p as AionDescription).DescriptionID);
  176. WriteShort(0);
  177. }
  178. else
  179. WriteString(p.ToString());
  180. }
  181. // Guardian Stone Activation Window
  182. if (message == 160027)
  183. {
  184. WriteLong(0);
  185. WriteLong(0);
  186. WriteInt(0);
  187. WriteShort(0);
  188. WriteByte(0);
  189. }
  190. // Artifact Activation Window
  191. else if (message == 160028)
  192. {
  193. WriteLong(0);
  194. WriteLong(0);
  195. WriteShort(0);
  196. WriteByte(0);
  197. }
  198. else
  199. {
  200. WriteInt(0);
  201. WriteShort(0);
  202. WriteByte(1);
  203. WriteInt(sender);
  204. WriteInt(6);
  205. }
  206. }
  207. }
  208. }