Ejemplo n.º 1
0
        // https://github.com/cmangos/mangos-wotlk/blob/master/src/game/Chat.cpp#L3512
        private static int OnChatMessage(IntPtr param, WoWClientServices.NetMessage msgId, uint time, IntPtr pData)
        {
            var data = new CDataStore(pData);

            var sb   = new StringBuilder();
            var type = (ChatMsgType)data.Read <byte>();

            sb.AppendFormat("[T:{0}] ", type);
            sb.AppendFormat("[L:{0}] ", data.Read <int>());
            sb.AppendFormat("[SG:{0}] ", data.Read <long>());
            data.Read <int>();

            switch (type)
            {
            case ChatMsgType.CHAT_MSG_MONSTER_SAY:
            case ChatMsgType.CHAT_MSG_MONSTER_PARTY:
            case ChatMsgType.CHAT_MSG_MONSTER_YELL:
            case ChatMsgType.CHAT_MSG_MONSTER_WHISPER:
            case ChatMsgType.CHAT_MSG_MONSTER_EMOTE:
            case ChatMsgType.CHAT_MSG_RAID_BOSS_WHISPER:
            case ChatMsgType.CHAT_MSG_RAID_BOSS_EMOTE:
            case ChatMsgType.CHAT_MSG_BATTLENET:
            case ChatMsgType.CHAT_MSG_WHISPER_FOREIGN:
                // Sender length, name and target GUID
                sb.AppendFormat("[SN:{0}] ", data.GetString(data.Read <int>()));
                sb.AppendFormat("[TG:{0}] ", data.Read <long>());

                /*
                 * if (targetGuid && !targetGuid.IsPlayer() && !targetGuid.IsPet() && (msgtype != CHAT_MSG_WHISPER_FOREIGN))
                 * {
                 *  data << uint32(strlen(targetName) + 1); // target name length
                 *  data << targetName; // target name
                 * }
                 */
                break;

            case ChatMsgType.CHAT_MSG_BG_SYSTEM_NEUTRAL:
            case ChatMsgType.CHAT_MSG_BG_SYSTEM_ALLIANCE:
            case ChatMsgType.CHAT_MSG_BG_SYSTEM_HORDE:
                // Target guid, sender length and name
                sb.AppendFormat("[TG:{0}] ", data.Read <long>());

                /*
                 * if (targetGuid && !targetGuid.IsPlayer())
                 * {
                 *  MANGOS_ASSERT(targetName);
                 *  data << uint32(strlen(targetName) + 1); // target name length
                 *  data << targetName; // target name
                 * }
                 */
                //sb.AppendFormat("[SN:{0}] ", data.GetString(data.Read<int>()));
                break;

            case ChatMsgType.CHAT_MSG_ACHIEVEMENT:
            case ChatMsgType.CHAT_MSG_GUILD_ACHIEVEMENT:
                // Target GUID
                sb.AppendFormat("[TG:{0}] ", data.Read <long>());
                break;

            case ChatMsgType.CHAT_MSG_CHANNEL:
                // Channel name, and target GUID
                sb.AppendFormat("[CN:{0}] ", data.GetString(64));     // verify length of channel name
                sb.AppendFormat("[TG:{0}] ", data.Read <long>());
                break;

            default:
                // Target GUID
                sb.AppendFormat("[TG:{0}] ", data.Read <long>());
                break;
            }

            // Message length and content, tag
            sb.AppendFormat("[M:{0}] ", data.GetString(data.Read <int>()));
            sb.AppendFormat("[T:{0}] ", (ChatTag)data.Read <byte>());

            Log.WriteLine(sb.ToString());

            // Call the WoW's internal chat message handler.
            data.Prepare();
            return(_chatMessageHandler(param, msgId, time, pData));
        }
Ejemplo n.º 2
0
 public void SendGamePacket(CDataStore pData)
 {
     pData.Prepare();
     if (_sendPacket == null)
         _sendPacket =
             Manager.Memory.RegisterDelegate<SendPacketDelegate>(Pointers.ClientServices.SendPacket.ToPointer());
     _sendPacket(pData.Pointer);
 }
Ejemplo n.º 3
0
 public void SendPacket(CDataStore pData)
 {
     pData.Prepare();
     if (_sendPacket2 == null)
         _sendPacket2 =
             Manager.Memory.RegisterDelegate<SendPacket2Delegate>(Pointers.ClientServices.SendPacket2.ToPointer());
     _sendPacket2(GetCurrent(), pData.Pointer);
 }
Ejemplo n.º 4
0
        // https://github.com/cmangos/mangos-wotlk/blob/master/src/game/Chat.cpp#L3512
        private static int OnChatMessage(IntPtr param, WoWClientServices.NetMessage msgId, uint time, IntPtr pData)
        {
            var data = new CDataStore(pData);

            var sb = new StringBuilder();
            var type = (ChatMsgType)data.Read<byte>();
            sb.AppendFormat("[T:{0}] ", type);
            sb.AppendFormat("[L:{0}] ", data.Read<int>());
            sb.AppendFormat("[SG:{0}] ", data.Read<long>());
            data.Read<int>();

            switch (type)
            {
                case ChatMsgType.CHAT_MSG_MONSTER_SAY:
                case ChatMsgType.CHAT_MSG_MONSTER_PARTY:
                case ChatMsgType.CHAT_MSG_MONSTER_YELL:
                case ChatMsgType.CHAT_MSG_MONSTER_WHISPER:
                case ChatMsgType.CHAT_MSG_MONSTER_EMOTE:
                case ChatMsgType.CHAT_MSG_RAID_BOSS_WHISPER:
                case ChatMsgType.CHAT_MSG_RAID_BOSS_EMOTE:
                case ChatMsgType.CHAT_MSG_BATTLENET:
                case ChatMsgType.CHAT_MSG_WHISPER_FOREIGN:
                    // Sender length, name and target GUID
                    sb.AppendFormat("[SN:{0}] ", data.GetString(data.Read<int>()));
                    sb.AppendFormat("[TG:{0}] ", data.Read<long>());
                    /*
                    if (targetGuid && !targetGuid.IsPlayer() && !targetGuid.IsPet() && (msgtype != CHAT_MSG_WHISPER_FOREIGN))
                    {
                        data << uint32(strlen(targetName) + 1); // target name length
                        data << targetName; // target name
                    }
                    */
                    break;

                case ChatMsgType.CHAT_MSG_BG_SYSTEM_NEUTRAL:
                case ChatMsgType.CHAT_MSG_BG_SYSTEM_ALLIANCE:
                case ChatMsgType.CHAT_MSG_BG_SYSTEM_HORDE:
                    // Target guid, sender length and name
                    sb.AppendFormat("[TG:{0}] ", data.Read<long>());
                    /*
                    if (targetGuid && !targetGuid.IsPlayer())
                    {
                        MANGOS_ASSERT(targetName);
                        data << uint32(strlen(targetName) + 1); // target name length
                        data << targetName; // target name
                    }
                    */
                    //sb.AppendFormat("[SN:{0}] ", data.GetString(data.Read<int>()));
                    break;

                case ChatMsgType.CHAT_MSG_ACHIEVEMENT:
                case ChatMsgType.CHAT_MSG_GUILD_ACHIEVEMENT:
                    // Target GUID
                    sb.AppendFormat("[TG:{0}] ", data.Read<long>());
                    break;

                case ChatMsgType.CHAT_MSG_CHANNEL:
                    // Channel name, and target GUID
                    sb.AppendFormat("[CN:{0}] ", data.GetString(64)); // verify length of channel name
                    sb.AppendFormat("[TG:{0}] ", data.Read<long>());
                    break;

                default:
                    // Target GUID
                    sb.AppendFormat("[TG:{0}] ", data.Read<long>());
                    break;
            }

            // Message length and content, tag
            sb.AppendFormat("[M:{0}] ", data.GetString(data.Read<int>()));
            sb.AppendFormat("[T:{0}] ", (ChatTag)data.Read<byte>());

            Log.WriteLine(sb.ToString());

            // Call the WoW's internal chat message handler.
            data.Prepare();
            return _chatMessageHandler(param, msgId, time, pData);
        }