From 88418ebb4dd9e7dd10eb64149b253e72a08babd4 Mon Sep 17 00:00:00 2001 From: tyabus Date: Sat, 4 Mar 2023 12:59:02 +0600 Subject: [PATCH 1/2] launcher: multirun should work on POSIX now --- launcher/launcher.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/launcher/launcher.cpp b/launcher/launcher.cpp index b5f4f882..ebb3d128 100644 --- a/launcher/launcher.cpp +++ b/launcher/launcher.cpp @@ -1278,6 +1278,10 @@ DLL_EXPORT int LauncherMain( int argc, char **argv ) // Figure out the directory the executable is running from UTIL_ComputeBaseDir(); + // 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; + #if defined( _X360 ) bool bSpewDllInfo = CommandLine()->CheckParm( "-dllinfo" ); bool bWaitForConsole = CommandLine()->CheckParm( "-vxconsole" ); @@ -1389,10 +1393,6 @@ DLL_EXPORT int LauncherMain( int argc, char **argv ) // Can only run one windowed source app at a time if ( !GrabSourceMutex() ) { - // 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; - // We're going to hijack the existing session and load a new savegame into it. This will mainly occur when users click on links in Bugzilla that will automatically copy saves and load them // directly from the web browser. The -hijack command prevents the launcher from objecting that there is already an instance of the game. if (CommandLine()->CheckParm( "-hijack" )) @@ -1443,7 +1443,7 @@ DLL_EXPORT int LauncherMain( int argc, char **argv ) #elif defined( POSIX ) else { - if ( !GrabSourceMutex() ) + if ( !GrabSourceMutex() && !multiRun ) { ::MessageBox(NULL, "Only one instance of the game can be running at one time.", "Source - Warning", 0 ); return -1; From 46fc2b7090b061a2586e9d51f93974eb90975f78 Mon Sep 17 00:00:00 2001 From: tyabus Date: Mon, 13 Mar 2023 17:47:44 +0600 Subject: [PATCH 2/2] launcher: don't grab/release mutex if multirun is enabled --- launcher/launcher.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/launcher/launcher.cpp b/launcher/launcher.cpp index ebb3d128..0b27da73 100644 --- a/launcher/launcher.cpp +++ b/launcher/launcher.cpp @@ -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;