Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Server.Commands.Generic
{
@ -36,28 +37,15 @@ namespace Server.Commands.Generic
if (!CheckObjectTypes(from, command, ext, out bool items, out bool mobiles))
return;
IPooledEnumerable<IEntity> eable;
if (items || mobiles)
eable = map.GetObjectsInBounds(rect, items, mobiles);
else
if (!(items || mobiles))
return;
eable.Free();
IPooledEnumerable<IEntity> eable = map.GetObjectsInBounds(rect, items, mobiles);
List<object> objs = new List<object>();
foreach (IEntity obj in eable)
{
if (mobiles && obj is Mobile && !BaseCommand.IsAccessible(from, obj))
continue;
if (ext.IsValid(obj))
objs.Add(obj);
}
List<object> objs = eable.Where(obj => !mobiles || !(obj is Mobile) || BaseCommand.IsAccessible(from, obj))
.Where(obj => ext.IsValid(obj)).Cast<object>().ToList();
eable.Free();
ext.Filter(objs);
RunCommand(from, objs, command, args);
@ -68,4 +56,4 @@ namespace Server.Commands.Generic
}
}
}
}
}