Ejemplo n.º 1
0
        public static bool IsIgnored(Mobile source, Mobile check)
        {
            ArrayList list = (ArrayList)m_IgnoreLists[source];

            if (list == null)
            {
                return(false);
            }

            for (int i = 0; i < list.Count; ++i)
            {
                IgnoreEntry ie = (IgnoreEntry)list[i];

                if (ie.Expired)
                {
                    list.RemoveAt(i--);
                }
                else if (ie.Ignored == check)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static void BeginIgnore(Mobile source, Mobile toIgnore)
        {
            ArrayList list = (ArrayList)m_IgnoreLists[source];

            if (list == null)
            {
                m_IgnoreLists[source] = list = new ArrayList();
            }

            for (int i = 0; i < list.Count; ++i)
            {
                IgnoreEntry ie = (IgnoreEntry)list[i];

                if (ie.Ignored == toIgnore)
                {
                    ie.Refresh();
                    return;
                }
                else if (ie.Expired)
                {
                    list.RemoveAt(i--);
                }
            }

            list.Add(new IgnoreEntry(toIgnore));
        }
Ejemplo n.º 3
0
        public static void BeginIgnore(Mobile source, Mobile toIgnore)
        {
            if (!m_IgnoreLists.TryGetValue(source, out List <IgnoreEntry> list))
            {
                m_IgnoreLists[source] = list = new List <IgnoreEntry>();
            }

            for (int i = 0; i < list.Count; ++i)
            {
                IgnoreEntry ie = list[i];

                if (ie.Ignored == toIgnore)
                {
                    ie.Refresh();
                    return;
                }

                if (ie.Expired)
                {
                    list.RemoveAt(i--);
                }
            }

            list.Add(new IgnoreEntry(toIgnore));
        }
Ejemplo n.º 4
0
        public static bool IsIgnored(Mobile source, Mobile check)
        {
            List <IgnoreEntry> list;

            m_IgnoreLists.TryGetValue(source, out list);

            if (list == null)
            {
                return(false);
            }

            for (int i = 0; i < list.Count; ++i)
            {
                IgnoreEntry ie = list[i];

                if (ie.Expired)
                {
                    list.RemoveAt(i--);
                }
                else if (ie.Ignored == check)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        public int HandlePacket(BaseClient client, PacketIn packet)
        {
            WorldClient cclient = (WorldClient)client;
            uint        charUID = packet.GetUint32Reversed();

            PacketOut   Out = new PacketOut((uint)Opcodes.ANS_IGNORELIST_REMOVE);
            IgnoreEntry ign = Databases.IgnoreTable.SingleOrDefault(i => i.CharacterIgnoreIndex == charUID);

            Databases.IgnoreTable.Remove(ign);
            Out.WriteUInt32((uint)ResponseCodes.RC_SUCCESS);
            Out.WriteUInt32Reverse(charUID);
            cclient.Send(Out);
            return(0);
        }
Ejemplo n.º 6
0
        public int HandlePacket(BaseClient client, PacketIn packet)
        {
            WorldClient cclient  = (WorldClient)client;
            string      charName = packet.GetParsedString();

            PacketOut      Out   = new PacketOut((uint)Opcodes.ANS_IGNORELIST_ADD);
            int            count = Databases.CharacterTable.Count(c => c.Name == charName);
            CharacterEntry chr   = Databases.CharacterTable.SingleOrDefault(c => c.Name == charName);

            if (cclient.Character.Name == charName)
            {
                Out.WriteUInt32Reverse((uint)ResponseCodes.RC_IGNORELIST_ADD_SELF);
            }
            else
            {
                if (cclient.Character.AccountIndex == chr.AccountIndex)
                {
                    Out.WriteUInt32Reverse((uint)ResponseCodes.RC_IGNORELIST_ADD_SAME_ACCOUNT);
                }
                else
                {
                    if (count < 1)
                    {
                        Out.WriteUInt32Reverse((uint)ResponseCodes.RC_IGNORELIST_ADD_NOT_FOUND);
                    }
                    else if (count >= 1)
                    {
                        Out.WriteUInt32((uint)ResponseCodes.RC_SUCCESS);
                        Out.WriteUInt32Reverse((uint)chr.Index);
                        Out.WriteParsedString(charName);
                        IgnoreEntry ign = new IgnoreEntry();
                        ign.Index = Databases.FriendTable.GenerateIndex();
                        ign.CharacterOwnerIndex  = cclient.Character.Index;
                        ign.CharacterIgnoreIndex = chr.Index;
                        Databases.IgnoreTable.Add(ign);
                    }
                }
            }
            cclient.Send(Out);
            return(0);
        }
Ejemplo n.º 7
0
        protected void PotentialIgnoreListRequest(ChatboxMessage message)
        {
            var body  = message.BodyBBCode;
            var match = IgnoreTrigger.Match(body);

            if (!match.Success)
            {
                return;
            }

            var command             = match.Groups[1].Value;
            var blockSender         = match.Groups[2].Value.Trim();
            var blockSenderLower    = blockSender.ToLowerInvariant();
            var blockRecipientLower = message.UserName.ToLowerInvariant();

            bool isIgnored;

            using (var ctx = GetNewContext())
            {
                isIgnored = ctx.IgnoreList
                            .Any(ie => ie.SenderFolded == blockSenderLower && ie.RecipientFolded == blockRecipientLower);
            }

            if (command == "ignore")
            {
                if (isIgnored)
                {
                    Connector.SendMessage(string.Format(
                                              "[noparse]{0}[/noparse]: You are already ignoring [i][noparse]{1}[/noparse][/i].",
                                              message.UserName,
                                              blockSender
                                              ));
                    return;
                }

                using (var ctx = GetNewContext())
                {
                    var entry = new IgnoreEntry
                    {
                        SenderFolded    = blockSenderLower,
                        RecipientFolded = blockRecipientLower
                    };
                    ctx.IgnoreList.Add(entry);
                    ctx.SaveChanges();
                }
                Logger.DebugFormat(
                    "{0} is now ignoring {1}",
                    Util.LiteralString(message.UserName),
                    Util.LiteralString(blockSender)
                    );

                Connector.SendMessage(string.Format(
                                          "[noparse]{0}[/noparse]: You are now ignoring [i][noparse]{1}[/noparse][/i].",
                                          message.UserName,
                                          blockSender
                                          ));
            }
            else if (command == "unignore")
            {
                if (!isIgnored)
                {
                    Connector.SendMessage(string.Format(
                                              "[noparse]{0}[/noparse]: You have not been ignoring [i][noparse]{1}[/noparse][/i].",
                                              message.UserName,
                                              blockSender
                                              ));
                    return;
                }

                using (var ctx = GetNewContext())
                {
                    var entry = ctx.IgnoreList
                                .FirstOrDefault(ie => ie.SenderFolded == blockSenderLower && ie.RecipientFolded == blockRecipientLower);
                    ctx.IgnoreList.Remove(entry);
                    ctx.SaveChanges();
                }
                Logger.DebugFormat(
                    "{0} is not ignoring {1} anymore",
                    Util.LiteralString(message.UserName),
                    Util.LiteralString(blockSender)
                    );

                Connector.SendMessage(string.Format(
                                          "[noparse]{0}[/noparse]: You are not ignoring [i][noparse]{1}[/noparse][/i] anymore.",
                                          message.UserName,
                                          blockSender
                                          ));
            }
        }