Beispiel #1
0
        void HandleMessageChat(InPacket packet)
        {
            var type = (ChatMessageType)packet.ReadByte();
            var lang = (Language)packet.ReadInt32();
            var guid = packet.ReadUInt64();
            var unkInt = packet.ReadInt32();

            switch (type)
            {
                case ChatMessageType.Say:
                case ChatMessageType.Yell:
                case ChatMessageType.Party:
                case ChatMessageType.PartyLeader:
                case ChatMessageType.Raid:
                case ChatMessageType.RaidLeader:
                case ChatMessageType.RaidWarning:
                case ChatMessageType.Guild:
                case ChatMessageType.Officer:
                case ChatMessageType.Emote:
                case ChatMessageType.TextEmote:
                case ChatMessageType.Whisper:
                case ChatMessageType.WhisperInform:
                case ChatMessageType.System:
                case ChatMessageType.Channel:
                case ChatMessageType.Battleground:
                case ChatMessageType.BattlegroundNeutral:
                case ChatMessageType.BattlegroundAlliance:
                case ChatMessageType.BattlegroundHorde:
                case ChatMessageType.BattlegroundLeader:
                case ChatMessageType.Achievement:
                case ChatMessageType.GuildAchievement:
                    {
                        ChatChannel channel = new ChatChannel();
                        channel.Type = type;

                        if (type == ChatMessageType.Channel)
                            channel.ChannelName = packet.ReadCString();

                        var sender = packet.ReadUInt64();

                        ChatMessage message = new ChatMessage();
                        var textLen = packet.ReadInt32();
                        message.Message = packet.ReadCString();
                        message.Language = lang;
                        message.ChatTag = (ChatTag)packet.ReadByte();
                        message.Sender = channel;

                        //! If we know the name of the sender GUID, use it
                        //! For system messages sender GUID is 0, don't need to do anything fancy
                        string senderName = null;
                        if (type == ChatMessageType.System ||
                            Game.World.PlayerNameLookup.TryGetValue(sender, out senderName))
                        {
                            message.Sender.Sender = senderName;
                            Game.UI.PresentChatMessage(message);
                            return;
                        }

                        //! If not we place the message in the queue,
                        //! .. either existent
                        Queue<ChatMessage> messageQueue = null;
                        if (Game.World.QueuedChatMessages.TryGetValue(sender, out messageQueue))
                            messageQueue.Enqueue(message);
                        //! or non existent
                        else
                        {
                            messageQueue = new Queue<ChatMessage>();
                            messageQueue.Enqueue(message);
                            Game.World.QueuedChatMessages.Add(sender, messageQueue);
                        }

                        //! Furthermore we send CMSG_NAME_QUERY to the server to retrieve the name of the sender
                        OutPacket response = new OutPacket(WorldCommand.CMSG_NAME_QUERY);
                        response.Write(sender);
                        Game.SendPacket(response);

                        //! Enqueued chat will be printed when we receive SMSG_NAME_QUERY_RESPONSE

                        break;
                    }
                default:
                    return;
            }
        }
Beispiel #2
0
 public abstract void PresentChatMessage(ChatMessage message);
        public void PresentChatMessage(ChatMessage message)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(message.Sender.Type == ChatMessageType.WhisperInform ? "To: " : message.Sender.Type.ToString());
            //! Color codes taken from default chat_cache in WTF folder
            //! TODO: RTF form?
            switch (message.Sender.Type)
            {
            case ChatMessageType.Channel:
                {
                    //sb.ForeColor(Color.FromArgb(255, 192, 192));
                    Console.ForegroundColor = ConsoleColor.DarkYellow;//Color.DarkSalmon;
                    sb.Append(" [");
                    sb.Append(message.Sender.ChannelName);
                    sb.Append("] ");
                    break;
                }
            case ChatMessageType.Whisper:
                    Game.World.LastWhisperers.Enqueue(message.Sender.Sender);
                    goto case ChatMessageType.WhisperInform;
            case ChatMessageType.WhisperInform:
            case ChatMessageType.WhisperForeign:
                    //sb.ForeColor(Color.FromArgb(255, 128, 255));
                Console.ForegroundColor = ConsoleColor.Magenta;//Color.DeepPink;
                break;
            case ChatMessageType.System:
            case ChatMessageType.Money:
            case ChatMessageType.TargetIcons:
            case ChatMessageType.Achievement:
                    //sb.ForeColor(Color.FromArgb(255, 255, 0));
                Console.ForegroundColor = ConsoleColor.Yellow;//Color.Gold;
                break;
            case ChatMessageType.Emote:
            case ChatMessageType.TextEmote:
            case ChatMessageType.MonsterEmote:
                    //sb.ForeColor(Color.FromArgb(255, 128, 64));
                Console.ForegroundColor = ConsoleColor.DarkRed;//Color.Chocolate;
                break;
            case ChatMessageType.Party:
                    //sb.ForeColor(Color.FromArgb(170, 170, 255));
                Console.ForegroundColor = ConsoleColor.DarkCyan;//Color.CornflowerBlue;
                break;
            case ChatMessageType.PartyLeader:
                    //sb.ForeColor(Color.FromArgb(118, 200, 255));
                Console.ForegroundColor = ConsoleColor.Cyan;//Color.DodgerBlue;
                break;
            case ChatMessageType.Raid:
                    //sb.ForeColor(Color.FromArgb(255, 172, 0));
                Console.ForegroundColor = ConsoleColor.Red;//Color.DarkOrange;
                break;
            case ChatMessageType.RaidLeader:
                    //sb.ForeColor(Color.FromArgb(255, 72, 9));
                Console.ForegroundColor = ConsoleColor.Red;//Color.DarkOrange;
                break;
            case ChatMessageType.RaidWarning:
                    //sb.ForeColor(Color.FromArgb(255, 72, 0));
                Console.ForegroundColor = ConsoleColor.Red;//Color.DarkOrange;
                break;
            case ChatMessageType.Guild:
            case ChatMessageType.GuildAchievement:
                    //sb.ForeColor(Color.FromArgb(64, 255, 64));
                Console.ForegroundColor = ConsoleColor.Green;//Color.LimeGreen;
                break;
            case ChatMessageType.Officer:
                    //sb.ForeColor(Color.FromArgb(64, 192, 64));
                Console.ForegroundColor = ConsoleColor.DarkGreen;//Color.DarkSeaGreen;
                break;
            case ChatMessageType.Yell:
                Console.ForegroundColor = ConsoleColor.DarkRed;
                break;
            case ChatMessageType.Say:
            default:
                    //sb.ForeColor(Color.FromArgb(255, 255, 255));
                Console.ForegroundColor = ConsoleColor.White;
                break;
            }

            sb.Append("[");
            if (message.ChatTag.HasFlag(ChatTag.Gm))
                sb.Append("<GM>");
            if (message.ChatTag.HasFlag(ChatTag.Afk))
                sb.Append("<AFK>");
            if (message.ChatTag.HasFlag(ChatTag.Dnd))
                sb.Append("<DND>");
            sb.Append(message.Sender.Sender);
            sb.Append("]: ");
            sb.Append(message.Message);

            LogLine(sb.ToString(), message.Language == Language.Addon ? LogLevel.Debug : LogLevel.Info);
        }
Beispiel #4
0
 public override void PresentChatMessage(ChatMessage message)
 {
 }