Fix macOS client/server failing to start from terminal
The macOS client and server were completely unusable when run from a terminal. They blocked forever in `[NSApp run];` which was called by Sys_InitProtocolHandler(). `applicationDidFinishLaunching` was never called to exit the NSApp run loop. Use SDL's SDL_DROPFILE event to receive URLs to handle on macOS instead. This also handles URLs while the game is running (connect to new server) instead of nothing happening when clicking a link while the game is running.
This commit is contained in:
1 parent
8b6333fbd3
commit
e452b7ac04
4 files changed
+29
-64
No files matched your search
+3
-20
@@ -643,20 +643,6 @@ void Sys_ParseArgs( int argc, char **argv )
|
||||
}
|
||||
|
||||
#ifdef PROTOCOL_HANDLER
|
||||
/*
|
||||
=================
|
||||
Sys_InitProtocolHandler
|
||||
|
||||
See sys_osx.m for macOS implementation.
|
||||
=================
|
||||
*/
|
||||
#ifndef __APPLE__
|
||||
char *Sys_InitProtocolHandler( void )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
=================
|
||||
Sys_ParseProtocolUri
|
||||
@@ -716,9 +702,9 @@ char *Sys_ParseProtocolUri( const char *uri )
|
||||
}
|
||||
}
|
||||
|
||||
bufsize = strlen( "+connect " ) + i + 1;
|
||||
bufsize = strlen( "connect " ) + i + 1;
|
||||
out = malloc( bufsize );
|
||||
strcpy( out, "+connect " );
|
||||
strcpy( out, "connect " );
|
||||
strncat( out, uri, i );
|
||||
return out;
|
||||
}
|
||||
@@ -815,10 +801,6 @@ int main( int argc, char **argv )
|
||||
|
||||
Sys_PlatformInit( );
|
||||
|
||||
#ifdef PROTOCOL_HANDLER
|
||||
protocolCommand = Sys_InitProtocolHandler( );
|
||||
#endif
|
||||
|
||||
// Set the initial time base
|
||||
Sys_Milliseconds( );
|
||||
|
||||
@@ -865,6 +847,7 @@ int main( int argc, char **argv )
|
||||
#ifdef PROTOCOL_HANDLER
|
||||
if ( protocolCommand != NULL )
|
||||
{
|
||||
Q_strcat( commandLine, sizeof( commandLine ), "+" );
|
||||
Q_strcat( commandLine, sizeof( commandLine ), protocolCommand );
|
||||
free( protocolCommand );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user