summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2020-10-05 12:27:14 +0200
committerGitHub <noreply@github.com>2020-10-05 12:27:14 +0200
commita9031b6bae742b333b1b390192fa590f2ecb07ea (patch)
treeb2802c81d24d339c201a0747d66ba44e9ea8b1b0 /src/main.cpp
parentFixed current end generator (#4968) (diff)
downloadcuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.gz
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.bz2
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.lz
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.xz
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.tar.zst
cuberite-a9031b6bae742b333b1b390192fa590f2ecb07ea.zip
Diffstat (limited to '')
-rw-r--r--src/main.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/main.cpp b/src/main.cpp
index e0ce68a8c..cb7633df3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,6 +1,7 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+#include "main.h"
#include "BuildInfo.h"
#include "Logger.h"
#include "MemorySettingsRepository.h"
@@ -17,17 +18,12 @@
-/** If set to true, the protocols will log each player's incoming (C->S) communication to a per-connection logfile. */
bool g_ShouldLogCommIn;
-
-/** If set to true, the protocols will log each player's outgoing (S->C) communication to a per-connection logfile. */
bool g_ShouldLogCommOut;
-
-/** If set to true, binary will attempt to run as a service. */
bool g_RunAsService;
/** Global that registers itself as a last chance exception handler to write a minidump on crash. */
-MiniDumpWriter g_MiniDumpWriter;
+static MiniDumpWriter g_MiniDumpWriter;
@@ -90,7 +86,7 @@ static void NonCtrlHandler(int a_Signal)
case SIGTERM:
{
// Server is shutting down, wait for it...
- cRoot::Stop();
+ cRoot::Get()->Stop();
return;
}
#ifdef SIGPIPE
@@ -115,7 +111,7 @@ static void NonCtrlHandler(int a_Signal)
// Handle CTRL events in windows, including console window close
static BOOL CtrlHandler(DWORD fdwCtrlType)
{
- cRoot::Stop();
+ cRoot::Get()->Stop();
LOGD("Terminate event raised from the Windows CtrlHandler");
// Delay as much as possible to try to get the server to shut down cleanly - 10 seconds given by Windows
@@ -134,7 +130,7 @@ static BOOL CtrlHandler(DWORD fdwCtrlType)
////////////////////////////////////////////////////////////////////////////////
// ParseArguments - Read the startup arguments and store into a settings object
-static cMemorySettingsRepository ParseArguments(int argc, char ** argv)
+static void ParseArguments(int argc, char ** argv, cMemorySettingsRepository & repo)
{
// Parse the comand line args:
TCLAP::CmdLine cmd("Cuberite");
@@ -152,7 +148,6 @@ static cMemorySettingsRepository ParseArguments(int argc, char ** argv)
cmd.parse(argc, argv);
// Copy the parsed args' values into a settings repository:
- cMemorySettingsRepository repo;
if (confArg.isSet())
{
AString conf_file = confArg.getValue();
@@ -204,8 +199,6 @@ static cMemorySettingsRepository ParseArguments(int argc, char ** argv)
{
g_MiniDumpWriter.AddDumpFlags(MiniDumpFlags::WithFullMemory);
}
-
- return repo;
}
@@ -238,7 +231,8 @@ static int UniversalMain(int argc, char * argv[], bool RunningAsService)
try
{
// Make sure g_RunAsService is set correctly before checking it's value
- auto Settings = ParseArguments(argc, argv);
+ cMemorySettingsRepository Settings;
+ ParseArguments(argc, argv, Settings);
// Attempt to run as a service
if (!RunningAsService && g_RunAsService)