Example #1
0
        internal static int RemoveInactivePlayers()
        {
            int count = 0;

            lock ( AddLocker ) {
                playersByIP = new Dictionary <IPAddress, List <PlayerInfo> >();
                PlayerInfo[] playerInfoListCache = PlayerInfoList;
                for (int i = 0; i < playerInfoListCache.Length; i++)
                {
                    if (!playersByIP.ContainsKey(playerInfoListCache[i].LastIP))
                    {
                        playersByIP[playerInfoListCache[i].LastIP] = new List <PlayerInfo>();
                    }
                    playersByIP[playerInfoListCache[i].LastIP].Add(PlayerInfoList[i]);
                }
                foreach (PlayerInfo p in playerInfoListCache.Where(p => PlayerIsInactive(p, true)))
                {
                    Trie.Remove(p.Name);
                    List.Remove(p);
                    count++;
                }
                List.TrimExcess();
                UpdateCache();
                playersByIP = null;
            }
            return(count);
        }
 /// <summary> Removes a PlayerInfo entry from the database. </summary>
 /// <returns> True if the entry is successfully found and removed; otherwise false. </returns>
 public bool Remove(PlayerInfo playerInfo)
 {
     if (playerInfo == null)
     {
         throw new ArgumentNullException("playerInfo");
     }
     return(trie.Remove(playerInfo.Name));
 }