iw4x-client/src/Components/Modules/Singleton.cpp
Edo 44098c51cd
[General]: Remove unnecessary global header (#600)
* [General]: Remove unnecessary global header

* [ServerList]: Fix comp
2022-11-26 17:38:34 +00:00

35 lines
860 B
C++

#include <STDInclude.hpp>
#include <version.hpp>
namespace Components
{
bool Singleton::FirstInstance = true;
bool Singleton::IsFirstInstance()
{
return FirstInstance;
}
Singleton::Singleton()
{
if (Flags::HasFlag("version"))
{
printf("%s", "IW4x " VERSION " (built " __DATE__ " " __TIME__ ")\n");
printf("%d\n", REVISION);
ExitProcess(0);
}
Console::FreeNativeConsole();
if (Loader::IsPerformingUnitTests() || Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) return;
FirstInstance = (CreateMutexA(nullptr, FALSE, "iw4x_mutex") && GetLastError() != ERROR_ALREADY_EXISTS);
if (!FirstInstance && !ConnectProtocol::Used() && MessageBoxA(nullptr, "Do you want to start another instance?\nNot all features will be available!", "Game already running", MB_ICONEXCLAMATION | MB_YESNO) == IDNO)
{
ExitProcess(0);
}
}
}