Don't start a STKHost if neither client nor server is requested.

This commit is contained in:
hiker 2015-11-01 19:45:28 +11:00
parent 4aea491ed0
commit 1334a467e3
3 changed files with 10 additions and 3 deletions

View File

@ -779,7 +779,7 @@ int handleCmdLine()
STKHost::create(/*is_Server*/true);
Log::info("main", "Creating a server.");
}
else
else if(CommandLine::has("--client"))
{
STKHost::create(/*is_server*/false);
Log::info("main", "Creating a client.");

View File

@ -32,6 +32,7 @@
#include "modes/world.hpp"
#include "network/protocol_manager.hpp"
#include "network/network_world.hpp"
#include "network/stk_host.hpp"
#include "online/request_manager.hpp"
#include "race/race_manager.hpp"
#include "states_screens/state_manager.hpp"
@ -176,7 +177,8 @@ void MainLoop::run()
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("Protocol manager update", 0x7F, 0x00, 0x7F);
ProtocolManager::getInstance()->update();
if (STKHost::isNetworking())
ProtocolManager::getInstance()->update();
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("Database polling update", 0x00, 0x7F, 0x7F);
@ -186,7 +188,8 @@ void MainLoop::run()
else if (!m_abort && ProfileWorld::isNoGraphics())
{
PROFILER_PUSH_CPU_MARKER("Protocol manager update", 0x7F, 0x00, 0x7F);
ProtocolManager::getInstance()->update();
if(STKHost::isNetworking())
ProtocolManager::getInstance()->update();
PROFILER_POP_CPU_MARKER();
PROFILER_PUSH_CPU_MARKER("Database polling update", 0x00, 0x7F, 0x7F);

View File

@ -124,6 +124,10 @@ public:
m_stk_host = NULL;
}
// ------------------------------------------------------------------------
/** Return if a network setting is happening. A network setting is active
* if a host (server or client) exists. */
static bool isNetworking() { return m_stk_host!=NULL; }
// ------------------------------------------------------------------------
static void* mainLoop(void* self);