Adds better type support for pooled enumerables. Refactors code. (#16)

This commit is contained in:
Kamron Batman 2018-08-09 14:08:34 -07:00 • committed by GitHub
parent 62b95f4d74
commit b06f5bf60d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 252 additions and 243 deletions

View file

@ -873,7 +873,7 @@ namespace Server.Commands
bool res = false; bool res = false;
IPooledEnumerable eable; IPooledEnumerable<Item> eable;
if ( srcItem is BaseDoor ) if ( srcItem is BaseDoor )
{ {
@ -1002,16 +1002,16 @@ namespace Server.Commands
if ( item is BaseDoor ) if ( item is BaseDoor )
{ {
IPooledEnumerable eable = maps[j].GetItemsInRange( loc, 1 ); IPooledEnumerable<BaseDoor> eable = maps[j].GetItemsInRange<BaseDoor>( loc, 1 );
Type itemType = item.GetType(); Type itemType = item.GetType();
foreach ( Item link in eable ) foreach ( BaseDoor link in eable )
{ {
if ( link != item && link.Z == item.Z && link.GetType() == itemType ) if ( link != item && link.Z == item.Z && link.GetType() == itemType )
{ {
((BaseDoor)item).Link = (BaseDoor)link; ((BaseDoor)item).Link = link;
((BaseDoor)link).Link = (BaseDoor)item; link.Link = (BaseDoor)item;
break; break;
} }
} }
@ -1151,4 +1151,4 @@ namespace Server.Commands
} }
} }
} }
} }

View file

@ -870,7 +870,7 @@ namespace Server.Commands
bool res = false; bool res = false;
IPooledEnumerable eable; IPooledEnumerable<Item> eable;
if ( srcItem is BaseDoor ) if ( srcItem is BaseDoor )
{ {
@ -999,16 +999,16 @@ namespace Server.Commands
if ( item is BaseDoor ) if ( item is BaseDoor )
{ {
IPooledEnumerable eable = maps[j].GetItemsInRange( loc, 1 ); IPooledEnumerable<BaseDoor> eable = maps[j].GetItemsInRange<BaseDoor>( loc, 1 );
Type itemType = item.GetType(); Type itemType = item.GetType();
foreach ( Item link in eable ) foreach ( BaseDoor link in eable )
{ {
if ( link != item && link.Z == item.Z && link.GetType() == itemType ) if ( link != item && link.Z == item.Z && link.GetType() == itemType )
{ {
((BaseDoor)item).Link = (BaseDoor)link; ((BaseDoor)item).Link = link;
((BaseDoor)link).Link = (BaseDoor)item; link.Link = (BaseDoor)item;
break; break;
} }
} }

View file

@ -1,5 +1,5 @@
using System; using System;
using System.Collections; using System.Collections.Generic;
using Server; using Server;
using Server.Items; using Server.Items;
@ -37,11 +37,11 @@ namespace Server.Commands
{ {
} }
private static Queue m_Queue = new Queue(); private static Queue<Item> m_Queue = new Queue<Item>();
public static bool FindTeleporter( Map map, Point3D p ) public static bool FindTeleporter( Map map, Point3D p )
{ {
IPooledEnumerable eable = map.GetItemsInRange( p, 0 ); IPooledEnumerable<Item> eable = map.GetItemsInRange( p, 0 );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {
@ -57,7 +57,7 @@ namespace Server.Commands
eable.Free(); eable.Free();
while ( m_Queue.Count > 0 ) while ( m_Queue.Count > 0 )
((Item)m_Queue.Dequeue()).Delete(); m_Queue.Dequeue().Delete();
return false; return false;
} }
@ -96,7 +96,7 @@ namespace Server.Commands
public void DestroyTeleporter( int x, int y, int z, Map map ) public void DestroyTeleporter( int x, int y, int z, Map map )
{ {
Point3D p = new Point3D( x, y, z ); Point3D p = new Point3D( x, y, z );
IPooledEnumerable eable = map.GetItemsInRange( p, 0 ); IPooledEnumerable<Item> eable = map.GetItemsInRange( p, 0 );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {
@ -107,7 +107,7 @@ namespace Server.Commands
eable.Free(); eable.Free();
while ( m_Queue.Count > 0 ) while ( m_Queue.Count > 0 )
((Item)m_Queue.Dequeue()).Delete(); m_Queue.Dequeue().Delete();
} }
public void CreateTeleportersMap( Map map ) public void CreateTeleportersMap( Map map )

View file

@ -181,4 +181,4 @@ namespace Server.Commands.Generic
{ {
} }
} }
} }

View file

@ -86,4 +86,4 @@ namespace Server.Commands.Generic
} }
} }
} }
} }

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using Server; using Server;
namespace Server.Commands.Generic namespace Server.Commands.Generic
@ -47,20 +48,16 @@ namespace Server.Commands.Generic
if ( !CheckObjectTypes( from, command, ext, out items, out mobiles ) ) if ( !CheckObjectTypes( from, command, ext, out items, out mobiles ) )
return; return;
IPooledEnumerable eable; IPooledEnumerable<IEntity> eable;
if ( items && mobiles ) if (items || mobiles)
eable = map.GetObjectsInBounds( rect ); eable = map.GetObjectsInBounds(rect, items, mobiles);
else if ( items )
eable = map.GetItemsInBounds( rect );
else if ( mobiles )
eable = map.GetMobilesInBounds( rect );
else else
return; return;
ArrayList objs = new ArrayList(); ArrayList objs = new ArrayList();
foreach ( object obj in eable ) foreach ( IEntity obj in eable )
{ {
if ( mobiles && obj is Mobile && !BaseCommand.IsAccessible( from, obj ) ) if ( mobiles && obj is Mobile && !BaseCommand.IsAccessible( from, obj ) )
continue; continue;
@ -81,4 +78,4 @@ namespace Server.Commands.Generic
} }
} }
} }
} }

View file

@ -100,7 +100,7 @@ namespace Server.Commands
public static void Add_Static( int itemID, Point3D location, Map map, string name ) public static void Add_Static( int itemID, Point3D location, Map map, string name )
{ {
IPooledEnumerable eable = map.GetItemsInRange( location, 0 ); IPooledEnumerable<Item> eable = map.GetItemsInRange( location, 0 );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {
@ -136,4 +136,4 @@ namespace Server.Commands
sign.MoveToWorld( location, map ); sign.MoveToWorld( location, map );
} }
} }
} }

View file

@ -127,7 +127,7 @@ namespace Server
CommandLogging.WriteLine( from, "{0} {1} invoking freeze from {2} to {3} in {4}", from.AccessLevel, CommandLogging.Format( from ), start, end, targetMap ); CommandLogging.WriteLine( from, "{0} {1} invoking freeze from {2} to {3} in {4}", from.AccessLevel, CommandLogging.Format( from ), start, end, targetMap );
IPooledEnumerable eable = targetMap.GetItemsInBounds( new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 ) ); IPooledEnumerable<Item> eable = targetMap.GetItemsInBounds( new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 ) );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {
@ -567,4 +567,4 @@ namespace Server
} }
} }
} }
} }

View file

@ -76,14 +76,10 @@ namespace Server.Commands
Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 ); Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );
IPooledEnumerable eable; IPooledEnumerable<IEntity> eable;
if ( (items || multis) && mobiles ) if ( (items || multis) && mobiles )
eable = map.GetObjectsInBounds( rect ); eable = map.GetObjectsInBounds( rect, items || multis, mobiles );
else if ( items || multis )
eable = map.GetItemsInBounds( rect );
else if ( mobiles )
eable = map.GetMobilesInBounds( rect );
else else
return; return;
@ -103,4 +99,4 @@ namespace Server.Commands
toDelete[i].Delete(); toDelete[i].Delete();
} }
} }
} }

View file

@ -172,7 +172,7 @@ namespace Server.Engines.ConPVP
if ( m_Flying || !Visible || m_Game == null || this.Parent != null ) if ( m_Flying || !Visible || m_Game == null || this.Parent != null )
return; return;
IPooledEnumerable eable = this.GetClientsInRange( 0 ); IPooledEnumerable<NetState> eable = this.GetClientsInRange( 0 );
foreach ( NetState ns in eable ) foreach ( NetState ns in eable )
{ {
Mobile m = ns.Mobile; Mobile m = ns.Mobile;
@ -518,7 +518,7 @@ namespace Server.Engines.ConPVP
if ( landTile.ID == 0x244 && statics.Length == 0 ) // 0x244 = invalid land tile if ( landTile.ID == 0x244 && statics.Length == 0 ) // 0x244 = invalid land tile
{ {
bool empty = true; bool empty = true;
IPooledEnumerable eable = this.Map.GetItemsInRange( point, 0 ); IPooledEnumerable<Item> eable = this.Map.GetItemsInRange( point, 0 );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {
@ -559,7 +559,7 @@ namespace Server.Engines.ConPVP
Rectangle2D rect = new Rectangle2D( pTop.X, pTop.Y, ( pBottom.X - pTop.X ) + 1, ( pBottom.Y - pTop.Y ) + 1 ); Rectangle2D rect = new Rectangle2D( pTop.X, pTop.Y, ( pBottom.X - pTop.X ) + 1, ( pBottom.Y - pTop.Y ) + 1 );
IPooledEnumerable area = this.Map.GetItemsInBounds( rect ); IPooledEnumerable<Item> area = this.Map.GetItemsInBounds( rect );
foreach ( Item i in area ) foreach ( Item i in area )
{ {
if ( i == this || i.ItemID >= 0x4000 ) if ( i == this || i.ItemID >= 0x4000 )
@ -620,8 +620,8 @@ namespace Server.Engines.ConPVP
area.Free(); area.Free();
area = this.Map.GetClientsInBounds( rect ); IPooledEnumerable<NetState> clients = this.Map.GetClientsInBounds( rect );
foreach ( NetState ns in area ) foreach ( NetState ns in clients)
{ {
Mobile m = ns.Mobile; Mobile m = ns.Mobile;
@ -645,7 +645,7 @@ namespace Server.Engines.ConPVP
if ( !found ) if ( !found )
continue; continue;
area.Free(); clients.Free();
// TODO: probably need to change this a lot... // TODO: probably need to change this a lot...
DoCatch( m ); DoCatch( m );
@ -653,7 +653,7 @@ namespace Server.Engines.ConPVP
return; return;
} }
area.Free(); clients.Free();
m_PathIdx = pathCheckEnd; m_PathIdx = pathCheckEnd;
@ -683,7 +683,7 @@ namespace Server.Engines.ConPVP
myZ = t.Z + height; myZ = t.Z + height;
} }
IPooledEnumerable eable = this.GetItemsInRange( 0 ); IPooledEnumerable<Item> eable = this.GetItemsInRange( 0 );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {
if ( item.Visible && item != this ) if ( item.Visible && item != this )

View file

@ -452,7 +452,7 @@ namespace Server.Engines.Craft
if ( map == null ) if ( map == null )
return false; return false;
IPooledEnumerable eable = map.GetItemsInRange( from.Location, 2 ); IPooledEnumerable<Item> eable = map.GetItemsInRange( from.Location, 2 );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {

View file

@ -64,7 +64,7 @@ namespace Server.Engines.Craft
if ( map == null ) if ( map == null )
return; return;
IPooledEnumerable eable = map.GetItemsInRange( from.Location, range ); IPooledEnumerable<Item> eable = map.GetItemsInRange( from.Location, range );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {
@ -738,4 +738,4 @@ namespace Server.Engines.Craft
{ {
} }
} }
} }

View file

@ -251,16 +251,12 @@ namespace Server.Factions
bool mobs = type.IsSubclassOf( typeof( Mobile ) ); bool mobs = type.IsSubclassOf( typeof( Mobile ) );
bool items = type.IsSubclassOf( typeof( Item ) ); bool items = type.IsSubclassOf( typeof( Item ) );
IPooledEnumerable eable; if ( !(items || mobs) )
if ( mobs )
eable = mob.GetMobilesInRange( range );
else if ( items )
eable = mob.GetItemsInRange( range );
else
return false; return false;
foreach ( object obj in eable ) IPooledEnumerable<IEntity> eable = mob.Map.GetObjectsInRange(mob.Location, range, items, mobs);
foreach ( IEntity obj in eable )
{ {
if ( type.IsAssignableFrom( obj.GetType() ) ) if ( type.IsAssignableFrom( obj.GetType() ) )
{ {
@ -275,15 +271,15 @@ namespace Server.Factions
public static bool IsNearType( Mobile mob, Type[] types, int range ) public static bool IsNearType( Mobile mob, Type[] types, int range )
{ {
IPooledEnumerable eable = mob.GetObjectsInRange( range ); IPooledEnumerable<IEntity> eable = mob.GetObjectsInRange( range );
foreach( object obj in eable ) foreach( IEntity obj in eable )
{ {
Type objType = obj.GetType(); Type objType = obj.GetType();
for( int i = 0; i < types.Length; i++ ) for( int i = 0; i < types.Length; i++ )
{ {
if( types[i].IsAssignableFrom( objType ) ) if ( types[i].IsAssignableFrom( objType ) )
{ {
eable.Free(); eable.Free();
return true; return true;
@ -1434,4 +1430,4 @@ namespace Server.Factions
} }
} }
} }
} }

View file

@ -15,7 +15,7 @@ namespace Server.Commands
public static bool FindMorphItem( int x, int y, int z, int inactiveItemID, int activeItemID ) public static bool FindMorphItem( int x, int y, int z, int inactiveItemID, int activeItemID )
{ {
IPooledEnumerable eable = Map.Felucca.GetItemsInRange( new Point3D( x, y, z ), 0 ); IPooledEnumerable<Item> eable = Map.Felucca.GetItemsInRange( new Point3D( x, y, z ), 0 );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {
@ -49,7 +49,7 @@ namespace Server.Commands
public static Item TryCreateItem( int x, int y, int z, Item srcItem ) public static Item TryCreateItem( int x, int y, int z, Item srcItem )
{ {
IPooledEnumerable eable = Map.Felucca.GetItemsInBounds( new Rectangle2D( x, y, 1, 1 ) ); IPooledEnumerable<Item> eable = Map.Felucca.GetItemsInBounds( new Rectangle2D( x, y, 1, 1 ) );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {

View file

@ -376,7 +376,7 @@ namespace Server.Mobiles
Packet p = null; Packet p = null;
IPooledEnumerable eable = Map.GetClientsInRange( Location ); IPooledEnumerable<NetState> eable = Map.GetClientsInRange( Location );
foreach( NetState state in eable ) foreach( NetState state in eable )
{ {

View file

@ -163,14 +163,14 @@ namespace Server.Items
public static SHTeleporter FindSHTeleporter( Map map, Point3D p ) public static SHTeleporter FindSHTeleporter( Map map, Point3D p )
{ {
IPooledEnumerable eable = map.GetItemsInRange( p, 0 ); IPooledEnumerable<SHTeleporter> eable = map.GetItemsInRange<SHTeleporter>( p, 0 );
foreach ( Item item in eable ) foreach (SHTeleporter item in eable )
{ {
if ( item is SHTeleporter && item.Z == p.Z ) if ( item.Z == p.Z )
{ {
eable.Free(); eable.Free();
return (SHTeleporter)item; return item;
} }
} }
@ -450,4 +450,4 @@ namespace Server.Items
m_LeftTele = (SHTeleComponent)reader.ReadItem(); m_LeftTele = (SHTeleComponent)reader.ReadItem();
} }
} }
} }

View file

@ -30,11 +30,11 @@ namespace Server.Items
private static bool FindMarkContainer( Point3D p, Map map ) private static bool FindMarkContainer( Point3D p, Map map )
{ {
IPooledEnumerable eable = map.GetItemsInRange( p, 0 ); IPooledEnumerable<MarkContainer> eable = map.GetItemsInRange<MarkContainer>( p, 0 );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {
if ( item.Z == p.Z && item is MarkContainer ) if ( item.Z == p.Z )
{ {
eable.Free(); eable.Free();
return true; return true;
@ -264,4 +264,4 @@ namespace Server.Items
m_Description = reader.ReadString(); m_Description = reader.ReadString();
} }
} }
} }

View file

@ -133,12 +133,11 @@ namespace Server.Items
else if ( RootParent == null ) else if ( RootParent == null )
{ {
List<Mobile> toDamage = new List<Mobile>(); List<Mobile> toDamage = new List<Mobile>();
IPooledEnumerable eable = Map.GetMobilesInRange( Location, 1 ); IPooledEnumerable<Mobile> eable = Map.GetMobilesInRange( Location, 1 );
foreach ( Mobile m in eable ) foreach ( Mobile m in eable )
{
toDamage.Add( m ); toDamage.Add( m );
}
eable.Free(); eable.Free();
Mobile victim; Mobile victim;

View file

@ -128,7 +128,7 @@ namespace Server.Items
} }
} }
IPooledEnumerable eable = this.GetClientsInRange( SecureRange ); IPooledEnumerable<NetState> eable = this.GetClientsInRange( SecureRange );
foreach ( NetState state in eable ) foreach ( NetState state in eable )
{ {
@ -214,4 +214,4 @@ namespace Server.Items
m_Safe = false; m_Safe = false;
} }
} }
} }

View file

@ -252,12 +252,12 @@ namespace Server.Items
if ( direct ) if ( direct )
alchemyBonus = (int)(from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10)); alchemyBonus = (int)(from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10));
IPooledEnumerable eable = LeveledExplosion ? (IPooledEnumerable)map.GetObjectsInRange( loc, ExplosionRange ) : (IPooledEnumerable)map.GetMobilesInRange( loc, ExplosionRange ); IPooledEnumerable<IEntity> eable = map.GetObjectsInRange(loc, ExplosionRange, LeveledExplosion, true);
ArrayList toExplode = new ArrayList(); List<IEntity> toExplode = new List<IEntity>();
int toDamage = 0; int toDamage = 0;
foreach ( object o in eable ) foreach ( IEntity o in eable )
{ {
if ( o is Mobile && (from == null || (SpellHelper.ValidIndirectTarget( from, (Mobile)o ) && from.CanBeHarmful( (Mobile)o, false )))) if ( o is Mobile && (from == null || (SpellHelper.ValidIndirectTarget( from, (Mobile)o ) && from.CanBeHarmful( (Mobile)o, false ))))
{ {
@ -306,4 +306,4 @@ namespace Server.Items
} }
} }
} }
} }

View file

@ -1,5 +1,5 @@
using System; using System;
using System.Collections; using System.Collections.Generic;
using Server; using Server;
using Server.Network; using Server.Network;
using Server.Targeting; using Server.Targeting;
@ -84,10 +84,10 @@ namespace Server.Items
from.PlaySound( 0x15F ); from.PlaySound( 0x15F );
Effects.SendPacket( from, from.Map, new HuedEffect( EffectType.Moving, from.Serial, Serial.Zero, 0x36D4, from.Location, loc, 5, 0, false, true, 0, 0 ) ); Effects.SendPacket( from, from.Map, new HuedEffect( EffectType.Moving, from.Serial, Serial.Zero, 0x36D4, from.Location, loc, 5, 0, false, true, 0, 0 ) );
ArrayList targets = new ArrayList(); List<Mobile> targets = new List<Mobile>();
bool playerVsPlayer = false; bool playerVsPlayer = false;
IPooledEnumerable eable = from.Map.GetMobilesInRange( new Point3D( loc ), 2 ); IPooledEnumerable<Mobile> eable = from.Map.GetMobilesInRange( new Point3D( loc ), 2 );
foreach ( Mobile m in eable ) foreach ( Mobile m in eable )
{ {
@ -222,4 +222,4 @@ namespace Server.Items
int version = reader.ReadEncodedInt(); int version = reader.ReadEncodedInt();
} }
} }
} }

View file

@ -1315,22 +1315,20 @@ namespace Server.Items
int inPack = 1; int inPack = 1;
IPooledEnumerable eable = defender.GetMobilesInRange( 1 ); IPooledEnumerable<BaseCreature> eable = defender.GetMobilesInRange<BaseCreature>( 1 );
foreach ( Mobile m in eable ) foreach ( BaseCreature m in eable )
{ {
if ( m != attacker && m is BaseCreature ) if ( m != attacker )
{ {
BaseCreature tc = (BaseCreature)m; if ( (m.PackInstinct & bc.PackInstinct) == 0 || (!m.Controlled && !m.Summoned) )
if ( (tc.PackInstinct & bc.PackInstinct) == 0 || (!tc.Controlled && !tc.Summoned) )
continue; continue;
Mobile theirMaster = tc.ControlMaster; Mobile theirMaster = m.ControlMaster;
if ( theirMaster == null ) if ( theirMaster == null )
theirMaster = tc.SummonMaster; theirMaster = m.SummonMaster;
if ( master == theirMaster && tc.Combatant == defender ) if ( master == theirMaster && m.Combatant == defender )
++inPack; ++inPack;
} }
} }
@ -1365,14 +1363,10 @@ namespace Server.Items
{ {
if ( MirrorImage.HasClone( defender ) && (defender.Skills.Ninjitsu.Value / 150.0) > Utility.RandomDouble() ) if ( MirrorImage.HasClone( defender ) && (defender.Skills.Ninjitsu.Value / 150.0) > Utility.RandomDouble() )
{ {
Clone bc; IPooledEnumerable<Clone> eable = defender.GetMobilesInRange<Clone>( 4 );
foreach ( Clone m in eable )
IPooledEnumerable eable = defender.GetMobilesInRange( 4 );
foreach ( Mobile m in eable)
{ {
bc = m as Clone; if ( m != null && m.Summoned && m.SummonMaster == defender )
if ( bc != null && bc.Summoned && bc.SummonMaster == defender )
{ {
attacker.SendLocalizedMessage( 1063141 ); // Your attack has been diverted to a nearby mirror image of your target! attacker.SendLocalizedMessage( 1063141 ); // Your attack has been diverted to a nearby mirror image of your target!
defender.SendLocalizedMessage( 1063140 ); // You manage to divert the attack onto one of your nearby mirror images. defender.SendLocalizedMessage( 1063140 ); // You manage to divert the attack onto one of your nearby mirror images.
@ -1916,7 +1910,7 @@ namespace Server.Items
int range = Core.ML ? 5 : 10; int range = Core.ML ? 5 : 10;
IPooledEnumerable eable = from.GetMobilesInRange(range); IPooledEnumerable<Mobile> eable = from.GetMobilesInRange(range);
foreach ( Mobile m in eable ) foreach ( Mobile m in eable )
{ {
if ( from != m && defender != m && SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false ) && ( !Core.ML || from.InLOS( m ) ) ) if ( from != m && defender != m && SpellHelper.ValidIndirectTarget( from, m ) && from.CanBeHarmful( m, false ) && ( !Core.ML || from.InLOS( m ) ) )

View file

@ -144,15 +144,12 @@ namespace Server
xTotal += fp.X; xTotal += fp.X;
yTotal += fp.Y; yTotal += fp.Y;
IPooledEnumerable eable = map.GetItemsInRange( new Point3D( fp.X, fp.Y, 0 ), 0 ); IPooledEnumerable<Spawner> eable = map.GetItemsInRange<Spawner>( new Point3D( fp.X, fp.Y, 0 ), 0 );
foreach ( Item item in eable ) foreach ( Spawner item in eable )
{ {
if ( item is Spawner ) hasSpawner = true;
{ break;
hasSpawner = true;
break;
}
} }
eable.Free(); eable.Free();
@ -529,4 +526,4 @@ namespace Server
} }
} }
} }
} }

View file

@ -1,5 +1,5 @@
using System; using System;
using System.Collections; using System.Collections.Generic;
using System.IO; using System.IO;
using Server.Mobiles; using Server.Mobiles;
using Server.Items; using Server.Items;
@ -40,7 +40,6 @@ namespace Server
if ( File.Exists( vendor_path ) ) if ( File.Exists( vendor_path ) )
{ {
ArrayList list = new ArrayList();
from.SendMessage( "Generating Vendors..." ); from.SendMessage( "Generating Vendors..." );
using ( StreamReader ip = new StreamReader( vendor_path ) ) using ( StreamReader ip = new StreamReader( vendor_path ) )
@ -295,15 +294,14 @@ namespace Server
return z; return z;
} }
private static Queue m_ToDelete = new Queue();
public static void ClearSpawners( int x, int y, int z, Map map ) public static void ClearSpawners( int x, int y, int z, Map map )
{ {
IPooledEnumerable eable = map.GetItemsInRange( new Point3D( x, y, z ), 0 ); IPooledEnumerable<Spawner> eable = map.GetItemsInRange<Spawner>( new Point3D( x, y, z ), 0 );
Queue<Spawner> m_ToDelete = new Queue<Spawner>();
foreach ( Item item in eable ) foreach ( Spawner item in eable )
{ {
if ( item is Spawner && item.Z == z ) if ( item.Z == z )
m_ToDelete.Enqueue( item ); m_ToDelete.Enqueue( item );
} }

View file

@ -2078,7 +2078,7 @@ namespace Server.Mobiles
int destroyables = 0; int destroyables = 0;
IPooledEnumerable eable = map.GetItemsInRange(new Point3D(x, y, m_Mobile.Location.Z), 1); IPooledEnumerable<Item> eable = map.GetItemsInRange(new Point3D(x, y, m_Mobile.Location.Z), 1);
foreach (Item item in eable) foreach (Item item in eable)
{ {
@ -2634,7 +2634,7 @@ namespace Server.Mobiles
if (srcSkill <= 0) if (srcSkill <= 0)
return; return;
IPooledEnumerable eable = m_Mobile.GetMobilesInRange(m_Mobile.RangePerception); IPooledEnumerable<Mobile> eable = m_Mobile.GetMobilesInRange(m_Mobile.RangePerception);
foreach (Mobile trg in eable) foreach (Mobile trg in eable)
{ {
if (trg != m_Mobile && trg.Player && trg.Alive && trg.Hidden && trg.AccessLevel == AccessLevel.Player && m_Mobile.InLOS(trg)) if (trg != m_Mobile && trg.Player && trg.Alive && trg.Hidden && trg.AccessLevel == AccessLevel.Player && m_Mobile.InLOS(trg))

View file

@ -5450,12 +5450,12 @@ namespace Server.Mobiles
{ {
Corpse toRummage = null; Corpse toRummage = null;
IPooledEnumerable eable = this.GetItemsInRange(2); IPooledEnumerable<Corpse> eable = this.GetItemsInRange<Corpse>(2);
foreach ( Item item in eable ) foreach ( Corpse item in eable )
{ {
if ( item is Corpse && item.Items.Count > 0 ) if ( item.Items.Count > 0 )
{ {
toRummage = (Corpse)item; toRummage = item;
break; break;
} }
} }

View file

@ -182,20 +182,15 @@ namespace Server.Mobiles
base.OnThink(); base.OnThink();
// Check to see if we need to devour any corpses // Check to see if we need to devour any corpses
IPooledEnumerable eable = GetItemsInRange( 3 ); // Get all corpses in range IPooledEnumerable<Corpse> eable = GetItemsInRange<Corpse>( 3 ); // Get all corpses in range
foreach( Item item in eable ) foreach( Corpse item in eable )
{ {
if( item is Corpse ) // For each Corpse // Ensure that the corpse was killed by us
if ( item.Killer == this && item.Owner != null )
{ {
Corpse corpse = item as Corpse; if( !item.DevourCorpse() && !item.Devoured )
PublicOverheadMessage( MessageType.Emote, 0x3B2, 1053032 ); // * The plague beast attempts to absorb the remains, but cannot! *
// Ensure that the corpse was killed by us
if( corpse != null && corpse.Killer == this && corpse.Owner != null )
{
if( !corpse.DevourCorpse() && !corpse.Devoured )
PublicOverheadMessage( MessageType.Emote, 0x3B2, 1053032 ); // * The plague beast attempts to absorb the remains, but cannot! *
}
} }
} }
eable.Free(); eable.Free();
@ -229,10 +224,10 @@ namespace Server.Mobiles
private void IncreaseHits( int hp ) private void IncreaseHits( int hp )
{ {
int maxhits = 2000; int maxhits = 2000;
if ( this.IsParagon ) if ( this.IsParagon )
maxhits = (int)(maxhits * Paragon.HitsBuff); maxhits = (int)(maxhits * Paragon.HitsBuff);
if( hp < 1000 && !Core.AOS ) if( hp < 1000 && !Core.AOS )
hp = (hp * 100) / 60; hp = (hp * 100) / 60;
@ -241,9 +236,9 @@ namespace Server.Mobiles
{ {
HitsMaxSeed = maxhits; HitsMaxSeed = maxhits;
int newHits = this.Hits + hp + Utility.RandomMinMax( 10, 20 ); // increase the hp until it hits if it goes over it'll max at 2000 int newHits = this.Hits + hp + Utility.RandomMinMax( 10, 20 ); // increase the hp until it hits if it goes over it'll max at 2000
this.Hits = Math.Min( maxhits, newHits ); this.Hits = Math.Min( maxhits, newHits );
// Also provide heal for each devour on top of the hp increase // Also provide heal for each devour on top of the hp increase
} }
else else
@ -258,4 +253,4 @@ namespace Server.Mobiles
} }
} }
} }
} }

View file

@ -605,7 +605,7 @@ namespace Server.Mobiles
if ( Core.AOS ) if ( Core.AOS )
{ {
IPooledEnumerable mobiles = Map.GetMobilesInRange( location, 0 ); IPooledEnumerable<Mobile> mobiles = Map.GetMobilesInRange( location, 0 );
foreach ( Mobile m in mobiles ) foreach ( Mobile m in mobiles )
{ {
@ -5175,4 +5175,4 @@ namespace Server.Mobiles
m_AutoStabled.Clear(); m_AutoStabled.Clear();
} }
} }
} }

View file

@ -1315,11 +1315,11 @@ namespace Server.Mobiles
OpenBackpack( from ); OpenBackpack( from );
else else
{ {
IPooledEnumerable mobiles = e.Mobile.GetMobilesInRange( 2 ); IPooledEnumerable<PlayerVendor> mobiles = e.Mobile.GetMobilesInRange<PlayerVendor>( 2 );
foreach ( Mobile m in mobiles ) foreach ( PlayerVendor m in mobiles )
if ( m is PlayerVendor && m.CanSee( e.Mobile ) && m.InLOS( e.Mobile ) ) if ( m.CanSee( e.Mobile ) && m.InLOS( e.Mobile ) )
((PlayerVendor)m).OpenBackpack( from ); m.OpenBackpack( from );
mobiles.Free(); mobiles.Free();
} }
@ -1741,4 +1741,4 @@ namespace Server.Mobiles
Timer.DelayCall( TimeSpan.Zero, new TimerCallback( Delete ) ); Timer.DelayCall( TimeSpan.Zero, new TimerCallback( Delete ) );
} }
} }
} }

View file

@ -448,7 +448,7 @@ namespace Server.Multis
vendor = false; vendor = false;
rentalContract = false; rentalContract = false;
IPooledEnumerable eable = map.GetObjectsInRange( location, 0 ); IPooledEnumerable<IEntity> eable = map.GetObjectsInRange( location, 0 );
foreach ( IEntity entity in eable ) foreach ( IEntity entity in eable )
{ {
@ -902,7 +902,7 @@ namespace Server.Multis
List<Item> list = new List<Item>(); List<Item> list = new List<Item>();
IPooledEnumerable eable = this.Map.GetItemsInBounds( rect ); IPooledEnumerable<Item> eable = this.Map.GetItemsInBounds( rect );
foreach ( Item item in eable ) foreach ( Item item in eable )
if ( item.Movable && IsInside( item ) ) if ( item.Movable && IsInside( item ) )
@ -1689,7 +1689,7 @@ namespace Server.Multis
bool valid = m_House != null && Sextant.Format( m_House.Location, m_House.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth ); bool valid = m_House != null && Sextant.Format( m_House.Location, m_House.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth );
if ( valid ) if ( valid )
location = String.Format( "{0}° {1}'{2}, {3}° {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W" ); location = String.Format( "{0}° {1}'{2}, {3}° {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W" );
else else
location = "unknown"; location = "unknown";
@ -3465,14 +3465,14 @@ namespace Server.Multis
return null; return null;
MultiComponentList mcl = Components; MultiComponentList mcl = Components;
IPooledEnumerable eable = map.GetItemsInBounds( new Rectangle2D( X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height ) ); IPooledEnumerable<Guildstone> eable = map.GetItemsInBounds<Guildstone>( new Rectangle2D( X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height ) );
foreach ( Item item in eable ) foreach ( Guildstone item in eable )
{ {
if ( item is Guildstone && Contains( item ) ) if ( Contains( item ) )
{ {
eable.Free(); eable.Free();
return (Guildstone)item; return item;
} }
} }
@ -3976,4 +3976,4 @@ namespace Server.Multis
return ( from == m_RegionOwner || AccountHandler.CheckAccount( from, m_RegionOwner ) ); return ( from == m_RegionOwner || AccountHandler.CheckAccount( from, m_RegionOwner ) );
} }
} }
} }

View file

@ -612,7 +612,7 @@ namespace Server.Multis
if ( from.AccessLevel < AccessLevel.GameMaster && from != m_Owner ) if ( from.AccessLevel < AccessLevel.GameMaster && from != m_Owner )
{ {
if ( m_TillerMan != null ) if ( m_TillerMan != null )
m_TillerMan.Say( Utility.Random( 1042876, 4 ) ); // Arr, don't do that! | Arr, leave me alone! | Arr, watch what thour'rt doing, matey! | Arr! Do that again and I’ll throw ye overhead! m_TillerMan.Say( Utility.Random( 1042876, 4 ) ); // Arr, don't do that! | Arr, leave me alone! | Arr, watch what thour'rt doing, matey! | Arr! Do that again and I’ll throw ye overhead!
return; return;
} }
@ -897,8 +897,8 @@ namespace Server.Multis
{ {
string sNumber = navPoint.Substring( start ); string sNumber = navPoint.Substring( start );
if ( !int.TryParse( sNumber, out number ) ) if ( !int.TryParse( sNumber, out number ) )
number = -1; number = -1;
if ( number != -1 ) if ( number != -1 )
{ {
@ -1225,7 +1225,7 @@ namespace Server.Multis
} }
} }
IPooledEnumerable eable = map.GetItemsInBounds( new Rectangle2D( p.X + newComponents.Min.X, p.Y + newComponents.Min.Y, newComponents.Width, newComponents.Height ) ); IPooledEnumerable<Item> eable = map.GetItemsInBounds( new Rectangle2D( p.X + newComponents.Min.X, p.Y + newComponents.Min.Y, newComponents.Width, newComponents.Height ) );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {

View file

@ -176,18 +176,13 @@ namespace Server.Regions
{ {
BaseGuard useGuard = null; BaseGuard useGuard = null;
IPooledEnumerable eable = focus.GetMobilesInRange( 8 ); IPooledEnumerable<BaseGuard> eable = focus.GetMobilesInRange<BaseGuard>( 8 );
foreach ( Mobile m in eable) foreach (BaseGuard m in eable)
{ {
if ( m is BaseGuard ) if ( m.Focus == null ) // idling
{ {
BaseGuard g = (BaseGuard)m; useGuard = m;
break;
if ( g.Focus == null ) // idling
{
useGuard = g;
break;
}
} }
} }
@ -322,7 +317,7 @@ namespace Server.Regions
if ( IsDisabled() ) if ( IsDisabled() )
return; return;
IPooledEnumerable eable = Map.GetMobilesInRange( p, 14 ); IPooledEnumerable<Mobile> eable = Map.GetMobilesInRange( p, 14 );
foreach ( Mobile m in eable ) foreach ( Mobile m in eable )
{ {

View file

@ -58,7 +58,7 @@ namespace Server.SkillHandlers
if ( range > 0 ) if ( range > 0 )
{ {
IPooledEnumerable inRange = src.Map.GetMobilesInRange( p, range ); IPooledEnumerable<Mobile> inRange = src.Map.GetMobilesInRange( p, range );
foreach ( Mobile trg in inRange ) foreach ( Mobile trg in inRange )
{ {
@ -83,23 +83,18 @@ namespace Server.SkillHandlers
if ( Faction.Find( src ) != null ) if ( Faction.Find( src ) != null )
{ {
IPooledEnumerable itemsInRange = src.Map.GetItemsInRange( p, range ); IPooledEnumerable<BaseFactionTrap> itemsInRange = src.Map.GetItemsInRange<BaseFactionTrap>( p, range );
foreach ( Item item in itemsInRange ) foreach ( BaseFactionTrap trap in itemsInRange )
{ {
if ( item is BaseFactionTrap ) if ( src.CheckTargetSkill( SkillName.DetectHidden, trap, 80.0, 100.0 ) )
{ {
BaseFactionTrap trap = (BaseFactionTrap) item; src.SendLocalizedMessage( 1042712, true, " " + (trap.Faction == null ? "" : trap.Faction.Definition.FriendlyName) ); // You reveal a trap placed by a faction:
if ( src.CheckTargetSkill( SkillName.DetectHidden, trap, 80.0, 100.0 ) ) trap.Visible = true;
{ trap.BeginConceal();
src.SendLocalizedMessage( 1042712, true, " " + (trap.Faction == null ? "" : trap.Faction.Definition.FriendlyName) ); // You reveal a trap placed by a faction:
trap.Visible = true; foundAnyone = true;
trap.BeginConceal();
foundAnyone = true;
}
} }
} }

View file

@ -67,7 +67,7 @@ namespace Server.SkillHandlers
{ {
string message = String.Format( "You notice {0} attempting to peek into {1}'s belongings.", from.Name, root.Name ); string message = String.Format( "You notice {0} attempting to peek into {1}'s belongings.", from.Name, root.Name );
IPooledEnumerable eable = map.GetClientsInRange( from.Location, 8 ); IPooledEnumerable<NetState> eable = map.GetClientsInRange( from.Location, 8 );
foreach ( NetState ns in eable ) foreach ( NetState ns in eable )
{ {
@ -103,4 +103,4 @@ namespace Server.SkillHandlers
} }
} }
} }
} }

View file

@ -252,7 +252,7 @@ namespace Server.Spells.Fifth
if ( map != null && caster != null ) if ( map != null && caster != null )
{ {
bool eastToWest = ( m_Item.ItemID == 0x3915 ); bool eastToWest = ( m_Item.ItemID == 0x3915 );
IPooledEnumerable eable = map.GetMobilesInBounds( new Rectangle2D( m_Item.X - (eastToWest ? 0 : 1), m_Item.Y - (eastToWest ? 1 : 0), (eastToWest ? 1 : 2), (eastToWest ? 2 : 1) ) ); IPooledEnumerable<Mobile> eable = map.GetMobilesInBounds( new Rectangle2D( m_Item.X - (eastToWest ? 0 : 1), m_Item.Y - (eastToWest ? 1 : 0), (eastToWest ? 1 : 2), (eastToWest ? 2 : 1) ) );
foreach ( Mobile m in eable ) foreach ( Mobile m in eable )
{ {
@ -298,4 +298,4 @@ namespace Server.Spells.Fifth
} }
} }
} }
} }

View file

@ -57,7 +57,7 @@ namespace Server.Spells.Fourth
if ( directTarget != null && Caster.CanBeBeneficial( directTarget, false ) ) if ( directTarget != null && Caster.CanBeBeneficial( directTarget, false ) )
targets.Add( directTarget ); targets.Add( directTarget );
IPooledEnumerable eable = map.GetMobilesInRange( new Point3D( p ), 2 ); IPooledEnumerable<Mobile> eable = map.GetMobilesInRange( new Point3D( p ), 2 );
foreach ( Mobile m in eable ) foreach ( Mobile m in eable )
{ {
@ -187,4 +187,4 @@ namespace Server.Spells.Fourth
} }
} }
} }
} }

View file

@ -48,7 +48,7 @@ namespace Server.Spells.Fourth
if ( map != null ) if ( map != null )
{ {
IPooledEnumerable eable = map.GetMobilesInRange( new Point3D( p ), Core.AOS ? 2 : 3 ); IPooledEnumerable<Mobile> eable = map.GetMobilesInRange( new Point3D( p ), Core.AOS ? 2 : 3 );
foreach ( Mobile m in eable ) foreach ( Mobile m in eable )
{ {

View file

@ -53,7 +53,7 @@ namespace Server.Spells.Seventh
if ( map != null ) if ( map != null )
{ {
IPooledEnumerable eable = map.GetMobilesInRange( new Point3D( p ), 2 ); IPooledEnumerable<Mobile> eable = map.GetMobilesInRange( new Point3D( p ), 2 );
foreach ( Mobile m in eable ) foreach ( Mobile m in eable )
{ {
@ -140,4 +140,4 @@ namespace Server.Spells.Seventh
} }
} }
} }
} }

View file

@ -66,7 +66,7 @@ namespace Server.Spells.Seventh
{ {
bool _gateFound = false; bool _gateFound = false;
IPooledEnumerable eable = map.GetItemsInRange( loc, 0 ); IPooledEnumerable<Item> eable = map.GetItemsInRange( loc, 0 );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {
if ( item is Moongate || item is PublicMoongate ) if ( item is Moongate || item is PublicMoongate )
@ -255,4 +255,4 @@ namespace Server.Spells.Seventh
} }
} }
} }
} }

View file

@ -49,10 +49,10 @@ namespace Server.Spells.Seventh
if ( map != null ) if ( map != null )
{ {
IPooledEnumerable eable = map.GetMobilesInRange( new Point3D( p ), 8 ); IPooledEnumerable<BaseCreature> eable = map.GetMobilesInRange<BaseCreature>( new Point3D( p ), 8 );
foreach ( Mobile m in eable ) foreach ( BaseCreature m in eable )
if ( m is BaseCreature && (m as BaseCreature).IsDispellable && Caster.CanBeHarmful( m, false ) ) if ( m.IsDispellable && Caster.CanBeHarmful( m, false ) )
targets.Add( m ); targets.Add( m );
eable.Free(); eable.Free();
@ -111,4 +111,4 @@ namespace Server.Spells.Seventh
} }
} }
} }
} }

View file

@ -53,7 +53,7 @@ namespace Server.Spells.Seventh
if ( map != null ) if ( map != null )
{ {
IPooledEnumerable eable = map.GetMobilesInRange( new Point3D( p ), 2 ); IPooledEnumerable<Mobile> eable = map.GetMobilesInRange( new Point3D( p ), 2 );
foreach ( Mobile m in eable ) foreach ( Mobile m in eable )
{ {
@ -136,4 +136,4 @@ namespace Server.Spells.Seventh
} }
} }
} }
} }

View file

@ -49,7 +49,7 @@ namespace Server.Spells.Sixth
if ( map != null ) if ( map != null )
{ {
IPooledEnumerable eable = map.GetMobilesInRange( new Point3D( p ), 2 ); IPooledEnumerable<Mobile> eable = map.GetMobilesInRange( new Point3D( p ), 2 );
foreach ( Mobile m in eable ) foreach ( Mobile m in eable )
{ {
@ -106,4 +106,4 @@ namespace Server.Spells.Sixth
} }
} }
} }
} }

View file

@ -46,7 +46,7 @@ namespace Server.Spells.Sixth
if ( map != null ) if ( map != null )
{ {
IPooledEnumerable eable = map.GetMobilesInRange( new Point3D( p ), 1 + (int)(Caster.Skills[SkillName.Magery].Value / 20.0) ); IPooledEnumerable<Mobile> eable = map.GetMobilesInRange( new Point3D( p ), 1 + (int)(Caster.Skills[SkillName.Magery].Value / 20.0) );
foreach ( Mobile m in eable ) foreach ( Mobile m in eable )
{ {
@ -120,4 +120,4 @@ namespace Server.Spells.Sixth
} }
} }
} }
} }

View file

@ -86,7 +86,7 @@ namespace Server.Spells.Spellweaving
return true; return true;
} }
IPooledEnumerable eable = map.GetItemsInRange( location, 0 ); // Added Tiles IPooledEnumerable<Item> eable = map.GetItemsInRange( location, 0 ); // Added Tiles
foreach( Item item in eable ) foreach( Item item in eable )
{ {
@ -162,4 +162,4 @@ namespace Server.Spells.Spellweaving
} }
} }
} }
} }

View file

@ -100,7 +100,7 @@ namespace Server.Spells.Third
m.PlaySound( 0x1FE ); m.PlaySound( 0x1FE );
IPooledEnumerable eable = m.GetItemsInRange( 0 ); IPooledEnumerable<Item> eable = m.GetItemsInRange( 0 );
foreach ( Item item in eable ) foreach ( Item item in eable )
{ {
@ -137,4 +137,4 @@ namespace Server.Spells.Third
} }
} }
} }
} }

View file

@ -172,8 +172,8 @@ namespace Server
{ {
ClientSelector = SelectClients; ClientSelector = SelectClients;
EntitySelector = SelectEntities; EntitySelector = SelectEntities;
MobileSelector = SelectMobiles; MobileSelector = SelectMobiles<Mobile>;
ItemSelector = SelectItems; ItemSelector = SelectItems<Item>;
MultiSelector = SelectMultis; MultiSelector = SelectMultis;
MultiTileSelector = SelectMultiTiles; MultiTileSelector = SelectMultiTiles;
} }
@ -185,21 +185,27 @@ namespace Server
public static IEnumerable<IEntity> SelectEntities(Sector s, Rectangle2D bounds) public static IEnumerable<IEntity> SelectEntities(Sector s, Rectangle2D bounds)
{ {
return return SelectEntities(s, true, true, bounds);
Enumerable.Empty<IEntity>()
.Union(s.Mobiles.Where(o => o != null && !o.Deleted))
.Union(s.Items.Where(o => o != null && !o.Deleted && o.Parent == null))
.Where(bounds.Contains);
} }
public static IEnumerable<Mobile> SelectMobiles(Sector s, Rectangle2D bounds) public static IEnumerable<IEntity> SelectEntities(Sector s, bool items, bool mobiles, Rectangle2D bounds)
{ {
return s.Mobiles.Where(o => o != null && !o.Deleted && bounds.Contains(o)); IEnumerable<IEntity> eable = Enumerable.Empty<IEntity>();
if (mobiles)
eable = eable.Union(s.Mobiles.Where(o => o != null && !o.Deleted));
if (items)
eable = eable.Union(s.Items.Where(o => o != null && !o.Deleted && o.Parent == null));
return eable.Where(bounds.Contains);
} }
public static IEnumerable<Item> SelectItems(Sector s, Rectangle2D bounds) public static IEnumerable<T> SelectMobiles<T>(Sector s, Rectangle2D bounds) where T : Mobile
{ {
return s.Items.Where(o => o != null && !o.Deleted && o.Parent == null && bounds.Contains(o)); return s.Mobiles.OfType<T>().Where(o => o != null && !o.Deleted && bounds.Contains(o));
}
public static IEnumerable<T> SelectItems<T>(Sector s, Rectangle2D bounds) where T : Item
{
return s.Items.OfType<T>().Where(o => o != null && !o.Deleted && o.Parent == null && o is T && bounds.Contains(o));
} }
public static IEnumerable<BaseMulti> SelectMultis(Sector s, Rectangle2D bounds) public static IEnumerable<BaseMulti> SelectMultis(Sector s, Rectangle2D bounds)
@ -261,18 +267,26 @@ namespace Server
} }
public static Map.PooledEnumerable<IEntity> GetEntities(Map map, Rectangle2D bounds) public static Map.PooledEnumerable<IEntity> GetEntities(Map map, Rectangle2D bounds)
{
return GetEntities(map, bounds, true, true);
}
public static Map.PooledEnumerable<IEntity> GetEntities(Map map, Rectangle2D bounds, bool items, bool mobiles)
{ {
return Map.PooledEnumerable<IEntity>.Instantiate(map, bounds, EntitySelector ?? SelectEntities); return Map.PooledEnumerable<IEntity>.Instantiate(map, bounds, EntitySelector ?? SelectEntities);
} }
public static Map.PooledEnumerable<Mobile> GetMobiles(Map map, Rectangle2D bounds) public static Map.PooledEnumerable<Mobile> GetMobiles(Map map, Rectangle2D bounds)
{ {
return Map.PooledEnumerable<Mobile>.Instantiate(map, bounds, MobileSelector ?? SelectMobiles); return GetMobiles<Mobile>(map, bounds);
} }
public static Map.PooledEnumerable<T> GetMobiles<T>(Map map, Rectangle2D bounds) where T : Mobile
public static Map.PooledEnumerable<Item> GetItems(Map map, Rectangle2D bounds)
{ {
return Map.PooledEnumerable<Item>.Instantiate(map, bounds, ItemSelector ?? SelectItems); return Map.PooledEnumerable<T>.Instantiate(map, bounds, SelectMobiles<T>);
}
public static Map.PooledEnumerable<T> GetItems<T>(Map map, Rectangle2D bounds) where T : Item
{
return Map.PooledEnumerable<T>.Instantiate(map, bounds, SelectItems<T>);
} }
public static Map.PooledEnumerable<BaseMulti> GetMultis(Map map, Rectangle2D bounds) public static Map.PooledEnumerable<BaseMulti> GetMultis(Map map, Rectangle2D bounds)
@ -615,10 +629,20 @@ namespace Server
public IPooledEnumerable<IEntity> GetObjectsInRange(Point3D p, int range) public IPooledEnumerable<IEntity> GetObjectsInRange(Point3D p, int range)
{ {
return GetObjectsInBounds(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1)); return GetObjectsInRange(p, range, true, true);
}
public IPooledEnumerable<IEntity> GetObjectsInRange(Point3D p, int range, bool items, bool mobiles)
{
return GetObjectsInBounds(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1), items, mobiles);
} }
public IPooledEnumerable<IEntity> GetObjectsInBounds(Rectangle2D bounds) public IPooledEnumerable<IEntity> GetObjectsInBounds(Rectangle2D bounds)
{
return GetObjectsInBounds(bounds, true, true);
}
public IPooledEnumerable<IEntity> GetObjectsInBounds(Rectangle2D bounds, bool items, bool mobiles)
{ {
return PooledEnumeration.GetEntities(this, bounds); return PooledEnumeration.GetEntities(this, bounds);
} }
@ -650,15 +674,21 @@ namespace Server
return GetItemsInRange(p, 18); return GetItemsInRange(p, 18);
#endif #endif
} }
public IPooledEnumerable<Item> GetItemsInRange(Point3D p, int range) public IPooledEnumerable<Item> GetItemsInRange(Point3D p, int range)
{ {
return GetItemsInBounds(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1)); return GetItemsInRange<Item>(p, range);
}
public IPooledEnumerable<T> GetItemsInRange<T>(Point3D p, int range) where T : Item
{
return GetItemsInBounds<T>(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1));
} }
public IPooledEnumerable<Item> GetItemsInBounds(Rectangle2D bounds) public IPooledEnumerable<Item> GetItemsInBounds(Rectangle2D bounds)
{ {
return PooledEnumeration.GetItems(this, bounds); return GetItemsInBounds<Item>(bounds);
}
public IPooledEnumerable<T> GetItemsInBounds<T>(Rectangle2D bounds) where T : Item
{
return PooledEnumeration.GetItems<T>(this, bounds);
} }
public IPooledEnumerable<Mobile> GetMobilesInRange(Point3D p) public IPooledEnumerable<Mobile> GetMobilesInRange(Point3D p)
@ -672,12 +702,22 @@ namespace Server
public IPooledEnumerable<Mobile> GetMobilesInRange(Point3D p, int range) public IPooledEnumerable<Mobile> GetMobilesInRange(Point3D p, int range)
{ {
return GetMobilesInBounds(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1)); return GetMobilesInRange<Mobile>(p, range);
}
public IPooledEnumerable<T> GetMobilesInRange<T>(Point3D p, int range) where T : Mobile
{
return GetMobilesInBounds<T>(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1));
} }
public IPooledEnumerable<Mobile> GetMobilesInBounds(Rectangle2D bounds) public IPooledEnumerable<Mobile> GetMobilesInBounds(Rectangle2D bounds)
{ {
return PooledEnumeration.GetMobiles(this, bounds); return GetMobilesInBounds<Mobile>(bounds);
}
public IPooledEnumerable<T> GetMobilesInBounds<T>(Rectangle2D bounds) where T : Mobile
{
return PooledEnumeration.GetMobiles<T>(this, bounds);
} }
#endregion #endregion

View file

@ -4710,15 +4710,18 @@ namespace Server
} }
#region Get*InRange #region Get*InRange
public IPooledEnumerable<Item> GetItemsInRange(int range)
public IPooledEnumerable<Item> GetItemsInRange( int range ) {
return GetItemsInRange<Item>(range);
}
public IPooledEnumerable<T> GetItemsInRange<T>( int range ) where T : Item
{ {
Map map = m_Map; Map map = m_Map;
if( map == null ) if( map == null )
return Server.Map.NullEnumerable<Item>.Instance; return Server.Map.NullEnumerable<T>.Instance;
return map.GetItemsInRange( m_Location, range ); return map.GetItemsInRange<T>( m_Location, range );
} }
public IPooledEnumerable<IEntity> GetObjectsInRange( int range ) public IPooledEnumerable<IEntity> GetObjectsInRange( int range )
@ -4732,13 +4735,17 @@ namespace Server
} }
public IPooledEnumerable<Mobile> GetMobilesInRange( int range ) public IPooledEnumerable<Mobile> GetMobilesInRange( int range )
{
return GetMobilesInRange<Mobile>(range);
}
public IPooledEnumerable<T> GetMobilesInRange<T>(int range) where T : Mobile
{ {
Map map = m_Map; Map map = m_Map;
if( map == null ) if (map == null)
return Server.Map.NullEnumerable<Mobile>.Instance; return Server.Map.NullEnumerable<T>.Instance;
return map.GetMobilesInRange( m_Location, range ); return map.GetMobilesInRange<T>(m_Location, range);
} }
public IPooledEnumerable<NetState> GetClientsInRange(int range) public IPooledEnumerable<NetState> GetClientsInRange(int range)

View file

@ -2084,10 +2084,10 @@ namespace Server.Network
if ( match ) if ( match )
authOK = true; authOK = true;
} }
else else
{ {
pvSrc.Seek( 16, SeekOrigin.Current ); pvSrc.Seek( 16, SeekOrigin.Current );
} }
ThirdPartyAuthCallback( state, authOK ); ThirdPartyAuthCallback( state, authOK );
} }
@ -2734,4 +2734,4 @@ namespace Server.Network
state.Dispose(); state.Dispose();
} }
} }
} }