aboutsummaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
Diffstat (limited to 'code')
-rw-r--r--code/qcommon/common.c9
-rw-r--r--code/sys/sys_local.h1
-rw-r--r--code/sys/sys_main.c2
-rw-r--r--code/sys/sys_unix.c12
-rw-r--r--code/sys/sys_win32.c25
5 files changed, 47 insertions, 2 deletions
diff --git a/code/qcommon/common.c b/code/qcommon/common.c
index 475d045..b35d848 100644
--- a/code/qcommon/common.c
+++ b/code/qcommon/common.c
@@ -2864,7 +2864,14 @@ void Com_Frame( void ) {
msec = minMsec;
do {
- Sys_Sleep( minMsec - msec );
+ int timeRemaining = minMsec - msec;
+
+ // The existing Sys_Sleep implementations aren't really
+ // precise enough to be of use beyond 100fps
+ // FIXME: implement a more precise sleep (RDTSC or something)
+ if( timeRemaining >= 10 )
+ Sys_Sleep( timeRemaining );
+
com_frameTime = Com_EventLoop();
if ( lastTime > com_frameTime ) {
lastTime = com_frameTime; // possible on first frame
diff --git a/code/sys/sys_local.h b/code/sys/sys_local.h
index e837b8b..97a9ad6 100644
--- a/code/sys/sys_local.h
+++ b/code/sys/sys_local.h
@@ -47,6 +47,7 @@ unsigned int CON_LogRead( char *out, unsigned int outSize );
char *Sys_StripAppBundle( char *pwd );
#endif
+void Sys_PlatformInit( void );
void Sys_SigHandler( int signal );
void Sys_ErrorDialog( const char *error );
void Sys_AnsiColorPrint( const char *msg );
diff --git a/code/sys/sys_main.c b/code/sys/sys_main.c
index dc846dd..bad8772 100644
--- a/code/sys/sys_main.c
+++ b/code/sys/sys_main.c
@@ -533,6 +533,8 @@ int main( int argc, char **argv )
}
#endif
+ Sys_PlatformInit( );
+
Sys_ParseArgs( argc, argv );
Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );
diff --git a/code/sys/sys_unix.c b/code/sys/sys_unix.c
index 40479b9..13ded33 100644
--- a/code/sys/sys_unix.c
+++ b/code/sys/sys_unix.c
@@ -511,3 +511,15 @@ void Sys_ErrorDialog( const char *error )
FS_FCloseFile( f );
}
+
+/*
+==============
+Sys_PlatformInit
+
+Unix specific initialisation
+==============
+*/
+void Sys_PlatformInit( void )
+{
+ // NOP
+}
diff --git a/code/sys/sys_win32.c b/code/sys/sys_win32.c
index fb924e6..79998dc 100644
--- a/code/sys/sys_win32.c
+++ b/code/sys/sys_win32.c
@@ -514,7 +514,7 @@ void Sys_FreeFileList( char **list )
==============
Sys_Sleep
-Block execution for msec or until input is recieved.
+Block execution for msec or until input is received.
==============
*/
void Sys_Sleep( int msec )
@@ -522,10 +522,18 @@ void Sys_Sleep( int msec )
if( msec == 0 )
return;
+#ifdef DEDICATED
if( msec < 0 )
WaitForSingleObject( GetStdHandle( STD_INPUT_HANDLE ), INFINITE );
else
WaitForSingleObject( GetStdHandle( STD_INPUT_HANDLE ), msec );
+#else
+ // Client Sys_Sleep doesn't support waiting on stdin
+ if( msec < 0 )
+ return;
+
+ Sleep( msec );
+#endif
}
/*
@@ -568,3 +576,18 @@ void Sys_ErrorDialog( const char *error )
}
}
}
+
+/*
+==============
+Sys_PlatformInit
+
+Windows specific initialisation
+==============
+*/
+void Sys_PlatformInit( void )
+{
+#ifndef DEDICATED
+ // Force the DirectX SDL backend to be used
+ _putenv( "SDL_VIDEODRIVER=directx" );
+#endif
+}