Пример #1
0
        public static void SendAreaTriggerMessage(IPacketReceiver client, string msg)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AREA_TRIGGER_MESSAGE, (msg.Length * 2) + 4))
            {
                packet.WriteUIntPascalString(msg);
                packet.Write((byte)0);

                client.Send(packet);
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a chat message packet for a player.
        /// </summary>
        /// <param name="type">the type of chat message</param>
        /// <param name="language">the language the message is in</param>
        /// <param name="id1">the ID of the chatter</param>
        /// <param name="id2">the ID of the receiver</param>
        /// <param name="target">the target or null (if its an area message)</param>
        /// <param name="msg">the message itself</param>
        /// <param name="tag">the chat tag of the chatter</param>
        /// <returns>Might return null</returns>
        private static RealmPacketOut CreateCharChatMessage(ChatMsgType type, ChatLanguage language, EntityId id1, EntityId id2,
                                                            string target, string msg, ChatTag tag)
        {
            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT);

            packet.Write((byte)type);
            packet.Write((uint)language);
            packet.Write(id1);
            packet.Write(0);
            if (target != null)
            {
                packet.WriteUIntPascalString(target);
            }
            packet.Write(id2);
            packet.WriteUIntPascalString(msg);
            packet.Write((byte)tag);

            return(packet);
        }
Пример #3
0
        /// <summary>
        /// Creates a packet
        /// </summary>
        public static RealmPacketOut CreateChatPacket(ChatMsgType type, ChatLanguage language, string msg, ChatTag tag)
        {
            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT, 23 + msg.Length);
            packet.WriteByte((byte)type);			// 1
            packet.WriteUInt((uint)language);		// 5
            packet.WriteUIntPascalString(msg);			// 22 + msg.Length
            packet.WriteByte((byte)tag);			// 23 + msg.Length

            return packet;
        }
Пример #4
0
		public static void SendAreaTriggerMessage(IPacketReceiver client, string msg)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AREA_TRIGGER_MESSAGE, (msg.Length * 2) + 4))
			{
				packet.WriteUIntPascalString(msg);
				packet.Write((byte)0);

				client.Send(packet);
			}
		}
Пример #5
0
        /// <summary>
        /// Sends a message to this channel.
        /// </summary>
        /// <param name="sender">the chatter saying the message</param>
        public void SendMessage(IChatter sender, string message)
        {
            ChannelMember mi;

            if (!Members.TryGetValue(sender.EntityId.Low, out mi))
            {
                ChannelHandler.SendNotOnChannelReply(sender, m_name);
                return;
            }

            if (mi.IsMuted)
            {
                ChannelHandler.SendMutedReply(sender, m_name);
                return;
            }

            bool isMod = mi.IsModerator;

            if (IsModerated && !isMod)
            {
                ChannelHandler.SendNotOnChannelReply(sender, m_name);
                return;
            }

            if (sender is IUser)
            {
                if (RealmCommandHandler.HandleCommand((IUser)sender, message, this))
                {
                    return;
                }
            }

            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT))
            {
                packet.Write((byte)ChatMsgType.Channel);
                packet.Write((uint)sender.SpokenLanguage);
                packet.Write(sender.EntityId);
                packet.Write(0);                                        // unknown
                packet.WriteCString(Name);
                packet.Write(sender.EntityId);
                packet.WriteUIntPascalString(message);
                packet.Write((byte)sender.ChatTag);                 // chat tag

                if (isMod)
                {
                    ChannelHandler.SendPacketToChannel(this, packet);
                }
                else
                {
                    ChannelHandler.SendPacketToChannel(this, packet, sender.EntityId);
                }

                ChatMgr.ChatNotify(sender, message, sender.SpokenLanguage, ChatMsgType.Channel, this);
            }
        }
Пример #6
0
        /// <summary>
        /// Creates a packet
        /// </summary>
        public static RealmPacketOut CreateChatPacket(ChatMsgType type, ChatLanguage language, string msg, ChatTag tag)
        {
            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT, 23 + msg.Length);

            packet.WriteByte((byte)type);                               // 1
            packet.WriteUInt((uint)language);                           // 5
            packet.WriteUIntPascalString(msg);                          // 22 + msg.Length
            packet.WriteByte((byte)tag);                                // 23 + msg.Length

            return(packet);
        }
Пример #7
0
 public static void SendTextEmote(WorldObject obj, TextEmote emote, INamed target)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_TEXT_EMOTE,
                                                       target == null ? 20 : target.Name.Length + 21))
     {
         packet.Write(obj.EntityId);
         packet.WriteUInt((uint)emote);
         packet.WriteInt(-1);
         packet.WriteUIntPascalString(target != null ? target.Name : "");
         obj.SendPacketToArea(packet, true, false, Locale.Any, new float?());
     }
 }
Пример #8
0
        public static RealmPacketOut CreateAchievementEarnedToGuild(uint achievementEntryId, Character chr)
        {
            RealmPacketOut realmPacketOut = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT);

            realmPacketOut.WriteByte((byte)48);
            realmPacketOut.WriteUInt(0U);
            realmPacketOut.Write((ulong)chr.EntityId);
            realmPacketOut.WriteUInt(5);
            realmPacketOut.Write((ulong)chr.EntityId);
            realmPacketOut.WriteUIntPascalString("|Hplayer:$N|h[$N]|h has earned the achievement $a!");
            realmPacketOut.WriteByte(0);
            realmPacketOut.WriteUInt(achievementEntryId);
            return(realmPacketOut);
        }
Пример #9
0
        // Client doesn't seem to be sending this
        //[ClientPacketHandler(RealmServerOpCode.CMSG_EMOTE)]
        //public static void HandleEmote(IRealmClient client, RealmPacketIn packet)
        //{
        //    var emote = (EmoteType)packet.ReadUInt32();

        //    if (emote != EmoteType.None)
        //    {
        //        var chr = client.ActiveCharacter;
        //        if (chr.CanMove && chr.CanInteract)
        //        {
        //            SendEmote(chr, emote);
        //        }
        //    }
        //}

        public static void SendTextEmote(WorldObject obj, TextEmote emote, INamed target)
        {
            var len = (target == null) ? 20 : target.Name.Length + 21;

            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TEXT_EMOTE, len))
            {
                packet.Write(obj.EntityId);
                packet.WriteUInt((uint)emote);
                packet.WriteInt(-1);
                packet.WriteUIntPascalString(target != null ? target.Name : "");

                obj.SendPacketToArea(packet, true);
            }
        }
Пример #10
0
        // Client doesn't seem to be sending this
        //[ClientPacketHandler(RealmServerOpCode.CMSG_EMOTE)]
        //public static void HandleEmote(IRealmClient client, RealmPacketIn packet)
        //{
        //    var emote = (EmoteType)packet.ReadUInt32();

        //    if (emote != EmoteType.None)
        //    {
        //        var chr = client.ActiveCharacter;
        //        if (chr.CanMove && chr.CanInteract)
        //        {
        //            SendEmote(chr, emote);
        //        }
        //    }
        //}

        public static void SendTextEmote(WorldObject obj, TextEmote emote, INamed target)
        {
            var len = (target == null) ? 20 : target.Name.Length + 21;

            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TEXT_EMOTE, len))
            {
                packet.Write(obj.EntityId);
                packet.WriteUInt((uint)emote);
                packet.WriteInt(-1);
                packet.WriteUIntPascalString(target != null ? target.Name : "");

                obj.SendPacketToArea(packet, true);
            }
        }
Пример #11
0
 public static RealmPacketOut CreateAchievementEarnedToGuild(AchievementEntryId achievementEntryId, Character chr)
 {
     // Must be a better way to do this.
     const string msg = "|Hplayer:$N|h[$N]|h has earned the achievement $a!";
     var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT);
     packet.WriteByte((byte) ChatMsgType.Achievment);
     packet.WriteUInt((uint) ChatLanguage.Universal);
     packet.Write(chr.EntityId);
     packet.WriteUInt(5);
     packet.Write(chr.EntityId);
     packet.WriteUIntPascalString(msg);
     packet.WriteByte(0);
     packet.WriteUInt((uint) achievementEntryId);
     return packet;
 }
Пример #12
0
        private static RealmPacketOut CreateObjectChatMessage(ChatMsgType type, ChatLanguage language, INamedEntity obj)
        {
            var name = obj.Name;

            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT, 31 + name.Length + 50);

            packet.Write((byte)type);                                                                                                                           // 1
            packet.Write((uint)language);                                                                                                                       // 5
            packet.Write(obj.EntityId);                                                                                                                         // 13
            packet.Write(0);                                                                                                                                    // 17
            packet.WriteUIntPascalString(name);                                                                                                                 // 21 + nameLength
            packet.Write((long)0);                                                                                                                              // 29 + nameLength
            //packet.Write(obj.EntityId);

            return(packet);
        }
Пример #13
0
        public static RealmPacketOut CreateAchievementEarnedToGuild(uint achievementEntryId, Character chr)
        {
            // Must be a better way to do this.
            const string msg    = "|Hplayer:$N|h[$N]|h has earned the achievement $a!";
            var          packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT);

            packet.WriteByte((byte)ChatMsgType.Achievment);
            packet.WriteUInt((uint)ChatLanguage.Universal);
            packet.Write(chr.EntityId);
            packet.WriteUInt(5);
            packet.Write(chr.EntityId);
            packet.WriteUIntPascalString(msg);
            packet.WriteByte(0);
            packet.WriteUInt(achievementEntryId);
            return(packet);
        }
Пример #14
0
        public void SendMessage(string message)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT))
            {
                packet.Write((byte)ChatMsgType.Channel);
                packet.Write((uint)ChatLanguage.Common);
                packet.Write(EntityId.Zero);
                packet.WriteCString("");
                packet.Write(EntityId.Zero);
                packet.WriteUIntPascalString(message);
                packet.Write((byte)ChatTag.None);                 // chat tag

                ChannelHandler.SendPacketToChannel(this, packet);
            }

            ChatMgr.ChatNotify(null, message, ChatLanguage.Common, ChatMsgType.Channel, this);
        }
Пример #15
0
        public void SendMessage(string message)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT))
            {
                packet.Write((byte)17);
                packet.Write(7U);
                packet.Write((ulong)EntityId.Zero);
                packet.WriteCString("");
                packet.Write((ulong)EntityId.Zero);
                packet.WriteUIntPascalString(message);
                packet.Write((byte)0);
                ChannelHandler.SendPacketToChannel(this, packet);
            }

            ChatMgr.ChatNotify((IChatter)null, message, ChatLanguage.Common, ChatMsgType.Channel,
                               (IGenericChatTarget)this);
        }
Пример #16
0
		/// <summary>
		/// Sends a message to this channel.
		/// </summary>
		/// <param name="sender">the chatter saying the message</param>
		public void SendMessage(IChatter sender, string message)
		{
		    ChannelMember mi;
			if (!Members.TryGetValue(sender.EntityId.Low, out mi))
			{
				ChannelHandler.SendNotOnChannelReply(sender, m_name);
				return;
			}

			if (mi.IsMuted)
			{
				ChannelHandler.SendMutedReply(sender, m_name);
				return;
			}

			bool isMod = mi.IsModerator;
			if (IsModerated && !isMod)
			{
				ChannelHandler.SendNotOnChannelReply(sender, m_name);
				return;
			}

			if (sender is IUser)
			{
				if (RealmCommandHandler.HandleCommand((IUser)sender, message, this))
					return;
			}

			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT))
			{
				packet.Write((byte)ChatMsgType.Channel);
				packet.Write((uint)sender.SpokenLanguage);
				packet.Write(sender.EntityId);
				packet.Write(0);			// unknown
				packet.WriteCString(Name);
				packet.Write(sender.EntityId);
				packet.WriteUIntPascalString(message);
				packet.Write((byte)sender.ChatTag); // chat tag

				if (isMod)
				{
					ChannelHandler.SendPacketToChannel(this, packet);
				}
				else
				{
					ChannelHandler.SendPacketToChannel(this, packet, sender.EntityId);
				}

				ChatMgr.ChatNotify(sender, message, sender.SpokenLanguage, ChatMsgType.Channel, this);
			}
		}
Пример #17
0
		public void SendMessage(string message)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT))
			{
				packet.Write((byte)ChatMsgType.Channel);
				packet.Write((uint)ChatLanguage.Common);
				packet.Write(EntityId.Zero);
				packet.WriteCString("");
				packet.Write(EntityId.Zero);
				packet.WriteUIntPascalString(message);
				packet.Write((byte)ChatTag.None); // chat tag

				ChannelHandler.SendPacketToChannel(this, packet);
			}

			ChatMgr.ChatNotify(null, message, ChatLanguage.Common, ChatMsgType.Channel, this);
		}
Пример #18
0
		private static RealmPacketOut CreateObjectChatMessage(ChatMsgType type, ChatLanguage language, INamedEntity obj)
		{
			var name = obj.Name;

			var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT, 31 + name.Length + 50);
			packet.Write((byte)type);															// 1
			packet.Write((uint)language);														// 5
			packet.Write(obj.EntityId);																// 13
			packet.Write(0);																	// 17
			packet.WriteUIntPascalString(name);														// 21 + nameLength
			packet.Write((long)0);																// 29 + nameLength
			//packet.Write(obj.EntityId);

			return packet;
		}
Пример #19
0
		/// <summary>
		/// Creates a chat message packet for a player.
		/// </summary>
		/// <param name="type">the type of chat message</param>
		/// <param name="language">the language the message is in</param>
		/// <param name="id1">the ID of the chatter</param>
		/// <param name="id2">the ID of the receiver</param>
		/// <param name="target">the target or null (if its an area message)</param>
		/// <param name="msg">the message itself</param>
		/// <param name="tag">the chat tag of the chatter</param>
		/// <returns>Might return null</returns>
		private static RealmPacketOut CreateCharChatMessage(ChatMsgType type, ChatLanguage language, EntityId id1, EntityId id2,
			string target, string msg, ChatTag tag)
		{
			var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT);
			packet.Write((byte)type);
			packet.Write((uint)language);
			packet.Write(id1);
			packet.Write(0);
			if (target != null)
				packet.WriteUIntPascalString(target);
			packet.Write(id2);
			packet.WriteUIntPascalString(msg);
			packet.Write((byte)tag);

			return packet;
		}