Пример #1
0
        public void RunCommand(Mobile from, object obj, BaseCommand command, string[] args)
        {
            //	try
            //	{
            CommandEventArgs e = new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args);

            if (!command.ValidateArgs(this, e))
            {
                return;
            }

            bool flushToLog = false;

            if (obj is ArrayList)
            {
                ArrayList list = (ArrayList)obj;

                if (list.Count > 20)
                {
                    CommandLogging.Enabled = false;
                }
                else if (list.Count == 0)
                {
                    command.LogFailure("Nothing was found to use this command on.");
                }

                command.ExecuteList(e, list);

                if (list.Count > 20)
                {
                    flushToLog             = true;
                    CommandLogging.Enabled = true;
                }
            }
            else if (obj != null)
            {
                if (command.ListOptimized)
                {
                    ArrayList list = new ArrayList
                    {
                        obj
                    };
                    command.ExecuteList(e, list);
                }
                else
                {
                    command.Execute(e, obj);
                }
            }

            command.Flush(from, flushToLog);
            //	}
            //	catch ( Exception ex )
            //	{
            //		from.SendMessage( ex.Message );
            //	}
        }
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                if (!mobiles) // sanity check
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                ArrayList list = new ArrayList();

                List <NetState> states = NetState.Instances;

                for (int i = 0; i < states.Count; ++i)
                {
                    NetState ns  = states[i];
                    Mobile   mob = ns.Mobile;

                    if (mob == null)
                    {
                        continue;
                    }

                    if (!BaseCommand.IsAccessible(from, mob))
                    {
                        continue;
                    }

                    if (ext.IsValid(mob))
                    {
                        list.Add(mob);
                    }
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception e)
            {
                from.SendMessage(e.Message);
                Diagnostics.ExceptionLogging.LogException(e);
            }
        }
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                var ext = Extensions.Parse(from, ref args);

                if (!CheckObjectTypes(from, command, ext, out var _, out var mobiles))
                {
                    return;
                }

                if (!mobiles) // sanity check
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                var list = new List <object>();

                var states = TcpServer.Instances;

                for (var i = 0; i < states.Count; ++i)
                {
                    var ns  = states[i];
                    var mob = ns.Mobile;

                    if (mob == null)
                    {
                        continue;
                    }

                    if (!BaseCommand.IsAccessible(from, mob))
                    {
                        continue;
                    }

                    if (ext.IsValid(mob))
                    {
                        list.Add(mob);
                    }
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
Пример #4
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                Region reg = from.Region;

                ArrayList list = new ArrayList();

                if (mobiles)
                {
                    foreach (Mobile mob in reg.GetMobiles())
                    {
                        if (!BaseCommand.IsAccessible(from, mob))
                        {
                            continue;
                        }

                        if (ext.IsValid(mob))
                        {
                            list.Add(mob);
                        }
                    }
                }
                else
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
                Server.Diagnostics.ExceptionLogging.LogException(ex);
            }
        }
Пример #5
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!this.CheckObjectTypes(from, command, ext, out items, out mobiles))
                    return;

                if (!mobiles) // sanity check
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                ArrayList list = new ArrayList();

                List<NetState> states = NetState.Instances;

                for (int i = 0; i < states.Count; ++i)
                {
                    NetState ns = states[i];
                    Mobile mob = ns.Mobile;

                    if (mob == null)
                        continue;

                    if (!BaseCommand.IsAccessible(from, mob))
                        continue;

                    if (ext.IsValid(mob))
                        list.Add(mob);
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
Пример #6
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                if (!mobiles)                   // sanity check
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                ArrayList list      = new ArrayList();
                ArrayList addresses = new ArrayList();

                System.Collections.Generic.List <NetState> states = NetState.Instances;

                for (int i = 0; i < states.Count; ++i)
                {
                    NetState ns  = (NetState)states[i];
                    Mobile   mob = ns.Mobile;

                    if (mob != null && !addresses.Contains(ns.Address) && ext.IsValid(mob))
                    {
                        list.Add(mob);
                        addresses.Add(ns.Address);
                    }
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
Пример #7
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                var ext = Extensions.Parse(from, ref args);

                if (!CheckObjectTypes(from, command, ext, out var _, out var mobiles))
                {
                    return;
                }

                var reg = from.Region;

                var list = new List <object>();

                if (mobiles)
                {
                    foreach (var mob in reg.GetMobiles())
                    {
                        if (!BaseCommand.IsAccessible(from, mob))
                        {
                            continue;
                        }

                        if (ext.IsValid(mob))
                        {
                            list.Add(mob);
                        }
                    }
                }
                else
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
		public override void Compile( Mobile from, BaseCommand command, ref string[] args, ref object obj )
		{
			try
			{
				Extensions ext = Extensions.Parse( from, ref args );

				bool items, mobiles;

				if ( !CheckObjectTypes( from, command, ext, out items, out mobiles ) )
					return;

				if ( !mobiles ) // sanity check
				{
					command.LogFailure( "This command does not support items." );
					return;
				}

				ArrayList list = new ArrayList();
				ArrayList addresses = new ArrayList();

				System.Collections.Generic.List<NetState> states = NetState.Instances;

				for ( int i = 0; i < states.Count; ++i )
				{
					NetState ns = (NetState)states[i];
					Mobile mob = ns.Mobile;

					if ( mob != null && !addresses.Contains( ns.Address ) && ext.IsValid( mob ) )
					{
						list.Add( mob );
						addresses.Add( ns.Address );
					}
				}

				ext.Filter( list );

				obj = list;
			}
			catch ( Exception ex )
			{
				from.SendMessage( ex.Message );
			}
		}
Пример #9
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

                if (!CheckObjectTypes(from, command, ext, out bool _, out bool mobiles))
                {
                    return;
                }

                if (!mobiles) // sanity check
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                List <object>    list      = new List <object>();
                List <IPAddress> addresses = new List <IPAddress>();

                HashSet <NetState> states = TcpServer.Instances;

                foreach (var ns in states)
                {
                    Mobile mob = ns.Mobile;

                    if (mob != null && !addresses.Contains(ns.Address) && ext.IsValid(mob))
                    {
                        list.Add(mob);
                        addresses.Add(ns.Address);
                    }
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
Пример #10
0
		public override void Compile( Mobile from, BaseCommand command, ref string[] args, ref object obj )
		{
			try
			{
				Extensions ext = Extensions.Parse( from, ref args );

				bool items, mobiles;

				if ( !CheckObjectTypes( from, command, ext, out items, out mobiles ) )
					return;

				Region reg = from.Region;

				ArrayList list = new ArrayList();

				if ( mobiles )
				{
					foreach ( Mobile mob in reg.GetMobiles() )
					{
						if( !BaseCommand.IsAccessible( from, mob ) )
							continue;

						if ( ext.IsValid( mob ) )
							list.Add( mob );
					}
				}
				else
				{
					command.LogFailure( "This command does not support items." );
					return;
				}

				ext.Filter( list );

				obj = list;
			}
			catch ( Exception ex )
			{
				from.SendMessage( ex.Message );
			}
		}
		public bool CheckObjectTypes( BaseCommand command, Extensions ext, out bool items, out bool mobiles )
		{
			items = mobiles = false;

			ObjectConditional cond = ObjectConditional.Empty;

            foreach (BaseExtension check in ext)
            {
                if (check is WhereExtension)
                {
                    cond = (check as WhereExtension).Conditional;

                    break;
                }
            }

			bool condIsItem = cond.IsItem;
			bool condIsMobile = cond.IsMobile;

			switch ( command.ObjectTypes )
			{
				case ObjectTypes.All:
				case ObjectTypes.Both:
				{
					if ( condIsItem )
						items = true;

					if ( condIsMobile )
						mobiles = true;

					break;
				}
				case ObjectTypes.Items:
				{
					if ( condIsItem )
					{
						items = true;
					}
					else if ( condIsMobile )
					{
						command.LogFailure( "You may not use a mobile type condition for this command." );
						return false;
					}

					break;
				}
				case ObjectTypes.Mobiles:
				{
					if ( condIsMobile )
					{
						mobiles = true;
					}
					else if ( condIsItem )
					{
						command.LogFailure( "You may not use an item type condition for this command." );
						return false;
					}

					break;
				}
			}

			return true;
		}
		public void RunCommand( Mobile from, object obj, BaseCommand command, string[] args )
		{
		//	try
		//	{
				CommandEventArgs e = new CommandEventArgs( from, command.Commands[0], GenerateArgString( args ), args );

				if ( !command.ValidateArgs( this, e ) )
					return;

				bool flushToLog = false;

				if ( obj is ArrayList )
				{
					ArrayList list = (ArrayList)obj;

					if ( list.Count > 20 )
						CommandLogging.Enabled = false;
					else if ( list.Count == 0 )
						command.LogFailure( "Nothing was found to use this command on." );

					command.ExecuteList( e, list );

					if ( list.Count > 20 )
					{
						flushToLog = true;
						CommandLogging.Enabled = true;
					}
				}
				else if ( obj != null )
				{
					if ( command.ListOptimized )
					{
						ArrayList list = new ArrayList();
						list.Add( obj );
						command.ExecuteList( e, list );
					}
					else
					{
						command.Execute( e, obj );
					}
				}

				command.Flush( from, flushToLog );
		//	}
		//	catch ( Exception ex )
		//	{
		//		from.SendMessage( ex.Message );
		//	}
		}
Пример #13
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                Region reg = from.Region;

                ArrayList list = new ArrayList();

                if (mobiles)
                {
                    foreach (Mobile mob in reg.GetMobiles())
                    {
                        if (!BaseCommand.IsAccessible(from, mob))
                        {
                            continue;
                        }

                        if (ext.IsValid(mob))
                        {
                            list.Add(mob);
                        }
                    }
                }

                else if (items)
                {
                    foreach (Item item in reg.GetItems())
                    {
                        if (!BaseCommand.IsAccessible(from, item))
                        {
                            continue;
                        }

                        if (ext.IsValid(item))
                        {
                            list.Add(item);
                        }
                    }
                }


                else
                {
                    command.LogFailure("Could not find item or mobile with property in region.");
                    return;
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
Пример #14
0
        public void RunCommand(Mobile from, object obj, BaseCommand command, string[] args)
        {
            try
            {
                if (command is GetCommand && obj is ArrayList && ((ArrayList)obj).Count > 20000)
                {
                    throw new Exception("Get command has too many potential target: " + ((ArrayList)obj).Count);
                }
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("RunCommand\t" + command.Commands[0] + "\t");
                }
                CommandEventArgs e = new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args);

                if (!command.ValidateArgs(this, e))
                {
                    return;
                }

                bool flushToLog = false;

                if (obj is ArrayList)
                {
                    if (LoggingCustom.CommandDebug)
                    {
                        LoggingCustom.LogCommandDebug("objArrayList\t");
                    }
                    ArrayList list = (ArrayList)obj;

                    if (list.Count > 20)
                    {
                        CommandLogging.Enabled = false;
                    }
                    else if (list.Count == 0)
                    {
                        command.LogFailure("Nothing was found to use this command on.");
                    }

                    command.ExecuteList(e, list);

                    if (list.Count > 20)
                    {
                        flushToLog             = true;
                        CommandLogging.Enabled = true;
                    }
                }
                else if (obj != null)
                {
                    if (LoggingCustom.CommandDebug)
                    {
                        LoggingCustom.LogCommandDebug("obj\t");
                    }
                    if (command.ListOptimized)
                    {
                        ArrayList list = new ArrayList();
                        list.Add(obj);
                        command.ExecuteList(e, list);
                    }
                    else
                    {
                        command.Execute(e, obj);
                    }
                }
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("flush\t");
                }
                command.Flush(from, flushToLog);
            }
            catch (Exception ex)
            {
                if (from != null)
                {
                    from.SendMessage(ex.Message);
                }
            }
        }
Пример #15
0
        public bool CheckObjectTypes(Mobile from, BaseCommand command, Extensions ext, out bool items, out bool mobiles)
        {
            items = mobiles = false;

            ObjectConditional cond = ObjectConditional.Empty;

            foreach (BaseExtension check in ext)
            {
                if (check is WhereExtension)
                {
                    cond = (check as WhereExtension).Conditional;

                    break;
                }
            }

            bool condIsItem   = cond.IsItem;
            bool condIsMobile = cond.IsMobile;

            switch (command.ObjectTypes)
            {
            case ObjectTypes.All:
            case ObjectTypes.Both:
            {
                if (condIsItem)
                {
                    items = true;
                }

                if (condIsMobile)
                {
                    mobiles = true;
                }

                break;
            }

            case ObjectTypes.Items:
            {
                if (condIsItem)
                {
                    items = true;
                }
                else if (condIsMobile)
                {
                    command.LogFailure("You may not use a mobile type condition for this command.");
                    return(false);
                }

                break;
            }

            case ObjectTypes.Mobiles:
            {
                if (condIsMobile)
                {
                    mobiles = true;
                }
                else if (condIsItem)
                {
                    command.LogFailure("You may not use an item type condition for this command.");
                    return(false);
                }

                break;
            }
            }

            return(true);
        }
		public void RunCommand( Mobile from, object obj, BaseCommand command, string[] args )
		{
			try
			{
                if (command is GetCommand && obj is ArrayList && ((ArrayList)obj).Count > 20000)
                {
                    throw new Exception("Get command has too many potential target: " + ((ArrayList)obj).Count);
                }
                if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "RunCommand\t" + command.Commands[0] + "\t");
                CommandEventArgs e = new CommandEventArgs( from, command.Commands[0], GenerateArgString( args ), args );
                
				if ( !command.ValidateArgs( this, e ) )
					return;

				bool flushToLog = false;

				if ( obj is ArrayList )
				{
                    if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "objArrayList\t");
					ArrayList list = (ArrayList)obj;

					if ( list.Count > 20 )
						CommandLogging.Enabled = false;
					else if ( list.Count == 0 )
						command.LogFailure( "Nothing was found to use this command on." );

					command.ExecuteList( e, list );

					if ( list.Count > 20 )
					{
						flushToLog = true;
						CommandLogging.Enabled = true;
					}
				}
				else if ( obj != null )
				{
                    if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "obj\t");
                    if ( command.ListOptimized )
					{
						ArrayList list = new ArrayList();
						list.Add( obj );
						command.ExecuteList( e, list );
					}
					else
					{
						command.Execute( e, obj );
					}
				}
                if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "flush\t"); 
				command.Flush( from, flushToLog );
			}
			catch ( Exception ex )
			{
				if (from != null) from.SendMessage( ex.Message );
			}
		}