Warnings improvements
* Turn off global-constructors warning. These are needed to implement cRoot signal handler functionality
* Add Clang flags based on version lookup instead of a compile test. The CMake config process is single threaded and slow enough already
* Reduced GetStackValue verbosity
+ Clarify EnchantmentLevel, StayCount, AlwaysTicked, ViewDistance signedness
+ Give SettingsRepositoryInterface a move constructor to simplify main.cpp code
- Remove do {} while (false) construction in redstone handler
This commit is contained in:
31
src/Root.cpp
31
src/Root.cpp
@@ -2,6 +2,7 @@
|
||||
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||
|
||||
#include "Root.h"
|
||||
#include "main.h"
|
||||
|
||||
// STD lib hreaders:
|
||||
#include <iostream>
|
||||
@@ -49,8 +50,18 @@
|
||||
|
||||
|
||||
|
||||
extern bool g_RunAsService;
|
||||
cRoot * cRoot::s_Root = nullptr;
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wglobal-constructors"
|
||||
#endif
|
||||
|
||||
decltype(cRoot::s_Root) cRoot::s_Root;
|
||||
decltype(cRoot::s_NextState) cRoot::s_NextState;
|
||||
decltype(cRoot::s_StopEvent) cRoot::s_StopEvent;
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -196,7 +207,7 @@ bool cRoot::Run(cSettingsRepositoryInterface & a_OverridesRepo)
|
||||
m_StartTime = std::chrono::steady_clock::now();
|
||||
|
||||
HandleInput();
|
||||
m_StopEvent.Wait();
|
||||
s_StopEvent.Wait();
|
||||
|
||||
// Stop the server:
|
||||
m_WebAdmin->Stop();
|
||||
@@ -235,7 +246,7 @@ bool cRoot::Run(cSettingsRepositoryInterface & a_OverridesRepo)
|
||||
LOG("Shutdown successful!");
|
||||
LOG("--- Stopped Log ---");
|
||||
|
||||
return m_NextState == NextState::Restart;
|
||||
return s_NextState == NextState::Restart;
|
||||
}
|
||||
|
||||
|
||||
@@ -959,7 +970,7 @@ void cRoot::HandleInput()
|
||||
cLogCommandOutputCallback Output;
|
||||
AString Command;
|
||||
|
||||
while (m_NextState == NextState::Run)
|
||||
while (s_NextState == NextState::Run)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
timeval Timeout{ 0, 0 };
|
||||
@@ -982,7 +993,7 @@ void cRoot::HandleInput()
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_NextState != NextState::Run)
|
||||
if (s_NextState != NextState::Run)
|
||||
{
|
||||
// Already shutting down, can't execute commands
|
||||
break;
|
||||
@@ -1003,7 +1014,7 @@ void cRoot::HandleInput()
|
||||
void cRoot::TransitionNextState(NextState a_NextState)
|
||||
{
|
||||
{
|
||||
auto Current = m_NextState.load();
|
||||
auto Current = s_NextState.load();
|
||||
do
|
||||
{
|
||||
// Stopping is final, so stops override restarts:
|
||||
@@ -1012,15 +1023,15 @@ void cRoot::TransitionNextState(NextState a_NextState)
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (!m_NextState.compare_exchange_strong(Current, a_NextState));
|
||||
while (!s_NextState.compare_exchange_strong(Current, a_NextState));
|
||||
}
|
||||
|
||||
if (m_NextState == NextState::Run)
|
||||
if (s_NextState == NextState::Run)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_StopEvent.Set();
|
||||
s_StopEvent.Set();
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
|
||||
Reference in New Issue
Block a user