2016-07-22 06:12:11 -04:00
# include "STDInclude.hpp"
namespace Components
{
bool Singleton : : FirstInstance = true ;
bool Singleton : : IsFirstInstance ( )
{
return Singleton : : FirstInstance ;
}
Singleton : : Singleton ( )
{
if ( Flags : : HasFlag ( " version " ) )
{
2016-08-30 17:55:11 -04:00
printf ( " IW4x " VERSION " (built " __DATE__ " " __TIME__ " ) \n " ) ;
2016-07-22 06:12:11 -04:00
ExitProcess ( 0 ) ;
}
2016-09-08 15:46:12 -04:00
Console : : FreeNativeConsole ( ) ;
2016-09-13 17:52:15 -04:00
if ( Loader : : PerformingUnitTests ( ) | | Dedicated : : IsEnabled ( ) | | ZoneBuilder : : IsEnabled ( ) ) return ;
2016-07-22 06:12:11 -04: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 )
{
ExitProcess ( 0 ) ;
}
}
}