From a9031b6bae742b333b1b390192fa590f2ecb07ea Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Mon, 5 Oct 2020 11:27:14 +0100 Subject: Fix cmake not adding Werror on clang, and _lots_ of warnings (#4963) * Fix cmake not adding Werror on clang, and _lots_ of warnings * WIP: Build fixes * Cannot make intermediate blockhandler instance * Tiger's changes * Fix BitIndex check * Handle invalid NextState values in cMultiVersionProtocol Co-authored-by: Tiger Wang --- src/main.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/main.cpp') 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) -- cgit v1.2.3