iw4x-client/src/Components/Modules/Singleton.cpp

30 lines
742 B
C++
Raw Normal View History

#include "STDInclude.hpp"
2015-12-27 14:05:43 -05:00
namespace Components
{
bool Singleton::FirstInstance = true;
bool Singleton::IsFirstInstance()
{
return Singleton::FirstInstance;
}
Singleton::Singleton()
{
2016-01-26 19:48:37 -05:00
if (Flags::HasFlag("version"))
{
2016-02-23 09:52:31 -05:00
printf("IW4x r" REVISION_STR "-" MILESTONE " (built " __DATE__ " " __TIME__ ")\n");
2016-01-26 19:48:37 -05:00
ExitProcess(0);
}
2016-01-04 18:49:34 -05:00
if (Dedicated::IsDedicated() || ZoneBuilder::IsEnabled()) return;
2015-12-27 14:05:43 -05:00
2016-03-09 19:52:40 -05:00
Singleton::FirstInstance = (CreateMutexA(NULL, FALSE, "iw4x_mutex") && GetLastError() != ERROR_ALREADY_EXISTS);
if (!Singleton::FirstInstance && !ConnectProtocol::Used() && MessageBoxA(0, "Do you want to start another instance?", "Game already running", MB_ICONEXCLAMATION | MB_YESNO) == IDNO)
2015-12-27 14:05:43 -05:00
{
ExitProcess(0);
2015-12-27 14:05:43 -05:00
}
}
}