Add a command line option to start the network console.

This commit is contained in:
hiker
2016-04-22 16:37:17 +10:00
parent d092dcf96c
commit b59194cdf3
3 changed files with 18 additions and 8 deletions

View File

@@ -801,6 +801,9 @@ int handleCmdLine()
if(CommandLine::has("--max-players", &n))
UserConfigParams::m_server_max_players=n;
if(CommandLine::has("--start-console"))
STKHost::m_enable_console = true;
if(CommandLine::has("--login", &s) )
{
login = s.c_str();

View File

@@ -46,19 +46,20 @@
#include <pthread.h>
#include <signal.h>
STKHost *STKHost::m_stk_host = NULL;
STKHost *STKHost::m_stk_host = NULL;
bool STKHost::m_enable_console = true;
void STKHost::create()
{
assert(m_stk_host == NULL);
if(NetworkConfig::get()->isServer())
if (NetworkConfig::get()->isServer())
m_stk_host = new STKHost(NetworkConfig::get()->getServerName());
else
{
Server *server = ServersManager::get()->getJoinedServer();
m_stk_host = new STKHost(server->getServerId(), 0);
}
if(!m_stk_host->m_network)
if (!m_stk_host->m_network)
{
delete m_stk_host;
m_stk_host = NULL;
@@ -294,18 +295,20 @@ void STKHost::init()
// ============================
if (enet_initialize() != 0)
{
Log::error("NetworkConsole", "Could not initialize enet.");
Log::error("STKHost", "Could not initialize enet.");
return;
}
Log::info("NetworkConsole", "Host initialized.");
Log::info("STKHost", "Host initialized.");
Network::openLog(); // Open packet log file
ProtocolManager::getInstance<ProtocolManager>();
// Optional: start the network console
m_network_console = new NetworkConsole();
m_network_console->run();
if(m_enable_console)
{
m_network_console = new NetworkConsole();
m_network_console->run();
}
} // STKHost
// ----------------------------------------------------------------------------

View File

@@ -112,6 +112,10 @@ private:
void handleLANRequests();
public:
/** If a network console should be started. Note that the console can cause
* a crash in release mode on windows (see #1529). */
static bool m_enable_console;
/** Creates the STKHost. It takes all confifguration parameters from
* NetworkConfig. This STKHost can either be a client or a server.