From 1334a467e36cd9ba9b039714b0fb9c8519b548fb Mon Sep 17 00:00:00 2001 From: hiker Date: Sun, 1 Nov 2015 19:45:28 +1100 Subject: [PATCH] Don't start a STKHost if neither client nor server is requested. --- src/main.cpp | 2 +- src/main_loop.cpp | 7 +++++-- src/network/stk_host.hpp | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e08f63f54..20b98d815 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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."); diff --git a/src/main_loop.cpp b/src/main_loop.cpp index eff144c97..e97a1ea47 100644 --- a/src/main_loop.cpp +++ b/src/main_loop.cpp @@ -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); diff --git a/src/network/stk_host.hpp b/src/network/stk_host.hpp index c1d3e92f5..3c1a7243c 100644 --- a/src/network/stk_host.hpp +++ b/src/network/stk_host.hpp @@ -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);