PageRenderTime 224ms CodeModel.GetById 111ms app.highlight 10ms RepoModel.GetById 100ms 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
  2All rights reserved.
  3
  4Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  5
  6* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  7
  8* 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.
  9
 10* 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.
 11
 12THIS 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.
 13*/
 14using System;
 15using System.Collections.Generic;
 16using System.Linq;
 17using System.Text;
 18using AionCxxLibrary.Packets;
 19using AionCxxLibrary.Network;
 20using AionCxxLibrary.Utilities;
 21using AionCxxLibrary.Enums;
 22using System.Net;
 23using System.Configuration;
 24using WorldServer.Services;
 25using WorldServer.Models;
 26
 27namespace WorldServer.Packets.Server
 28{
 29    public class SPkt_CryptKey : AionServerPacket
 30    {
 31        public override void WritePacket()
 32        {
 33            WorldConnection con = (WorldConnection)Connection;
 34            int key = ((WorldCrypter)con.Crypter)._crypt.enableKey();
 35            WriteInt(key);
 36        }
 37    }
 38
 39    public class SPkt_ServerVersion : AionServerPacket
 40    {
 41        public override void WritePacket()
 42        {
 43            WriteByte(0);
 44            WriteByte(2); // ServerID
 45            WriteInt(0x01b1b1);
 46            WriteInt(0x01b1aa);
 47            WriteInt(0);
 48            WriteInt(0x01b21a);
 49            WriteInt(0x4edf6585);
 50            WriteByte(0);
 51            WriteByte(2); // CountryCode
 52            WriteByte(0);
 53            WriteByte(1); // Server Mode
 54            WriteInt((int)Utility.DateTimeToTimestamp(DateTime.Now));
 55            WriteShort(0x15e);
 56            WriteShort(0xa01);
 57            WriteShort(0xa01);
 58            WriteShort(0x370a);
 59            WriteShort(2);
 60            WriteByte(0x14);
 61            WriteByte(1);
 62            WriteInt(0);
 63            WriteByte(1);
 64            WriteShort(0);
 65
 66            WriteBytes(Utility.IPAddressToByteArray("188.165.229.196"));
 67            WriteShort(10241);
 68        }
 69    }
 70
 71    public class SPkt_Login : AionServerPacket
 72    {
 73        public override void WritePacket()
 74        {
 75            WriteInt(Connection.account == null ? 1 : 0);
 76            WriteString(Connection.account == null ? "" : Connection.account.Name.ToLower());
 77        }
 78    }
 79
 80    public class SPkt_Time : AionServerPacket
 81    {
 82        int time;
 83
 84        public SPkt_Time(int clienttime)
 85        {
 86            time = clienttime;
 87        }
 88
 89        public override void WritePacket()
 90        {
 91            int now = (int)Utility.CurrentMillis();
 92            WriteInt(now); // Server Time
 93            WriteInt(time); // Client Time
 94            Log.Debug("Client Time " + time + " Server " + now);
 95        }
 96    }
 97
 98    public class SPkt_AtreiaClock : AionServerPacket
 99    {
100        public override void WritePacket()
101        {
102            WriteInt((int)(Utility.DateTimeToTimestamp(DateTime.Now) / 10000));
103        }
104    }
105
106    public class SPkt_ChooseServer : AionServerPacket
107    {
108        int key;
109        public SPkt_ChooseServer(int reconnectKey)
110        {
111            key = reconnectKey;
112        }
113        public override void WritePacket()
114        {
115            WriteByte(0);
116            WriteInt(key);
117        }
118    }
119
120    public class SPkt_KeepAlive : AionServerPacket
121    {
122        public override void WritePacket()
123        {
124            WriteShort(0);
125        }
126    }
127
128    public class SPkt_EnterWorldCheck : AionServerPacket
129    {
130        public override void WritePacket()
131        {
132            WriteInt(0);
133        }
134    }
135
136    public  class SPkt_EnterWorldAccepted : AionServerPacket
137    {
138        public override void WritePacket()
139        {
140            WriteShort(0);
141            WriteByte(0);
142        }
143    }
144
145    public class SPkt_ClientSettings : AionServerPacket
146    {
147        byte type;
148        byte[] data;
149
150        public SPkt_ClientSettings(byte type, byte[] data)
151        {
152            this.type = type;
153            this.data = data;
154        }
155
156        public override void WritePacket()
157        {
158            WriteShort(type);
159            WriteByte(0x1c);
160            WriteBytes(data);
161        }
162    }
163
164    public class SPkt_WorldQuit : AionServerPacket
165    {
166        bool plasticSurgery;
167
168        public SPkt_WorldQuit(bool GoingToPlasticSurgery)
169        {
170            plasticSurgery = GoingToPlasticSurgery;
171        }
172
173        public override void WritePacket()
174        {
175            WriteInt(plasticSurgery ? 2 : 1);
176            WriteByte(0);
177        }
178    }
179
180    public class SPkt_UIQuestion : AionServerPacket
181    {
182        int sender;
183        int message;
184        object[] parameters;
185        public SPkt_UIQuestion(int senderId, int messageId, params object[] parameters)
186        {
187            this.sender = senderId;
188            this.message = messageId;
189            this.parameters = parameters;
190        }
191
192        public override void WritePacket()
193        {
194            WriteInt(message);
195            foreach (object p in parameters)
196            {
197                if (p is AionDescription)
198                {
199                    WriteShort(0x24);
200                    WriteInt((p as AionDescription).DescriptionID);
201                    WriteShort(0);
202                }
203                else
204                    WriteString(p.ToString());
205            }
206            // Guardian Stone Activation Window
207            if (message == 160027)
208            {
209                WriteLong(0);
210                WriteLong(0);
211                WriteInt(0);
212                WriteShort(0);
213                WriteByte(0);
214            }
215            // Artifact Activation Window
216            else if (message == 160028)
217            {
218                WriteLong(0);
219                WriteLong(0);
220                WriteShort(0);
221                WriteByte(0);
222            }
223            else
224            {
225                WriteInt(0);
226                WriteShort(0);
227                WriteByte(1);
228                WriteInt(sender);
229                WriteInt(6);
230            }
231        }
232
233    }
234
235}