2016-01-04 14:58:00 -05:00
# 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 " ) )
{
printf ( " iw4x IW4x r " REVISION_STR " - " MILESTONE " (built " __DATE__ " " __TIME__ " ) \n " ) ;
ExitProcess ( 0 ) ;
}
2016-01-04 18:49:34 -05:00
if ( Dedicated : : IsDedicated ( ) | | ZoneBuilder : : IsEnabled ( ) ) return ;
2015-12-27 14:05:43 -05:00
2015-12-27 14:16:01 -05:00
Singleton : : FirstInstance = ( CreateMutex ( NULL , FALSE , " iw4x_mutex " ) & & GetLastError ( ) ! = ERROR_ALREADY_EXISTS ) ;
2016-01-04 07:05:42 -05:00
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
{
2016-01-04 07:05:42 -05:00
ExitProcess ( 0 ) ;
2015-12-27 14:05:43 -05:00
}
}
}