List<PlayerMobile> players = new List<PlayerMobile>( ); //Initialize a PlayerMobile collection
foreach( Mobile wm in World.Mobiles.Values )
{
if( wm is PlayerMobile && !wm.Deleted ) //Filter Mobiles by PlayerMobile type
players.Add( (PlayerMobile)wm );
}
foreach( PlayerMobile pm in players )
{
if( Insensitive.Equals(pm.RawName, name) ) //Case-insensitive string equality
{
players.Clear(); //Clear the list before the method exits to free allocated memory
return false;
}
}
players.Clear(); //Clear the list before the method exits to free allocated memory
return true;
foreach( Mobile wm in World.Mobiles.Values )
if( wm is PlayerMobile && !wm.Deleted && Insensitive.Equals(wm.RawName, name))
return false;
return true;
Vorspire, why so serious?
private static Queue m_ChangeQueue = Queue.Synchronized( new Queue() );
http://msdn.microsoft.com/en-us/library/system.collections.queue.synchronized.aspx said:Returns a Queue wrapper that is synchronized (thread safe).
lock ( m_Queue )
m_Queue.Enqueue( t );
public static void Slice()
{
lock ( m_Queue )
{
http://msdn.microsoft.com/en-us/library/c5kehkcz(v=vs.71).aspx said:lock ensures that one thread does not enter a critical section while another thread is in the critical section of code. If another thread attempts to enter a locked code, it will wait (block) until the object is released.
if( wm != m && wm is PlayerMobile && !wm.Deleted )
What would you change if you wanted to allow duplicate names on the same account?
foreach( NetState state in World.Mobiles.Values where m != null select m.NetState)
{
}
foreach( NetState state in World.Mobiles.Values.Where( m => m != null ).Select( m => m.NetState ) )
{
}