/// <summary>
        /// Send information about this CityServer to the LoginServer...
        /// </summary>
        /// <param name="Client">The client connected to the LoginServer.</param>
        public static void SendServerInfo(NetworkClient Client)
        {
            PacketStream Packet = new PacketStream(0x64, 0);
            Packet.WriteByte(0x64);

            MemoryStream PacketBody = new MemoryStream();
            BinaryWriter PacketWriter = new BinaryWriter(PacketBody);

            PacketWriter.Write((string)GlobalSettings.Default.CityName);
            PacketWriter.Write((string)GlobalSettings.Default.CityDescription);
            PacketWriter.Write((string)Settings.BINDING.Address.ToString());
            PacketWriter.Write((int)Settings.BINDING.Port);
            PacketWriter.Write((byte)1); //CityInfoStatus.OK
            PacketWriter.Write((ulong)GlobalSettings.Default.CityThumbnail);
            PacketWriter.Write((string)GlobalSettings.Default.ServerID);
            PacketWriter.Write((ulong)GlobalSettings.Default.Map);
            PacketWriter.Flush();

            Packet.WriteUInt16((ushort)(PacketBody.ToArray().Length + PacketHeaders.UNENCRYPTED));

            Packet.Write(PacketBody.ToArray(), 0, (int)PacketWriter.BaseStream.Length);
            Packet.Flush();

            PacketWriter.Close();

            Client.Send(Packet.ToArray());
        }
Ejemplo n.º 2
0
        public static void HandleChallengeResponse(NetworkClient Client, ProcessedPacket P)
        {
            PacketStream OutPacket;

            if (P.DecryptedSuccessfully)
            {
                int Length = P.ReadByte();
                byte[] CResponse;

                if (P.BufferLength >= Length)
                    CResponse = P.ReadBytes(Length);
                else
                {
                    //Authentication failed, so send this packet unencrypted.
                    OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE_CITY, 0);
                    OutPacket.WriteHeader();
                    OutPacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + 1));
                    OutPacket.WriteByte(0x03); //Bad challenge response.
                    Client.Send(OutPacket.ToArray());

                    Logger.LogInfo("Sent LOGIN_FAILURE_CITY!");
                    return;
                }

                AESDecryptionArgs DecryptionArgs = Client.ClientEncryptor.GetDecryptionArgsContainer().AESDecryptArgs;

                if (DecryptionArgs.Challenge.SequenceEqual(CResponse))
                {
                    OutPacket = new PacketStream((byte)PacketType.LOGIN_SUCCESS_CITY, 0);
                    OutPacket.WriteByte(0x01);
                    Client.SendEncrypted((byte)PacketType.LOGIN_SUCCESS_CITY, OutPacket.ToArray());

                    Logger.LogInfo("Sent LOGIN_SUCCESS_CITY!");
                }
                else
                {
                    //Authentication failed, so send this packet unencrypted.
                    OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE_CITY, 0);
                    OutPacket.WriteHeader();
                    OutPacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + 1));
                    OutPacket.WriteByte(0x03); //Bad challenge response.
                    Client.Send(OutPacket.ToArray());

                    Logger.LogInfo("Sent LOGIN_FAILURE_CITY!");
                }
            }
            else
            {
                //Authentication failed, so send this packet unencrypted.
                OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE_CITY, 0);
                OutPacket.WriteHeader();
                OutPacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + 1));
                OutPacket.WriteByte(0x03); //Bad challenge response.
                Client.Send(OutPacket.ToArray());

                Debug.WriteLine("HandleChallengeResponse - decryption failed!");
                Logger.LogInfo("Sent LOGIN_FAILURE_CITY!");
            }
        }
 /// <summary>
 /// Requests a token from the LoginServer, that can be used to log into a CityServer.
 /// </summary>
 /// <param name="Client">A NetworkClient instance.</param>
 public static void RequestCityToken(NetworkClient Client)
 {
     PacketStream Packet = new PacketStream((byte)PacketType.REQUEST_CITY_TOKEN, 0);
     Packet.WriteHeader();
     Packet.WriteByte((byte)PacketHeaders.ENCRYPTED + 2);
     Packet.WriteByte(0x01); //Dummy
     Client.SendEncrypted((byte)PacketType.CITY_TOKEN, Packet.ToArray());
 }
Ejemplo n.º 4
0
 public Handler(TcpClient tcpClient, Main main)
 {
     this.main = main;
     this.tcpClient = tcpClient;
     this.packetStream = new PacketStream(tcpClient, false);
     Thread thread = new Thread(new ThreadStart(Work));
     thread.Start();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Requests a token from the LoginServer, that can be used to log into a CityServer.
 /// </summary>
 /// <param name="Client">A NetworkClient instance.</param>
 public static void RequestCityToken(NetworkClient Client, Sim SelectedCharacter)
 {
     PacketStream Packet = new PacketStream((byte)PacketType.REQUEST_CITY_TOKEN, 0);
     Packet.WritePascalString(Client.ClientEncryptor.Username);
     Packet.WritePascalString(SelectedCharacter.ResidingCity.UUID);
     Packet.WritePascalString(SelectedCharacter.GUID.ToString());
     Client.SendEncrypted((byte)PacketType.REQUEST_CITY_TOKEN, Packet.ToArray());
 }
Ejemplo n.º 6
0
        public void TestEmptyPacketStreamPushEmptyData()
        {
            PacketStream stream = new PacketStream();

            stream.Push(new byte[0], 0);

            Assert.AreEqual(0, stream.Data.Length);
        }
Ejemplo n.º 7
0
        public void TestEmptyPacketStreamPushNullData()
        {
            PacketStream stream = new PacketStream();

            stream.Push(null, 0);

            Assert.AreEqual(0, stream.Data.Length);
        }
Ejemplo n.º 8
0
        public override MemoryStream DecryptPacket(PacketStream EncryptedPacket, DecryptionArgsContainer DecryptionArgs)
        {
            CryptoStream CStream = new CryptoStream(EncryptedPacket, m_DecryptTransformer, CryptoStreamMode.Read);

            byte[] DecryptedBuffer = new byte[DecryptionArgs.UnencryptedLength];
            CStream.Read(DecryptedBuffer, 0, DecryptedBuffer.Length);

            return new MemoryStream(DecryptedBuffer);
        }
Ejemplo n.º 9
0
        public void TestEmptyPacketStreamPush()
        {
            PacketStream stream = new PacketStream();

            stream.Push(new byte[] { 0x01 }, 1);

            Assert.AreEqual(1, stream.Data.Length);
            Assert.AreEqual(0x01, stream.Data[0]);
        }
Ejemplo n.º 10
0
 public ClientState(PacketStream InStream)
 {
     this.InStream = InStream;
     FileStream datFile = new FileStream("./Tibia.dat", FileMode.Open);
     FileStream sprFile = new FileStream("./Tibia.spr", FileMode.Open);
     GameData = new TibiaGameData(datFile, sprFile);
     Protocol = new TibiaGameProtocol(GameData);
     Viewport = new ClientViewport(GameData, Protocol);
 }
Ejemplo n.º 11
0
        public Client(Server server, Socket clientSocket)
        {
            Server = server;
            ClientSocket = clientSocket;
            RemoteEP = (IPEndPoint)ClientSocket.RemoteEndPoint;

            Player = new Player();

            BaseStream = new NetworkStream(ClientSocket);
            Stream = new PacketStream(BaseStream);
        }
Ejemplo n.º 12
0
        public static void TrimStream(ref ConanStream stream)
        {
            if (stream.Position == stream.Length)
            {
                stream = new PacketStream();
                return;
            }

            var remaining = new byte[stream.Length - stream.Position];
            stream.Read(remaining, 0, remaining.Length);
            stream = new ConanStream(remaining);
        }
Ejemplo n.º 13
0
        public void TestAllDataPacketStreamShift()
        {
            PacketStream stream = new PacketStream() {
                Data = new byte[] { 0x01, 0x02, 0x03, 0x04 }
            };

            byte[] data = stream.Shift(4);

            Assert.AreEqual(0x01, data[0]);
            Assert.AreEqual(0x02, data[1]);
            Assert.AreEqual(0x03, data[2]);
            Assert.AreEqual(0x04, data[3]);
            Assert.AreEqual(0, stream.Data.Length);
        }
        /// <summary>
        /// A cityserver logged in!
        /// </summary>
        public static void HandleCityServerLogin(NetworkClient Client, ProcessedPacket P)
        {
            Logger.LogInfo("CityServer logged in!\r\n");

            string Name = P.ReadString();
            string Description = P.ReadString();
            string IP = P.ReadString();
            int Port = P.ReadInt32();
            CityInfoStatus Status = (CityInfoStatus)P.ReadByte();
            ulong Thumbnail = P.ReadUInt64();
            string UUID = P.ReadString();
            ulong Map = P.ReadUInt64();

            CityInfo Info = new CityInfo(true);
            Info.Name = Name;
            Info.Description = Description;
            Info.IP = IP;
            Info.Port = Port;
            Info.Status = Status;
            Info.Thumbnail = Thumbnail;
            Info.UUID = UUID;
            Info.Map = Map;
            Info.Client = Client;
            Info.Online = true;

            NetworkFacade.CServerListener.CityServers.Add(Info);
            NetworkFacade.CServerListener.PotentialLogins.TryTake(out Client);

            NetworkClient[] Clients = new NetworkClient[NetworkFacade.ClientListener.Clients.Count];
            NetworkFacade.ClientListener.Clients.CopyTo(Clients, 0);

            PacketStream ClientPacket = new PacketStream((byte)PacketType.NEW_CITY_SERVER, 0);
            ClientPacket.WriteString(Name);
            ClientPacket.WriteString(Description);
            ClientPacket.WriteString(IP);
            ClientPacket.WriteInt32(Port);
            ClientPacket.WriteByte((byte)Status);
            ClientPacket.WriteUInt64(Thumbnail);
            ClientPacket.WriteString(UUID);
            ClientPacket.WriteUInt64(Map);

            foreach(NetworkClient Receiver in Clients)
                Receiver.SendEncrypted((byte)PacketType.NEW_CITY_SERVER, ClientPacket.ToArray());
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Sends a CharacterCreate packet to the LoginServer.
        /// </summary>
        /// <param name="Character">The character to create.</param>
        /// <param name="TimeStamp">The timestamp of when this character was created.</param>
        public static void SendCharacterCreate(TSOClient.VM.Sim Character, string TimeStamp)
        {
            PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_CREATE, 0);
            Packet.WritePascalString(PlayerAccount.Client.ClientEncryptor.Username);
            Packet.WritePascalString(TimeStamp);
            Packet.WritePascalString(Character.Name);
            Packet.WritePascalString(Character.Sex);
            Packet.WritePascalString(Character.Description);
            Packet.WriteUInt64(Character.HeadOutfitID);
            Packet.WriteUInt64(Character.BodyOutfitID);
            Packet.WriteByte((byte)Character.AppearanceType);

            Packet.WritePascalString(Character.ResidingCity.Name);
            Packet.WriteUInt64(Character.ResidingCity.Thumbnail);
            Packet.WritePascalString(Character.ResidingCity.UUID);
            Packet.WriteUInt64(Character.ResidingCity.Map);
            Packet.WritePascalString(Character.ResidingCity.IP);
            Packet.WriteInt32(Character.ResidingCity.Port);

            byte[] PacketData = Packet.ToArray();
            PlayerAccount.Client.SendEncrypted((byte)PacketType.CHARACTER_CREATE, PacketData);
        }
        public override void Read(PacketStream stream)
        {
            var name = stream.ReadString();

            _log.Warn("CSDeleteBlockedUserPacket, {0}", name);
        }
Ejemplo n.º 17
0
 public override PacketStream Write(PacketStream stream)
 {
     return(_character.Write(stream));
 }
Ejemplo n.º 18
0
 public override PacketStream Write(PacketStream stream)
 {
     stream.Write(_characterId);
     return(stream);
 }
Ejemplo n.º 19
0
        public void TestSinglePacketStreamPeekShift()
        {
            PacketStream stream = new PacketStream() {
                Data = new byte[] {0x01, 0x02, 0x03, 0x04}
            };

            Assert.AreEqual(0x01, stream.PeekShift(1).First());
            Assert.AreEqual(4, stream.Data.Length);
            Assert.AreEqual(0x01, stream.Data[0]);
            Assert.AreEqual(0x02, stream.Data[1]);
            Assert.AreEqual(0x03, stream.Data[2]);
            Assert.AreEqual(0x04, stream.Data[3]);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Client requested information about its characters.
        /// </summary>
        public static void HandleCharacterInfoRequest(NetworkClient Client, ProcessedPacket P)
        {
            Logger.LogInfo("Received CharacterInfoRequest!");

            string DateTimeStr = P.ReadString();
            DateTime Timestamp;

            if (DateTimeStr != string.Empty)
                Timestamp = DateTime.Parse(DateTimeStr);
            else
            {
                //Unix epoch
                Timestamp = new DateTime(1970, 1, 1, 0, 0, 1);
            }

            Character[] Characters = new Character[] { };

            using (var db = DataAccess.Get())
            {
                var account = db.Accounts.GetByUsername(Client.ClientEncryptor.Username);
                Characters = db.Characters.GetForAccount((int)account.AccountID).ToArray();
            }

            int NumChars = 0, NewChars = 0;

            if (Characters != null)
            {
                PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_LIST, 0);
                MemoryStream PacketData = new MemoryStream();
                BinaryWriter PacketWriter = new BinaryWriter(PacketData);

                NumChars = Characters.Length;

                foreach (Character avatar in Characters)
                {
                    //Zero means same, less than zero means T1 is earlier than T2, more than zero means T1 is later.
                    if (DateTime.Compare(Timestamp, avatar.LastCached) < 0)
                    {
                        NewChars++;

                        PacketWriter.Write((int)avatar.CharacterID);
                        PacketWriter.Write(avatar.GUID.ToString());
                        PacketWriter.Write(avatar.LastCached.ToString("yyyy.MM.dd hh:mm:ss",
                            CultureInfo.InvariantCulture));
                        PacketWriter.Write(avatar.Name);
                        PacketWriter.Write(avatar.Sex);
                        PacketWriter.Write(avatar.Description);
                        PacketWriter.Write((ulong)avatar.HeadOutfitID);
                        PacketWriter.Write((ulong)avatar.BodyOutfitID);
                        PacketWriter.Write((byte)avatar.AppearanceType);
                        PacketWriter.Write((string)avatar.CityName);
                        PacketWriter.Write((ulong)avatar.CityThumb);
                        PacketWriter.Write((string)avatar.City);
                        PacketWriter.Write((ulong)avatar.CityMap);
                        PacketWriter.Write((string)avatar.CityIp);
                        PacketWriter.Write((int)avatar.CityPort);
                        PacketWriter.Write((int)avatar.Money);
                    }
                }

                //NOTE: If Characters != null, but no chars were new, NumChars will be however many characters,
                //      and NewChars will be 0.

                Packet.WriteByte((byte)NumChars);
                Packet.WriteByte((byte)NewChars);
                Packet.Write(PacketData.ToArray(), 0, (int)PacketData.Length);
                PacketWriter.Close();
                Client.SendEncrypted((byte)PacketType.CHARACTER_LIST, Packet.ToArray());
            }
            else //No characters existed for the account.
            {
                PacketStream Packet = new PacketStream(0x05, 0);
                Packet.WriteByte((byte)NumChars); //0 characters.
                Packet.WriteByte((byte)NewChars); //0 new characters.

                Client.SendEncrypted((byte)PacketType.CHARACTER_LIST, Packet.ToArray());
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Client wanted to log in!
        /// </summary>
        public static void HandleLoginRequest(NetworkClient Client, ProcessedPacket P)
        {
            try
            {
                Logger.LogInfo("Received LoginRequest!\r\n");

                byte Version1 = (byte)P.ReadByte();
                byte Version2 = (byte)P.ReadByte();
                byte Version3 = (byte)P.ReadByte();
                byte Version4 = (byte)P.ReadByte();

                string ClientVersion = Version1.ToString() + "." + Version2.ToString() + "." + Version3.ToString() +
                    "." + Version4.ToString();

                if (ClientVersion != GlobalSettings.Default.ClientVersion)
                {
                    PacketStream OutPacket = new PacketStream((byte)PacketType.INVALID_VERSION, 2);
                    OutPacket.WriteHeader();
                    OutPacket.WriteByte(0x01);
                    Client.Send(OutPacket.ToArray());

                    Logger.LogInfo("Bad version - sent SInvalidVersion!\r\n");
                    Client.Disconnect();
                    return;
                }

                PacketStream EncryptedPacket = new PacketStream((byte)PacketType.LOGIN_NOTIFY, 0);
                EncryptedPacket.WriteHeader();

                AESEncryptor Enc = (AESEncryptor)Client.ClientEncryptor;

                if (Enc == null)
                    Enc = new AESEncryptor("");

                Enc.PublicKey = P.ReadBytes((P.ReadByte()));
                Enc.NOnce = P.ReadBytes((P.ReadByte()));
                Enc.PrivateKey = NetworkFacade.ServerKey;
                Client.ClientEncryptor = Enc;

                MemoryStream StreamToEncrypt = new MemoryStream();
                BinaryWriter Writer = new BinaryWriter(StreamToEncrypt);
                Writer.Write(Enc.Challenge, 0, Enc.Challenge.Length);
                Writer.Flush();

                byte[] EncryptedData = StaticStaticDiffieHellman.Encrypt(NetworkFacade.ServerKey,
                    System.Security.Cryptography.ECDiffieHellmanCngPublicKey.FromByteArray(Enc.PublicKey,
                    System.Security.Cryptography.CngKeyBlobFormat.EccPublicBlob), Enc.NOnce, StreamToEncrypt.ToArray());

                EncryptedPacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED +
                    (1 + NetworkFacade.ServerPublicKey.Length) +
                    (1 + EncryptedData.Length)));

                EncryptedPacket.WriteByte((byte)NetworkFacade.ServerPublicKey.Length);
                EncryptedPacket.WriteBytes(NetworkFacade.ServerPublicKey);
                EncryptedPacket.WriteByte((byte)EncryptedData.Length);
                EncryptedPacket.WriteBytes(EncryptedData);

                Client.Send(EncryptedPacket.ToArray());
            }
            //This should HOPEFULLY wade off clients sending unreadable (I.E old protocol) packets...
            catch (Exception E)
            {
                Logger.LogDebug("Error while handling login request, disconnecting client: " +
                    E.ToString());
                Client.Disconnect();
                return;
            }
        }
Ejemplo n.º 22
0
 public override PacketStream Write(PacketStream stream)
 {
     stream.Write((uint)_questId);
     return(stream);
 }
        public override void Read(PacketStream stream)
        {
            var id = stream.ReadUInt32();

            Connection.ActiveChar.Appellations.Change(id);
        }
Ejemplo n.º 24
0
 public override PacketStream Write(PacketStream stream)
 {
     stream.Write(_mailId);
     return(stream);
 }
Ejemplo n.º 25
0
 public override PacketStream Write(PacketStream stream)
 {
     stream.Write(_time);
     return(stream);
 }
Ejemplo n.º 26
0
        public override void Read(PacketStream stream)
        {
            var id = stream.ReadUInt32();

            _log.Debug("RequestCharBrief, Id: {0}", id);
        }
 public override PacketStream Write(PacketStream stream)
 {
     stream.Write(_tl);
     stream.Write(_newName);
     return(stream);
 }
 public override void Read(PacketStream stream)
 {
     // Empty struct
     _log.Warn("LeaveTrialAudience");
 }
 public override PacketStream Write(PacketStream stream)
 {
     stream.Write(_moneyAmount);
     return(stream);
 }
Ejemplo n.º 30
0
 public override PacketStream Write(PacketStream stream)
 {
     stream.Write(_emoticonId);
     stream.Write(0);
     return(stream);
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Client created a character!
        /// </summary>
        public static void HandleCharacterCreate(NetworkClient Client, ProcessedPacket P)
        {
            Logger.LogInfo("Received CharacterCreate!");

            string AccountName = SanitizeAccount(P.ReadString());
            //Need to be variable length, because the success packet contains a token.
            PacketStream CCStatusPacket = new PacketStream((byte)PacketType.CHARACTER_CREATION_STATUS, 0);

            using (var db = DataAccess.Get())
            {
                Account Acc = db.Accounts.GetByUsername(AccountName);

                if (Acc.NumCharacters >= 3)
                {
                    CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.ExceededCharacterLimit);
                    Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray());

                    return;
                }

                //TODO: Send GUID to client...
                var Char = new Character();
                string LastCached = P.ReadString();
                if (LastCached == string.Empty)
                {
                    //TODO: Proper error...
                    CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.NameAlreadyExisted);
                    Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray());
                    return;
                }

                Char.LastCached = ProtoHelpers.ParseDateTime(LastCached);
                Char.Name = P.ReadString();
                Char.Sex = P.ReadString();
                Char.Description = P.ReadString();
                Char.GUID = Guid.NewGuid();
                Char.HeadOutfitID = (long)P.ReadUInt64();
                Char.BodyOutfitID = (long)P.ReadUInt64();
                Char.AccountID = Acc.AccountID;
                Char.AppearanceType = P.ReadByte();
                Char.CityName = P.ReadString();
                Char.CityThumb = (long)P.ReadUInt64();
                Char.City = P.ReadString();
                Char.CityMap = (long)P.ReadUInt64();
                Char.CityIp = P.ReadString();
                Char.CityPort = P.ReadInt32();
                Char.Money = NetworkFacade.INITIAL_MONEY;

                //These are going into DB, so be nazi. Sieg heil!
                if (Char.Name == string.Empty || Char.Sex == string.Empty ||
                    Char.Description == string.Empty)
                {
                    CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.NameAlreadyExisted);
                    Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray());
                    return;
                }

                var status = db.Characters.CreateCharacter(Char);

                switch (status)
                {
                    case LoginDataModel.Entities.CharacterCreationStatus.NameAlreadyExisted:
                        CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.NameAlreadyExisted);
                        Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray());
                        break;
                    case LoginDataModel.Entities.CharacterCreationStatus.NameTooLong:
                        CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.NameTooLong);
                        Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray());
                        break;
                    case LoginDataModel.Entities.CharacterCreationStatus.Success:
                        Guid Token = Guid.NewGuid();

                        //This actually updates the record, not sure how.
                        Acc.NumCharacters++;

                        //THIS NEEDS TO HAPPEN FIRST FOR CITY SERVER AUTHENTICATION TO WORK!
                        CityInfo CServer = NetworkFacade.CServerListener.GetCityServer(Char.City);

                        //Just in case...
                        if (CServer != null)
                        {
                            PacketStream CServerPacket = new PacketStream(0x01, 0);
                            CServerPacket.WriteHeader();

                            ushort PacketLength = (ushort)(PacketHeaders.UNENCRYPTED + 1 + 4 + (Client.RemoteIP.Length + 1)
                                + 4 + (Char.GUID.ToString().Length + 1) + (Token.ToString().Length + 1));
                            CServerPacket.WriteUInt16(PacketLength);

                            CServerPacket.WriteByte(1); //CharacterCreate = true
                            CServerPacket.WriteInt32(Acc.AccountID);
                            CServerPacket.WriteString(Client.RemoteIP);
                            CServerPacket.WriteInt32(Client.RemotePort);
                            CServerPacket.WriteString(Char.GUID.ToString());
                            CServerPacket.WriteString(Token.ToString(""));
                            CServer.Client.Send(CServerPacket.ToArray());
                        }

                        CCStatusPacket.WriteByte((int)LoginDataModel.Entities.CharacterCreationStatus.Success);
                        CCStatusPacket.WriteString(Char.GUID.ToString());
                        CCStatusPacket.WriteString(Token.ToString());
                        Client.SendEncrypted(CCStatusPacket.PacketID, CCStatusPacket.ToArray());

                        break;
                }
            }
        }
 public override PacketStream Write(PacketStream stream)
 {
     stream.WriteBc(_id);
     stream.WriteBc(_targetId);
     return(stream);
 }
Ejemplo n.º 33
0
        /// <summary>
        /// Client requested information about a city.
        /// </summary>
        public static void HandleCityInfoRequest(NetworkClient Client, ProcessedPacket P)
        {
            //This packet only contains a dummy byte, don't bother reading it.
            PacketStream Packet = new PacketStream((byte)PacketType.CITY_LIST, 0);
            Packet.WriteByte((byte)NetworkFacade.CServerListener.CityServers.Count);

            if (NetworkFacade.CServerListener.CityServers.Count > 0)
            {
                lock (NetworkFacade.CServerListener.CityServers)
                {
                    foreach (CityInfo CInfo in NetworkFacade.CServerListener.CityServers)
                    {
                        Packet.WriteString(CInfo.Name);
                        Packet.WriteString(CInfo.Description);
                        Packet.WriteString(CInfo.IP);
                        Packet.WriteInt32(CInfo.Port);

                        //Hack (?) to ensure status is written correctly.
                        switch (CInfo.Status)
                        {
                            case CityInfoStatus.Ok:
                                Packet.WriteByte(1);
                                break;
                            case CityInfoStatus.Busy:
                                Packet.WriteByte(2);
                                break;
                            case CityInfoStatus.Full:
                                Packet.WriteByte(3);
                                break;
                            case CityInfoStatus.Reserved:
                                Packet.WriteByte(4);
                                break;
                        }

                        Packet.WriteUInt64(CInfo.Thumbnail);
                        Packet.WriteString(CInfo.UUID);
                        Packet.WriteUInt64(CInfo.Map);
                    }
                }
            }

            Client.SendEncrypted((byte)PacketType.CITY_LIST, Packet.ToArray());
        }
Ejemplo n.º 34
0
        public override void Read(PacketStream stream)
        {
            var memberId = stream.ReadUInt32();

            _log.Debug("FamilyKick, memberId: {0}", memberId);
        }
Ejemplo n.º 35
0
        public override void Read(PacketStream stream)
        {
            var id = stream.ReadUInt32();

            _log.Warn("JoinTrialAudience, Id: {0}", id);
        }
Ejemplo n.º 36
0
        public static void Handle0Xf98E10B3(INetworkClient client, ConanPacket packet)
        {
            var aBuffer = new PacketStream();

            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201c);
            aBuffer.WriteUInt32(0x00000068);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0);
            aBuffer.WriteUInt32(0x00000017);
            aBuffer.WriteUInt32(0x0001e1da);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201c);
            aBuffer.WriteUInt32(0x00000068);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0);
            aBuffer.WriteUInt32(0x00000008);
            aBuffer.WriteUInt32(0xffffffff);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201c);
            aBuffer.WriteUInt32(0x00000068);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0);
            aBuffer.WriteUInt32(0x00000017);
            aBuffer.WriteUInt32(0x0001e1db);
            aBuffer.Send(client);

            var data = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x08, 0x91, 0xc8, 0x80, 0x80, 0xe0, 0xca,
                0xe4, 0xea, 0x20, 0x12, 0x07, 0x08, 0x00, 0x10, 0x81, 0x80, 0x80, 0x20, 0x12, 0x08, 0x08,
                0x08, 0x10, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x12, 0x06, 0x08, 0x17, 0x10, 0xdb, 0xc3, 0x07,
                0x12, 0x04, 0x08, 0x2e, 0x10, 0x07, 0x1a, 0x53, 0x0a, 0x14, 0x0d, 0x79, 0x9b, 0xa3, 0x95,
                0x15, 0x12, 0xcc, 0xbc, 0xaa, 0x1d, 0x57, 0x16, 0x3c, 0x4d, 0x25, 0x63, 0xa0, 0x9f, 0xa1,
                0x12, 0x14, 0x0d, 0x79, 0x9b, 0xa3, 0x95, 0x15, 0x12, 0xcc, 0xbc, 0xaa, 0x1d, 0x57, 0x16,
                0x3c, 0x4d, 0x25, 0x63, 0xa0, 0x9f, 0xa1, 0x1a, 0x14, 0x0d, 0x79, 0x9b, 0xa3, 0x95, 0x15,
                0x12, 0xcc, 0xbc, 0xaa, 0x1d, 0x57, 0x16, 0x3c, 0x4d, 0x25, 0x63, 0xa0, 0x9f, 0xa1, 0x25,
                0x4c, 0xf2, 0x04, 0x00, 0x2d, 0x4c, 0xf2, 0x04, 0x00, 0x38, 0x01, 0x45, 0x4b, 0x59, 0x41,
                0x30, 0x00, 0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2020);
            aBuffer.WriteUInt32(0x00000068);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201c);
            aBuffer.WriteUInt32(0x00000068);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0);
            aBuffer.WriteUInt32(0x00000017);
            aBuffer.WriteUInt32(0x0001e1dc);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201c);
            aBuffer.WriteUInt32(0x00000068);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0);
            aBuffer.WriteUInt32(0x00000008);
            aBuffer.WriteUInt32(0xffffffff);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201c);
            aBuffer.WriteUInt32(0x00000068);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0);
            aBuffer.WriteUInt32(0x00000017);
            aBuffer.WriteUInt32(0x0001e1dd);
            aBuffer.Send(client);

            var data2 = new byte[]
            {
                0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x80, 0x08, 0x92, 0xc8, 0x80, 0x80, 0xe0, 0xca,
                0xe4, 0xea, 0x20, 0x12, 0x07, 0x08, 0x00, 0x10, 0x81, 0x80, 0x80, 0x20, 0x12, 0x08, 0x08,
                0x08, 0x10, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x12, 0x06, 0x08, 0x17, 0x10, 0xdd, 0xc3, 0x07,
                0x12, 0x04, 0x08, 0x2e, 0x10, 0x07, 0x1a, 0x53, 0x0a, 0x14, 0x0d, 0xbc, 0x59, 0x3a, 0x99,
                0x15, 0x13, 0x29, 0x69, 0x02, 0x1d, 0xcf, 0x54, 0x5f, 0x7a, 0x25, 0xa9, 0x3d, 0x47, 0x9d,
                0x12, 0x14, 0x0d, 0xbc, 0x59, 0x3a, 0x99, 0x15, 0x13, 0x29, 0x69, 0x02, 0x1d, 0xcf, 0x54,
                0x5f, 0x7a, 0x25, 0xa9, 0x3d, 0x47, 0x9d, 0x1a, 0x14, 0x0d, 0xbc, 0x59, 0x3a, 0x99, 0x15,
                0x13, 0x29, 0x69, 0x02, 0x1d, 0xcf, 0x54, 0x5f, 0x7a, 0x25, 0xa9, 0x3d, 0x47, 0x9d, 0x25,
                0xe3, 0xf1, 0x04, 0x00, 0x2d, 0xe3, 0xf1, 0x04, 0x00, 0x38, 0x01, 0x45, 0x4f, 0x47, 0x53,
                0x4c, 0x00, 0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2020);
            aBuffer.WriteUInt32(0x00000068);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data2);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201c);
            aBuffer.WriteUInt32(0x00000068);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0);
            aBuffer.WriteUInt32(0x00000017);
            aBuffer.WriteUInt32(0x0001e1de);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201c);
            aBuffer.WriteUInt32(0x00000068);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0);
            aBuffer.WriteUInt32(0x00000008);
            aBuffer.WriteUInt32(0xffffffff);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201c);
            aBuffer.WriteUInt32(0x00000068);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0);
            aBuffer.WriteUInt32(0x00000017);
            aBuffer.WriteUInt32(0x0001e1df);
            aBuffer.Send(client);

            var data3 = new byte[]
            {
                0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x7d, 0x08, 0x93, 0xc8, 0x80, 0x80, 0xe0, 0xca,
                0xe4, 0xea, 0x20, 0x12, 0x04, 0x08, 0x00, 0x10, 0x01, 0x12, 0x08, 0x08, 0x08, 0x10, 0xff,
                0xff, 0xff, 0xff, 0x0f, 0x12, 0x06, 0x08, 0x17, 0x10, 0xdf, 0xc3, 0x07, 0x12, 0x04, 0x08,
                0x2e, 0x10, 0x07, 0x1a, 0x53, 0x0a, 0x14, 0x0d, 0x99, 0xbf, 0x60, 0xdd, 0x15, 0xf6, 0x73,
                0x09, 0x76, 0x1d, 0xca, 0xed, 0x49, 0x79, 0x25, 0xd2, 0xc7, 0xed, 0x8d, 0x12, 0x14, 0x0d,
                0x99, 0xbf, 0x60, 0xdd, 0x15, 0xf6, 0x73, 0x09, 0x76, 0x1d, 0xca, 0xed, 0x49, 0x79, 0x25,
                0xd2, 0xc7, 0xed, 0x8d, 0x1a, 0x14, 0x0d, 0x99, 0xbf, 0x60, 0xdd, 0x15, 0xf6, 0x73, 0x09,
                0x76, 0x1d, 0xca, 0xed, 0x49, 0x79, 0x25, 0xd2, 0xc7, 0xed, 0x8d, 0x25, 0x15, 0x4b, 0x33,
                0x00, 0x2d, 0x15, 0x4b, 0x33, 0x00, 0x38, 0x01, 0x45, 0x35, 0x50, 0x55, 0x43, 0x00, 0x00,
                0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2020);
            aBuffer.WriteUInt32(0x00000068);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data3);
            aBuffer.Send(client);

            var data4 = new byte[]
            {
                0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0a, 0x08, 0x9b, 0xc8, 0x02, 0x18,
                0x01, 0x28, 0x08, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04,
                0xf2, 0x4c, 0x00, 0x04, 0xf2, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x30,
                0x41, 0x59, 0x4b, 0x95, 0xa3, 0x9b, 0x79, 0xaa, 0xbc, 0xcc, 0x12, 0x4d, 0x3c, 0x16, 0x57,
                0xa1, 0x9f, 0xa0, 0x63, 0x95, 0xa3, 0x9b, 0x79, 0xaa, 0xbc, 0xcc, 0x12, 0x4d, 0x3c, 0x16,
                0x57, 0xa1, 0x9f, 0xa0, 0x63, 0xb2, 0x90, 0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0xb2, 0x90,
                0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000078);
            aBuffer.WriteUInt32(0x642cd3d6);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data4);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201c);
            aBuffer.WriteUInt32(0x00000065);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0x00000010);
            aBuffer.WriteUInt32(0x00000017);
            aBuffer.WriteUInt32(0x0001e1e1);
            aBuffer.Send(client);

            var data5 = new byte[]
            {
                0x00, 0x10, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0a, 0x08, 0x9b, 0xc8, 0x02, 0x18,
                0x02, 0x28, 0x08, 0x30, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04,
                0xf1, 0xe3, 0x00, 0x04, 0xf1, 0xe3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x4c,
                0x53, 0x47, 0x4f, 0x99, 0x3a, 0x59, 0xbc, 0x02, 0x69, 0x29, 0x13, 0x7a, 0x5f, 0x54, 0xcf,
                0x9d, 0x47, 0x3d, 0xa9, 0x99, 0x3a, 0x59, 0xbc, 0x02, 0x69, 0x29, 0x13, 0x7a, 0x5f, 0x54,
                0xcf, 0x9d, 0x47, 0x3d, 0xa9, 0xb2, 0x90, 0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0xb2, 0x90,
                0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000078);
            aBuffer.WriteUInt32(0x642cd3d6);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data5);
            aBuffer.Send(client);

            var data6 = new byte[]
            {
                0x00, 0x10, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0a, 0x08, 0x9b, 0xc8, 0x02, 0x18,
                0x03, 0x28, 0x08, 0x30, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x33,
                0x4b, 0x15, 0x00, 0x33, 0x4b, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x43,
                0x55, 0x50, 0x35, 0xdd, 0x60, 0xbf, 0x99, 0x76, 0x09, 0x73, 0xf6, 0x79, 0x49, 0xed, 0xca,
                0x8d, 0xed, 0xc7, 0xd2, 0xdd, 0x60, 0xbf, 0x99, 0x76, 0x09, 0x73, 0xf6, 0x79, 0x49, 0xed,
                0xca, 0x8d, 0xed, 0xc7, 0xd2, 0xb2, 0x90, 0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0xb2, 0x90,
                0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000078);
            aBuffer.WriteUInt32(0x642cd3d6);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data6);
            aBuffer.Send(client);

            var data7 = new byte[]
            {
                0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0a, 0x08, 0x9b, 0xc8, 0x02, 0x18,
                0x02, 0x28, 0x08, 0x30, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04,
                0xf1, 0xe3, 0x00, 0x04, 0xf1, 0xe3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x4c,
                0x53, 0x47, 0x4f, 0x99, 0x3a, 0x59, 0xbc, 0x02, 0x69, 0x29, 0x13, 0x7a, 0x5f, 0x54, 0xcf,
                0x9d, 0x47, 0x3d, 0xa9, 0x99, 0x3a, 0x59, 0xbc, 0x02, 0x69, 0x29, 0x13, 0x7a, 0x5f, 0x54,
                0xcf, 0x9d, 0x47, 0x3d, 0xa9, 0xb2, 0x90, 0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0xb2, 0x90,
                0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000078);
            aBuffer.WriteUInt32(0x642cd3d6);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data7);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201c);
            aBuffer.WriteUInt32(0x00000065);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0x00000005);
            aBuffer.WriteUInt32(0x00000017);
            aBuffer.WriteUInt32(0x0001e1e3);
            aBuffer.Send(client);

            var data8 = new byte[]
            {
                0x00, 0x04, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0a, 0x08, 0x9b, 0xc8, 0x02, 0x18,
                0x03, 0x28, 0x08, 0x30, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x12, 0x00, 0x33,
                0x4b, 0x15, 0x00, 0x33, 0x4b, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x43,
                0x55, 0x50, 0x35, 0xdd, 0x60, 0xbf, 0x99, 0x76, 0x09, 0x73, 0xf6, 0x79, 0x49, 0xed, 0xca,
                0x8d, 0xed, 0xc7, 0xd2, 0xdd, 0x60, 0xbf, 0x99, 0x76, 0x09, 0x73, 0xf6, 0x79, 0x49, 0xed,
                0xca, 0x8d, 0xed, 0xc7, 0xd2, 0xb2, 0x90, 0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0xb2, 0x90,
                0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000078);
            aBuffer.WriteUInt32(0x642cd3d6);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data8);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201c);
            aBuffer.WriteUInt32(0x00000065);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0x00000017);
            aBuffer.WriteUInt32(0x0001e1e5);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000015);
            aBuffer.WriteUInt32(0xf98e10b3);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteByte(0);
            aBuffer.WriteUInt32(0x00000360);
            aBuffer.WriteUInt32(0x00000003);
            aBuffer.Send(client);

            var data9 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data9);
            aBuffer.Send(client);

            var data10 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data10);
            aBuffer.Send(client);

            var data11 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data11);
            aBuffer.Send(client);

            var data12 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data12);
            aBuffer.Send(client);

            var data13 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data13);
            aBuffer.Send(client);

            var data14 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data14);
            aBuffer.Send(client);

            var data15 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data15);
            aBuffer.Send(client);

            var data16 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0xbc, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data16);
            aBuffer.Send(client);

            var data17 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data17);
            aBuffer.Send(client);

            var data18 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data18);
            aBuffer.Send(client);

            var data19 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data19);
            aBuffer.Send(client);

            var data20 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data20);
            aBuffer.Send(client);

            var data21 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data21);
            aBuffer.Send(client);

            var data22 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data22);
            aBuffer.Send(client);

            var data23 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data23);
            aBuffer.Send(client);

            var data24 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xd0, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data24);
            aBuffer.Send(client);

            var data25 = new byte[]
            {
                0x00, 0x00, 0x00, 0x6c, 0x00, 0x0b, 0xbc, 0x46, 0x00, 0x0b, 0xbc, 0x46, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x01, 0x4b, 0x4d, 0x39, 0x36, 0xc0, 0xeb, 0xa3, 0x41, 0x80, 0x61,
                0x06, 0xf3, 0x12, 0xb8, 0x35, 0x3e, 0xb3, 0xc3, 0x96, 0x42, 0xc0, 0xeb, 0xa3, 0x41, 0x80,
                0x61, 0x06, 0xf3, 0x12, 0xb8, 0x35, 0x3e, 0xb3, 0xc3, 0x96, 0x42, 0xb2, 0x90, 0x80, 0x5c,
                0x29, 0xe6, 0x27, 0xca, 0xb2, 0x90, 0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0x00, 0x00, 0x00,
                0x01, 0x00, 0x00, 0x00, 0x00, 0x01
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2050);
            aBuffer.WriteArray(data25);
            aBuffer.Send(client);

            var data26 = new byte[]
            {
                0x00, 0x00, 0x00, 0x6d, 0x00, 0x0b, 0xbc, 0x47, 0x00, 0x0b, 0xbc, 0x47, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x01, 0x50, 0x44, 0x42, 0x31, 0x64, 0xa7, 0x64, 0xb9, 0x96, 0xb5,
                0xca, 0xb8, 0xe4, 0x76, 0x7c, 0x76, 0xa7, 0x0d, 0xe4, 0xe7, 0x64, 0xa7, 0x64, 0xb9, 0x96,
                0xb5, 0xca, 0xb8, 0xe4, 0x76, 0x7c, 0x76, 0xa7, 0x0d, 0xe4, 0xe7, 0xb2, 0x90, 0x80, 0x5c,
                0x29, 0xe6, 0x27, 0xca, 0xb2, 0x90, 0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0x00, 0x00, 0x00,
                0x01, 0x00, 0x00, 0x00, 0x00, 0x01
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2050);
            aBuffer.WriteArray(data26);
            aBuffer.Send(client);

            var data27 = new byte[]
            {
                0x00, 0x00, 0x00, 0x70, 0x00, 0x0b, 0xbc, 0x4b, 0x00, 0x0b, 0xbc, 0x4b, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x01, 0x49, 0x31, 0x4b, 0x4b, 0xcd, 0x42, 0x9c, 0xfd, 0x62, 0xf3,
                0x3e, 0x51, 0x4d, 0x49, 0x8e, 0x24, 0xb0, 0x4f, 0x6c, 0xcb, 0xcd, 0x42, 0x9c, 0xfd, 0x62,
                0xf3, 0x3e, 0x51, 0x4d, 0x49, 0x8e, 0x24, 0xb0, 0x4f, 0x6c, 0xcb, 0xb2, 0x90, 0x80, 0x5c,
                0x29, 0xe6, 0x27, 0xca, 0xb2, 0x90, 0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0x00, 0x00, 0x00,
                0x01, 0x00, 0x00, 0x00, 0x00, 0x01
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2050);
            aBuffer.WriteArray(data27);
            aBuffer.Send(client);

            var data28 = new byte[]
            {
                0x00, 0x00, 0x04, 0xe2, 0x00, 0x32, 0x9b, 0x83, 0x00, 0x32, 0x9b, 0x83, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x01, 0x4c, 0x50, 0x4d, 0x58, 0x85, 0x42, 0xef, 0xf0, 0x2c, 0xae,
                0x85, 0x4a, 0xc7, 0x0d, 0x86, 0xcb, 0xeb, 0xf0, 0x6e, 0xcb, 0x85, 0x42, 0xef, 0xf0, 0x2c,
                0xae, 0x85, 0x4a, 0xc7, 0x0d, 0x86, 0xcb, 0xeb, 0xf0, 0x6e, 0xcb, 0xb2, 0x90, 0x80, 0x5c,
                0x29, 0xe6, 0x27, 0xca, 0xb2, 0x90, 0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0x00, 0x00, 0x00,
                0x01, 0x00, 0x00, 0x00, 0x00, 0x01
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2050);
            aBuffer.WriteArray(data28);
            aBuffer.Send(client);

            var data29 = new byte[]
            {
                0x00, 0x00, 0x01, 0x03, 0x00, 0x38, 0x15, 0xc0, 0x00, 0x38, 0x15, 0xc0, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x01, 0x4c, 0x35, 0x56, 0x33, 0x64, 0x01, 0x8d, 0x59, 0x5b, 0xb1,
                0x00, 0x9d, 0x52, 0x74, 0xc5, 0x57, 0x6d, 0x47, 0x45, 0xd4, 0x64, 0x01, 0x8d, 0x59, 0x5b,
                0xb1, 0x00, 0x9d, 0x52, 0x74, 0xc5, 0x57, 0x6d, 0x47, 0x45, 0xd4, 0xb2, 0x90, 0x80, 0x5c,
                0x29, 0xe6, 0x27, 0xca, 0xb2, 0x90, 0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0x00, 0x00, 0x00,
                0x01, 0x00, 0x00, 0x00, 0x00, 0x01
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2050);
            aBuffer.WriteArray(data29);
            aBuffer.Send(client);

            var data30 = new byte[]
            {
                0x00, 0x00, 0x04, 0xe4, 0x00, 0x39, 0xe7, 0x83, 0x00, 0x39, 0xe7, 0x83, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x01, 0x37, 0x30, 0x39, 0x4c, 0x14, 0xbd, 0x51, 0x26, 0x54, 0x6d,
                0xd8, 0x6b, 0x7c, 0x60, 0xbd, 0x85, 0x1f, 0x3f, 0x36, 0xc6, 0x14, 0xbd, 0x51, 0x26, 0x54,
                0x6d, 0xd8, 0x6b, 0x7c, 0x60, 0xbd, 0x85, 0x1f, 0x3f, 0x36, 0xc6, 0xb2, 0x90, 0x80, 0x5c,
                0x29, 0xe6, 0x27, 0xca, 0xb2, 0x90, 0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0x00, 0x00, 0x00,
                0x01, 0x00, 0x00, 0x00, 0x00, 0x01
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2050);
            aBuffer.WriteArray(data30);
            aBuffer.Send(client);

            var data31 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data31);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0xa8bbeb7f);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt16(0x0001);
            aBuffer.WriteUInt32(0x00416544);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0xa8bbeb7f);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt16(0x0001);
            aBuffer.WriteUInt32(0x00416541);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0xa8bbeb7f);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt16(0x0001);
            aBuffer.WriteUInt32(0x00416542);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0xa8bbeb7f);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt16(0x0001);
            aBuffer.WriteUInt32(0x00416548);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0xa8bbeb7f);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt16(0x0001);
            aBuffer.WriteUInt32(0x004165f1);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0xa8bbeb7f);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt16(0x0001);
            aBuffer.WriteUInt32(0x004165ef);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0xa8bbeb7f);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt16(0x0001);
            aBuffer.WriteUInt32(0x00416546);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0xa8bbeb7f);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt16(0x0001);
            aBuffer.WriteUInt32(0x00416545);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0xa8bbeb7f);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt16(0x0001);
            aBuffer.WriteUInt32(0x004165f0);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0xa8bbeb7f);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt16(0x0001);
            aBuffer.WriteUInt32(0x00416547);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0xa8bbeb7f);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt16(0x0001);
            aBuffer.WriteUInt32(0x00416543);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000012);
            aBuffer.WriteUInt32(0xa8bbeb7f);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt16(0x0001);
            aBuffer.WriteUInt32(0x00416549);
            aBuffer.Send(client);

            var data32 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x39, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data32);
            aBuffer.Send(client);

            var data33 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe5, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data33);
            aBuffer.Send(client);

            var data34 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xdb, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data34);
            aBuffer.Send(client);

            var data35 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xdd, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data35);
            aBuffer.Send(client);

            var data36 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x03, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data36);
            aBuffer.Send(client);

            var data37 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x04, 0xc4, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data37);
            aBuffer.Send(client);

            var data38 = new byte[]
            {
                0x00, 0x00, 0x04, 0xe6, 0x00, 0x4b, 0x3e, 0xc8, 0x00, 0x4b, 0x3e, 0xc8, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x01, 0x4c, 0x31, 0x44, 0x53, 0xb3, 0xae, 0xe6, 0xaa, 0x50, 0x9c,
                0xcd, 0x1e, 0xb4, 0xe9, 0xf4, 0xb4, 0x7e, 0xcf, 0xe7, 0xd2, 0xb3, 0xae, 0xe6, 0xaa, 0x50,
                0x9c, 0xcd, 0x1e, 0xb4, 0xe9, 0xf4, 0xb4, 0x7e, 0xcf, 0xe7, 0xd2, 0xb2, 0x90, 0x80, 0x5c,
                0x29, 0xe6, 0x27, 0xca, 0xb2, 0x90, 0x80, 0x5c, 0x29, 0xe6, 0x27, 0xca, 0x00, 0x00, 0x00,
                0x01, 0x00, 0x00, 0x00, 0x00, 0x01
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x2050);
            aBuffer.WriteArray(data38);
            aBuffer.Send(client);

            var data39 = new byte[]
            {
                0x00, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0e, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002d);
            aBuffer.WriteUInt32(0x6b6fd368);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data39);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x00000011);
            aBuffer.WriteUInt32(0x40749b8a);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteByte(1);
            aBuffer.WriteUInt32(0x0000003d);
            aBuffer.Send(client);

            var data40 = new byte[]
            {
                0x00, 0x00, 0x00, 0x07, 0xe2, 0x00, 0x00, 0xcf, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00
            };

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000003a);
            aBuffer.WriteUInt32(0xf508f4c1);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteArray(data40);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender4, GameServerListener.Receiver4, null,
                                0x201b);
            aBuffer.Send(client);

            aBuffer = new PacketStream();
            aBuffer.WriteHeader(GameServerListener.Sender2, GameServerListener.Receiver2, null,
                                0x2000);
            aBuffer.WriteUInt32(0x0000002b);
            aBuffer.WriteUInt32(0x10d27bc0);
            aBuffer.WriteUInt32(0x0000c350);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteByte(0x01);
            aBuffer.WriteUInt32(0x62);
            aBuffer.WriteUInt32(0x0000c79c);
            aBuffer.WriteUInt32(0x00000fab); //map
            aBuffer.WriteUInt32(0);
            aBuffer.WriteUInt32(client.Account.ClientInstance);
            aBuffer.WriteUInt32(0);
            aBuffer.WriteUInt32(0);
            aBuffer.WriteUInt32(0);
            aBuffer.WriteByte(0);
            aBuffer.Send(client);
        }
Ejemplo n.º 37
0
        public override PacketStream Write(PacketStream stream)
        {
            stream.WriteBc(_unit.ObjId);
            stream.Write(_unit.Name);
            stream.Write(_type);
            switch (_type) // UnitOwnerInfo?
            {
            case 0:
                var character = (Character)_unit;
                stream.Write(character.Id); // type(id)
                stream.Write(0L);           // v?
                break;

            case 1:
                var npc = (Npc)_unit;
                stream.WriteBc(npc.ObjId);
                stream.Write(npc.TemplateId); // npc templateId
                stream.Write(0u);             // type(id)
                break;

            case 2:
                var slave = (Slave)_unit;
                stream.Write(0u);               // type(id)
                stream.Write(slave.TlId);       // tl
                stream.Write(slave.TemplateId); // type(id)
                stream.Write(0u);               // type(id)
                break;

            case 3:
                var house = (House)_unit;
                stream.Write(house.TlId);       // tl
                stream.Write(house.TemplateId); // house templateId
                stream.Write(house.BuildStep);  // buildstep
                break;

            case 4:
                var transfer = (Transfer)_unit;
                stream.Write(transfer.TlId);       // tl
                stream.Write(transfer.TemplateId); // transfer templateId
                break;

            case 5:
                var mount = (Mount)_unit;
                stream.Write(mount.TlId);       // tl
                stream.Write(mount.TemplateId); // npc teplateId

                if (mount.Master == null)
                {
                    stream.Write(0);
                }
                else
                {
                    var master = (Character)mount.Master;
                    stream.Write(master.Id);     // characterId (masterId)
                }

                break;

            case 6:               // TODO ?
                stream.Write(0L); // type(id)
                stream.Write(0u); // type(id)
                break;
            }

            stream.Write(_unit.Master?.Name ?? ""); // master

            stream.Write(Helpers.ConvertX(_unit.Position.X));
            stream.Write(Helpers.ConvertY(_unit.Position.Y));
            stream.Write(Helpers.ConvertZ(_unit.Position.Z));
            stream.Write(_unit.Scale);
            stream.Write(_unit.Level);
            stream.Write(_unit.ModelId); // modelRef

            if (_unit is Character)
            {
                var character = (Character)_unit;
                foreach (var item in character.Inventory.Equip)
                {
                    if (item == null)
                    {
                        stream.Write(0);
                    }
                    else
                    {
                        stream.Write(item);
                    }
                }
            }
            else if (_unit is Npc)
            {
                var npc = (Npc)_unit;
                foreach (var item in npc.Equip)
                {
                    if (item is BodyPart)
                    {
                        stream.Write(item.TemplateId);
                    }
                    else if (item != null)
                    {
                        stream.Write(item.TemplateId);
                        stream.Write(0L);
                        stream.Write((byte)0);
                    }
                    else
                    {
                        stream.Write(0);
                    }
                }
            }
            else if (_unit is Slave)
            {
                for (var i = 0; i < 28; i++)
                {
                    stream.Write((ulong)0); // id
                    stream.Write((byte)0);  // grade
                    stream.Write((byte)0);  // flags
                    stream.Write(0);        // stackSize
                    stream.Write((long)0);  // creationTime
                    stream.Write((uint)0);  // lifespanMins
                    stream.Write((uint)0);  // type(id)
                    stream.Write((byte)1);  // worldId
                    stream.Write((ulong)0); // unsecureDateTime
                }
            }
            else
            {
                for (var i = 0; i < 28; i++)
                {
                    stream.Write(0);
                }
            }

            stream.Write(_unit.ModelParams);
            stream.WriteBc(0);
            stream.Write(_unit.Hp * 100); // preciseHealth
            stream.Write(_unit.Mp * 100); // preciseMana
            stream.Write((byte)255);      // point // TODO UnitAttached
//            if (point != 255) // -1
//            {
//                stream.WriteBc(0);
//            }

            if (_unit is Character)
            {
                var character = (Character)_unit;
                if (character.Bonding == null)
                {
                    stream.Write((sbyte)-1); // point
                }
                else
                {
                    stream.Write(character.Bonding);
                }
            }
            else
            {
                stream.Write((sbyte)-1); // point
            }
            // TODO UnitModelPosture
            stream.Write(_modelPostureType); // type
            stream.Write(false);             // isLooted

            switch (_modelPostureType)
            {
            case 1:     // build
                for (var i = 0; i < 2; i++)
                {
                    stream.Write(false);     // door
                }
                for (var i = 0; i < 6; i++)
                {
                    stream.Write(false);     // window
                }
                break;

            case 4:     // npc
                var npc = (Npc)_unit;
                stream.Write(npc.Template.AnimActionId);
                stream.Write(true);     // active
                break;

            case 7:
                stream.Write(0u);    // type(id)
                stream.Write(0f);    // growRate
                stream.Write(0);     // randomSeed
                stream.Write(false); // isWithered
                stream.Write(false); // isHarvested
                break;

            case 8:               // object?
                stream.Write(0f); // pitch
                stream.Write(0f); // yaw
                break;
            }

            stream.Write(_unit.ActiveWeapon);

            if (_unit is Character)
            {
                var character = (Character)_unit;
                stream.Write((byte)character.Skills.Skills.Count);
                foreach (var skill in character.Skills.Skills.Values)
                {
                    stream.Write(skill.Id);
                    stream.Write(skill.Level);
                }

                stream.Write(character.Skills.PassiveBuffs.Count);
                foreach (var buff in character.Skills.PassiveBuffs.Values)
                {
                    stream.Write(buff.Id);
                }
            }
            else
            {
                stream.Write((byte)0); // learnedSkillCount
                stream.Write(0);       // learnedBuffCount
            }

            stream.Write(_unit.Position.RotationX);
            stream.Write(_unit.Position.RotationY);
            stream.Write(_unit.Position.RotationZ);
            stream.Write(_unit.RaceGender);

            if (_unit is Character)
            {
                stream.WritePisc(0, 0, ((Character)_unit).Appellations.ActiveAppellation, 0); // pisc
            }
            else
            {
                stream.WritePisc(0, 0, 0, 0);                  // pisc
            }
            stream.WritePisc(_unit.Faction?.Id ?? 0, 0, 0, 0); // pisc

            if (_unit is Character)
            {
                var character = (Character)_unit;
                var flags     = new BitSet(16);

                if (character.Invisible)
                {
                    flags.Set(5);
                }

                if (character.IdleStatus)
                {
                    flags.Set(13);
                }

                stream.WritePisc(0, 0);            // очки чести полученные в PvP, кол-во убийств в PvP
                stream.Write(flags.ToByteArray()); // flags(ushort)

                /*
                 * 0x01 - 8bit - режим боя
                 * 0x04 - 6bit - невидимость?
                 * 0x08 - 5bit - дуэль
                 * 0x40 - 2bit - gmmode, дополнительно 7 байт
                 * 0x80 - 1bit - дополнительно tl(ushort), tl(ushort), tl(ushort), tl(ushort)
                 * 0x0100 - 16bit - дополнительно 3 байт (bc), firstHitterTeamId(uint)
                 * 0x0400 - 14bit - надпись "Отсутсвует" под именем
                 */
            }
            else
            {
                stream.WritePisc(0, 0);  // pisc
                stream.Write((ushort)0); // flags
            }

            if (_unit is Character)
            {
                var character = (Character)_unit;

                var activeAbilities = character.Abilities.GetActiveAbilities();
                foreach (var ability in character.Abilities.Values)
                {
                    stream.Write(ability.Exp);
                    stream.Write(ability.Order);
                }

                stream.Write((byte)activeAbilities.Count);
                foreach (var ability in activeAbilities)
                {
                    stream.Write((byte)ability);
                }

                stream.WriteBc(0);

                character.VisualOptions.Write(stream, 15);

                stream.Write(1); // premium
            }

            var goodBuffs   = new List <Effect>();
            var badBuffs    = new List <Effect>();
            var hiddenBuffs = new List <Effect>();

            _unit.Effects.GetAllBuffs(goodBuffs, badBuffs, hiddenBuffs);

            stream.Write((byte)goodBuffs.Count); // TODO max 32
            foreach (var effect in goodBuffs)
            {
                stream.Write(effect.Index);
                stream.Write(effect.Template.BuffId);
                stream.Write(effect.SkillCaster);
                stream.Write(0u);                      // type(id)
                stream.Write(effect.Caster.Level);     // sourceLevel
                stream.Write((short)1);                // sourceAbLevel
                stream.Write(effect.Duration);         // totalTime
                stream.Write(effect.GetTimeElapsed()); // elapsedTime
                stream.Write(effect.Tick);             // tickTime
                stream.Write(0);                       // tickIndex
                stream.Write(1);                       // stack
                stream.Write(0);                       // charged
                stream.Write(0u);                      // type(id) -> cooldownSkill
            }

            stream.Write((byte)badBuffs.Count); // TODO max 24
            foreach (var effect in badBuffs)
            {
                stream.Write(effect.Index);
                stream.Write(effect.Template.BuffId);
                stream.Write(effect.SkillCaster);
                stream.Write(0u);                      // type(id)
                stream.Write(effect.Caster.Level);     // sourceLevel
                stream.Write((short)1);                // sourceAbLevel
                stream.Write(effect.Duration);         // totalTime
                stream.Write(effect.GetTimeElapsed()); // elapsedTime
                stream.Write(effect.Tick);             // tickTime
                stream.Write(0);                       // tickIndex
                stream.Write(1);                       // stack
                stream.Write(0);                       // charged
                stream.Write(0u);                      // type(id) -> cooldownSkill
            }

            stream.Write((byte)hiddenBuffs.Count); // TODO max 24
            foreach (var effect in hiddenBuffs)
            {
                stream.Write(effect.Index);
                stream.Write(effect.Template.BuffId);
                stream.Write(effect.SkillCaster);
                stream.Write(0u);                      // type(id)
                stream.Write(effect.Caster.Level);     // sourceLevel
                stream.Write((short)1);                // sourceAbLevel
                stream.Write(effect.Duration);         // totalTime
                stream.Write(effect.GetTimeElapsed()); // elapsedTime
                stream.Write(effect.Tick);             // tickTime
                stream.Write(0);                       // tickIndex
                stream.Write(1);                       // stack
                stream.Write(0);                       // charged
                stream.Write(0u);                      // type(id) -> cooldownSkill
            }

            return(stream);
        }
Ejemplo n.º 38
0
Archivo: RAPI.cs Proyecto: wyrover/ospy
        private void HandleRapiHandshake()
        {
            RAPIConnectionState state = RAPIConnectionState.HANDSHAKE;

            List <PacketSlice> slices = new List <PacketSlice>();
            TransactionNode    parentNode, node;
            string             str;
            UInt32             val;

            // Read and verify the initial request
            UInt32 initialRequest = stream.ReadU32LE(slices);

            if (initialRequest != NOTIFY_INITIAL_HANDSHAKE && initialRequest != NOTIFY_CONNECTION_READY)
            {
                logger.AddMessage("RAPI protocol error, unknown initial request {0}", initialRequest);
                return;
            }

            node             = new TransactionNode((initialRequest == 0) ? "RAPIInitialHandshake" : "RAPIConnectionStart");
            node.Description = node.Name;

            node.AddField("InitialRequest", (initialRequest == NOTIFY_INITIAL_HANDSHAKE) ? "NOTIFY_INITIAL_HANDSHAKE" : "NOTIFY_CONNECTION_READY", "Initial request.", slices);

            // Now it's our turn
            stream = session.GetNextStreamDirection();

            if (initialRequest == NOTIFY_INITIAL_HANDSHAKE)
            {
                UInt32 firstPing = stream.ReadU32LE(slices);
                node.AddField("FirstPing", firstPing, "First ping, should be 3.", slices);

                // And the first pong
                stream = session.GetNextStreamDirection();

                UInt32 firstPong = stream.ReadU32LE(slices);
                node.AddField("FirstPong", firstPong, "First pong, should be 4 for older WM5, 6 for newer versions.", slices);

                if (firstPong == 6)
                {
                    // Now we're supposed to send 4 DWORDs
                    stream = session.GetNextStreamDirection();

                    UInt32 secondPing = stream.ReadU32LE(slices);
                    node.AddField("SecondPingValue1", secondPing, "Second ping value #1, should be 7.", slices);

                    secondPing = stream.ReadU32LE(slices);
                    node.AddField("SecondPingValue2", secondPing, "Second ping value #2, should be 8.", slices);

                    secondPing = stream.ReadU32LE(slices);
                    node.AddField("SecondPingValue3", secondPing, "Second ping value #3, should be 4.", slices);

                    secondPing = stream.ReadU32LE(slices);
                    node.AddField("SecondPingValue4", secondPing, "Second ping value #4, should be 1.", slices);

                    // And the device should reply
                    stream = session.GetNextStreamDirection();

                    UInt32 secondPong = stream.ReadU32LE(slices);
                    node.AddField("SecondPong", secondPong, "Second pong, should be 4.", slices);
                }

                // Got it
                session.AddNode(node);

                parentNode             = new TransactionNode("RAPIDeviceInfo");
                parentNode.Description = parentNode.Name;

                UInt32 deviceInfoLen       = stream.ReadU32LE(slices);
                UInt32 remainingDevInfoLen = deviceInfoLen;
                parentNode.AddField("Length", deviceInfoLen, "Device info length.", slices);

                if (deviceInfoLen > MAX_DEVICE_INFO_LENGTH)
                {
                    logger.AddMessage("RAPI protocol error, length of the device info package should be below {0}, was {1}", MAX_DEVICE_INFO_LENGTH, deviceInfoLen);
                    return;
                }

                node = new TransactionNode(parentNode, "DeviceInfo");

                Guid guid = new Guid(stream.ReadBytes(16, slices));
                str = String.Format("{{0}}", guid.ToString());
                node.AddField("DeviceGUID", str, "Device GUID.", slices);
                remainingDevInfoLen -= 16;

                val = stream.ReadU32LE(slices);
                node.AddField("OsVersionMajor", val, "OS version, major.", slices);
                remainingDevInfoLen -= 4;

                val = stream.ReadU32LE(slices);
                node.AddField("OsVersionMinor", val, "OS version, minor.", slices);
                remainingDevInfoLen -= 4;

                val = stream.ReadU32LE(slices);
                node.AddField("DeviceNameLength", val, "Device name length (in characters, not bytes).", slices);
                remainingDevInfoLen -= 4;

                // calculate the string size in unicode, with terminating NUL word
                val = (val + 1) * 2;
                str = stream.ReadCStringUnicode((int)val, slices);
                node.AddField("DeviceName", str, "Device name.", slices);
                remainingDevInfoLen -= val;

                val = stream.ReadU32LE(slices);
                node.AddField("DeviceVersion", StaticUtils.FormatFlags(val), "Device version.", slices);
                remainingDevInfoLen -= 4;

                val = stream.ReadU32LE(slices);
                node.AddField("DeviceProcessorType", StaticUtils.FormatFlags(val), "Device processor type.", slices);
                remainingDevInfoLen -= 4;

                val = stream.ReadU32LE(slices);
                node.AddField("Unknown1", StaticUtils.FormatFlags(val), "Counter or a flag? ANDed with 0xFFFFFFFE in the code (should take a closer look at this).", slices);
                remainingDevInfoLen -= 4;

                val = stream.ReadU32LE(slices);
                node.AddField("CurrentPartnerId", StaticUtils.FormatFlags(val), "Current partner id.", slices);
                remainingDevInfoLen -= 4;

                val = stream.ReadU32LE(slices);
                node.AddField("DeviceId", StaticUtils.FormatFlags(val), "Current device id. Lives in HKCU\\Software\\Microsoft\\Windows CE Services\\Partners\\<DeviceIdentifier>.", slices);
                remainingDevInfoLen -= 4;

                /*
                 * dw = stream.ReadU32LE(slices);
                 * node.AddField("PlatformNameLength", dw, "Platform name length.", slices);
                 * remainingDevInfoLen -= 4;*/

                // Don't swallow the 4 last
                remainingDevInfoLen -= 4;

                byte[] bytes = stream.ReadBytes((int)remainingDevInfoLen, slices);
                node.AddField("UnknownData1", StaticUtils.FormatByteArray(bytes), "Unknown device info data.", slices);

                val = stream.ReadU32LE(slices);
                node.AddField("PasswordMask", StaticUtils.FormatFlags(val), "Password mask. Non-zero if a password is set.", slices);
                remainingDevInfoLen -= 4;

                state = (val != 0) ? RAPIConnectionState.AUTH : RAPIConnectionState.SESSION;

                // Now it's our turn
                stream = session.GetNextStreamDirection();

                node = parentNode;
            }
            else
            {
                state = RAPIConnectionState.SESSION;
            }

            // Add the last node for each case
            session.AddNode(node);

            while (state == RAPIConnectionState.AUTH)
            {
                parentNode             = new TransactionNode("RAPIAuthAttempt");
                parentNode.Description = parentNode.Name;

                node = new TransactionNode(parentNode, "Request");

                val = stream.ReadU16LE(slices);
                node.AddField("Length", val, "Authentication data length.", slices);

                byte[] bytes = stream.ReadBytes((int)val, slices);
                node.AddField("Data", StaticUtils.FormatByteArray(bytes), "Authentication data.", slices);

                stream = session.GetNextStreamDirection();

                node = new TransactionNode(parentNode, "Response");

                val = stream.ReadU16LE(slices);
                node.AddField("Success", (val != 0) ? "TRUE" : "FALSE", "Whether the authentication attempt was successful.", slices);

                session.AddNode(parentNode);

                stream = session.GetNextStreamDirection();

                if (val != 0)
                {
                    state = RAPIConnectionState.SESSION;
                }
            }
        }
Ejemplo n.º 39
0
        public void TestSinglePacketStreamShift()
        {
            PacketStream stream = new PacketStream() {
                Data = new byte[] { 0x01, 0x02, 0x03, 0x04 }
            };

            byte[] data = stream.Shift(1);

            Assert.AreEqual(0x01, data.First());
            Assert.AreEqual(3, stream.Data.Length);
            Assert.AreEqual(0x02, stream.Data[0]);
            Assert.AreEqual(0x03, stream.Data[1]);
            Assert.AreEqual(0x04, stream.Data[2]);
        }
        public static void HandlePlayerOnlineResponse(NetworkClient Client, ProcessedPacket P)
        {
            byte Result = (byte)P.ReadByte();
            string Token = P.ReadString();
            //NOTE: Might have to find another way to identify a client, since two people
            //		can be on the same account from the same IP.
            string RemoteIP = P.ReadString();
            int RemotePort = P.ReadInt32();

            PacketStream Packet;
            NetworkClient FoundClient;

            switch(Result)
            {
                case 0x01:
                    Packet = new PacketStream((byte)PacketType.REQUEST_CITY_TOKEN, 0);
                    Packet.WriteString(Token);
                    FoundClient = NetworkFacade.ClientListener.GetClient(RemoteIP, RemotePort);

                    if(FoundClient != null)
                        FoundClient.SendEncrypted((byte)PacketType.REQUEST_CITY_TOKEN, Packet.ToArray());

                    break;
                case 0x02: //Write player was already online packet!
                    Packet = new PacketStream((byte)PacketType.PLAYER_ALREADY_ONLINE, 0);
                    Packet.WriteByte(0x00); //Dummy
                    FoundClient = NetworkFacade.ClientListener.GetClient(RemoteIP, RemotePort);

                    if (FoundClient != null)
                        FoundClient.SendEncrypted((byte)PacketType.PLAYER_ALREADY_ONLINE, Packet.ToArray());

                    break;
            }
        }
Ejemplo n.º 41
0
        public void TestUninitializedPacketStreamShift()
        {
            PacketStream stream = new PacketStream();

            Assert.IsNull(stream.Shift(1));
        }
Ejemplo n.º 42
0
        /// <summary>
        /// Sends a pulse to the LoginServer, to let it know this server is alive.
        /// </summary>
        private void m_PulseTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            PacketStream Packet = new PacketStream(0x66, 3);
            Packet.WriteByte(0x66);
            Packet.WriteUInt16(3);
            Packet.Flush();
            m_LoginClient.Send(Packet.ToArray());

            Packet.Dispose();
        }
Ejemplo n.º 43
0
        public override void Read(PacketStream stream)
        {
            // TODO ... coming soon

            _log.Debug("ChangeSlaveEquipment");
        }
Ejemplo n.º 44
0
        protected override void Read(PacketStream stream)
        {
            var gsId = stream.ReadByte();

            AuthGameManager.Instance.Add(gsId, Connection);
        }
Ejemplo n.º 45
0
        public void TestEmptyPacketStreamSizeOne()
        {
            PacketStream stream = new PacketStream();

            stream.Push(new byte[] { 0x01 }, 1);

            Assert.AreEqual(1, stream.Size());
        }
Ejemplo n.º 46
0
 public override void Read(PacketStream stream)
 {
     var type = stream.ReadInt64();
 }
Ejemplo n.º 47
0
 public override void Read(PacketStream stream)
 {
     _log.Warn("LeaveInstantGame");
 }
Ejemplo n.º 48
0
 public override PacketStream Write(PacketStream stream)
 {
     stream.Write(_tlId);
     stream.Write(_duration);
     return(stream);
 }
Ejemplo n.º 49
0
        /// <summary>
        /// Client sent a response to our challenge, as well as account name and password.
        /// </summary>
        public static void HandleChallengeResponse(NetworkClient Client, ProcessedPacket P)
        {
            PacketStream OutPacket;

            if (P.BufferLength <= 1)
            {
                OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE, 0);
                OutPacket.WriteByte(0x03); //Bad challenge response.
                Client.Send(OutPacket.ToArray());

                Logger.LogInfo("Bad challenge response - sent SLoginFailResponse!\r\n");
                return; //How does this even happen?!
            }

            int Length = P.ReadByte();
            byte[] CResponse;

            if (P.BufferLength >= Length)
                CResponse = P.ReadBytes(Length);
            else
                return;

            AESDecryptionArgs DecryptionArgs = Client.ClientEncryptor.GetDecryptionArgsContainer().AESDecryptArgs;

            if (DecryptionArgs.Challenge.SequenceEqual(CResponse))
            {
                string AccountName = SanitizeAccount(P.ReadString());

                Length = P.ReadByte();
                byte[] PasswordHash;

                if (P.BufferLength >= Length)
                    PasswordHash = P.ReadBytes(Length);
                else
                    return;

                // Check whether the accountname is empty or is/contains "username"
                if (AccountName == string.Empty || AccountName.ToLower().Equals("username") || AccountName.ToLower().Contains("username"))
                {
                    OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE, 0);
                    OutPacket.WriteHeader();
                    OutPacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + 1));
                    OutPacket.WriteByte(0x01);
                    Client.Send(OutPacket.ToArray());

                    Logger.LogInfo(@"Bad accountname (""" + AccountName + @""") - sent SLoginFailResponse!\r\n");
                    Client.Disconnect();
                    return;
                }

                using (var db = DataAccess.Get())
                {
                    var account = db.Accounts.GetByUsername(AccountName);

                    if (!GlobalSettings.Default.CreateAccountsOnLogin)
                    {
                        Logger.LogInfo("Done reading LoginRequest, checking account...\r\n");

                        if (account == null)
                        {
                            OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE, 0);
                            OutPacket.WriteHeader();
                            OutPacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + 1));
                            OutPacket.WriteByte(0x01);
                            Client.Send(OutPacket.ToArray());

                            Logger.LogInfo(@"Bad accountname (""" + AccountName + @""") - sent SLoginFailResponse!\r\n");
                            Client.Disconnect();
                            return;
                        }
                    }
                    else
                    {
                        if (account == null)
                        {
                            try
                            {
                                if (!AccountName.ToLower().Equals("username") || !AccountName.ToLower().Contains("username"))
                                db.Accounts.Create(new Account
                                {
                                    AccountName = AccountName.ToLower(),
                                    Password = Convert.ToBase64String(PasswordHash)
                                });
                            }
                            catch (Exception)
                            {
                                OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE, 0);
                                OutPacket.WriteHeader();
                                OutPacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + 1));
                                OutPacket.WriteByte(0x01);
                                Client.Send(OutPacket.ToArray());

                                Logger.LogInfo(@"Bad accountname (""" + AccountName + @""") - sent SLoginFailResponse!\r\n");
                                Client.Disconnect();
                                return;
                            }

                            account = db.Accounts.GetByUsername(AccountName);
                        }
                    }

                    if (account.IsCorrectPassword(AccountName, PasswordHash))
                    {
                        OutPacket = new PacketStream((byte)PacketType.LOGIN_SUCCESS, 0);
                        OutPacket.WriteByte(0x01);
                        Client.ClientEncryptor.Username = AccountName;
                        Client.SendEncrypted((byte)PacketType.LOGIN_SUCCESS, OutPacket.ToArray());

                        Logger.LogInfo("Sent SLoginSuccessResponse!\r\n");
                        return;
                    }
                    else
                    {
                        OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE, 0);
                        OutPacket.WriteHeader();
                        OutPacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + 1));
                        OutPacket.WriteByte(0x02);
                        Client.Send(OutPacket.ToArray());

                        Logger.LogInfo("Bad password - sent SLoginFailResponse!\r\n");
                        Client.Disconnect();
                        return;
                    }
                }
            }

            OutPacket = new PacketStream((byte)PacketType.LOGIN_FAILURE, 0);
            OutPacket.WriteHeader();
            OutPacket.WriteUInt16((ushort)(PacketHeaders.UNENCRYPTED + 1));
            OutPacket.WriteByte(0x03); //Bad challenge response.
            Client.Send(OutPacket.ToArray());

            Logger.LogInfo("Bad challenge response - sent SLoginFailResponse!\r\n");
            return;
        }
Ejemplo n.º 50
0
 public override PacketStream Write(PacketStream stream)
 {
     stream.Write(_reason);
     stream.Write(_causedByMe);
     return(stream);
 }
Ejemplo n.º 51
0
        /// <summary>
        /// Client wanted to retire a character.
        /// </summary>
        public static void HandleCharacterRetirement(NetworkClient Client, ProcessedPacket P)
        {
            PacketStream Packet;

            string AccountName = P.ReadString();
            string GUID = P.ReadString();

            if (AccountName == string.Empty || GUID == string.Empty)
                return;

            using (var db = DataAccess.Get())
            {
                Account Acc = db.Accounts.GetByUsername(AccountName);
                IQueryable<Character> Query = db.Characters.GetForAccount(Acc.AccountID);

                //F**K, I hate LINQ.
                Guid CharGUID = new Guid(GUID);
                Character Char = Query.Where(x => x.GUID == CharGUID).SingleOrDefault();

                if (Char != null)
                    db.Characters.RetireCharacter(Char);
                else
                    return;

                //This actually updates the record, not sure how.
                Acc.NumCharacters--;

                if (Char != null)
                {
                    CityInfo CInfo = NetworkFacade.CServerListener.GetCityServer(Char.City);

                    //Just in case...
                    if (CInfo != null)
                    {
                        Packet = new PacketStream(0x02, 0);
                        Packet.WriteHeader();

                        ushort PacketLength = (ushort)(PacketHeaders.UNENCRYPTED + 4 + GUID.Length + 1);

                        Packet.WriteUInt16(PacketLength);
                        Packet.WriteInt32(Acc.AccountID);
                        Packet.WriteString(GUID);
                        CInfo.Client.Send(Packet.ToArray());
                    }
                }
            }

            Packet = new PacketStream((byte)PacketType.RETIRE_CHARACTER_STATUS, 0);
            Packet.WriteString(GUID);
            Client.SendEncrypted((byte)PacketType.RETIRE_CHARACTER_STATUS, Packet.ToArray());
        }
Ejemplo n.º 52
0
 public override void Read(PacketStream stream)
 {
     // Empty struct
     _log.Debug("ListMailContinue");
 }
Ejemplo n.º 53
0
        /// <summary>
        /// Client wanted to transfer to a city server.
        /// </summary>
        public static void HandleCityTokenRequest(NetworkClient Client, ProcessedPacket P)
        {
            string AccountName = P.ReadString();
            string CityGUID = P.ReadString();
            string CharGUID = P.ReadString();

            if (AccountName == string.Empty || CityGUID == string.Empty || CharGUID == string.Empty)
                return;

            Guid Token = Guid.NewGuid();
            CityInfo CServer = NetworkFacade.CServerListener.GetCityServer(CityGUID);

            using (var db = DataAccess.Get())
            {
                Account Acc = db.Accounts.GetByUsername(AccountName);

                PacketStream CServerPacket = new PacketStream(0x01, 0);
                CServerPacket.WriteHeader();

                ushort PacketLength = (ushort)(PacketHeaders.UNENCRYPTED + 1 + 4 + (Client.RemoteIP.Length + 1)
                    + 4 + (CharGUID.ToString().Length + 1) + (Token.ToString().Length + 1));
                CServerPacket.WriteUInt16(PacketLength);

                CServerPacket.WriteByte(0); //CharacterCreate = false.
                CServerPacket.WriteInt32(Acc.AccountID);
                CServerPacket.WriteString(Client.RemoteIP);
                CServerPacket.WriteInt32(Client.RemotePort);
                CServerPacket.WriteString(CharGUID.ToString());
                CServerPacket.WriteString(Token.ToString(""));
                CServer.Client.Send(CServerPacket.ToArray());
            }
        }
Ejemplo n.º 54
0
 public override PacketStream Write(PacketStream stream)
 {
     stream.WriteBc(_objId);
     stream.Write(_buffId);
     return(stream);
 }
Ejemplo n.º 55
0
Archivo: RAPI.cs Proyecto: wyrover/ospy
        private void HandleRapiSession()
        {
            List <PacketSlice> slices = new List <PacketSlice>();
            TransactionNode    node, req, resp;
            string             str;
            UInt32             val, retVal, lastError;

            while (stream.GetBytesAvailable() > 0)
            {
                UInt32             msgLen, msgType;
                List <PacketSlice> msgLenSlices  = new List <PacketSlice>(1);
                List <PacketSlice> msgTypeSlices = new List <PacketSlice>(1);

                // Message length
                msgLen = stream.ReadU32LE(msgLenSlices);

                if (msgLen == 5)
                {
                    node             = new TransactionNode("RAPINotification");
                    node.Description = node.Name;

                    node.AddField("MessageType", "RAPI_NOTIFICATION", "Message type.", msgLenSlices);

                    val = stream.ReadU32LE(slices);
                    node.AddField("NotificationType", (val == 4) ? "REQUEST_NEW_CONNECTION" : StaticUtils.FormatFlags(val), "Notification type.", slices);

                    val = stream.ReadU32LE(slices);
                    node.AddField("Argument", val, "Argument.", slices);

                    session.AddNode(node);

                    if (stream.GetBytesAvailable() < 4)
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }
                else if (msgLen == 1)
                {
                    node             = new TransactionNode("RAPIKeepalive");
                    node.Description = node.Name;

                    req = new TransactionNode(node, "Request");
                    req.AddField("MessageType", "RAPI_PING", "Message type.", msgLenSlices);

                    stream = session.GetNextStreamDirection();
                    if (stream.GetBytesAvailable() < 4)
                    {
                        break;
                    }

                    stream.ReadU32LE(slices);

                    resp = new TransactionNode(node, "Response");
                    resp.AddField("MessageType", "RAPI_PONG", "Message type.", slices);

                    session.AddNode(node);

                    stream = session.GetNextStreamDirection();

                    if (stream.GetBytesAvailable() < 4)
                    {
                        break;
                    }
                    else
                    {
                        continue;
                    }
                }

                // Message type
                msgType = stream.ReadU32LE(msgTypeSlices);
                if (msgType >= rapiCallNames.Length)
                {
                    logger.AddMessage("Unknown call name: {0:x8}", msgType);
                    return;
                }

                string name = rapiCallNames[msgType];

                RAPICallNode call = new RAPICallNode(name);
                call.Description = call.Name;

                req  = call.Request;
                resp = call.Response;

                req.AddField("MessageLength", msgLen, "Length of the RAPI request.", msgLenSlices);
                req.AddField("MessageType", String.Format("{0} (0x{1:x2})", name, msgType), "Type of the RAPI request.", msgTypeSlices);

                if (name == "CeRegOpenKeyEx")
                {
                    val = stream.ReadU32LE(slices);
                    req.AddField("hKey", StaticUtils.FormatRegKey(val),
                                 "Handle to a currently open key or one of the following predefined reserved handle values:\n" +
                                 "HKEY_CLASSES_ROOT\nHKEY_CURRENT_USER\nHKEY_LOCAL_MACHINE\nHKEY_USERS",
                                 slices);

                    str = stream.ReadRAPIString(slices);
                    req.AddField("szSubKey", str,
                                 "A null-terminated string containing the name of the subkey to open.",
                                 slices);

                    req.Summary = String.Format("{0}, \"{1}\"", StaticUtils.FormatRegKey(val, true), str);

                    SwitchToResponseAndParseResult(resp, slices, out retVal, out lastError);

                    val = stream.ReadU32LE(slices);
                    string result = String.Format("0x{0:x8}", val);
                    resp.AddField("hkResult", result, "Handle to the opened key.", slices);

                    if (retVal == Constants.ERROR_SUCCESS)
                    {
                        resp.Summary = String.Format("{0}, {1}", StaticUtils.FormatRetVal(retVal, true), result);
                    }
                    else
                    {
                        resp.Summary = StaticUtils.FormatRetVal(retVal, true);
                    }
                }
                else if (name == "CeRegCreateKeyEx")
                {
                    val = stream.ReadU32LE(slices);
                    req.AddField("hKey", StaticUtils.FormatRegKey(val),
                                 "Handle to a currently open key or one of the following predefined reserved handle values:\n" +
                                 "HKEY_CLASSES_ROOT\nHKEY_CURRENT_USER\nHKEY_LOCAL_MACHINE\nHKEY_USERS", slices);

                    string szSubKey = stream.ReadRAPIString(slices);
                    req.AddField("szSubKey", (szSubKey != null) ? szSubKey : "(null)",
                                 "A null-terminated string specifying the name of a subkey that this function opens or creates. " +
                                 "The subkey specified must be a subkey of the key identified by the hKey parameter. This subkey " +
                                 "must not begin with the backslash character (\\). If the parameter is NULL, then RegCreateKeyEx " +
                                 "behaves like RegOpenKey, where it opens the key specified by hKey.", slices);

                    string szClass = stream.ReadRAPIString(slices);
                    req.AddField("szClass", (szClass != null) ? szClass : "(null)",
                                 "A null-terminated string that specifies the class (object type) of this key. This parameter is " +
                                 "ignored if the key already exists.", slices);

                    req.Summary = String.Format("{0}, {1}, {2}",
                                                StaticUtils.FormatRegKey(val, true),
                                                StaticUtils.FormatStringArgument(szSubKey),
                                                StaticUtils.FormatStringArgument(szClass));

                    SwitchToResponseAndParseResult(resp, slices, out retVal, out lastError);

                    string result = String.Format("0x{0:x8}", stream.ReadU32LE(slices));
                    resp.AddField("hkResult", result, "Handle to the opened key.", slices);

                    UInt32 disposition = stream.ReadU32LE(slices);
                    resp.AddField("dwDisposition", StaticUtils.FormatRegDisposition(disposition),
                                  "Receives one of REG_CREATED_NEW_KEY and REG_OPENED_EXISTING_KEY.",
                                  slices);

                    if (retVal == Constants.ERROR_SUCCESS)
                    {
                        resp.Summary = String.Format("{0}, {1}, {2}",
                                                     StaticUtils.FormatRetVal(retVal, true), result, StaticUtils.FormatRegDisposition(disposition, true));
                    }
                    else
                    {
                        resp.Summary = StaticUtils.FormatRetVal(retVal, true);
                    }
                }
                else if (name == "CeRegCloseKey")
                {
                    val = stream.ReadU32LE(slices);
                    req.AddField("hKey", StaticUtils.FormatRegKey(val),
                                 "Handle to the open key to close.", slices);

                    req.Summary = StaticUtils.FormatRegKey(val, true);

                    SwitchToResponseAndParseResult(resp, slices, out retVal, out lastError);

                    resp.Summary = StaticUtils.FormatRetVal(retVal, true);
                }
                else if (name == "CeRegQueryValueEx")
                {
                    val = stream.ReadU32LE(slices);
                    req.AddField("hKey", StaticUtils.FormatRegKey(val),
                                 "Handle to a currently open key or any of the following predefined reserved handle values:\n" +
                                 "HKEY_CLASSES_ROOT\nHKEY_CURRENT_USER\nHKEY_LOCAL_MACHINE\nHKEY_USERS", slices);

                    string szValueName = stream.ReadRAPIString(slices);
                    req.AddField("szValueName", szValueName,
                                 "A string containing the name of the value to query.", slices);

                    UInt32 cbData = stream.ReadU32LE(slices);
                    req.AddField("cbData", cbData,
                                 "A variable that specifies the maximum number of bytes to return.", slices);

                    req.Summary = String.Format("{0}, {1}, {2}",
                                                StaticUtils.FormatRegKey(val, true),
                                                StaticUtils.FormatStringArgument(szValueName),
                                                cbData);

                    SwitchToResponseAndParseResult(resp, slices, out retVal, out lastError);

                    UInt32 dwType = stream.ReadU32LE(slices);
                    resp.AddField("dwType", StaticUtils.FormatRegType(dwType),
                                  "The type of data associated with the specified value.",
                                  slices);

                    cbData = stream.ReadU32LE(slices);
                    resp.AddField("cbData", Convert.ToString(cbData),
                                  "The size of the data returned.", slices);

                    str = ReadAndFormatDataForRegType(dwType, cbData, slices);
                    if (str == null)
                    {
                        str = "NULL";
                    }
                    resp.AddField("Data", str, "The data returned.", slices);

                    resp.Summary = StaticUtils.FormatRetVal(retVal, true);
                }
                else if (name == "CeRegSetValueEx")
                {
                    UInt32 key = stream.ReadU32LE(slices);
                    req.AddField("hKey", StaticUtils.FormatRegKey(key),
                                 "Handle to a currently open key or any of the following predefined reserved handle values:\n" +
                                 "HKEY_CLASSES_ROOT\nHKEY_CURRENT_USER\nHKEY_LOCAL_MACHINE\nHKEY_USERS", slices);

                    string szValueName = stream.ReadRAPIString(slices);
                    req.AddField("szValueName", szValueName,
                                 "String containing the name of the value to set. If a value with this name is not already " +
                                 "present in the key, the function adds it to the key. If this parameter is NULL or an empty " +
                                 "string, the function sets the type and data for the key's unnamed value. Registry keys do " +
                                 "not have default values, but they can have one unnamed value, which can be of any type.",
                                 slices);

                    UInt32 dwType = stream.ReadU32LE(slices);
                    req.AddField("dwType", StaticUtils.FormatRegType(dwType),
                                 "Type of information to be stored as the value's data.",
                                 slices);

                    UInt32 cbData = stream.ReadU32LE(slices);
                    req.AddField("cbData", Convert.ToString(cbData),
                                 "Specifies the size, in bytes, of the information passed in the the Data field.",
                                 slices);

                    str = ReadAndFormatDataForRegType(dwType, cbData, slices);
                    if (str == null)
                    {
                        str = "NULL";
                    }
                    req.AddField("Data", str, "Buffer containing the data to be stored with the specified value name.",
                                 slices);

                    string dataSummary;
                    if (dwType == Constants.REG_DWORD || dwType == Constants.REG_DWORD_BIG_ENDIAN)
                    {
                        dataSummary = str;
                    }
                    else
                    {
                        dataSummary = String.Format("[{0} bytes]", cbData);
                    }

                    req.Summary = String.Format("{0}, {1}, {2}, {3}",
                                                StaticUtils.FormatRegKey(key), StaticUtils.FormatStringArgument(szValueName), StaticUtils.FormatRegType(dwType), dataSummary);

                    SwitchToResponseAndParseResult(resp, slices, out retVal, out lastError);

                    resp.Summary = StaticUtils.FormatRetVal(retVal, true);
                }
                else if (name == "CeProcessConfig")
                {
                    str = stream.ReadRAPIString(slices);
                    req.AddXMLField("szRequest", str, "Config request.", slices);

                    UInt32 flags = stream.ReadU32LE(slices);
                    req.AddField("dwFlags", StaticUtils.FormatFlags(flags), "Flags.", slices);

                    req.Summary = String.Format("[{0} bytes], 0x{1:x8}",
                                                str.Length, flags);

                    SwitchToResponseAndParseResult(resp, slices, out retVal, out lastError);

                    str = stream.ReadRAPIString(slices);
                    resp.AddXMLField("szResponse", str, "Config response.", slices);

                    if (retVal == Constants.ERROR_SUCCESS)
                    {
                        resp.Summary = String.Format("{0}, [{1} bytes]",
                                                     StaticUtils.FormatRetVal(retVal, true), (str != null) ? str.Length : 0);
                    }
                    else
                    {
                        resp.Summary = StaticUtils.FormatRetVal(retVal, true);
                    }
                }
                else if (name == "CeGetDesktopDeviceCaps")
                {
                    string caps = FormatDeviceCaps(stream.ReadU32LE(slices));
                    req.AddField("nIndex", caps, "The item to return.", slices);

                    req.Summary = caps;

                    SwitchToResponseAndParseResult(resp, slices, out retVal, out lastError, false);

                    resp.Summary = StaticUtils.FormatValue(retVal);
                }
                else if (name == "CeSyncStart")
                {
                    string xml = stream.ReadRAPIString(slices);
                    req.AddXMLField("szXML", (xml != null) ? xml : "(null)",
                                    "Optional message.", slices);

                    if (xml != null)
                    {
                        req.Summary = String.Format("[{0} bytes]", xml.Length);
                    }
                    else
                    {
                        req.Summary = "NULL";
                    }

                    SwitchToResponseAndParseResult(resp, slices, out retVal, out lastError);

                    resp.Summary = StaticUtils.FormatRetVal(retVal, true);
                }
                else if (name == "CeSyncResume" || name == "CeSyncPause")
                {
                    req.Summary = "";

                    SwitchToResponseAndParseResult(resp, slices, out retVal, out lastError, false);

                    resp.Summary = StaticUtils.FormatRetVal(retVal, true);
                }
                else if (name == "CeStartReplication")
                {
                    req.Summary = "";

                    SwitchToResponseAndParseResult(resp, slices, out retVal, out lastError, false);

                    resp.Summary = StaticUtils.FormatBool(retVal);
                }
                else if (name == "CeGetFileAttributes")
                {
                    string fileName = stream.ReadRAPIString(slices);

                    req.AddXMLField("szFileName", fileName,
                                    "Name of a file or directory.", slices);

                    req.Summary = String.Format("\"{0}\"", fileName);

                    SwitchToResponseAndParseResult(resp, slices, out retVal, out lastError, false);

                    resp.Summary = StaticUtils.FormatValue(retVal);
                }
                else
                {
                    if (msgLen > 4)
                    {
                        byte[] bytes = stream.ReadBytes((int)msgLen - 4, slices);
                        req.AddField("UnparsedData", StaticUtils.FormatByteArray(bytes), "Unparsed data.", slices);
                    }

                    req.Summary = "[not yet parsed]";

                    SwitchToResponseAndParseResult(resp, slices, out retVal, out lastError, false);

                    resp.Summary = "[not yet parsed]";
                }

                session.AddNode(call);

                stream = session.GetNextStreamDirection();
                if (stream.GetBytesAvailable() == 0)
                {
                    break;
                }
            }
        }
Ejemplo n.º 56
0
 public override PacketStream Write(PacketStream stream)
 {
     stream.Write(_portal);
     return(stream);
 }
Ejemplo n.º 57
0
        private void HandleCommandPacket(NetworkClient client, Account account, ConanPacket packet)
        {
            var recObjTyp = packet.Data.ReadUInt32();
            var recClientInst = packet.Data.ReadUInt32();
            var unk0 = packet.Data.ReadByte();
            var recDataLength = packet.Data.ReadUInt32();
            var unk2 = packet.Data.ReadUInt32();
            var unk3 = packet.Data.ReadByte();
            var runByte = packet.Data.ReadByte();

            UInt32 recVal = 0;
            var runId = 0;
            while (runByte != 0x22)
            {
                if (runId == 0)
                    recVal = runByte;
                if (runId == 1)
                    recVal += (runByte*0x100u);
                if (runId == 2)
                    recVal += (runByte*0x10000u);
                if (runId == 3)
                    recVal += (runByte*0x1000000u);

                runByte = packet.Data.ReadByte();
                runId++;
            }

            var recCmd = packet.Data.ReadShortString();
            var strend = packet.Data.ReadByte();
            var unk4 = packet.Data.ReadUInt16(); // MELVIN
            var recSecCmd = packet.Data.ReadShortString();

            switch (recCmd)
            {
                case "IntroDone":
                {
                    var aBuffer = new PacketStream();
                    aBuffer.WriteHeader(Sender2, Receiver2, null, 0x2000);
                    aBuffer.WriteUInt32(0x00000019);
                    aBuffer.WriteUInt32(0x96b8dc59);
                    aBuffer.WriteUInt32(0x0000c350);
                    aBuffer.WriteUInt32(account.ClientInstance);
                    aBuffer.WriteByte(0);
                    aBuffer.WriteUInt32(0x00000001);
                    aBuffer.WriteUInt32(0x000000ba);
                    aBuffer.WriteUInt32(0);
                    aBuffer.Send(client);
                }
                    break;
                case "ChangeSex":
                    account.Character.Sex = (byte) recVal;
                    break;
                case "ChangeRace":
                    account.Character.Race = (byte) recVal;
                    break;
                case "ChangeHeadMesh":
                    account.Character.HeadMesh = recVal;
                    break;
                case "ChangeSize":
                    account.Character.Size = (byte) recVal;
                    break;
                case "ChangeClass":
                    account.Character.Class = (byte) recVal;
                    break;
                case "ChangeVoice":
                    account.Character.Voice = (byte) recVal;
                    break;
                case "SetMorphValue":
                    Logger.Info("Second Command: " + recSecCmd + " with value: " + recVal);
                    if (recSecCmd.Length > 0)
                    {
                        //vector<string> scriptData = String::splitString(recSecCmd, "_");
                        //Logger.Info("Splitted String: %s - " + scriptData[0], scriptData[1]);
                        account.CreateCounter++;
                        account.CreateState = 1;

                        new PacketStream().WriteHeader(Sender2, Receiver2, null, 0x2000)
                            .WriteArrayPrependLengthUInt32(new ConanStream()
                                //aBuffer.WriteUInt32(recSecCmd.Length + (5*4) + (1*2) + (2*1)); // length
                                .WriteUInt32(0xbadf5a4b)
                                .WriteUInt32(0x0000c350)
                                .WriteUInt32(account.ClientInstance)
                                .WriteByte(0)
                                .WriteString(recSecCmd)
                                .WriteUInt32(0x3f800000)
                                .WriteByte(0)
                                .WriteUInt32(account.CreateCounter + 1))
                            .Send(client);
                    }
                    else
                    {
                        account.CreateCounter = 0;
                    }
                    break;
                case "TheNameIs":
                {
                    Logger.Info("Attempt to create Char with the name: " + recSecCmd);
                    account.Character.Name = recSecCmd;

                    //MELVIN
                    /*if (!Database.isValidCharName(account.charInfo.Name))
                    {
                        //TODO add missing return packet
                        Logger.Info("Charname is incorrect !");
                        closesocket(account.clientSocket);
                        break;
                    */

                    var aBuffer = new PacketStream();
                    aBuffer.WriteHeader(Sender2, Receiver2, null, 0x2000);
                    aBuffer.WriteUInt32(account.Character.Name.Length + (5*4) + (1*2) + (1*1));
                    aBuffer.WriteUInt32(0xadce0cda);
                    aBuffer.WriteUInt32(0x0000c350);
                    aBuffer.WriteUInt32(account.ClientInstance);
                    aBuffer.WriteUInt32(0);
                    aBuffer.WriteUInt32(0x03010000);
                    aBuffer.WriteByte(0);
                    aBuffer.WriteString(account.Character.Name);
                    aBuffer.Send(client);

                    var data = new byte[]
                    {
                        0x00, 0x00, 0x00, 0x00, 0x1f, 0x08, 0x05, 0x10, 0x02, 0x18, 0x00, 0x22
                    };
                    aBuffer = new PacketStream();
                    aBuffer.WriteHeader(Sender2, Receiver2, null, 0x2000);
                    aBuffer.WriteUInt32(account.Character.Name.Length + (10 + 1) + data.Length + (4*4) + (1*2) + (2*1));
                    aBuffer.WriteUInt32(0xa36d3b74);
                    aBuffer.WriteUInt32(0x0000c350);
                    aBuffer.WriteUInt32(account.ClientInstance);
                    aBuffer.WriteArray(data);
                    aBuffer.WriteString("NicknameOk");
                    aBuffer.WriteByte(0x2a);
                    aBuffer.WriteString(account.Character.Name);
                    aBuffer.WriteUInt32(0x32040800);
                    aBuffer.WriteUInt16(0x1000);
                    aBuffer.Send(client);

                    var data2 = new byte[]
                    {
                        0x00, 0x00, 0x00, 0x07, 0xe2, 0x00, 0x00, 0xcf, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                        0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
                        0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x46, 0x37, 0x00, 0x00, 0x00, 0x00,
                        0x00
                    };
                    aBuffer = new PacketStream();
                    aBuffer.WriteHeader(Sender2, Receiver2, null, 0x2000);
                    aBuffer.WriteUInt32(data2.Length + (3*4));
                    aBuffer.WriteUInt32(0xf508f4c1);
                    aBuffer.WriteUInt32(0x0000c350);
                    aBuffer.WriteUInt32(account.ClientInstance);
                    aBuffer.WriteArray(data2);
                    aBuffer.Send(client);

                    var data3 = new byte[]
                    {
                        0x00, 0x00, 0x00, 0x00, 0x24, 0x08, 0x05, 0x10, 0x02, 0x18, 0x00, 0x22, 0x14,
                        0x43, 0x68, 0x61, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x69, 0x6e,
                        0x69, 0x73, 0x68, 0x65, 0x64,
                        0x2a, 0x00, 0x32, 0x04, 0x08, 0x00, 0x10, 0x00
                    };
                    aBuffer = new PacketStream();
                    aBuffer.WriteHeader(Sender2, Receiver2, null, 0x2000);
                    aBuffer.WriteUInt32(data3.Length + (3*4));
                    aBuffer.WriteUInt32(0xa36d3b74);
                    aBuffer.WriteUInt32(0x0000c350);
                    aBuffer.WriteUInt32(account.ClientInstance);
                    aBuffer.WriteArray(data3);

                    aBuffer.Send(client);

                    var data4 = new byte[]
                    {
                        0x00, 0x00, 0xc3, 0x50, 0x00, 0x00, 0x27, 0xf6, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00,
                        0x00, 0x00, 0x0a, 0x08, 0xc5, 0xc3, 0x02, 0x18, 0x01, 0x28, 0x18, 0x30, 0x00
                    };
                    aBuffer = new PacketStream();
                    aBuffer.WriteHeader(Sender2, Receiver2, null, 0x2000);
                    aBuffer.WriteUInt32(data4.Length + (1*4));
                    aBuffer.WriteUInt32(0x642cd3d6);
                    aBuffer.WriteArray(data4);

                    aBuffer.Send(client);

                    var data5 = new byte[]
                    {
                        0x00, 0x00, 0xc3, 0x50, 0x00, 0x00, 0x27, 0xf7, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00,
                        0x00, 0x00, 0x0a, 0x08, 0xc5, 0xc3, 0x02, 0x18, 0x01, 0x28, 0x18, 0x30, 0x00
                    };
                    aBuffer = new PacketStream();
                    aBuffer.WriteHeader(Sender2, Receiver2, null, 0x2000);
                    aBuffer.WriteUInt32(data5.Length + (1*4));
                    aBuffer.WriteUInt32(0x642cd3d6);
                    aBuffer.WriteArray(data5);

                    aBuffer.Send(client);

                    var data6 = new byte[]
                    {
                        0x01, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x14
                    };
                    aBuffer = new PacketStream();
                    aBuffer.WriteHeader(Sender2, Receiver2, null, 0x2000);
                    aBuffer.WriteUInt32(data6.Length + (3*4));
                    aBuffer.WriteUInt32(0xf98e10b3);
                    aBuffer.WriteUInt32(0x0000c350);
                    aBuffer.WriteUInt32(account.ClientInstance);
                    aBuffer.WriteArray(data6);

                    aBuffer.Send(client);
                }
                    break;
                default:
                    Logger.Info("Receive unknown command: {0} with value {1}", recCmd, recVal);
                    break;
            }
        }
Ejemplo n.º 58
0
        public override void Read(PacketStream stream)
        {
            var mailId = stream.ReadInt64();

            _log.Debug("TakeAttachmentMoney, mailId: {0}", mailId);
        }
Ejemplo n.º 59
0
        private static void SendReadyForPlayScreen(NetworkClient client, Account account)
        {
            var blobData1 = new byte[]
            {
                //0x43, 0xa7, 0x40, 0x00,
                //0x43, 0x14, 0x66, 0x66,
                //0x44, 0x25, 0x4c, 0xcd,
                //0x00, 0x00, 0x07, 0xe2, //2018 = 2*1009 -> -1 -> 1xCoord
                //0x43, 0xa7, 0x40, 0x00,
                //0x43, 0x14, 0x66, 0x66,
                //0x44, 0x25, 0x4c, 0xcd,
                0x00, 0x00, 0xc7, 0x9e,
                0x00, 0x00, 0x0f, 0xaa,
                0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x64,
                0x00
            };

            var aBuffer = new PacketStream();
            aBuffer.WriteHeader(Sender6, Receiver6, null, 0x2024);
            aBuffer.WriteVector3(account.Character.Position);
            aBuffer.WriteUInt32(0x00007e2); //2018 = 2*1009 -> -1 -> 1xCoord
            aBuffer.WriteVector3(account.Character.Position);
            aBuffer.WriteArray(blobData1);
            aBuffer.Send(client);

            new PacketStream().WriteHeader(Sender5, Receiver5, null, 0x2000)
                .WriteArrayPrependLengthUInt32(new ConanStream()
                    .WriteUInt32(0x06ec1255)
                    .WriteUInt32(0x0000c350)
                    .WriteUInt32(account.ClientInstance)
                    .WriteUInt16(0x0009))
                .Send(client);

            new PacketStream().WriteHeader(Sender5, Receiver5, null, 0x2000)
                .WriteArrayPrependLengthUInt32(new ConanStream()
                    .WriteUInt32(0x864cfef8)
                    .WriteUInt32(0x0000c350)
                    .WriteUInt32(account.ClientInstance)
                    .WriteByte(0))
                .Send(client);
        }
Ejemplo n.º 60
0
 public override void WriteData(PacketStream stream)
 {
     stream.WritePisc(0, Buff.Duration / 10, 0, (long)(Buff.Tick / 10));  // TODO unk, Duration / 10, unk / 10, Tick / 10
 }