From 9ab7164d05215c29574c7c47fb7c8a1200f7746e Mon Sep 17 00:00:00 2001 From: Volker Fischer Date: Tue, 9 Feb 2016 15:05:06 +0000 Subject: [PATCH] the Musicians value in the server list shows a warning if the server is full --- ChangeLog | 2 ++ src/connectdlg.cpp | 23 ++++++++++++++++++----- src/serverlist.cpp | 10 ++++++---- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index d2d4542f..a239d82e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ - avoid a single jitter buffer for the auto detection +- the Musicians value in the server list shows a warning if the server is full + - bug fix: ping time measurement may be invalid for the Linux OS diff --git a/src/connectdlg.cpp b/src/connectdlg.cpp index 4158972d..b4ccb21c 100755 --- a/src/connectdlg.cpp +++ b/src/connectdlg.cpp @@ -89,9 +89,11 @@ CConnectDlg::CConnectDlg ( const bool bNewShowCompleteRegList, #endif lvwServers->clear(); - // add invisible column which is used for sorting the list - lvwServers->setColumnCount ( 5 ); + // add invisible columns which are used for sorting the list and storing + // the maximum number of clients + lvwServers->setColumnCount ( 6 ); lvwServers->hideColumn ( 4 ); + lvwServers->hideColumn ( 5 ); // per default the root shall not be decorated (to save space) lvwServers->setRootIsDecorated ( false ); @@ -267,7 +269,7 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr, } // the ping time shall be shown in bold font - QFont CurPingTimeFont = pNewListViewItem->font( 3 ); + QFont CurPingTimeFont = pNewListViewItem->font ( 3 ); CurPingTimeFont.setBold ( true ); pNewListViewItem->setFont ( 1, CurPingTimeFont ); @@ -297,6 +299,9 @@ strLocation += ", " + vecServerInfo[iIdx].HostAddr.InetAddr.toString() + // must fit in an integer type) pNewListViewItem->setText ( 4, "99999999" ); + // store the maximum number of clients + pNewListViewItem->setText ( 5, QString().setNum ( vecServerInfo[iIdx].iMaxNumClients ) ); + // store host address pNewListViewItem->setData ( 0, Qt::UserRole, CurHostAddress.toString() ); @@ -530,8 +535,16 @@ void CConnectDlg::SetPingTimeAndNumClientsResult ( CHostAddress& } // update number of clients text - pCurListViewItem-> - setText ( 2, QString().setNum ( iNumClients ) ); + if ( iNumClients >= pCurListViewItem->text ( 5 ).toInt() ) + { + pCurListViewItem-> + setText ( 2, QString().setNum ( iNumClients ) + " (full)" ); + } + else + { + pCurListViewItem-> + setText ( 2, QString().setNum ( iNumClients ) ); + } // a ping time was received, set item to visible (note that we have // to check if the item is hidden, otherwise we get a lot of CPU diff --git a/src/serverlist.cpp b/src/serverlist.cpp index cd0b99c5..bcaef032 100755 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -58,9 +58,10 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum, // never be deleted ServerList.clear(); - // init server list entry (server info for this server) with defaults, per + // Init server list entry (server info for this server) with defaults. Per // definition the client substitudes the IP address of the central server - // itself for his server list + // itself for his server list. If we are the central server, we assume that + // we have a permanent server. CServerListEntry ThisServerListEntry ( CHostAddress(), iPortNumber, "", @@ -68,7 +69,7 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum, QLocale::system().country(), "", iNumChannels, - true ); + GetIsCentralServer() ); // parse the server info string according to definition: // [this server name];[this server city]; ... @@ -107,7 +108,8 @@ CServerListManager::CServerListManager ( const quint16 iNPortNum, while ( ( iServInfoNumSplitItems - iCurUsedServInfoSplitItems >= 4 ) && ( iNumPredefinedServers <= MAX_NUM_SERVERS_IN_SERVER_LIST ) ) { - // create a new server list entry + // create a new server list entry, we assume that servers which are + // registered via the command line are permanent servers CServerListEntry NewServerListEntry ( CHostAddress(), 0, // port number not used "",