Example #1
0
        /// <summary>
        /// Packets handled in this function could possibly be overriden by a plugin
        /// </summary>
        internal void HandleOverridePacket(PacketEventArgs e)
        {
            switch ((AresId)e.Packet.Id)
            {
            case AresId.MSG_CHAT_CLIENT_PUBLIC:
                ClientPublic pub = (ClientPublic)e.Packet;

                if (!string.IsNullOrEmpty(pub.Message))
                {
                    server.SendPacket((s) =>
                                      s.Vroom == Vroom &&
                                      s.CanSee(this) &&
                                      !s.Ignored.Contains(Name),
                                      new ServerPublic(Name, pub.Message));
                }
                break;

            case AresId.MSG_CHAT_CLIENT_EMOTE:
                ClientEmote emote = (ClientEmote)e.Packet;

                if (!string.IsNullOrEmpty(emote.Message))
                {
                    server.SendPacket((s) =>
                                      s.Vroom == Vroom &&
                                      s.CanSee(this) &&
                                      !s.Ignored.Contains(Name),
                                      new ServerEmote(Name, emote.Message));
                }
                break;

            case AresId.MSG_CHAT_CLIENT_PVT: {
                Private priv = (Private)e.Packet;

                if (string.IsNullOrEmpty(priv.Message))
                {
                    return;
                }

                IClient target = server.FindUser((s) => s.Name == priv.Username);

                if (target != null)
                {
                    if (target.Ignored.Contains(Name))
                    {
                        SendPacket(new IgnoringYou(priv.Username));
                    }
                    else
                    {
                        priv.Username = Name;
                        server.SendPacket(target, priv);
                    }
                }
                else
                {
                    SendPacket(new Offline(priv.Username));
                }
            }
            break;

            case AresId.MSG_CHAT_CLIENT_PERSONAL_MESSAGE:
                ClientPersonal personal = (ClientPersonal)e.Packet;
                Message = personal.Message;
                break;

            case AresId.MSG_CHAT_CLIENT_AVATAR:
                ClientAvatar avatar = (ClientAvatar)e.Packet;

                if (avatar.AvatarBytes.Length == 0)
                {
                    Avatar = null;
                }
                else
                {
                    Avatar = avatar.AvatarBytes;
                    OrgAvatar ??= avatar.AvatarBytes;
                }
                break;

            case AresId.MSG_CHAT_CLIENT_CUSTOM_DATA: {
                ClientCustom custom = (ClientCustom)e.Packet;

                string username = string.IsNullOrEmpty(custom.Username) ? Name : custom.Username;
                custom.Username = Name;

                IClient target = server.FindUser((s) => s.Name == username);

                if (target != null && !target.Ignored.Contains(Name))
                {
                    server.SendPacket(target, custom);
                }
            }
            break;

            case AresId.MSG_CHAT_CLIENT_CUSTOM_DATA_ALL:
                ClientCustomAll customAll = (ClientCustomAll)e.Packet;

                server.SendPacket((s) =>
                                  s != this &&
                                  s.Vroom == Vroom &&
                                  s.CanSee(this),
                                  new ClientCustom(Name, customAll));

                break;
            }
        }
Example #2
0
        /// <summary>
        /// Packets handled in this function could possibly be overriden by a plugin
        /// </summary>
        internal void HandleOverridePacket(PacketEventArgs e)
        {
            switch ((AresId)e.Packet.Id)
            {
            case AresId.MSG_CHAT_CLIENT_PUBLIC:
                ClientPublic pub = (ClientPublic)e.Packet;

                if (!String.IsNullOrEmpty(pub.Message))
                {
                    server.SendPacket((s) =>
                                      s.Vroom == Vroom &&
                                      !s.Ignored.Contains(Name),
                                      new ServerPublic(Name, pub.Message));
                }
                break;

            case AresId.MSG_CHAT_CLIENT_EMOTE:
                ClientEmote emote = (ClientEmote)e.Packet;

                if (!String.IsNullOrEmpty(emote.Message))
                {
                    server.SendPacket((s) =>
                                      s.Vroom == Vroom &&
                                      !s.Ignored.Contains(Name),
                                      new ServerEmote(Name, emote.Message));
                }
                break;

            case AresId.MSG_CHAT_CLIENT_PVT: {
                Private priv = (Private)e.Packet;

                if (String.IsNullOrEmpty(priv.Message))
                {
                    return;
                }

                IClient target = server.FindUser((s) => s.Name == priv.Username);

                if (target != null)
                {
                    if (target.Ignored.Contains(Name))
                    {
                        server.SendPacket(this, new IgnoringYou(priv.Username));
                    }
                    else
                    {
                        priv.Username = Name;
                        server.SendPacket(target, priv);
                    }
                }
                else
                {
                    server.SendPacket(this, new Offline(priv.Username));
                }
            }
            break;

            case AresId.MSG_CHAT_CLIENT_COMMAND:
                //Command cmd = (Command)e.Packet;
                //Not necessary to handle this here anymore
                break;

            case AresId.MSG_CHAT_CLIENT_PERSONAL_MESSAGE:
                ClientPersonal personal = (ClientPersonal)e.Packet;
                Message = personal.Message;
                break;

            case AresId.MSG_CHAT_CLIENT_AVATAR:
                ClientAvatar avatar = (ClientAvatar)e.Packet;

                if (Avatar.Equals(avatar))
                {
                    break;
                }

                if (avatar.AvatarBytes.Length == 0)
                {
                    Avatar = AresAvatar.Null;
                }
                else
                {
                    Avatar = new AresAvatar(avatar.AvatarBytes);

                    if (OrgAvatar == null)
                    {
                        OrgAvatar = new AresAvatar(avatar.AvatarBytes);
                    }
                }
                break;

            case AresId.MSG_CHAT_CLIENT_CUSTOM_DATA: {
                ClientCustom custom = (ClientCustom)e.Packet;

                string username = custom.Username;
                custom.Username = Name;

                IClient target = server.FindUser((s) => s.Name == username);

                if (target != null && !target.Ignored.Contains(Name))
                {
                    server.SendPacket(target, custom);
                }
            }
            break;

            case AresId.MSG_CHAT_CLIENT_CUSTOM_DATA_ALL:
                ClientCustomAll customAll = (ClientCustomAll)e.Packet;

                server.SendPacket((s) =>
                                  s != this &&
                                  s.Vroom == Vroom,
                                  new ClientCustom(Name, customAll));

                break;
            }
        }