public void Handle_NameQuery(PacketIn packet)
        {
            WoWGuid guid = new WoWGuid(packet.ReadUInt64());
            string  name = packet.ReadString();

            packet.ReadByte();
            Race      Race   = (Race)packet.ReadUInt32();
            Gender    Gender = (Gender)packet.ReadUInt32();
            Classname Class  = (Classname)packet.ReadUInt32();


            if (objectMgr.objectExists(guid))        // Update existing Object
            {
                Object obj = objectMgr.getObject(guid);
                obj.Name = name;
                objectMgr.updateObject(obj);
            }
            else                    // Create new Object        -- FIXME: Add to new 'names only' list?
            {
                Object obj = new Object(guid);
                obj.Name = name;
                objectMgr.addObject(obj);

                /* Process chat message if we looked them up now */
                for (int i = 0; i < ChatQueued.Count; i++)
                {
                    ChatQueue message = (ChatQueue)ChatQueued[i];
                    if (message.GUID.GetOldGuid() == guid.GetOldGuid())
                    {
                        Log.WriteLine(LogType.Chat, "[{1}] {0}", message.Message, name);
                        ChatQueued.Remove(message);
                    }
                }
            }
        }
        public void HandleChat(PacketIn packet)
        {
            try
            {
                string  channel = null;
                UInt64  guid = 0;
                WoWGuid fguid = null, fguid2 = null;
                string  username = null;

                byte   Type     = packet.ReadByte();
                UInt32 Language = packet.ReadUInt32();

                guid  = packet.ReadUInt64();
                fguid = new WoWGuid(guid);
                packet.ReadInt32();

                if ((ChatMsg)Type == ChatMsg.Channel)
                {
                    channel = packet.ReadString();
                }

                if (Type == 47)
                {
                    return;
                }
                fguid2 = new WoWGuid(packet.ReadUInt64());

                UInt32 Length  = packet.ReadUInt32();
                string Message = Encoding.Default.GetString(packet.ReadBytes((int)Length));

                //Message = Regex.Replace(Message, @"\|H[a-zA-z0-9:].|h", ""); // Why do i should need spells and quest linked? ;>
                Message = Regex.Replace(Message, @"\|[rc]{1}[a-zA-z0-9]{0,8}", ""); // Colorfull chat message also isn't the most important thing.

                byte afk = 0;

                if (fguid.GetOldGuid() == 0)
                {
                    username = "******";
                }
                else
                {
                    if (objectMgr.objectExists(fguid))
                    {
                        username = objectMgr.getObject(fguid).Name;
                    }
                }

                if (username == null)
                {
                    ChatQueue que = new ChatQueue();
                    que.GUID     = fguid;
                    que.Type     = Type;
                    que.Language = Language;
                    if ((ChatMsg)Type == ChatMsg.Channel)
                    {
                        que.Channel = channel;
                    }
                    que.Length  = Length;
                    que.Message = Message;
                    que.AFK     = afk;
                    ChatQueued.Add(que);
                    QueryName(guid);
                    return;
                }

                object[] param = new object[] { (ChatMsg)Type, channel, username, Message };
                mCore.Event(new Event(EventType.EVENT_CHAT_MSG, "0", param));
                //Log.WriteLine(LogType.Chat, "[{1}] {0}", Message, username);
            }
            catch (Exception ex)
            {
                Log.WriteLine(LogType.Error, "Exception Occured");
                Log.WriteLine(LogType.Error, "Message: {0}", ex.Message);
                Log.WriteLine(LogType.Error, "Stacktrace: {0}", ex.StackTrace);
            }
        }
Esempio n. 3
0
        public void HandleChat(PacketIn packet)
        {
            try
            {

                string channel = null;
                UInt64 guid = 0;
                WoWGuid fguid = null, fguid2 = null;
                string username = null;

                byte Type = packet.ReadByte();
                UInt32 Language = packet.ReadUInt32();

                guid = packet.ReadUInt64();
                fguid = new WoWGuid(guid);
                packet.ReadInt32();

                if ((ChatMsg)Type == ChatMsg.Channel)
                {
                    channel = packet.ReadString();
                }

                if (Type == 47)
                    return;
                fguid2 = new WoWGuid(packet.ReadUInt64());

                UInt32 Length = packet.ReadUInt32();
                string Message = Encoding.Default.GetString(packet.ReadBytes((int)Length));

                //Message = Regex.Replace(Message, @"\|H[a-zA-z0-9:].|h", ""); // Why do i should need spells and quest linked? ;>
                Message = Regex.Replace(Message, @"\|[rc]{1}[a-zA-z0-9]{0,8}", ""); // Colorfull chat message also isn't the most important thing.

                byte afk = 0;

                if (fguid.GetOldGuid() == 0)
                {
                    username = "******";
                }
                else
                {
                    if (objectMgr.objectExists(fguid))
                        username = objectMgr.getObject(fguid).Name;
                }

                if (username == null)
                {

                    ChatQueue que = new ChatQueue();
                    que.GUID = fguid;
                    que.Type = Type;
                    que.Language = Language;
                    if ((ChatMsg)Type == ChatMsg.Channel)
                        que.Channel = channel;
                    que.Length = Length;
                    que.Message = Message;
                    que.AFK = afk;
                    ChatQueued.Add(que);
                    QueryName(guid);
                    return;
                }

                object[] param = new object[] { (ChatMsg)Type, channel, username, Message };
                mCore.Event(new Event(EventType.EVENT_CHAT_MSG, "0", param));
                //Log.WriteLine(LogType.Chat, "[{1}] {0}", Message, username);
            }
            catch (Exception ex)
            {
                Log.WriteLine(LogType.Error, "Exception Occured");
                Log.WriteLine(LogType.Error, "Message: {0}", ex.Message);
                Log.WriteLine(LogType.Error, "Stacktrace: {0}", ex.StackTrace);
            }
        }