generic enumerable refactor

This commit is contained in:
Mark Sturgill 2013-10-15 21:30:35 -07:00
parent 88488bc616
commit f5f24d3a92
5 changed files with 56 additions and 56 deletions

View file

@ -70,7 +70,7 @@ namespace Server
{
Packet playSound = null;
IPooledEnumerable eable = map.GetClientsInRange( new Point3D( p ) );
IPooledEnumerable<NetState> eable = map.GetClientsInRange( new Point3D( p ) );
foreach ( NetState state in eable ) {
state.Mobile.ProcessDelta();
@ -108,7 +108,7 @@ namespace Server
Packet preEffect = null, boltEffect = null, playSound = null;
IPooledEnumerable eable = map.GetClientsInRange( e.Location );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(e.Location);
foreach ( NetState state in eable ) {
if ( state.Mobile.CanSee( e ) ) {
@ -178,7 +178,7 @@ namespace Server
{
Packet particles = null, regular = null;
IPooledEnumerable eable = map.GetClientsInRange( e.Location );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(e.Location);
foreach ( NetState state in eable ) {
state.Mobile.ProcessDelta();
@ -248,7 +248,7 @@ namespace Server
{
Packet particles = null, regular = null;
IPooledEnumerable eable = map.GetClientsInRange( target.Location );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(target.Location);
foreach ( NetState state in eable ) {
state.Mobile.ProcessDelta();
@ -320,7 +320,7 @@ namespace Server
{
Packet particles = null, regular = null;
IPooledEnumerable eable = map.GetClientsInRange( from.Location );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(from.Location);
foreach ( NetState state in eable ) {
state.Mobile.ProcessDelta();
@ -350,7 +350,7 @@ namespace Server
public static void SendPacket( Point3D origin, Map map, Packet p )
{
if ( map != null ) {
IPooledEnumerable eable = map.GetClientsInRange( origin );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(origin);
p.Acquire();
@ -369,7 +369,7 @@ namespace Server
{
if ( map != null )
{
IPooledEnumerable eable = map.GetClientsInRange( new Point3D( origin ) );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(new Point3D(origin));
p.Acquire();

View file

@ -1353,7 +1353,7 @@ namespace Server
if ( oldLocation.m_X != 0 )
{
IPooledEnumerable eable = m_Map.GetClientsInRange( oldLocation, GetMaxUpdateRange() );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(oldLocation, GetMaxUpdateRange());
foreach ( NetState state in eable ) {
Mobile m = state.Mobile;
@ -1389,7 +1389,7 @@ namespace Server
if ( m_Map != null )
{
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location, GetMaxUpdateRange() );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location, GetMaxUpdateRange());
foreach (NetState state in eable) {
Mobile m = state.Mobile;
@ -1408,7 +1408,7 @@ namespace Server
}
else if ( m_Map != null )
{
IPooledEnumerable eable;
IPooledEnumerable<NetState> eable;
if ( oldLocation.m_X != 0 )
{
@ -1802,7 +1802,7 @@ namespace Server
{
Point3D worldLoc = GetWorldLocation();
IPooledEnumerable eable = m_Map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
foreach (NetState state in eable) {
Mobile m = state.Mobile;
@ -2169,7 +2169,7 @@ namespace Server
writer.WriteEncodedInt( info.m_SavedFlags );
}
public IPooledEnumerable GetObjectsInRange( int range )
public IPooledEnumerable<IEntity> GetObjectsInRange( int range )
{
Map map = m_Map;
@ -2182,7 +2182,7 @@ namespace Server
return map.GetObjectsInRange( GetWorldLocation(), range );
}
public IPooledEnumerable GetItemsInRange( int range )
public IPooledEnumerable<Item> GetItemsInRange( int range )
{
Map map = m_Map;
@ -2195,7 +2195,7 @@ namespace Server
return map.GetItemsInRange( GetWorldLocation(), range );
}
public IPooledEnumerable GetMobilesInRange( int range )
public IPooledEnumerable<Mobile> GetMobilesInRange( int range )
{
Map map = m_Map;
@ -2208,7 +2208,7 @@ namespace Server
return map.GetMobilesInRange( GetWorldLocation(), range );
}
public IPooledEnumerable GetClientsInRange( int range )
public IPooledEnumerable<NetState> GetClientsInRange( int range )
{
Map map = m_Map;
@ -3187,7 +3187,7 @@ namespace Server
Packet p = null;
Point3D worldLoc = GetWorldLocation();
IPooledEnumerable eable = map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
foreach ( NetState state in eable ) {
Mobile m = state.Mobile;
@ -3232,7 +3232,7 @@ namespace Server
Packet p = null;
Point3D worldLoc = GetWorldLocation();
IPooledEnumerable eable = map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
foreach ( NetState state in eable ) {
Mobile m = state.Mobile;
@ -3262,7 +3262,7 @@ namespace Server
if ( sendOPLUpdate )
{
Point3D worldLoc = GetWorldLocation();
IPooledEnumerable eable = map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
foreach ( NetState state in eable ) {
Mobile m = state.Mobile;
@ -3372,7 +3372,7 @@ namespace Server
Packet p = null;
Point3D worldLoc = GetWorldLocation();
IPooledEnumerable eable = m_Map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
foreach ( NetState state in eable )
{
@ -3412,7 +3412,7 @@ namespace Server
Packet p = null;
Point3D worldLoc = GetWorldLocation();
IPooledEnumerable eable = m_Map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
foreach ( NetState state in eable )
{
@ -3566,7 +3566,7 @@ namespace Server
{
if ( m_Parent == null )
{
IPooledEnumerable eable;
IPooledEnumerable<NetState> eable;
if ( m_Location.m_X != 0 )
{
@ -3973,7 +3973,7 @@ namespace Server
List<Item> items = new List<Item>();
IPooledEnumerable eable = map.GetItemsInRange( p, 0 );
IPooledEnumerable<Item> eable = map.GetItemsInRange( p, 0 );
foreach ( Item item in eable )
{
@ -4151,7 +4151,7 @@ namespace Server
{
Point3D worldLoc = GetWorldLocation();
IPooledEnumerable eable = m_Map.GetClientsInRange( worldLoc, GetMaxUpdateRange() );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange());
foreach (NetState state in eable) {
Mobile m = state.Mobile;

View file

@ -466,7 +466,7 @@ namespace Server
List<Item> items = new List<Item>();
IPooledEnumerable eable = GetItemsInRange( new Point3D( x, y, 0 ), 0 );
IPooledEnumerable<Item> eable = GetItemsInRange( new Point3D( x, y, 0 ), 0 );
foreach ( Item item in eable )
{
@ -1933,7 +1933,7 @@ namespace Server
if( contains && statics.Length == 0 )
{
IPooledEnumerable eable = GetItemsInRange( point, 0 );
IPooledEnumerable<Item> eable = GetItemsInRange( point, 0 );
foreach( Item item in eable )
{
@ -1979,7 +1979,7 @@ namespace Server
Rectangle2D rect = new Rectangle2D( pTop.m_X, pTop.m_Y, (pBottom.m_X - pTop.m_X) + 1, (pBottom.m_Y - pTop.m_Y) + 1 );
IPooledEnumerable area = GetItemsInBounds( rect );
IPooledEnumerable<Item> area = GetItemsInBounds( rect );
foreach( Item i in area )
{

View file

@ -3314,7 +3314,7 @@ namespace Server
if( m_Map != null )
{
IPooledEnumerable eable = m_Map.GetObjectsInRange( m_Location, Core.GlobalMaxUpdateRange );
IPooledEnumerable<IEntity> eable = m_Map.GetObjectsInRange( m_Location, Core.GlobalMaxUpdateRange );
foreach(IEntity o in eable) {
if(o == this)
@ -4029,7 +4029,7 @@ namespace Server
{
Packet animPacket = null;
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach( NetState state in eable ) {
if( state != m_NetState ) {
@ -4393,7 +4393,7 @@ namespace Server
if( m_DragEffects && map != null && (root == null || root is Item) )
{
IPooledEnumerable eable = map.GetClientsInRange( from.Location );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(from.Location);
Packet p = null;
foreach( NetState ns in eable ) {
@ -4528,7 +4528,7 @@ namespace Server
if( map != null && (root == null || root is Item) )
{
IPooledEnumerable eable = map.GetClientsInRange( m_Location );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(m_Location);
Packet p = null;
bool sameLoc = false;
@ -4771,7 +4771,7 @@ namespace Server
#region Get*InRange
public IPooledEnumerable GetItemsInRange( int range )
public IPooledEnumerable<Item> GetItemsInRange( int range )
{
Map map = m_Map;
@ -4781,7 +4781,7 @@ namespace Server
return map.GetItemsInRange( m_Location, range );
}
public IPooledEnumerable GetObjectsInRange( int range )
public IPooledEnumerable<IEntity> GetObjectsInRange( int range )
{
Map map = m_Map;
@ -4791,7 +4791,7 @@ namespace Server
return map.GetObjectsInRange( m_Location, range );
}
public IPooledEnumerable GetMobilesInRange( int range )
public IPooledEnumerable<Mobile> GetMobilesInRange( int range )
{
Map map = m_Map;
@ -4801,7 +4801,7 @@ namespace Server
return map.GetMobilesInRange( m_Location, range );
}
public IPooledEnumerable GetClientsInRange( int range )
public IPooledEnumerable<NetState> GetClientsInRange(int range)
{
Map map = m_Map;
@ -4863,7 +4863,7 @@ namespace Server
if( m_Map != null )
{
IPooledEnumerable eable = m_Map.GetObjectsInRange( m_Location, range );
IPooledEnumerable<IEntity> eable = m_Map.GetObjectsInRange( m_Location, range );
#if Framework_4_0
Parallel.ForEach(eable, o => {
@ -5334,7 +5334,7 @@ namespace Server
if( map == null )
return;
IPooledEnumerable eable = map.GetClientsInRange( m_Location );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(m_Location);
Packet pNew = null;
Packet pOld = null;
@ -6270,7 +6270,7 @@ namespace Server
Packet p = null;
//Packet pNew = null;
IPooledEnumerable eable = map.GetClientsInRange( m_Location );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(m_Location);
foreach( NetState state in eable ) {
if( state.Mobile.CanSee( this ) ) {
@ -6318,7 +6318,7 @@ namespace Server
{
Packet p = Packet.Acquire(new PlaySound(soundID, this));
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach( NetState state in eable ) {
if( state.Mobile.CanSee( this ) ) {
@ -6582,7 +6582,7 @@ namespace Server
{
if( m_Map != null )
{
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach( NetState state in eable ) {
if( state != m_NetState && (everyone || !state.Mobile.CanSee( this )) )
@ -6599,11 +6599,11 @@ namespace Server
if( m_Map != null && ns != null )
{
IPooledEnumerable eable = m_Map.GetObjectsInRange( m_Location, Core.GlobalMaxUpdateRange );
IPooledEnumerable<IEntity> eable = m_Map.GetObjectsInRange( m_Location, Core.GlobalMaxUpdateRange );
#if Framework_4_0
Parallel.ForEach(eable, o => {
#else
foreach ( object o in eable ) {
foreach ( IEntity o in eable ) {
#endif
if( o is Mobile ) {
Mobile m = (Mobile)o;
@ -6804,11 +6804,11 @@ namespace Server
if( m_Map != null && ns != null )
{
IPooledEnumerable eable = m_Map.GetObjectsInRange( m_Location, Core.GlobalMaxUpdateRange );
IPooledEnumerable<IEntity> eable = m_Map.GetObjectsInRange( m_Location, Core.GlobalMaxUpdateRange );
#if Framework_4_0
Parallel.ForEach(eable, o => {
#else
foreach ( object o in eable ) {
foreach ( IEntity o in eable ) {
#endif
if( o is Item ) {
Item item = (Item)o;
@ -7987,7 +7987,7 @@ namespace Server
if (m_Map != null)
{
IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location);
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach (NetState state in eable) {
if (!state.Mobile.CanSee(this)) {
@ -9120,7 +9120,7 @@ namespace Server
{
// First, send a remove message to everyone who can no longer see us. (inOldRange && !inNewRange)
IPooledEnumerable eable = map.GetClientsInRange( oldLocation );
IPooledEnumerable<NetState> eable = map.GetClientsInRange(oldLocation);
foreach( NetState ns in eable ) {
if( ns != m_NetState && !Utility.InUpdateRange( newLocation, ns.Mobile.Location ) ) {
@ -9135,13 +9135,13 @@ namespace Server
// Check to see if we are attached to a client
if( ourState != null )
{
eable = map.GetObjectsInRange( newLocation, Core.GlobalMaxUpdateRange );
IPooledEnumerable<IEntity> eeable = map.GetObjectsInRange( newLocation, Core.GlobalMaxUpdateRange );
// We are attached to a client, so it's a bit more complex. We need to send new items and people to ourself, and ourself to other clients
#if Framework_4_0
Parallel.ForEach(eable, o => {
#else
foreach ( object o in eable ) {
foreach ( IEntity o in eeable ) {
#endif
if( o is Item )
{
@ -9222,7 +9222,7 @@ namespace Server
);
#endif
eable.Free();
eeable.Free();
}
else
{
@ -9565,7 +9565,7 @@ namespace Server
{
if( m_Map != null )
{
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach( NetState state in eable ) {
if( state.Mobile.CanSee( this ) )
@ -10257,7 +10257,7 @@ namespace Server
Packet hbpPacket = null;
Packet hbyPacket = null;
IPooledEnumerable eable = m.Map.GetClientsInRange(m.m_Location);
IPooledEnumerable<NetState> eable = m.Map.GetClientsInRange(m.m_Location);
foreach ( NetState state in eable ) {
beholder = state.Mobile;
@ -10543,7 +10543,7 @@ namespace Server
p.Acquire();
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach( NetState state in eable ) {
if( state.Mobile.CanSee( this ) && (noLineOfSight || state.Mobile.InLOS( this )) ) {
@ -10573,7 +10573,7 @@ namespace Server
{
Packet p = Packet.Acquire( new MessageLocalized( m_Serial, Body, type, hue, 3, number, Name, args ) );
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach( NetState state in eable ) {
if( state.Mobile.CanSee( this ) && (noLineOfSight || state.Mobile.InLOS( this )) ) {
@ -10598,7 +10598,7 @@ namespace Server
{
Packet p = Packet.Acquire( new MessageLocalizedAffix( m_Serial, Body, type, hue, 3, number, Name, affixType, affix, args ) );
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach( NetState state in eable ) {
if( state.Mobile.CanSee( this ) && (noLineOfSight || state.Mobile.InLOS( this )) ) {
@ -10673,7 +10673,7 @@ namespace Server
{
Packet p = Packet.Acquire( new MessageLocalized( m_Serial, Body, type, hue, 3, number, Name, args ) );
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach( NetState state in eable ) {
if( state != m_NetState && state.Mobile.CanSee( this ) ) {
@ -10700,7 +10700,7 @@ namespace Server
p.Acquire();
IPooledEnumerable eable = m_Map.GetClientsInRange( m_Location );
IPooledEnumerable<NetState> eable = m_Map.GetClientsInRange(m_Location);
foreach( NetState state in eable ) {
if( state != m_NetState && state.Mobile.CanSee( this ) ) {

View file

@ -307,7 +307,7 @@ namespace Server
if ( multis )
{
IPooledEnumerable eable = m_Owner.GetMultiTilesAt( x, y );
IPooledEnumerable<StaticTile[]> eable = m_Owner.GetMultiTilesAt( x, y );
if ( eable == Map.NullEnumerable<StaticTile[]>.Instance )
return tiles[x & 0x7][y & 0x7];