summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/con_tty.c18
-rw-r--r--src/sys/sys_cocoa.m40
-rw-r--r--src/sys/sys_local.h1
-rw-r--r--src/sys/sys_main.c13
-rw-r--r--src/sys/sys_unix.c58
-rw-r--r--src/sys/sys_win32.c19
6 files changed, 128 insertions, 21 deletions
diff --git a/src/sys/con_tty.c b/src/sys/con_tty.c
index cdd686a1..6f3376e1 100644
--- a/src/sys/con_tty.c
+++ b/src/sys/con_tty.c
@@ -41,6 +41,7 @@ called before and after a stdout or stderr output
=============================================================
*/
+static qboolean stdin_active;
// general flag to tell about tty console mode
static qboolean ttycon_on = qfalse;
static int ttycon_hide = 0;
@@ -255,6 +256,7 @@ Initialize the console input (tty mode if possible)
void CON_Init( void )
{
struct termios tc;
+ const char* term = getenv("TERM");
// If the process is backgrounded (running non interactively)
// then SIGTTIN or SIGTOU is emitted, if not caught, turns into a SIGSTP
@@ -264,10 +266,12 @@ void CON_Init( void )
// Make stdin reads non-blocking
fcntl( 0, F_SETFL, fcntl( 0, F_GETFL, 0 ) | O_NONBLOCK );
- if (isatty(STDIN_FILENO)!=1)
+ if (isatty(STDIN_FILENO) != 1
+ || (term && (!strcmp(term, "raw") || !strcmp(term, "dumb"))))
{
- Com_Printf( "stdin is not a tty, tty console mode disabled\n");
+ Com_Printf("tty console mode disabled\n");
ttycon_on = qfalse;
+ stdin_active = qtrue;
return;
}
@@ -409,18 +413,11 @@ char *CON_Input( void )
return NULL;
}
- else
+ else if (stdin_active)
{
int len;
fd_set fdset;
struct timeval timeout;
- static qboolean stdin_active;
-
- if (!com_dedicated || !com_dedicated->value)
- return NULL;
-
- if (!stdin_active)
- return NULL;
FD_ZERO(&fdset);
FD_SET(0, &fdset); // stdin
@@ -444,6 +441,7 @@ char *CON_Input( void )
return text;
}
+ return NULL;
}
/*
diff --git a/src/sys/sys_cocoa.m b/src/sys/sys_cocoa.m
new file mode 100644
index 00000000..cfc754dd
--- /dev/null
+++ b/src/sys/sys_cocoa.m
@@ -0,0 +1,40 @@
+/*
+===========================================================================
+Copyright (C) 1999-2005 Id Software, Inc.
+
+This file is part of Quake III Arena source code.
+
+Quake III Arena source code is free software; you can redistribute it
+and/or modify it under the terms of the GNU General Public License as
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version.
+
+Quake III Arena source code is distributed in the hope that it will be
+useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Quake III Arena source code; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+===========================================================================
+*/
+
+#ifndef MACOS_X
+#error This file is for Mac OS X only. You probably should not compile it.
+#endif
+
+// Please note that this file is just some Mac-specific bits. Most of the
+// Mac OS X code is shared with other Unix platforms in sys_unix.c ...
+
+#import <Cocoa/Cocoa.h>
+
+void Cocoa_MsgBox( const char *text )
+{
+ NSRunInformationalAlertPanel(@"ioquake3",
+ [NSString stringWithUTF8String:text],
+ @"OK", nil, nil);
+}
+
+// end of sys_cocoa.m ...
+
diff --git a/src/sys/sys_local.h b/src/sys/sys_local.h
index 6d001046..4ecc9227 100644
--- a/src/sys/sys_local.h
+++ b/src/sys/sys_local.h
@@ -48,6 +48,7 @@ unsigned int CON_LogRead( char *out, unsigned int outSize );
char *Sys_StripAppBundle( char *pwd );
#endif
+void Sys_GLimpSafeInit( void );
void Sys_GLimpInit( void );
void Sys_PlatformInit( void );
void Sys_SigHandler( int signal );
diff --git a/src/sys/sys_main.c b/src/sys/sys_main.c
index 0d682261..0a4183c7 100644
--- a/src/sys/sys_main.c
+++ b/src/sys/sys_main.c
@@ -517,8 +517,6 @@ int main( int argc, char **argv )
// Run time
const SDL_version *ver = SDL_Linked_Version( );
-#define STRING(s) #s
-#define XSTRING(s) STRING(s)
#define MINSDL_VERSION \
XSTRING(MINSDL_MAJOR) "." \
XSTRING(MINSDL_MINOR) "." \
@@ -534,6 +532,9 @@ int main( int argc, char **argv )
Sys_PlatformInit( );
+ // Set the initial time base
+ Sys_Milliseconds( );
+
Sys_ParseArgs( argc, argv );
Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );
@@ -541,7 +542,15 @@ int main( int argc, char **argv )
// Concatenate the command line for passing to Com_Init
for( i = 1; i < argc; i++ )
{
+ const qboolean containsSpaces = strchr(argv[i], ' ') != NULL;
+ if (containsSpaces)
+ Q_strcat( commandLine, sizeof( commandLine ), "\"" );
+
Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] );
+
+ if (containsSpaces)
+ Q_strcat( commandLine, sizeof( commandLine ), "\"" );
+
Q_strcat( commandLine, sizeof( commandLine ), " " );
}
diff --git a/src/sys/sys_unix.c b/src/sys/sys_unix.c
index b55bbe6d..3360469d 100644
--- a/src/sys/sys_unix.c
+++ b/src/sys/sys_unix.c
@@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <sys/time.h>
#include <pwd.h>
#include <libgen.h>
+#include <fcntl.h>
// Used to determine where to store user-specific files
static char homePath[ MAX_OSPATH ] = { 0 };
@@ -54,11 +55,15 @@ char *Sys_DefaultHomePath(void)
{
Q_strncpyz( homePath, p, sizeof( homePath ) );
#ifdef MACOS_X
- Q_strcat( homePath, sizeof( homePath ), "/Library/Application Support/Tremulous" );
+ Q_strcat( homePath, sizeof( homePath ), "/Library" );
+ mkdir( homePath, 0750 );
+ Q_strcat( homePath, sizeof( homePath ), "/Application Support" );
+ mkdir( homePath, 0750 );
+ Q_strcat( homePath, sizeof( homePath ), "/Tremulous" );
#else
Q_strcat( homePath, sizeof( homePath ), "/.tremulous" );
#endif
- if( mkdir( homePath, 0777 ) )
+ if( mkdir( homePath, 0750 ) )
{
if( errno != EEXIST )
{
@@ -497,23 +502,58 @@ void Sys_ErrorDialog( const char *error )
{
char buffer[ 1024 ];
unsigned int size;
- fileHandle_t f;
+ int f = -1;
+ const char *homepath = Cvar_VariableString( "fs_homepath" );
+ const char *gamedir = Cvar_VariableString( "fs_gamedir" );
const char *fileName = "crashlog.txt";
+ char *ospath = FS_BuildOSPath( homepath, gamedir, fileName );
Sys_Print( va( "%s\n", error ) );
- // Write console log to file
- f = FS_FOpenFileWrite( fileName );
- if( !f )
+#if defined(MACOS_X) && !DEDICATED
+ /* This function has to be in a separate file, compiled as Objective-C. */
+ extern void Cocoa_MsgBox( const char *text );
+ if (!com_dedicated || !com_dedicated->integer)
+ Cocoa_MsgBox(error);
+#endif
+
+ /* make sure the write path for the crashlog exists... */
+ if( FS_CreatePath( ospath ) ) {
+ Com_Printf( "ERROR: couldn't create path '%s' for crash log.\n", ospath );
+ return;
+ }
+
+ /* we might be crashing because we maxed out the Quake MAX_FILE_HANDLES,
+ which will come through here, so we don't want to recurse forever by
+ calling FS_FOpenFileWrite()...use the Unix system APIs instead. */
+ f = open(ospath, O_CREAT | O_TRUNC | O_WRONLY, 0640);
+ if( f == -1 )
{
Com_Printf( "ERROR: couldn't open %s\n", fileName );
return;
}
- while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 )
- FS_Write( buffer, size, f );
+ /* We're crashing, so we don't care much if write() or close() fails. */
+ while( ( size = CON_LogRead( buffer, sizeof( buffer ) ) ) > 0 ) {
+ if (write( f, buffer, size ) != size) {
+ Com_Printf( "ERROR: couldn't fully write to %s\n", fileName );
+ break;
+ }
+ }
- FS_FCloseFile( f );
+ close(f);
+}
+
+/*
+==============
+Sys_GLimpSafeInit
+
+Unix specific "safe" GL implementation initialisation
+==============
+*/
+void Sys_GLimpSafeInit( void )
+{
+ // NOP
}
/*
diff --git a/src/sys/sys_win32.c b/src/sys/sys_win32.c
index aac4384d..18efe406 100644
--- a/src/sys/sys_win32.c
+++ b/src/sys/sys_win32.c
@@ -583,6 +583,25 @@ static qboolean SDL_VIDEODRIVER_externallySet = qfalse;
/*
==============
+Sys_GLimpSafeInit
+
+Windows specific "safe" GL implementation initialisation
+==============
+*/
+void Sys_GLimpSafeInit( void )
+{
+#ifndef DEDICATED
+ if( !SDL_VIDEODRIVER_externallySet )
+ {
+ // Here, we want to let SDL decide what do to unless
+ // explicitly requested otherwise
+ _putenv( "SDL_VIDEODRIVER=" );
+ }
+#endif
+}
+
+/*
+==============
Sys_GLimpInit
Windows specific GL implementation initialisation