예제 #1
0
        void HandleNameQueryResponse(PacketReader reader)
        {
            UInt64 playerGUID = reader.ReadPackedGuid();
            bool noData = reader.ReadBoolean();
            if (noData)
                return;

            string name = reader.ReadCString();
            reader.ReadCString(); // Realm Name (Cross Realm)
            reader.ReadByte();
            reader.ReadByte();
            reader.ReadByte();

            bool declined = reader.ReadBoolean(); // Name declined/not declined
            if (declined)
                for (byte i = 0; i < 5; ++i)
                    reader.ReadByte();

            PlayerName result = Manager.m_WorldServer.PlayerNameList.Find(
                delegate(PlayerName playerName)
                {
                    return playerName.GUID == playerGUID;
                });

            if (result == null)
            {
                PlayerName playerName = new PlayerName();
                playerName.GUID = playerGUID;
                playerName.Name = name;
                QueryChatMessage.Name = name;

                ReceiveMsg = QueryChatMessage;
                PlayerNameList.Add(playerName);
            }
        }
예제 #2
0
        public Character(PacketReader reader)
        {
            GUID = reader.ReadUInt64();
            Name = reader.ReadCString();
            Race = reader.ReadByte();
            Class = reader.ReadByte();
            Gender = (Gender)reader.ReadByte();
            Bytes = reader.ReadBytes(5);
            Level = reader.ReadByte();
            ZoneId = reader.ReadUInt32();
            MapId = reader.ReadUInt32();
            X = reader.ReadSingle();
            Y = reader.ReadSingle();
            Z = reader.ReadSingle();
            GuildId = reader.ReadUInt32();
            Flags = reader.ReadUInt32();
            reader.ReadUInt32();
            reader.ReadByte();
            PetInfoId = reader.ReadUInt32();
            PetLevel = reader.ReadUInt32();
            PetFamilyId = reader.ReadUInt32();

            for (int i = 0; i < Items.Length - 1; ++i)
                Items[i] = new Item(reader);

            for (int i = 0; i < 4; ++i)
            {
                reader.ReadUInt32();
                reader.ReadByte();
                reader.ReadUInt32();
            }
        }
예제 #3
0
        void HandleChannelNotify(PacketReader reader)
        {
            ChatNotify chatNotify = (ChatNotify)reader.ReadByte();
            string name = reader.ReadCString();

            switch (chatNotify)
            {
                case ChatNotify.CHAT_YOU_JOINED_NOTICE:
                    break;
            }
        }
예제 #4
0
 void HandleChannelList(PacketReader reader)
 {
     byte type = reader.ReadByte();
     string name = reader.ReadCString();
     ChannelFlags flags = (ChannelFlags)reader.ReadByte();
     UInt32 size = reader.ReadUInt32();
     for (UInt32 i = 0; i < size; i++)
     {
         reader.ReadUInt64();
         reader.ReadByte();
     }
 }
예제 #5
0
        void HandleServerAuthResponse(PacketReader reader)
        {
            byte detail = reader.ReadByte();
            uint billingTimeRemaining = reader.ReadUInt32();
            byte billingFlags = reader.ReadByte();
            uint billingTimeRested = reader.ReadByte();
            byte expansion = reader.ReadByte();

            if (detail == 0x0C)
            {
                PacketWriter writer = new PacketWriter(Opcodes.ClientEnumerateCharacters);
                Send(writer);
            }
            else
                ErrorMessage = "Could not respond to ServerAuthResponse";
        }
예제 #6
0
        void HandleServerAuthChallenge(PacketReader reader)
        {
            uint one = reader.ReadUInt32();
            uint seed = reader.ReadUInt32();

            BigInteger seed1 = reader.ReadBytes(16).ToBigInteger();
            BigInteger seed2 = reader.ReadBytes(16).ToBigInteger();

            var rand = System.Security.Cryptography.RandomNumberGenerator.Create();
            byte[] bytes = new byte[4];
            rand.GetBytes(bytes);

            BigInteger _seed = bytes.ToBigInteger();

            uint zero = 0;

            byte[] response = HashAlgorithm.SHA1.Hash(Encoding.ASCII.GetBytes(Manager.m_WorldServer.username.ToUpper()),
                BitConverter.GetBytes(zero),
                BitConverter.GetBytes((uint)_seed),
                BitConverter.GetBytes(seed),
                Manager.m_WorldServer.SessionKey.ToCleanByteArray());

            PacketWriter writer = new PacketWriter(Opcodes.ClientAuthSession);
            writer.Write((uint)12340);
            writer.Write(zero);
            writer.Write(Manager.m_WorldServer.username.ToUpper().ToCString());
            writer.Write(zero);
            writer.Write((uint)_seed);
            writer.Write(zero);
            writer.Write(zero);
            writer.Write(zero);
            writer.Write((ulong)zero);
            writer.Write(response);
            writer.Write(zero);

            Send(writer);

            AuthenticationCrypto.Initialize(Manager.m_WorldServer.SessionKey.ToCleanByteArray());
        }
예제 #7
0
        private void ReceivePayload(IAsyncResult ar)
        {
            if (IsClientConnected())
            {
                int bytesReceived = tcpClient.Client.EndReceive(ar);
                if (bytesReceived != 0)
                {
                    Interlocked.Add(ref transferred, bytesReceived);
                    Interlocked.Add(ref received, bytesReceived);

                    if (bytesReceived == remaining)
                    {
                        ServerHeader header = (ServerHeader)ar.AsyncState;
                        PacketReader packet = new PacketReader(header, Buffer);
                        HandleIncoming(packet);

                        Start();
                    }
                    else
                    {
                        index += bytesReceived;
                        remaining -= bytesReceived;
                        tcpClient.Client.BeginReceive(Buffer, index, remaining, SocketFlags.None, new AsyncCallback(ReceivePayload), ar.AsyncState);
                    }
                }
            }
        }
예제 #8
0
 /// <summary>
 /// Handles incoming Opcodes
 /// </summary>
 /// <param name="packet"></param>
 private void HandleIncoming(PacketReader packet)
 {
     PacketHandler handler;
     if (PacketHandlers.TryGetValue((Opcodes)packet.Header.Opcode, out handler))
     {
         if (AuthenticationCrypto.Status == AuthStatus.Ready)
             handler.BeginInvoke(packet, r => handler.EndInvoke(r), null);
         else
             handler(packet);
     }
 }
예제 #9
0
 public Item(PacketReader reader)
 {
     DisplayId = reader.ReadUInt32();
     InventoryType = reader.ReadByte();
     reader.ReadUInt32();
 }
예제 #10
0
        void HandleServerChatMessage(PacketReader reader)
        {
            ChatType type = (ChatType)reader.ReadByte();
            Language language;
            UInt64 targetGUID;
            UInt64 targetGUIDOther;
            UInt32 messageLength;
            string channelName = null;
            string message;

            if ((type != ChatType.CHAT_TYPE_CHANNEL && type != ChatType.CHAT_TYPE_WHISPER))
                language = (Language)reader.ReadUInt32();
            else
                language = (Language)reader.ReadUInt32();

            targetGUID = reader.ReadUInt64();
            reader.ReadUInt32();

            switch (type)
            {
                case ChatType.CHAT_TYPE_CHANNEL:
                    channelName = reader.ReadCString();
                    break;
            }

            targetGUIDOther = reader.ReadUInt64();
            messageLength = reader.ReadUInt32();
            message = reader.ReadCString();
            reader.ReadByte();

            PlayerName result = PlayerNameList.Find(
                delegate(PlayerName playerName)
                {
                    return playerName.GUID == targetGUID;
                });

            if (type == ChatType.CHAT_TYPE_SYSTEM)
            {
                foreach (string syntax in message.Split('\n'))
                    if (!CmdList.Contains(syntax)) // Prevent double message
                        CmdList.Add(syntax);
            }

            if (result != null)
            {
                QueryChatMessage.Type = type;
                QueryChatMessage.Message = message;
                QueryChatMessage.Name = result.Name;
                if (channelName != null)
                    QueryChatMessage.ChannelName = channelName;
                ReceiveMsg = QueryChatMessage;
            }
            else
            {
                QueryChatMessage.Type = type;
                QueryChatMessage.Message = message;
                if (channelName != null)
                    QueryChatMessage.ChannelName = channelName;
            }

            if (targetGUID > 0)
            {
                PacketWriter writer = new PacketWriter(Opcodes.CMSG_NAME_QUERY);
                writer.Write(targetGUID);
                Send(writer);
            }
        }
예제 #11
0
 void HandleChatPlayerNotFound(PacketReader reader)
 {
     WarningMessage = "Player " + reader.ReadCString() + " not found..";
 }