| 750 | } |
| 751 | |
| 752 | class CPlayerScoreNameLess |
| 753 | { |
| 754 | const int m_ScoreKind; |
| 755 | |
| 756 | public: |
| 757 | CPlayerScoreNameLess(int ClientScoreKind) : |
| 758 | m_ScoreKind(ClientScoreKind) |
| 759 | { |
| 760 | } |
| 761 | |
| 762 | bool operator()(const CServerInfo::CClient &Client0, const CServerInfo::CClient &Client1) const |
| 763 | { |
| 764 | // Sort players before non players |
| 765 | if(Client0.m_Player && !Client1.m_Player) |
| 766 | return true; |
| 767 | if(!Client0.m_Player && Client1.m_Player) |
| 768 | return false; |
| 769 | |
| 770 | int Score0 = Client0.m_Score; |
| 771 | int Score1 = Client1.m_Score; |
| 772 | |
| 773 | if(m_ScoreKind == CServerInfo::CLIENT_SCORE_KIND_TIME || m_ScoreKind == CServerInfo::CLIENT_SCORE_KIND_TIME_BACKCOMPAT) |
| 774 | { |
| 775 | // Sort unfinished (-9999) and still connecting players (-1) after others |
| 776 | if(Score0 < 0 && Score1 >= 0) |
| 777 | return false; |
| 778 | if(Score0 >= 0 && Score1 < 0) |
| 779 | return true; |
| 780 | } |
| 781 | |
| 782 | if(Score0 != Score1) |
| 783 | { |
| 784 | // Handle the sign change introduced with CLIENT_SCORE_KIND_TIME |
| 785 | if(m_ScoreKind == CServerInfo::CLIENT_SCORE_KIND_TIME) |
| 786 | return Score0 < Score1; |
| 787 | else |
| 788 | return Score0 > Score1; |
| 789 | } |
| 790 | |
| 791 | return str_comp_nocase(Client0.m_aName, Client1.m_aName) < 0; |
| 792 | } |
| 793 | }; |
| 794 | |
| 795 | std::sort(pEntry->m_Info.m_aClients, pEntry->m_Info.m_aClients + Info.m_NumReceivedClients, CPlayerScoreNameLess(pEntry->m_Info.m_ClientScoreKind)); |
| 796 | |