launcher: don't grab/release mutex if multirun is enabled

This commit is contained in:
tyabus 2023-03-13 17:47:44 +06:00
parent 88418ebb4d
commit 46fc2b7090

View File

@ -104,6 +104,7 @@ static IEngineAPI *g_pEngineAPI;
static IHammer *g_pHammer;
bool g_bTextMode = false;
bool g_MultiRun = false;
static char g_szBasedir[MAX_PATH];
static char g_szGamedir[MAX_PATH];
@ -922,6 +923,9 @@ char g_lockFilename[MAX_PATH];
#endif
bool GrabSourceMutex()
{
if( g_MultiRun )
return true;
#ifdef WIN32
if ( IsPC() )
{
@ -1016,6 +1020,9 @@ bool GrabSourceMutex()
void ReleaseSourceMutex()
{
if( g_MultiRun )
return;
#ifdef WIN32
if ( IsPC() && g_hMutex )
{
@ -1280,7 +1287,7 @@ DLL_EXPORT int LauncherMain( int argc, char **argv )
// Allow the user to explicitly say they want to be able to run multiple instances of the source mutex.
// Useful for side-by-side comparisons of different renderers.
bool multiRun = CommandLine()->CheckParm( "-multirun" ) != NULL;
g_MultiRun = CommandLine()->CheckParm( "-multirun" ) != NULL;
#if defined( _X360 )
bool bSpewDllInfo = CommandLine()->CheckParm( "-dllinfo" );
@ -1430,12 +1437,12 @@ DLL_EXPORT int LauncherMain( int argc, char **argv )
}
else
{
if (!multiRun) {
if (!g_MultiRun) {
::MessageBox(NULL, "Only one instance of the game can be running at one time.", "Source - Warning", MB_ICONINFORMATION | MB_OK);
}
}
if (!multiRun) {
if (!g_MultiRun) {
return retval;
}
}
@ -1443,7 +1450,7 @@ DLL_EXPORT int LauncherMain( int argc, char **argv )
#elif defined( POSIX )
else
{
if ( !GrabSourceMutex() && !multiRun )
if ( !GrabSourceMutex() && !g_MultiRun )
{
::MessageBox(NULL, "Only one instance of the game can be running at one time.", "Source - Warning", 0 );
return -1;