コード例 #1
0
        /// <summary>
        /// Sends a message to everyone inside the clan room.
        /// </summary>
        /// <param name="character">The character who is sending the message.</param>
        /// <param name="message">The message to send.</param>
        public void Message(Character character, string message)
        {
            Room r = Get((long)character.ClanRoom);

            if (r != null)
            {
                if (r.CanTalk(character.LongName))
                {
                    lock (r.Users)
                    {
                        r.Users.ForEach((l) =>
                        {
                            GameEngine.World.CharacterManager.Get(l).Session.SendData(
                                new ClanMessagePacketComposer(message, character.LongName, r.Name,
                                                              r.NextUniqueId, (byte)character.ClientRights).Serialize());
                            ChatUtilities.LogChat(character.Name, ChatType.Clanchat,
                                                  StringUtilities.LongToString(r.Owner), message);
                        });
                    }
                }
                else
                {
                    character.Session.SendData(new MessagePacketComposer(
                                                   "You do not have a high enough rank to talk.").Serialize());
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// Handles private messages by the character.
 /// </summary>
 /// <param name="character">The character to handle packet for.</param>
 /// <param name="packet">The packet containing handle data.</param>
 public void Handle(Character character, Packet packet)
 {
     if (!character.Muted)
     {
         long   name    = packet.ReadLong();
         int    length  = packet.ReadByte() & 0xFF;
         string message = ChatUtilities.DecryptChat(packet, length);
         character.Contacts.SendMessage(name, message);
     }
 }
コード例 #3
0
        /// <summary>
        /// Constructs a send private message packet.
        /// </summary>
        /// <param name="name">The name of the character, the message is being sent to.</param>
        /// <param name="message">The message being sent.</param>
        public SendPMPacketComposer(long name, string message)
        {
            byte[] bytes = new byte[message.Length];
            ChatUtilities.EncryptChat(bytes, 0, 0, message.Length, Encoding.ASCII.GetBytes(message));

            SetOpcode(89);
            SetType(PacketType.Byte);
            AppendLong(name);
            AppendByte((byte)message.Length);
            AppendBytes(bytes);
        }
コード例 #4
0
        /// <summary>
        /// Constructs a recieve private message packet.
        /// </summary>
        /// <param name="name">The name of the character, the message is being recieved from.</param>
        /// <param name="rights">The rights of the character, the message is being recieved from.</param>
        /// <param name="message">The message recieved.</param>
        public RecievePMPacketComposer(long name, byte rights, string message, int count)
        {
            byte[] bytes = new byte[message.Length + 1];
            bytes[0] = (byte)message.Length;
            ChatUtilities.EncryptChat(bytes, 0, 1, message.Length, Encoding.ASCII.GetBytes(message));

            SetOpcode(178);
            SetType(PacketType.Byte);
            AppendLong(name);
            AppendShort(1);
            AppendByte((byte)((count << 16) & 0xFF));
            AppendByte((byte)((count << 8) & 0xFF));
            AppendByte((byte)(count & 0xFF));
            AppendByte((byte)rights);
            AppendBytes(bytes);
        }
コード例 #5
0
        /// <summary>
        /// Sends a message to the the specified friend.
        /// </summary>
        /// <param name="name">The name of the friend.</param>
        /// <param name="message">The message to send.</param>
        public void SendMessage(long name, string message)
        {
            List <Character> chars = new List <Character>(GameEngine.World.CharacterManager.Characters.Values);

            foreach (Character c in chars)
            {
                if (c.LongName == name)
                {
                    c.Session.SendData(new RecievePMPacketComposer(this.character.LongName,
                                                                   (byte)this.character.ClientRights, message, this.character.Contacts.NextUniqueId).Serialize());
                    this.character.Session.SendData(new SendPMPacketComposer(name, message).Serialize());
                    ChatUtilities.LogChat(this.character.Name, ChatType.Private, c.Name, message);
                    return;
                }
            }
            this.character.Session.SendData(new MessagePacketComposer("Your friend is currently unavailible.").Serialize());
        }
コード例 #6
0
        /// <summary>
        /// Constructs the packet.
        /// </summary>
        /// <param name="message">The message to display.</param>
        public ClanMessagePacketComposer(string message, long playerName, long clanName, int messageCount, byte rights)
        {
            SetOpcode(229);
            SetType(PacketType.Byte);
            AppendLong(playerName);
            AppendByte(1);
            AppendLong(clanName);
            AppendShort(1);

            byte[] bytes = new byte[message.Length + 1];
            bytes[0] = (byte)message.Length;
            ChatUtilities.EncryptChat(bytes, 0, 1, message.Length, Encoding.ASCII.GetBytes(message));

            AppendByte((byte)((messageCount << 16) & 0xFF));
            AppendByte((byte)((messageCount << 8) & 0xFF));
            AppendByte((byte)(messageCount & 0xFF));
            AppendByte(rights);
            AppendBytes(bytes);
        }
コード例 #7
0
        /// <summary>
        /// Handles the chat information sent from the client.
        /// </summary>
        /// <param name="character">The character to handle packet for.</param>
        /// <param name="packet">The packet containing handle data.</param>
        public void Handle(Character character, Packet packet)
        {
            if (!character.Muted)
            {
                int    effects = packet.ReadShort() & 0xFFFF;
                int    length  = packet.ReadByte();
                string text    = ChatUtilities.DecryptChat(packet, length);

                if (character.ClanRoom != null && text.StartsWith("/"))
                {
                    GameEngine.Content.ClanChat.Message(character, text.Substring(1));
                }
                else
                {
                    character.Speak(ChatMessage.Create(effects, length, text));
                    ChatUtilities.LogChat(character.Name, ChatType.Normal, null, text);
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// Appends any needed update masks.
        /// </summary>
        /// <param name="character">The character to update.</param>
        /// <param name="updateBlock">The update block to add generated data to.</param>
        /// <param name="forceAppearance">Whether to force the appearance update.</param>
        public static void AppendMasks(Character character, GenericPacketComposer updateBlock, bool forceAppearance)
        {
            int mask = 0x0;

            if (character.UpdateFlags.Damage2UpdateRequired)
            {
                mask |= 0x200;
            }
            if (character.UpdateFlags.FaceToUpdateRequired)
            {
                mask |= 0x20;
            }
            if (character.UpdateFlags.GraphicsUpdateRequired)
            {
                mask |= 0x400;
            }
            if (character.UpdateFlags.ChatUpdateRequired)
            {
                mask |= 0x8;
            }
            if (character.UpdateFlags.AnimationUpdateRequired)
            {
                mask |= 0x1;
            }
            if (character.UpdateFlags.AppearanceUpdateRequired || forceAppearance)
            {
                mask |= 0x80;
            }
            if (character.UpdateFlags.DamageUpdateRequired)
            {
                mask |= 0x2;
            }

            if (mask >= 0x100)
            {
                mask |= 0x10;
                updateBlock.AppendByte((byte)(mask & 0xFF));
                updateBlock.AppendByte((byte)(mask >> 8));
            }
            else
            {
                updateBlock.AppendByte((byte)(mask & 0xFF));
            }

            if (character.UpdateFlags.Damage2UpdateRequired)
            {
                //AppendDamage2Update(p, updateBlock);
            }
            if (character.UpdateFlags.FaceToUpdateRequired)
            {
                updateBlock.AppendShort(character.UpdateFlags.FaceTo);
            }
            if (character.UpdateFlags.GraphicsUpdateRequired)
            {
                updateBlock.AppendShort(character.CurrentGraphic.Id);
                updateBlock.AppendIntSecondary(character.CurrentGraphic.Delay);
            }
            if (character.UpdateFlags.ChatUpdateRequired)
            {
                updateBlock.AppendShortA((short)character.CurrentChatMessage.Effects);
                updateBlock.AppendByteC((byte)character.ClientRights);
                byte[] chatStr = new byte[256];
                chatStr[0] = (byte)character.CurrentChatMessage.Text.Length;
                byte offset = (byte)(1 + ChatUtilities.EncryptChat(chatStr, 0, 1,
                                                                   character.CurrentChatMessage.Text.Length,
                                                                   Encoding.ASCII.GetBytes(character.CurrentChatMessage.Text)));
                updateBlock.AppendByteC(offset);
                updateBlock.AppendBytes(chatStr, 0, offset);
            }
            if (character.UpdateFlags.AnimationUpdateRequired)
            {
                updateBlock.AppendShort(character.CurrentAnimation.Id);
                updateBlock.AppendByteS(character.CurrentAnimation.Delay);
            }
            if (character.UpdateFlags.AppearanceUpdateRequired || forceAppearance)
            {
                AppendAppearanceUpdate(character, updateBlock);
            }
            if (character.UpdateFlags.DamageUpdateRequired)
            {
                //AppendDamageUpdate(p, updateBlock);
            }
        }