1
0

Moved MaxPlayers and Description from cWorld to cServer.

Also started creating a new cWorld::cTickThread class, but not used yet.
This commit is contained in:
madmaxoft
2013-08-11 19:18:06 +02:00
parent b58ca60815
commit eb9d45e906
8 changed files with 274 additions and 186 deletions

View File

@@ -76,6 +76,38 @@ struct cServer::sServerState
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cServer:
cServer::cServer(void) :
m_pState(new sServerState),
m_ListenThreadIPv4(*this, cSocket::IPv4, "Client"),
m_ListenThreadIPv6(*this, cSocket::IPv6, "Client"),
m_Millisecondsf(0),
m_Milliseconds(0),
m_bIsConnected(false),
m_bRestarting(false),
m_RCONServer(*this)
{
}
cServer::~cServer()
{
// TODO: Shut down the server gracefully
m_pState->bStopTickThread = true;
delete m_pState->pTickThread; m_pState->pTickThread = NULL;
delete m_pState;
}
void cServer::ClientDestroying(const cClientHandle * a_Client)
{
m_SocketThreads.StopReading(a_Client);
@@ -123,6 +155,9 @@ void cServer::RemoveClient(const cClientHandle * a_Client)
bool cServer::InitServer(cIniFile & a_SettingsIni)
{
m_Description = a_SettingsIni.GetValue ("Server", "Description", "MCServer! - In C++!").c_str();
m_MaxPlayers = a_SettingsIni.GetValueI("Server", "MaxPlayers", 100);
if (m_bIsConnected)
{
LOGERROR("ERROR: Trying to initialize server while server is already running!");
@@ -201,35 +236,6 @@ bool cServer::InitServer(cIniFile & a_SettingsIni)
cServer::cServer(void)
: m_pState(new sServerState)
, m_ListenThreadIPv4(*this, cSocket::IPv4, "Client")
, m_ListenThreadIPv6(*this, cSocket::IPv6, "Client")
, m_Millisecondsf(0)
, m_Milliseconds(0)
, m_bIsConnected(false)
, m_bRestarting(false)
, m_RCONServer(*this)
{
}
cServer::~cServer()
{
// TODO: Shut down the server gracefully
m_pState->bStopTickThread = true;
delete m_pState->pTickThread; m_pState->pTickThread = NULL;
delete m_pState;
}
void cServer::PrepareKeys(void)
{
// TODO: Save and load key for persistence across sessions