2022-02-27 07:53:44 -05:00
# include <STDInclude.hpp>
2022-12-26 07:07:24 -05:00
# include "ConnectProtocol.hpp"
# include "Console.hpp"
2017-01-19 16:23:59 -05:00
2022-11-26 12:38:34 -05:00
# include <version.hpp>
2017-01-19 16:23:59 -05:00
namespace Components
{
bool Singleton : : FirstInstance = true ;
bool Singleton : : IsFirstInstance ( )
{
2022-11-26 12:38:34 -05:00
return FirstInstance ;
2017-01-19 16:23:59 -05:00
}
Singleton : : Singleton ( )
{
if ( Flags : : HasFlag ( " version " ) )
{
2022-11-26 12:38:34 -05:00
printf ( " %s " , " IW4x " VERSION " (built " __DATE__ " " __TIME__ " ) \n " ) ;
2017-01-19 16:23:59 -05:00
printf ( " %d \n " , REVISION ) ;
2023-01-06 17:06:10 -05:00
ExitProcess ( EXIT_SUCCESS ) ;
2017-01-19 16:23:59 -05:00
}
Console : : FreeNativeConsole ( ) ;
2022-10-15 16:31:16 -04:00
if ( Loader : : IsPerformingUnitTests ( ) | | Dedicated : : IsEnabled ( ) | | ZoneBuilder : : IsEnabled ( ) ) return ;
2017-01-19 16:23:59 -05:00
2022-11-26 12:38:34 -05:00
FirstInstance = ( CreateMutexA ( nullptr , FALSE , " iw4x_mutex " ) & & GetLastError ( ) ! = ERROR_ALREADY_EXISTS ) ;
2017-01-19 16:23:59 -05:00
2022-11-26 12:38:34 -05:00
if ( ! FirstInstance & & ! ConnectProtocol : : Used ( ) & & MessageBoxA ( nullptr , " Do you want to start another instance? \n Not all features will be available! " , " Game already running " , MB_ICONEXCLAMATION | MB_YESNO ) = = IDNO )
2017-01-19 16:23:59 -05:00
{
2023-01-06 17:06:10 -05:00
ExitProcess ( EXIT_SUCCESS ) ;
2017-01-19 16:23:59 -05:00
}
}
}