added a command line argument, some code style changes
This commit is contained in:
parent
74ac1d075f
commit
36d13454b3
5 changed files with 54 additions and 42 deletions
|
@ -804,7 +804,7 @@ void CServer::CreateAndSendChanListForThisChan ( const int iCurChanID )
|
|||
vecChannels[iCurChanID].CreateConClientListMes ( vecChanInfo );
|
||||
}
|
||||
|
||||
void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID,
|
||||
void CServer::CreateAndSendChatTextForAllConChannels ( const int iCurChanID,
|
||||
const QString& strChatText )
|
||||
{
|
||||
// Create message which is sent to all connected clients -------------------
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "channel.h"
|
||||
#include "util.h"
|
||||
#include "serverlogging.h"
|
||||
#include "serverlist.h"
|
||||
|
||||
|
||||
/* Definitions ****************************************************************/
|
||||
|
@ -106,7 +107,9 @@ public:
|
|||
const quint16 iPortNumber,
|
||||
const QString& strHTMLStatusFileName,
|
||||
const QString& strHistoryFileName,
|
||||
const QString& strServerNameForHTMLStatusFile );
|
||||
const QString& strServerNameForHTMLStatusFile,
|
||||
const bool bIsCentralServer,
|
||||
const QString& strCentralServer );
|
||||
|
||||
void Start();
|
||||
void Stop();
|
||||
|
@ -178,6 +181,9 @@ protected:
|
|||
CHighPrecisionTimer HighPrecisionTimer;
|
||||
CVector<short> vecsSendData;
|
||||
|
||||
// server list
|
||||
CServerListManager ServerListManager;
|
||||
|
||||
public slots:
|
||||
void OnTimer();
|
||||
void OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage );
|
||||
|
|
|
@ -33,7 +33,7 @@ CServerListManager::CServerListManager ( const bool NbEbld )
|
|||
// never be deleted
|
||||
ServerList.clear();
|
||||
|
||||
// per definition the client substitudes the IP address of the master server
|
||||
// per definition the client substitudes the IP address of the central server
|
||||
// itself for his server list
|
||||
ServerList.append ( CServerListEntry (
|
||||
CHostAddress(),
|
||||
|
@ -47,10 +47,11 @@ ServerList.append ( CServerListEntry (
|
|||
|
||||
|
||||
|
||||
// connections -------------------------------------------------------------
|
||||
// Connections -------------------------------------------------------------
|
||||
QObject::connect ( &TimerPollList, SIGNAL ( timeout() ),
|
||||
this, SLOT ( OnTimerPollList() ) );
|
||||
|
||||
|
||||
// Timers ------------------------------------------------------------------
|
||||
// start timer for polling the server list
|
||||
if ( bEnabled )
|
||||
|
@ -64,7 +65,7 @@ void CServerListManager::OnTimerPollList()
|
|||
{
|
||||
QMutexLocker locker ( &Mutex );
|
||||
|
||||
// check all list entries except of the very first one (which is the master
|
||||
// check all list entries except of the very first one (which is the central
|
||||
// server entry) if they are still valid
|
||||
for ( int iIdx = 1; iIdx < ServerList.size(); iIdx++ )
|
||||
{
|
||||
|
@ -83,41 +84,45 @@ void CServerListManager::RegisterServer ( const CHostAddress& InetAddr,
|
|||
{
|
||||
QMutexLocker locker ( &Mutex );
|
||||
|
||||
// define invalid index used as a flag
|
||||
const int ciInvalidIdx = -1;
|
||||
|
||||
// Check if server is already registered. Use IP number and port number to
|
||||
// fully identify a server. The very first list entry must not be checked
|
||||
// since this is per definition the master server (i.e., this server)
|
||||
int iSelIdx = ciInvalidIdx; // initialize with an illegal value
|
||||
for ( int iIdx = 1; iIdx < ServerList.size(); iIdx++ )
|
||||
if ( bEnabled )
|
||||
{
|
||||
if ( ServerList[iIdx].HostAddr == InetAddr )
|
||||
{
|
||||
// store entry index
|
||||
iSelIdx = iIdx;
|
||||
// define invalid index used as a flag
|
||||
const int ciInvalidIdx = -1;
|
||||
|
||||
// entry found, leave for-loop
|
||||
continue;
|
||||
// Check if server is already registered. Use IP number and port number
|
||||
// to fully identify a server. The very first list entry must not be
|
||||
// checked since this is per definition the central server (i.e., this
|
||||
// server)
|
||||
int iSelIdx = ciInvalidIdx; // initialize with an illegal value
|
||||
for ( int iIdx = 1; iIdx < ServerList.size(); iIdx++ )
|
||||
{
|
||||
if ( ServerList[iIdx].HostAddr == InetAddr )
|
||||
{
|
||||
// store entry index
|
||||
iSelIdx = iIdx;
|
||||
|
||||
// entry found, leave for-loop
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// if server is not yet registered, we have to create a new entry
|
||||
if ( iSelIdx == ciInvalidIdx )
|
||||
{
|
||||
// create a new server list entry and init with received data
|
||||
ServerList.append ( CServerListEntry ( InetAddr, ServerInfo ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// update all data and call update registration function
|
||||
ServerList[iSelIdx].strName = ServerInfo.strName;
|
||||
ServerList[iSelIdx].strTopic = ServerInfo.strTopic;
|
||||
ServerList[iSelIdx].eCountry = ServerInfo.eCountry;
|
||||
ServerList[iSelIdx].strCity = ServerInfo.strCity;
|
||||
ServerList[iSelIdx].iNumClients = ServerInfo.iNumClients;
|
||||
ServerList[iSelIdx].iMaxNumClients = ServerInfo.iMaxNumClients;
|
||||
ServerList[iSelIdx].bPermanentOnline = ServerInfo.bPermanentOnline;
|
||||
ServerList[iSelIdx].UpdateRegistration();
|
||||
}
|
||||
}
|
||||
|
||||
// if server is not yet registered, we have to create a new entry
|
||||
if ( iSelIdx == ciInvalidIdx )
|
||||
{
|
||||
// create a new server list entry and init with received data
|
||||
ServerList.append ( CServerListEntry ( InetAddr, ServerInfo ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
// update all data and call update registration function
|
||||
ServerList[iSelIdx].strName = ServerInfo.strName;
|
||||
ServerList[iSelIdx].strTopic = ServerInfo.strTopic;
|
||||
ServerList[iSelIdx].eCountry = ServerInfo.eCountry;
|
||||
ServerList[iSelIdx].strCity = ServerInfo.strCity;
|
||||
ServerList[iSelIdx].iNumClients = ServerInfo.iNumClients;
|
||||
ServerList[iSelIdx].iMaxNumClients = ServerInfo.iMaxNumClients;
|
||||
ServerList[iSelIdx].bPermanentOnline = ServerInfo.bPermanentOnline;
|
||||
ServerList[iSelIdx].UpdateRegistration();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,8 @@ CHistoryGraph::CHistoryGraph() :
|
|||
PlotPixmap = PlotPixmap.scaled (
|
||||
PlotCanvasRect.width(), PlotCanvasRect.height() );
|
||||
|
||||
// connections
|
||||
|
||||
// Connections -------------------------------------------------------------
|
||||
QObject::connect ( &TimerDailyUpdate, SIGNAL ( timeout() ),
|
||||
this, SLOT ( OnTimerDailyUpdate() ) );
|
||||
}
|
||||
|
@ -100,7 +101,7 @@ void CHistoryGraph::DrawFrame ( const int iNewNumTicksX )
|
|||
QPainter PlotPainter ( &PlotPixmap );
|
||||
|
||||
|
||||
// create actual plot region (grid frame) ----------------------------------
|
||||
// Create actual plot region (grid frame) ----------------------------------
|
||||
PlotPainter.setPen ( PlotFrameColor );
|
||||
PlotPainter.drawRect ( PlotGridFrame );
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ void CSettings::ReadIniFile ( const QString& sFileName )
|
|||
}
|
||||
|
||||
|
||||
// actual settings data ---------------------------------------------------
|
||||
// Actual settings data ---------------------------------------------------
|
||||
// IP addresses
|
||||
for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ )
|
||||
{
|
||||
|
@ -191,7 +191,7 @@ void CSettings::WriteIniFile ( const QString& sFileName )
|
|||
QDomDocument IniXMLDocument;
|
||||
|
||||
|
||||
// actual settings data ---------------------------------------------------
|
||||
// Actual settings data ---------------------------------------------------
|
||||
// IP addresses
|
||||
for ( int iIPAddrIdx = 0; iIPAddrIdx < MAX_NUM_SERVER_ADDR_ITEMS; iIPAddrIdx++ )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue