Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -5,80 +5,76 @@ using Server.Targeting;
|
|||
|
||||
namespace Server.Commands.Generic
|
||||
{
|
||||
public class ContainedCommandImplementor : BaseCommandImplementor
|
||||
{
|
||||
public ContainedCommandImplementor()
|
||||
{
|
||||
Accessors = new[]{ "Contained" };
|
||||
SupportRequirement = CommandSupport.Contained;
|
||||
AccessLevel = AccessLevel.GameMaster;
|
||||
Usage = "Contained <command> [condition]";
|
||||
Description = "Invokes the command on all child items in a targeted container. Optional condition arguments can further restrict the set of objects.";
|
||||
}
|
||||
public class ContainedCommandImplementor : BaseCommandImplementor
|
||||
{
|
||||
public ContainedCommandImplementor()
|
||||
{
|
||||
Accessors = new[] { "Contained" };
|
||||
SupportRequirement = CommandSupport.Contained;
|
||||
AccessLevel = AccessLevel.GameMaster;
|
||||
Usage = "Contained <command> [condition]";
|
||||
Description =
|
||||
"Invokes the command on all child items in a targeted container. Optional condition arguments can further restrict the set of objects.";
|
||||
}
|
||||
|
||||
public override void Process( Mobile from, BaseCommand command, string[] args )
|
||||
{
|
||||
if ( command.ValidateArgs( this, new CommandEventArgs( from, command.Commands[0], GenerateArgString( args ), args ) ) )
|
||||
from.BeginTarget( -1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None, new TargetStateCallback( OnTarget ), new object[]{ command, args } );
|
||||
}
|
||||
public override void Process(Mobile from, BaseCommand command, string[] args)
|
||||
{
|
||||
if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args)))
|
||||
from.BeginTarget(-1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None,
|
||||
new TargetStateCallback(OnTarget), new object[] { command, args });
|
||||
}
|
||||
|
||||
public void OnTarget( Mobile from, object targeted, object state )
|
||||
{
|
||||
if ( !BaseCommand.IsAccessible( from, targeted ) )
|
||||
{
|
||||
from.SendMessage( "That is not accessible." );
|
||||
return;
|
||||
}
|
||||
public void OnTarget(Mobile from, object targeted, object state)
|
||||
{
|
||||
if (!BaseCommand.IsAccessible(from, targeted))
|
||||
{
|
||||
from.SendMessage("That is not accessible.");
|
||||
return;
|
||||
}
|
||||
|
||||
object[] states = (object[])state;
|
||||
BaseCommand command = (BaseCommand)states[0];
|
||||
string[] args = (string[])states[1];
|
||||
object[] states = (object[])state;
|
||||
BaseCommand command = (BaseCommand)states[0];
|
||||
string[] args = (string[])states[1];
|
||||
|
||||
if ( command.ObjectTypes == ObjectTypes.Mobiles )
|
||||
return; // sanity check
|
||||
if (command.ObjectTypes == ObjectTypes.Mobiles)
|
||||
return; // sanity check
|
||||
|
||||
if ( !(targeted is Container) )
|
||||
{
|
||||
from.SendMessage( "That is not a container." );
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Extensions ext = Extensions.Parse( from, ref args );
|
||||
if (!(targeted is Container))
|
||||
from.SendMessage("That is not a container.");
|
||||
else
|
||||
try
|
||||
{
|
||||
Extensions ext = Extensions.Parse(from, ref args);
|
||||
|
||||
bool items, mobiles;
|
||||
bool items, mobiles;
|
||||
|
||||
if ( !CheckObjectTypes( from, command, ext, out items, out mobiles ) )
|
||||
return;
|
||||
if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
|
||||
return;
|
||||
|
||||
if ( !items )
|
||||
{
|
||||
from.SendMessage( "This command only works on items." );
|
||||
return;
|
||||
}
|
||||
if (!items)
|
||||
{
|
||||
from.SendMessage("This command only works on items.");
|
||||
return;
|
||||
}
|
||||
|
||||
Container cont = (Container)targeted;
|
||||
Container cont = (Container)targeted;
|
||||
|
||||
Item[] found = cont.FindItemsByType( typeof( Item ), true );
|
||||
Item[] found = cont.FindItemsByType(typeof(Item), true);
|
||||
|
||||
ArrayList list = new ArrayList();
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
for ( int i = 0; i < found.Length; ++i )
|
||||
{
|
||||
if ( ext.IsValid( found[i] ) )
|
||||
list.Add( found[i] );
|
||||
}
|
||||
for (int i = 0; i < found.Length; ++i)
|
||||
if (ext.IsValid(found[i]))
|
||||
list.Add(found[i]);
|
||||
|
||||
ext.Filter( list );
|
||||
ext.Filter(list);
|
||||
|
||||
RunCommand( from, list, command, args );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
from.SendMessage( e.Message );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RunCommand(from, list, command, args);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
from.SendMessage(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue