private void CacheSpecialGameAccounts()
    {
        this.m_hsGameAccount   = null;
        this.m_bestGameAccount = null;
        ulong lastOnlineMicrosec = 0L;

        foreach (BnetGameAccount account in this.m_gameAccounts.Values)
        {
            BnetProgramId programId = account.GetProgramId();
            if (programId != null)
            {
                if (programId == BnetProgramId.HEARTHSTONE)
                {
                    this.m_hsGameAccount = account;
                    if (account.IsOnline() || !BnetFriendMgr.Get().IsFriend(account.GetId()))
                    {
                        this.m_bestGameAccount = account;
                    }
                    break;
                }
                if (this.m_bestGameAccount == null)
                {
                    this.m_bestGameAccount = account;
                    lastOnlineMicrosec     = this.m_bestGameAccount.GetLastOnlineMicrosec();
                }
                else
                {
                    BnetProgramId id2 = this.m_bestGameAccount.GetProgramId();
                    if (programId.IsGame() && !id2.IsGame())
                    {
                        this.m_bestGameAccount = account;
                        lastOnlineMicrosec     = this.m_bestGameAccount.GetLastOnlineMicrosec();
                    }
                    else if ((account.IsOnline() && programId.IsGame()) && id2.IsGame())
                    {
                        ulong num2 = account.GetLastOnlineMicrosec();
                        if (num2 > lastOnlineMicrosec)
                        {
                            this.m_bestGameAccount = account;
                            lastOnlineMicrosec     = num2;
                        }
                    }
                }
            }
        }
    }
    public static int FriendSortCompare(BnetPlayer friend1, BnetPlayer friend2)
    {
        int result = 0;

        if ((friend1 == null) || (friend2 == null))
        {
            return((friend1 != friend2) ? ((friend1 != null) ? -1 : 1) : 0);
        }
        if (friend1.IsOnline() || friend2.IsOnline())
        {
            if (friend1.IsOnline() && !friend2.IsOnline())
            {
                return(-1);
            }
            if (!friend1.IsOnline() && friend2.IsOnline())
            {
                return(1);
            }
            BnetProgramId bestProgramId = friend1.GetBestProgramId();
            BnetProgramId id2           = friend2.GetBestProgramId();
            if (FriendSortFlagCompare(friend1, friend2, bestProgramId == BnetProgramId.HEARTHSTONE, id2 == BnetProgramId.HEARTHSTONE, out result))
            {
                return(result);
            }
            bool lhsflag = (bestProgramId != null) ? bestProgramId.IsGame() : false;
            bool rhsflag = (id2 != null) ? id2.IsGame() : false;
            if (FriendSortFlagCompare(friend1, friend2, lhsflag, rhsflag, out result))
            {
                return(result);
            }
            bool flag3 = (bestProgramId != null) ? bestProgramId.IsPhoenix() : false;
            bool flag4 = (id2 != null) ? id2.IsPhoenix() : false;
            if (FriendSortFlagCompare(friend1, friend2, flag3, flag4, out result))
            {
                return(result);
            }
        }
        return(FriendNameSortCompare(friend1, friend2));
    }