mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Core: allow launching dedicated server without terminal window
The terminal window isn't always necessary, especially on Linux systems. In fact, it causes issues on some Wine environments. Allow user to disable it with -noconsole. This option only exists on the dedicated server. The client builds have the console disabled by default, and can enable them with -wconsole.
This commit is contained in:
parent
5d38b3762b
commit
cb72778a25
@ -30,7 +30,9 @@ bool g_bSdkInitCallInitiated = false;
|
|||||||
bool g_bSdkShutdownCallInitiated = false;
|
bool g_bSdkShutdownCallInitiated = false;
|
||||||
|
|
||||||
bool g_bSdkShutdownInitiatedFromConsoleHandler = false;
|
bool g_bSdkShutdownInitiatedFromConsoleHandler = false;
|
||||||
HMODULE s_hModuleHandle = NULL;
|
|
||||||
|
static bool s_bConsoleInitialized = false;
|
||||||
|
static HMODULE s_hModuleHandle = NULL;
|
||||||
|
|
||||||
//#############################################################################
|
//#############################################################################
|
||||||
// UTILITY
|
// UTILITY
|
||||||
@ -116,9 +118,11 @@ void SDK_Init()
|
|||||||
|
|
||||||
#ifndef DEDICATED
|
#ifndef DEDICATED
|
||||||
if (CommandLine()->CheckParm("-wconsole"))
|
if (CommandLine()->CheckParm("-wconsole"))
|
||||||
#endif // !DEDICATED
|
#else
|
||||||
|
if (!CommandLine()->CheckParm("-noconsole"))
|
||||||
|
#endif // !DEDICATED
|
||||||
{
|
{
|
||||||
Console_Init(bAnsiColor);
|
s_bConsoleInitialized = Console_Init(bAnsiColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpdLog_Init(bAnsiColor);
|
SpdLog_Init(bAnsiColor);
|
||||||
@ -186,7 +190,7 @@ void SDK_Shutdown()
|
|||||||
|
|
||||||
// If the shutdown was initiated from the console window itself, don't
|
// If the shutdown was initiated from the console window itself, don't
|
||||||
// shutdown the console as it would otherwise deadlock in FreeConsole!
|
// shutdown the console as it would otherwise deadlock in FreeConsole!
|
||||||
if (!g_bSdkShutdownInitiatedFromConsoleHandler)
|
if (s_bConsoleInitialized && !g_bSdkShutdownInitiatedFromConsoleHandler)
|
||||||
Console_Shutdown();
|
Console_Shutdown();
|
||||||
|
|
||||||
g_bSdkInitialized = false;
|
g_bSdkInitialized = false;
|
||||||
|
@ -109,6 +109,11 @@ void CSurface::Init()
|
|||||||
this->m_ConsoleToggle->SetSize({ 110, 18 });
|
this->m_ConsoleToggle->SetSize({ 110, 18 });
|
||||||
this->m_ConsoleToggle->SetLocation({ 290, 7 });
|
this->m_ConsoleToggle->SetLocation({ 290, 7 });
|
||||||
this->m_ConsoleToggle->SetTabIndex(0);
|
this->m_ConsoleToggle->SetTabIndex(0);
|
||||||
|
#ifdef DEDI_LAUNCHER
|
||||||
|
this->m_ConsoleToggle->SetChecked(true);
|
||||||
|
#else // For client builds, don't show the console by default
|
||||||
|
this->m_ConsoleToggle->SetChecked(false);
|
||||||
|
#endif // DEDI_LAUNCHER
|
||||||
this->m_ConsoleToggle->SetText("Show console");
|
this->m_ConsoleToggle->SetText("Show console");
|
||||||
this->m_ConsoleToggle->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left);
|
this->m_ConsoleToggle->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left);
|
||||||
this->m_GameGroupExt->AddControl(this->m_ConsoleToggle);
|
this->m_GameGroupExt->AddControl(this->m_ConsoleToggle);
|
||||||
@ -968,6 +973,8 @@ void CSurface::AppendConsoleParameters(string& svParameters)
|
|||||||
{
|
{
|
||||||
if (this->m_ConsoleToggle->Checked())
|
if (this->m_ConsoleToggle->Checked())
|
||||||
AppendParameterInternal(svParameters, "-wconsole");
|
AppendParameterInternal(svParameters, "-wconsole");
|
||||||
|
else
|
||||||
|
AppendParameterInternal(svParameters, "-noconsole");
|
||||||
|
|
||||||
if (this->m_ColorConsoleToggle->Checked())
|
if (this->m_ColorConsoleToggle->Checked())
|
||||||
AppendParameterInternal(svParameters, "-ansicolor");
|
AppendParameterInternal(svParameters, "-ansicolor");
|
||||||
|
@ -77,8 +77,9 @@ void FlashConsoleBackground(int nFlashCount, int nFlashInterval, COLORREF color)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: terminal window setup
|
// Purpose: terminal window setup
|
||||||
// Input : bAnsiColor -
|
// Input : bAnsiColor -
|
||||||
|
// Output : true on success, false otherwise
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Console_Init(const bool bAnsiColor)
|
bool Console_Init(const bool bAnsiColor)
|
||||||
{
|
{
|
||||||
#ifndef _TOOLS
|
#ifndef _TOOLS
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
@ -89,7 +90,7 @@ void Console_Init(const bool bAnsiColor)
|
|||||||
snprintf(szBuf, sizeof(szBuf), "Failed to create console window! [%s]\n", std::system_category().message(static_cast<int>(::GetLastError())).c_str());
|
snprintf(szBuf, sizeof(szBuf), "Failed to create console window! [%s]\n", std::system_category().message(static_cast<int>(::GetLastError())).c_str());
|
||||||
|
|
||||||
OutputDebugStringA(szBuf);
|
OutputDebugStringA(szBuf);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-- Set the window title
|
//-- Set the window title
|
||||||
@ -133,12 +134,15 @@ void Console_Init(const bool bAnsiColor)
|
|||||||
#ifndef _TOOLS
|
#ifndef _TOOLS
|
||||||
SetConsoleCtrlHandler(ConsoleHandlerRoutine, true);
|
SetConsoleCtrlHandler(ConsoleHandlerRoutine, true);
|
||||||
#endif // !_TOOLS
|
#endif // !_TOOLS
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: terminal window shutdown
|
// Purpose: terminal window shutdown
|
||||||
|
// Output : true on success, false otherwise
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Console_Shutdown()
|
bool Console_Shutdown()
|
||||||
{
|
{
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Destroy the console window
|
// Destroy the console window
|
||||||
@ -148,8 +152,10 @@ void Console_Shutdown()
|
|||||||
snprintf(szBuf, sizeof(szBuf), "Failed to destroy console window! [%s]\n", std::system_category().message(static_cast<int>(::GetLastError())).c_str());
|
snprintf(szBuf, sizeof(szBuf), "Failed to destroy console window! [%s]\n", std::system_category().message(static_cast<int>(::GetLastError())).c_str());
|
||||||
|
|
||||||
OutputDebugStringA(szBuf);
|
OutputDebugStringA(szBuf);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _TOOLS
|
#ifndef _TOOLS
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
void SetConsoleBackgroundColor(COLORREF color);
|
void SetConsoleBackgroundColor(COLORREF color);
|
||||||
void FlashConsoleBackground(int nFlashCount, int nFlashInterval, COLORREF color);
|
void FlashConsoleBackground(int nFlashCount, int nFlashInterval, COLORREF color);
|
||||||
|
|
||||||
void Console_Init(const bool bAnsiColor);
|
bool Console_Init(const bool bAnsiColor);
|
||||||
void Console_Shutdown();
|
bool Console_Shutdown();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user