Ejemplo n.º 1
0
        private static void SetName(Mobile m, string name)
        {
            name = name.Trim();

            if (!NameVerification.Validate(name, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote))
            {
                name = "Generic Player";
            }

            m.Name = name;
        }
Ejemplo n.º 2
0
        private static void EventSink_Speech(SpeechEventArgs e)
        {
            Mobile from = e.Mobile;

            if (from.IsStaff())
            {
                return;
            }

            if (!NameVerification.Validate(e.Speech, 0, int.MaxValue, true, true, false, int.MaxValue, Exceptions, Disallowed, StartDisallowed))
            {
                e.Blocked = !OnProfanityDetected(from, e.Speech);
            }
        }
        private static void EventSink_Speech(SpeechEventArgs e)
        {
            Mobile from = e.Mobile;

            if (from.AccessLevel > AccessLevel.Player)
            {
                return;
            }

            if (NameVerification.Validate(e.Speech, 0, int.MaxValue, true, true, false, int.MaxValue, m_Exceptions, m_Disallowed, m_StartDisallowed) != NameResultMessage.Allowed)
            {
                e.Blocked = !OnProfanityDetected(from, e.Speech);
            }
        }
Ejemplo n.º 4
0
        private static void EventSink_RenameRequest(Mobile from, Mobile targ, string name)
        {
            if (from.CanSee(targ) && from.InRange(targ, 12) && targ.CanBeRenamedBy(from))
            {
                name = name.Trim();

                if (NameVerification.Validate(
                        name,
                        1,
                        16,
                        true,
                        false,
                        true,
                        0,
                        NameVerification.Empty,
                        NameVerification.StartDisallowed,
                        Core.ML ? NameVerification.Disallowed : Array.Empty <string>()
                        ))
                {
                    if (Core.ML)
                    {
                        var disallowed = ProfanityProtection.Disallowed;

                        for (var i = 0; i < disallowed.Length; i++)
                        {
                            if (name.IndexOfOrdinal(disallowed[i]) != -1)
                            {
                                from.SendLocalizedMessage(1072622); // That name isn't very polite.
                                return;
                            }
                        }

                        from.SendLocalizedMessage(
                            1072623,
                            $"{targ.Name}\t{name}"
                            ); // Pet ~1_OLDPETNAME~ renamed to ~2_NEWPETNAME~.
                    }

                    targ.Name = name;
                }
                else
                {
                    from.SendMessage("That name is unacceptable.");
                }
            }
        }
Ejemplo n.º 5
0
        private static void EventSink_RenameRequest(RenameRequestEventArgs e)
        {
            Mobile from = e.From;
            Mobile targ = e.Target;
            string name = e.Name;

            if (from.CanSee(targ) && from.InRange(targ, 12) && targ.CanBeRenamedBy(from))
            {
                name = name.Trim();

                var numExceptions = 0;
                var exceptions    = NameVerification.Empty;

                if (targ is BaseCreature)
                {
                    exceptions    = new char[] { ' ' };
                    numExceptions = 5;
                }

                if (NameVerification.Validate(name, 1, 16, true, false, true, numExceptions, exceptions, NameVerification.StartDisallowed, (Core.ML ? NameVerification.Disallowed : new string[] { })))
                {
                    if (Core.ML)
                    {
                        string[] disallowed = ProfanityProtection.Disallowed;

                        for (int i = 0; i < disallowed.Length; i++)
                        {
                            if (name.IndexOf(disallowed[i]) != -1)
                            {
                                from.SendLocalizedMessage(1072622); // That name isn't very polite.
                                return;
                            }
                        }

                        from.SendLocalizedMessage(1072623, String.Format("{0}\t{1}", targ.Name, name)); // Pet ~1_OLDPETNAME~ renamed to ~2_NEWPETNAME~.
                    }

                    targ.Name = name;
                }
                else
                {
                    from.SendMessage("That name is unacceptable.");
                }
            }
        }
Ejemplo n.º 6
0
        private static void EventSink_RenameRequest(RenameRequestEventArgs e)
        {
            Mobile from = e.From;
            Mobile targ = e.Target;
            string name = e.Name;

            if (from.CanSee(targ) && from.InRange(targ, 12) && targ.CanBeRenamedBy(from))
            {
                name = name.Trim();

                if (NameVerification.Validate(name, 1, 16, true, false, true, 0, NameVerification.Empty))
                {
                    targ.Name = name;
                }
                else
                {
                    from.SendMessage("That name is unacceptable.");
                }
            }
        }
Ejemplo n.º 7
0
        public static bool AlreadyInUse(Mobile m, string name)
        {
            if (m == null || name == null || name.Length == 0)
            {
                return(true);
            }

            string nameToLower = name.ToLower();

            if (nameToLower == "generic player")
            {
                return(true);
            }

            /*
             * if (AllowedDupes.Contains(nameToLower))
             *  return false;
             *
             * if (Disallowed.Contains(nameToLower))
             *  return true;
             */

            if (!NameVerification.Validate(name, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote))
            {
                return(true);
            }

            foreach (Mobile mob in World.Mobiles.Values)
            {
                if (mob is PlayerMobile && mob != m && mob.RawName != null && mob.RawName.ToLower() == nameToLower && ((PlayerMobile)m).CreationTime > ((PlayerMobile)mob).CreationTime)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 8
0
        private static void EventSink_RenameRequest(RenameRequestEventArgs e)
        {
            Mobile from = e.From;
            Mobile targ = e.Target;
            string name = e.Name;

            if (from.CanSee(targ) && from.InRange(targ, 12) && targ.CanBeRenamedBy(from))
            {
                name = name.Trim();

                if (NameVerification.Validate(name, 1, 16, true, false, true, 0, NameVerification.Empty, NameVerification.StartDisallowed, (/*Core.ML ?*/ NameVerification.Disallowed /*: new string[]{}*/)) == NameResultMessage.Allowed)
                {
//					if( Core.ML )
//					{
                    string[] disallowed = ProfanityProtection.Disallowed;

                    for (int i = 0; i < disallowed.Length; i++)
                    {
                        if (name.IndexOf(disallowed[i]) != -1)
                        {
                            from.SendLocalizedMessage(1072622);                                       // That name isn't very polite.
                            return;
                        }
                    }

                    from.SendLocalizedMessage(1072623, String.Format("{0}\t{1}", targ.Name, name));                                 // Pet ~1_OLDPETNAME~ renamed to ~2_NEWPETNAME~.
//					}

                    targ.Name = name;
                }
                else
                {
                    from.SendMessage("That name is unacceptable.");
                }
            }
        }
Ejemplo n.º 9
0
        public static bool CheckDupe(Mobile m, string name)
        {
            if (m == null || name == null || name.Length == 0)
            {
                return(false);
            }

            name = name.Trim();             //Trim the name and re-assign it

            if (!NameVerification.Validate(name, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote))
            {
                return(false);
            }

            foreach (Mobile wm in World.Mobiles.Values)
            {
                if (wm != m && !wm.Deleted && wm is PlayerMobile && Insensitive.Equals(wm.RawName, name)) //Filter Mobiles by PlayerMobile type and do the name check in one go, no need for another list.
                {
                    return(false);                                                                        // No need to clear anything since we did not make any temporary lists.
                }
            }

            return(true);
        }
Ejemplo n.º 10
0
        public static void ReserveName(CommandEventArgs e)
        {
            if (e.Arguments.Length == 0 || string.IsNullOrEmpty(e.Arguments[0]))
            {
                e.Mobile.SendMessage(0x22, String.Format("Please specify the name."));
                return;
            }

            var key = e.Arguments[0].ToLower();

            if (!NameVerification.Validate(key, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote))
            {
                e.Mobile.SendMessage(0x22, String.Format("The name \"{0}\" is invalid.", e.Arguments[0]));
            }
            else if (e.Mobile is PlayerMobile && !Names.Contains(key))
            {
                Names.Add(key);
                e.Mobile.SendMessage(0x59, String.Format("The name \"{0}\" has been reserved.", e.Arguments[0]));
            }
            else
            {
                e.Mobile.SendMessage(0x22, String.Format("The name \"{0}\" has already been reserved.", e.Arguments[0]));
            }
        }
Ejemplo n.º 11
0
        private static Account CreateAccount(NetState state, string un, string pw)
        {
            if (un.Length == 0 || pw.Length == 0)
            {
                return(null);
            }

            bool isSafe = true;

            for (int i = 0; isSafe && i < un.Length; ++i)
            {
                isSafe = (un[i] >= 0x20 && un[i] < 0x80);
            }

            for (int i = 0; isSafe && i < pw.Length; ++i)
            {
                isSafe = (pw[i] >= 0x20 && pw[i] < 0x80);
            }

            if (!isSafe || (NameVerification.Validate(un, 0, int.MaxValue, true, true, false, int.MaxValue, new char[0]) != NameResultMessage.Allowed))
            {
                return(null);
            }

            if (!CanCreate(state.Address))
            {
                Console.WriteLine("Login: {0}: Account '{1}' not created, ip already has {2} account{3}.", state, un, MaxAccountsPerIP, MaxAccountsPerIP == 1 ? "" : "s");
                return(null);
            }

            Console.WriteLine("Login: {0}: Creating new account '{1}'", state, un);

            Account a = new Account(un, pw);

            return(a);
        }
Ejemplo n.º 12
0
        public static void ValidateAllNames_OnCommand(CommandEventArgs e)
        {
            Dictionary <string, List <PlayerMobile> > table = new Dictionary <string, List <PlayerMobile> >(World.Mobiles.Values.Count);

            foreach (Mobile m in World.Mobiles.Values)
            {
                if (!(m is PlayerMobile))
                {
                    continue;
                }

                string rawName = m.RawName.ToLower().Trim();

                if (rawName == "generic player")
                {
                    continue;
                }

                if (m.AccessLevel > AccessLevel.Player)
                {
                    continue;
                }

                m.RawName = "testtest1233";

                if (!NameVerification.Validate(rawName, 2, 16, true, true, true, 1, NameVerification.SpaceDashPeriodQuote))
                {
                    m.RawName = "testtest1234";
                    Console.WriteLine(rawName);
                    if (table.ContainsKey(rawName))
                    {
                        List <PlayerMobile> players = table[rawName];
                        players.Add(m as PlayerMobile);
                    }
                    else
                    {
                        List <PlayerMobile> newList = new List <PlayerMobile>();
                        newList.Add(m as PlayerMobile);
                        table.Add(rawName, newList);
                    }
                }
                else
                {
                    m.RawName = rawName;
                }

                Queue <PlayerMobile> toRename = new Queue <PlayerMobile>();

                foreach (KeyValuePair <string, List <PlayerMobile> > entry in table)
                {
                    var list = entry.Value;

                    if (list.Count == 0)
                    {
                        continue;
                    }
                    else if (list.Count == 1)
                    {
                        toRename.Enqueue(list[0]);
                    }
                    else
                    {
                        list.Sort(new Comparison <PlayerMobile>(SortByGameTime));

                        for (int i = 1; i < list.Count; i++)
                        {
                            toRename.Enqueue(list[i]);
                        }
                    }
                }

                while (toRename.Count > 0)
                {
                    PlayerMobile pm = toRename.Dequeue();
                    pm.RawName = "Generic Player";
                }

                toRename.Clear();
            }
        }