r1434 - in trunk/code: qcommon sys

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Aug 3 15:42:53 EDT 2008


Author: tma
Date: 2008-08-03 15:42:53 -0400 (Sun, 03 Aug 2008)
New Revision: 1434

Modified:
   trunk/code/qcommon/common.c
   trunk/code/sys/sys_local.h
   trunk/code/sys/sys_main.c
   trunk/code/sys/sys_unix.c
   trunk/code/sys/sys_win32.c
Log:
* Change win32 client Sys_Sleep so it ONLY sleeps since before it was waking on 
  more or less any input event; fine for the server, not so much use for the
  client
* In the main loop, don't bother sleeping if it's going to be less than 10ms as
  the methods we're using to sleep at the moment aren't very precise
* Add Sys_PlatformInit for platform specific initialisation
* In win32 Sys_PlatformInit force selection of the DirectX SDL backend in order
  to get better fullscreen mouse input (in conjunction with a patched SDL DLL
  http://bugzilla.libsdl.org/show_bug.cgi?id=265)


Modified: trunk/code/qcommon/common.c
===================================================================
--- trunk/code/qcommon/common.c	2008-08-03 19:31:42 UTC (rev 1433)
+++ trunk/code/qcommon/common.c	2008-08-03 19:42:53 UTC (rev 1434)
@@ -2864,7 +2864,14 @@
 
 	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

Modified: trunk/code/sys/sys_local.h
===================================================================
--- trunk/code/sys/sys_local.h	2008-08-03 19:31:42 UTC (rev 1433)
+++ trunk/code/sys/sys_local.h	2008-08-03 19:42:53 UTC (rev 1434)
@@ -47,6 +47,7 @@
 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 );

Modified: trunk/code/sys/sys_main.c
===================================================================
--- trunk/code/sys/sys_main.c	2008-08-03 19:31:42 UTC (rev 1433)
+++ trunk/code/sys/sys_main.c	2008-08-03 19:42:53 UTC (rev 1434)
@@ -533,6 +533,8 @@
 	}
 #endif
 
+	Sys_PlatformInit( );
+
 	Sys_ParseArgs( argc, argv );
 	Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
 	Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );

Modified: trunk/code/sys/sys_unix.c
===================================================================
--- trunk/code/sys/sys_unix.c	2008-08-03 19:31:42 UTC (rev 1433)
+++ trunk/code/sys/sys_unix.c	2008-08-03 19:42:53 UTC (rev 1434)
@@ -511,3 +511,15 @@
 
 	FS_FCloseFile( f );
 }
+
+/*
+==============
+Sys_PlatformInit
+
+Unix specific initialisation
+==============
+*/
+void Sys_PlatformInit( void )
+{
+	// NOP
+}

Modified: trunk/code/sys/sys_win32.c
===================================================================
--- trunk/code/sys/sys_win32.c	2008-08-03 19:31:42 UTC (rev 1433)
+++ trunk/code/sys/sys_win32.c	2008-08-03 19:42:53 UTC (rev 1434)
@@ -514,7 +514,7 @@
 ==============
 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 @@
 	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 @@
 		}
 	}
 }
+
+/*
+==============
+Sys_PlatformInit
+
+Windows specific initialisation
+==============
+*/
+void Sys_PlatformInit( void )
+{
+#ifndef DEDICATED
+	// Force the DirectX SDL backend to be used
+	_putenv( "SDL_VIDEODRIVER=directx" );
+#endif
+}




More information about the quake3-commits mailing list