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

24 lines
565 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()
{
if (Dedicated::IsDedicated()) return;
2015-12-27 14:16:01 -05:00
Singleton::FirstInstance = (CreateMutex(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
}
}
}