Example #1
0
void PortableFrame(void){

	//GL_State( glState.glStateBits);

	qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );

	//TODO
	//qglBindTexture (GL_TEXTURE_2D, glState.currenttextures[glState.currenttmu]);

	pumpEvents();
	IN_Frame( );
	Com_Frame( );

	if (!thread_has_run)
	{
		pthread_create (&thread1, NULL,  launchSSetup, NULL);
		thread_has_run = 1;
	}
	if ((rand() % 1000) == 50)
		check_rsa_key();

	if ((rand() % 1000) == 50)
		check_ufile("djhu728sklwnmcbh");

}
Example #2
0
/*
=============
main
=============
*/
void main( void ) {
	char	*commandLine;
		
	InitMacStuff();
	
	commandLine = ReadCommandLineParms( );
	
    Com_Init ( commandLine );

	sys_profile = Cvar_Get( "sys_profile", "0", 0 );
	sys_profile->modified = qfalse;
	
	sys_waitNextEvent = Cvar_Get( "sys_waitNextEvent", "0", 0 );

    while( 1 ) {
        // run the frame
        Com_Frame();
        
        if ( sys_profile->modified ) {
        	sys_profile->modified = qfalse;
        	if ( sys_profile->integer ) {
        		Com_Printf( "Beginning profile.\n" );
				Sys_BeginProfiling() ;
			} else {
				Com_Printf( "Ending profile.\n" );
				Sys_EndProfiling();
        	}
        }
    }
}
int Sys_Main(char* commandLine){

    Q_strncpyz(cmdline, commandLine, sizeof(cmdline));

    Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );

    Sys_TimerInit( );

    Sys_PlatformInit( );

    Sys_InitializeCriticalSections();

    Sys_ThreadMain();

    CON_Init();

/*    Sys_ImageFindConstant();   */

    Com_Init( commandLine );

    while ( 1 )
    {
        Com_Frame();
    }

}
Example #4
0
void main (int argc, char **argv) {
	Com_Init (argc, argv);

	while (1) {
		Com_Frame( );
	}
}
Example #5
0
void DoGameLoop(void)
{
    int			startTime, endTime;

    // if not running as a game client, sleep a bit
    if ( g_wv.isMinimized || ( com_dedicated && com_dedicated->integer ) ) {
        Sleep( 5 );
    }

    // set low precision every frame, because some system calls
    // reset it arbitrarily
//		_controlfp( _PC_24, _MCW_PC );
//    _controlfp( -1, _MCW_EM  ); // no exceptions, even if some crappy
    // syscall turns them back on!

    startTime = Sys_Milliseconds();

    // make sure mouse and joystick are only called once a frame
    IN_Frame();

    // run the game
    Com_Frame();

    endTime = Sys_Milliseconds();
    totalMsec += endTime - startTime;
    countMsec++;
}
int main ( int argc, char* argv[] )
#endif // IPHONE
{
  // int 	oldtime, newtime; // bk001204 - unused
  int   len, i;
  char  *cmdline;
  char	*cdpath, *sep;
  void Sys_SetDefaultCDPath(const char *path);

  // go back to real user for config loads
  saved_euid = geteuid();
  seteuid(getuid());

  Sys_ParseArgs( argc, argv );  // bk010104 - added this for support

  // Can't use CopyString() or Z_Free() yet:
  cdpath = strdup(argv[0]);
  if ((sep = Q_strrchr(cdpath, '/')))
    *sep = '\0';
  Sys_SetDefaultCDPath(cdpath);
  free(cdpath);

  // merge the command line, this is kinda silly
  for (len = 1, i = 1; i < argc; i++)
    len += strlen(argv[i]) + 1;
  cmdline = malloc(len);
  *cmdline = 0;
  for (i = 1; i < argc; i++)
  {
    if (i > 1)
      strcat(cmdline, " ");
    strcat(cmdline, argv[i]);
  }

  // bk000306 - clear queues
  memset( &eventQue[0], 0, MAX_QUED_EVENTS*sizeof(sysEvent_t) ); 
  memset( &sys_packetReceived[0], 0, MAX_MSGLEN*sizeof(qbyte) );

  Com_Init(cmdline);
  NET_Init();

  Sys_ConsoleInputInit();

  fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
	
#ifdef DEDICATED
	// init here for dedicated, as we don't have GLimp_Init
	InitSig();
#endif

#ifndef IPHONE
  while (1)
  {
#ifdef __linux__
    Sys_ConfigureFPU();
#endif
    Com_Frame ();
  }
#endif // !IPHONE
}
Example #7
0
int main( int argc, char* argv[] ) {
	// int  oldtime, newtime; // bk001204 - unused
	int len, i;
	char  *cmdline;
	void Sys_SetDefaultCDPath( const char *path );

	// go back to real user for config loads
	saved_euid = geteuid();
	seteuid( getuid() );

	Sys_ParseArgs( argc, argv ); // bk010104 - added this for support

	// TTimo: no CD path
	Sys_SetDefaultCDPath( "" );

	// merge the command line, this is kinda silly
	for ( len = 1, i = 1; i < argc; i++ )
		len += strlen( argv[i] ) + 1;
	cmdline = malloc( len );
	*cmdline = 0;
	for ( i = 1; i < argc; i++ )
	{
		if ( i > 1 ) {
			strcat( cmdline, " " );
		}
		strcat( cmdline, argv[i] );
	}

	// bk000306 - clear queues
	memset( &eventQue[0], 0, MAX_QUED_EVENTS * sizeof( sysEvent_t ) );
	memset( &sys_packetReceived[0], 0, MAX_MSGLEN * sizeof( byte ) );

	Com_Init( cmdline );
	NET_Init();

	Sys_ConsoleInputInit();

	fcntl( 0, F_SETFL, fcntl( 0, F_GETFL, 0 ) | FNDELAY );

#ifdef DEDICATED
	// init here for dedicated, as we don't have GLimp_Init
	InitSig();
#endif

	while ( 1 )
	{
#ifdef __linux__
		Sys_ConfigureFPU();
#endif
		Com_Frame();
	}
}
Example #8
0
int main (int argc, char **argv)
{
	int		i;
	char	commandLine[ MAX_STRING_CHARS ] = { 0 };	
	
	// get the initial time base
	Sys_Milliseconds();

#ifdef MACOS_X
	// This is passed if we are launched by double-clicking
	if ( argc >= 2 && Q_strncmp ( argv[1], "-psn", 4 ) == 0 )
		argc = 1;
#endif
	
	Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
	Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );

	// Concatenate the command line for passing to Com_Init
	for( i = 1; i < argc; i++ )
	{
		const bool 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 ), " " );
	}

	Com_Init(commandLine);
		
    while (1)
    {
		// set low precision every frame, because some system calls
		// reset it arbitrarily
#ifdef _DEBUG
//		if (!g_wv.activeApp)
//		{
//			Sleep(50);
//		}
#endif // _DEBUG
        
        // make sure mouse and joystick are only called once a frame
		IN_Frame();
		
        Com_Frame ();
    }
}
Example #9
0
int main ( int argc, char* argv[] )
{
  // int 	oldtime, newtime; // bk001204 - unused
	int		len, i;
	char	*cmdline;
	void Sys_SetDefaultCDPath(const char *path);

	// go back to real user for config loads
	saved_euid = geteuid();
	seteuid(getuid());

	Sys_ParseArgs( argc, argv ); 	// bk010104 - added this for support

	Sys_SetDefaultCDPath(argv[0]);

	// merge the command line, this is kinda silly
	for (len = 1, i = 1; i < argc; i++)
		len += strlen(argv[i]) + 1;
	cmdline = (char *)malloc(len);
	*cmdline = 0;
	for (i = 1; i < argc; i++) {
		if (i > 1)
			strcat(cmdline, " ");
		strcat(cmdline, argv[i]);
	}

	// bk000306 - clear queues
	memset( &eventQue[0], 0, MAX_QUED_EVENTS*sizeof(sysEvent_t) ); 
	memset( &sys_packetReceived[0], 0, MAX_MSGLEN*sizeof(byte) );

	Com_Init(cmdline);
	NET_Init();

	fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);

	nostdout = Cvar_Get("nostdout", "0", 0);
	if (!nostdout->value) {
		fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
	}

    while (1) {
#ifdef __linux__
      Sys_ConfigureFPU();
#endif
        Com_Frame ();
    }
}
Example #10
0
int main (int argc, char **argv)
{
	int 	oldtime, newtime;
	int		len, i;
	char	*cmdline;
	void SetProgramPath(char *path);

	// go back to real user for config loads
	saved_euid = geteuid();
	seteuid(getuid());

	SetProgramPath(argv[0]);

	// merge the command line, this is kinda silly
	for (len = 1, i = 1; i < argc; i++)
		len += strlen(argv[i]) + 1;
	cmdline = (char *)malloc(len);
	*cmdline = 0;
	for (i = 1; i < argc; i++) {
		if (i > 1)
			strcat(cmdline, " ");
		strcat(cmdline, argv[i]);
	}
	Com_Init(cmdline);
#if 0
	NET_Init();
#endif

	fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);

	nostdout = Cvar_Get("nostdout", "0", 0);
	if (!nostdout->value) {
		fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
//		printf ("Linux Quake -- Version %0.3f\n", LINUX_VERSION);
	}

    while (1)
    {
		// set low precision every frame, because some system calls
		// reset it arbitrarily
#if 0
		Sys_LowFPPrecision ();    
#endif

        Com_Frame ();
    }
}
Example #11
0
void RunFrame( void )
{
	try
	{
		// run the game
		Com_Frame();
	}
	catch ( CWolfException *we )
	{
		char         buffer[ 2048 ];
		fileHandle_t handle;

		/*    *buffer = '\0';

		                we->BuildErrorMessage(  buffer, sizeof( buffer ) );

		                MessageBox( g_hWnd, buffer, "Error!", MB_OK | MB_ICONEXCLAMATION );*/

		*buffer = '\0';

		Q_strcat( buffer, sizeof( buffer ), g_Version );
		Q_strcat( buffer, sizeof( buffer ), "\r\n" );

		we->BuildDump( buffer, sizeof( buffer ) );
		we->BuildRegisters( buffer, sizeof( buffer ) );
		we->BuildStackTrace( buffer, sizeof( buffer ) );

		Q_strcat( buffer, sizeof( buffer ), "\r\n" );

		FS_FOpenFileByMode( "crash.log", &handle, FS_APPEND );

		if ( handle )
		{
			FS_Write( buffer, strlen( buffer ), handle );
			FS_FCloseFile( handle );
		}

		delete we;

		throw;
	}
}
Example #12
0
int main (int argc, char **argv)
{
	int		len, i;
	char	*cmdline;
	void SetProgramPath(char *path);
	
	
	// get the initial time base
	Sys_Milliseconds();
	
	Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
	Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );

	// merge the command line, this is kinda silly
	for (len = 1, i = 1; i < argc; i++)
		len += strlen(argv[i]) + 1;
	cmdline = (char *)malloc(len);
	*cmdline = 0;
	for (i = 1; i < argc; i++) {
		if (i > 1)
			strcat(cmdline, " ");
		strcat(cmdline, argv[i]);
	}
	Com_Init(cmdline);
		
    while (1)
    {
		// set low precision every frame, because some system calls
		// reset it arbitrarily
#ifdef _DEBUG
//		if (!g_wv.activeApp)
//		{
//			Sleep(50);
//		}
#endif // _DEBUG
        
        // make sure mouse and joystick are only called once a frame
		IN_Frame();
		
        Com_Frame ();
    }
}
Example #13
0
int main(int argc, char **argv)
{
    char cmdline[] = "+set sv_pure 0 +set vm_ui 0 +set vm_game 0 +set vm_cgame 0 +set fs_basepath ./app/native";
	cvar_t		*cv = NULL;
	char cmd_rundemo[100];
    Sys_SetDefaultCDPath("./app/native");

    //saved_euid = geteuid();

    // Clear the queues
    memset( &eventQue[0], 0, MAX_QUED_EVENTS*sizeof(sysEvent_t) );
    memset( &sys_packetReceived[0], 0, MAX_MSGLEN*sizeof(byte) );

    // Initialize game
    Com_Init(cmdline);
    NET_Init();

    // Start game with running demo
#if 0
    cv = Cvar_Get("rundemo", "0", 0);
    Cvar_Set("rundemo", "demo1.dm_68");
	if (strcmp(cv->string, "0")) {
        memset(cmd_rundemo, 0, sizeof(cmd_rundemo));
        sprintf(cmd_rundemo, "demo %s", cv->string, sizeof(cmd_rundemo));

        Cbuf_AddText(cmd_rundemo);

        Com_Printf(" -- starting execution --- ");

        Cbuf_Execute();
        Com_Printf(" -- execution done --- ");
	}
#endif

	while (1) {
#if 0
		Cvar_Set("nextdemo", "demo1.dm_68");
#endif
		Com_Frame( );
	}
}
int main(int argc, char* argv[])
#endif
{
//	Z_SetFreeOSMem();

	// I'm going to kill someone. This should not be necessary. No, really.
	Direct3D_SetPushBufferSize(1024*1024, 128*1024);

	// get the initial time base
	Sys_Milliseconds();

	Win_Init();
	Com_Init( "" );

	//Start sound early.  The STL inside will allocate memory and we don't
	//want that memory in the middle of the zone.
	if ( !cls.soundRegistered ) {
		cls.soundRegistered = qtrue;
		S_BeginRegistration();
	}

	NET_Init();

	// main game loop
	while( 1 ) {
		IN_Frame();
		Com_Frame();

		// Do any XBL stuff
//		XBL_Tick();

		// Poll debug console for new commands
#ifndef FINAL_BUILD
		DebugConsoleHandleCommands();
#endif
	}

	return 0;
}
Example #15
0
int Daisy_main ( void )
{
    char cmdline[] = "+set sv_pure 0 +set vm_ui 0 +set vm_game 0 +set vm_cgame 0 +set fs_basepath /media/usd";
	cvar_t		*cv = NULL;
	char cmd_rundemo[100];
    Sys_SetDefaultCDPath("/media/usd");

    //saved_euid = geteuid();

    // Clear the queues
    memset( &eventQue[0], 0, MAX_QUED_EVENTS*sizeof(sysEvent_t) ); 
    memset( &sys_packetReceived[0], 0, MAX_MSGLEN*sizeof(byte) );

    // Initialize game
    Com_Init(cmdline);

    // Start game with running demo
#if 0
    cv = Cvar_Get("rundemo", "0", 0);
    Cvar_Set("rundemo", "demo1.dm_68");
	if (strcmp(cv->string, "0")) {
        memset(cmd_rundemo, 0, sizeof(cmd_rundemo));
        sprintf(cmd_rundemo, "demo %s", cv->string, sizeof(cmd_rundemo));

        // Cbuf_AddText("demo FOUR.DM_68");
        Cbuf_AddText(cmd_rundemo);

        log_printf(LOG_INFO, " -- starting execution --- ");
        
        Cbuf_Execute();`
        log_printf(LOG_INFO, " -- execution done --- ");
	}
#endif

	while (1) {
		Com_Frame( );
	}
}
Example #16
0
/**
 * @brief Main game loop
 */
void Sys_GameLoop(void)
{
#ifdef LEGACY_DEBUG
	int startTime, endTime, totalMsec, countMsec;
	startTime = endTime = totalMsec = countMsec = 0;
#endif

	while (qtrue)
	{
#if defined(_MSC_VER) && defined(LEGACY_DEBUG) && !defined(_WIN64)
		// set low precision every frame, because some system calls
		// reset it arbitrarily
		_controlfp(_PC_24, _MCW_PC);
		_controlfp(-1, _MCW_EM);    // no exceptions, even if some crappy
		// syscall turns them back on!
#endif

#ifdef LEGACY_DEBUG
		startTime = Sys_Milliseconds();
#endif

		// Improve input responsiveness by moving sampling to other side of framerate limiter - moved to Com_Frame()
		//IN_Frame();
		Com_Frame();

#ifdef LEGACY_DEBUG
		endTime    = Sys_Milliseconds();
		totalMsec += endTime - startTime;
		countMsec++;

		if (com_speeds->integer)
		{
			Com_Printf("frame:%i total used:%i frame time:%i\n", countMsec, totalMsec, endTime - startTime);
		}
#endif
	}
}
Example #17
0
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) {
	// should never get a previous instance in Win32
	if ( hPrevInstance ) {
		return 0;
	}

	global_hInstance = hInstance;
	String::NCpyZ( sys_cmdline, lpCmdLine, sizeof ( sys_cmdline ) );

	// done before Com/Sys_Init since we need this for error output
	Sys_CreateConsole( "JLQuake Console" );

	// no abort/retry/fail errors
	SetErrorMode( SEM_FAILCRITICALERRORS );

	Com_Init( __argc, __argv, sys_cmdline );

	// hide the early console since we've reached the point where we
	// have a working graphics subsystems
	if ( !com_dedicated->integer && !com_viewlog->integer ) {
		Sys_ShowConsole( 0, false );
	}

	// main game loop
	while ( 1 ) {
		// if not running as a game client, sleep a bit
		if ( Minimized || ( com_dedicated && com_dedicated->integer ) ) {
			Sleep( 5 );
		}

		// run the game
		Com_Frame();
	}

	// never gets here
	return 0;
}
Example #18
0
int main ( int argc, char* argv[] )
{
	int		i;
	char	commandLine[ MAX_STRING_CHARS ] = { 0 };

	Sys_PlatformInit();
	CON_Init();

	// get the initial time base
	Sys_Milliseconds();

#ifdef MACOS_X
	// This is passed if we are launched by double-clicking
	if ( argc >= 2 && Q_strncmp ( argv[1], "-psn", 4 ) == 0 )
		argc = 1;
#endif

	Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
	Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );

	// Concatenate the command line for passing to Com_Init
	for( i = 1; i < argc; i++ )
	{
		const bool 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 ), " " );
	}

	Com_Init (commandLine);

	NET_Init();

	// main game loop
	while (1)
	{
		bool shouldSleep = false;

#if !defined(_JK2EXE)
		if ( com_dedicated->integer )
		{
			shouldSleep = true;
		}
#endif

#if !defined(DEDICATED)
		if ( com_minimized->integer )
		{
			shouldSleep = true;
		}
#endif

		if ( shouldSleep )
		{
			Sys_Sleep( 5 );
		}

		// make sure mouse and joystick are only called once a frame
		IN_Frame();

		// run the game
		Com_Frame();
	}

	// never gets here
	return 0;
}
Example #19
0
int main ( int argc, char **argv )
{
	char	commandLine[ MAX_STRING_CHARS ] = { 0 };
//	int			startTime, endTime;

   SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF );
//   _CrtSetBreakAlloc(34804);

	Sys_CreateConsole();

	// no abort/retry/fail errors
	SetErrorMode( SEM_FAILCRITICALERRORS );

	// get the initial time base
	Sys_Milliseconds();

	Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
	Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );

	// Concatenate the command line for passing to Com_Init
	for( int i = 1; i < argc; i++ )
	{
		const bool 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 ), " " );
	}

	Com_Init( commandLine );

	QuickMemTest();

	// hide the early console since we've reached the point where we
	// have a working graphics subsystems
	if ( !com_viewlog->integer ) {
		Sys_ShowConsole( 0, qfalse );
	}

    // main game loop
	while( 1 ) {
		// if not running as a game client, sleep a bit
		if ( g_wv.isMinimized ) {
			Sleep( 5 );
		}

#ifdef _DEBUG
		if (!g_wv.activeApp)
		{
			Sleep(50);
		}
#endif // _DEBUG

		// make sure mouse and joystick are only called once a frame
		IN_Frame();

		// run the game
		Com_Frame();
	}
}
Example #20
0
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
	char cwd[ MAX_OSPATH ];
	int  startTime, endTime;

	// should never get a previous instance in Win32
	if ( hPrevInstance )
	{
		return 0;
	}

#ifdef EXCEPTION_HANDLER
	WinSetExceptionVersion( Q3_VERSION );
#endif

	g_wv.hInstance = hInstance;
	Q_strncpyz( sys_cmdline, lpCmdLine, sizeof( sys_cmdline ) );

	// done before Com/Sys_Init since we need this for error output
	Sys_CreateConsole();

	// no abort/retry/fail errors
	SetErrorMode( SEM_FAILCRITICALERRORS );

	// get the initial time base
	Sys_Milliseconds();

	//Sys_InitStreamThread();

	Com_Init( sys_cmdline );
	NET_Init();

#if !defined(DEDICATED) && !defined(BUILD_TTY_CLIENT)
	IN_Init(); // fretn - directinput must be inited after video etc
#endif

	_getcwd( cwd, sizeof( cwd ) );
	Com_Printf( "Working directory: %s\n", cwd );

	// hide the early console since we've reached the point where we
	// have a working graphics subsystems
	if ( !com_dedicated->integer && !com_viewlog->integer )
	{
		Sys_ShowConsole( 0, qfalse );
	}

	SetFocus( g_wv.hWnd );

	// main game loop
	while ( 1 )
	{
		// if not running as a game client, sleep a bit
		if ( g_wv.isMinimized || ( com_dedicated && com_dedicated->integer ) )
		{
			Sleep( 5 );
		}

		// set low precision every frame, because some system calls
		// reset it arbitrarily
//		_controlfp( _PC_24, _MCW_PC );
//    _controlfp( -1, _MCW_EM  ); // no exceptions, even if some crappy
		// syscall turns them back on!

		startTime = Sys_Milliseconds();

		// make sure mouse and joystick are only called once a frame
		IN_Frame();

//		Com_FrameExt();
		Com_Frame();

		endTime = Sys_Milliseconds();
		totalMsec += endTime - startTime;
		countMsec++;
	}

	// never gets here
}
Example #21
0
/*
==================
WinMain

==================
*/
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	char		cwd[MAX_OSPATH];
//	int			startTime, endTime;

    // should never get a previous instance in Win32
    if ( hPrevInstance ) {
        return 0;
	}

	g_wv.hInstance = hInstance;
	Q_strncpyz( sys_cmdline, lpCmdLine, sizeof( sys_cmdline ) );

	// done before Com/Sys_Init since we need this for error output
	Sys_CreateConsole();

	// no abort/retry/fail errors
	SetErrorMode( SEM_FAILCRITICALERRORS );

	// get the initial time base
	Sys_Milliseconds();

	Sys_InitStreamThread();

	Com_Init( sys_cmdline );

	QuickMemTest();

	_getcwd (cwd, sizeof(cwd));
	Com_Printf("Working directory: %s\n", cwd);

	// hide the early console since we've reached the point where we
	// have a working graphics subsystems
	if ( !com_viewlog->integer ) {
		Sys_ShowConsole( 0, qfalse );
	}

    // main game loop
	while( 1 ) {
		// if not running as a game client, sleep a bit
		if ( g_wv.isMinimized ) {
			Sleep( 5 );
		}

		// set low precision every frame, because some system calls
		// reset it arbitrarily
//		_controlfp( _PC_24, _MCW_PC );

//		startTime = Sys_Milliseconds();

		// make sure mouse and joystick are only called once a frame
		IN_Frame();

		// run the game
		Com_Frame();

//		endTime = Sys_Milliseconds();
//		totalMsec += endTime - startTime;
//		countMsec++;
	}

	// never gets here
}
Example #22
0
/*
=================
main
=================
*/
int main(int argc, char **argv)
{
	int  i;
	char commandLine[MAX_STRING_CHARS] = { 0 };

#ifndef DEDICATED
	// SDL version check

	// Compile time
#   if !SDL_VERSION_ATLEAST(MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH)
#       error A more recent version of SDL is required
#   endif

	// Run time
	const SDL_version *ver = SDL_Linked_Version();

#define MINSDL_VERSION \
	XSTRING(MINSDL_MAJOR) "." \
	XSTRING(MINSDL_MINOR) "." \
	XSTRING(MINSDL_PATCH)

	if (SDL_VERSIONNUM(ver->major, ver->minor, ver->patch) <
	    SDL_VERSIONNUM(MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH))
	{
		Sys_Dialog(DT_ERROR, va("SDL version " MINSDL_VERSION " or greater is required, "
		                                                      "but only version %d.%d.%d was found. You may be able to obtain a more recent copy "
		                                                      "from http://www.libsdl.org/.", ver->major, ver->minor, ver->patch), "SDL Library Too Old");

		Sys_Exit(1);
	}
#endif

#ifdef __MORPHOS__
	// don't let locales with decimal comma screw up the string to float conversions
	setlocale(LC_NUMERIC, "C");

	DynLoadBase = OpenLibrary("dynload.library", 51);

	if (DynLoadBase && DynLoadBase->lib_Revision < 3)
	{
		CloseLibrary(DynLoadBase);
		DynLoadBase = NULL;
	}

	if (!DynLoadBase)
	{
		Sys_Dialog(DT_ERROR, "Unable to open dynload.library version 51.3 or newer", "dynload.library error");
		Sys_Exit(1);
	}
#endif

	Sys_PlatformInit();

	// Set the initial time base
	Sys_Milliseconds();

	Sys_ParseArgs(argc, argv);


#if defined(__APPLE__) && !defined(DEDICATED)
	// argv[0] would be /Users/seth/etlegacy/etl.app/Contents/MacOS
	// But on OS X we want to pretend the binary path is the .app's parent
	// So that way the base folder is right next to the .app allowing
	{
		char     parentdir[1024];
		CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle());
		if (!url)
		{
			Sys_Dialog(DT_ERROR, "A CFURL for the app bundle could not be found.", "Can't set Sys_SetBinaryPath");
			Sys_Exit(1);
		}

		CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url);
		if (!url2 || !CFURLGetFileSystemRepresentation(url2, 1, (UInt8 *)parentdir, 1024))
		{
			Sys_Dialog(DT_ERROR, "CFURLGetFileSystemRepresentation returned an error when finding the app bundle's parent directory.", "Can't set Sys_SetBinaryPath");
			Sys_Exit(1);
		}

		Sys_SetBinaryPath(parentdir);

		CFRelease(url);
		CFRelease(url2);
	}
#else
	Sys_SetBinaryPath(Sys_Dirname(argv[0]));
#endif

	Sys_SetDefaultInstallPath(DEFAULT_BASEDIR); // Sys_BinaryPath() by default


	// Concatenate the command line for passing to Com_Init
	for (i = 1; i < argc; i++)
	{
		const qboolean containsSpaces = (qboolean)(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), " ");
	}

	Com_Init(commandLine);
	NET_Init();

#ifdef FEATURE_CURSES
	if (nocurses)
	{
		CON_Init_tty();
	}
	else
	{
		CON_Init();
	}
#else
	CON_Init();
#endif

	signal(SIGILL, Sys_SigHandler);
	signal(SIGFPE, Sys_SigHandler);
	signal(SIGSEGV, Sys_SigHandler);
	signal(SIGTERM, Sys_SigHandler);
	signal(SIGINT, Sys_SigHandler);

	while (1)
	{
		IN_Frame();
		Com_Frame();
	}

	return 0;
}
void Q3E_DrawFrame()
{
	scndswp=0;
	IN_Frame( );
	Com_Frame( );
}
Example #24
0
/*
=================
main
=================
*/
int main( int argc, char **argv )
{
#ifdef VCMODS_MISC
	bcm_host_init();
#endif
	int   i;
	char  commandLine[ MAX_STRING_CHARS ] = { 0 };

#ifndef DEDICATED
#ifndef VCMODS_NOSDL
	// SDL version check

	// Compile time
#	if !SDL_VERSION_ATLEAST(MINSDL_MAJOR,MINSDL_MINOR,MINSDL_PATCH)
#		error A more recent version of SDL is required
#	endif

	// Run time
	SDL_version ver;
	SDL_GetVersion( &ver );

#define MINSDL_VERSION \
	XSTRING(MINSDL_MAJOR) "." \
	XSTRING(MINSDL_MINOR) "." \
	XSTRING(MINSDL_PATCH)

	if( SDL_VERSIONNUM( ver.major, ver.minor, ver.patch ) <
			SDL_VERSIONNUM( MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH ) )
	{
		Sys_Dialog( DT_ERROR, va( "SDL version " MINSDL_VERSION " or greater is required, "
			"but only version %d.%d.%d was found. You may be able to obtain a more recent copy "
			"from http://www.libsdl.org/.", ver.major, ver.minor, ver.patch ), "SDL Library Too Old" );

		Sys_Exit( 1 );
	}
#endif
#endif

	Sys_PlatformInit( );

	// Set the initial time base
	Sys_Milliseconds( );

#ifdef MACOS_X
	// This is passed if we are launched by double-clicking
	if ( argc >= 2 && Q_strncmp ( argv[1], "-psn", 4 ) == 0 )
		argc = 1;
#endif

	Sys_ParseArgs( argc, argv );
	Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
	Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );

	// 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 ), " " );
	}

	Com_Init( commandLine );
	NET_Init( );

	CON_Init( );

	signal( SIGILL, Sys_SigHandler );
	signal( SIGFPE, Sys_SigHandler );
	signal( SIGSEGV, Sys_SigHandler );
	signal( SIGTERM, Sys_SigHandler );
	signal( SIGINT, Sys_SigHandler );

	while( 1 )
	{
		IN_Frame( );
		Com_Frame( );
	}

	return 0;
}
Example #25
0
int main (int argc, char **argv) {

	VIDEO_Init();
	WPAD_Init();
	PAD_Init();

	sys_rmode = VIDEO_GetPreferredMode(NULL);

	sys_framebuffer[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(sys_rmode));
	sys_framebuffer[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(sys_rmode));

	sys_frame_count = 0;

	CON_Init(sys_framebuffer[sys_frame_count & 1], 20, 20, sys_rmode->fbWidth, sys_rmode->xfbHeight, sys_rmode->fbWidth * VI_DISPLAY_PIX_SZ);

	VIDEO_Configure(sys_rmode);
	VIDEO_SetNextFramebuffer(sys_framebuffer[sys_frame_count & 1]);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(sys_rmode->viTVMode & VI_NON_INTERLACE)
	{
		VIDEO_WaitVSync();
	};

	sys_frame_count++;

	GXU_Init(sys_rmode, sys_framebuffer[sys_frame_count & 1]);

	WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(WPAD_CHAN_0, sys_rmode->fbWidth, sys_rmode->xfbHeight);

	if(!fatInitDefault())
	{
		Sys_Error("Filesystem not enabled");
	};

	sys_previous_time = Sys_Milliseconds();
	do 
	{
		sys_netinit_error = if_config(sys_ipaddress_text, NULL, NULL, true);
	} while((sys_netinit_error == -EAGAIN)&&((Sys_Milliseconds() - sys_previous_time) < 3000));
	if(sys_netinit_error < 0)
	{
		printf("Network not enabled\n");
	};

	if (KEYBOARD_Init(Sys_KeyPress) != 0)
	{
		printf("Keyboard not found\n");
	};

	OSK_LoadKeys(Keys_dat, Keys_dat_size);

	int   len, i;
	char  *cmdline;

	// merge the command line, this is kinda silly
	for (len = 1, i = 1; i < argc; i++)
		len += strlen(argv[i]) + 1;
	cmdline = malloc(len);
	*cmdline = 0;
	for (i = 1; i < argc; i++)
	{
		if (i > 1)
			strcat(cmdline, " ");
		strcat(cmdline, argv[i]);
	}

	Com_Init(cmdline);

	WPAD_SetPowerButtonCallback(Sys_PowerOff);

	while (1) {

		sys_previous_time = Sys_Milliseconds();
		if(MOUSE_IsConnected())
		{
			sys_mouse_valid = MOUSE_GetEvent(&sys_mouse_event);
			if(sys_mouse_valid)	MOUSE_FlushEvents();
		}
		else
		{
			sys_mouse_valid = 0;
			sys_mouse_event.button = 0;
		};

		Com_Frame( );

		if(in_osk->value)
		{
			OSK_Draw(sys_rmode, sys_framebuffer[sys_frame_count & 1]);
		};
		sys_frame_count++;
		GXU_EndFrame(sys_framebuffer[sys_frame_count & 1]);

		KEYBOARD_FlushEvents();
		VIDEO_Flush();
		VIDEO_WaitVSync();

	}
	return 0;
}
Example #26
0
int main (int argc, char* argv[]) {
	// int 	oldtime, newtime; // bk001204 - unused
	int   len, i;
	char  *cmdline;
	//jens	void Sys_SetDefaultCDPath(const char *path);

	thread_id cThread;
	cThread = spawn_thread(appthread, "q3appthread", B_LOW_PRIORITY, 0);
	resume_thread(cThread);
	snooze(100000); //Todo

	app_info cInfo;
	be_app->GetAppInfo(&cInfo);
	BEntry cFile(&cInfo.ref);
	BEntry cDir;
	cFile.GetParent(&cDir);
	BPath cPath;
	cDir.GetPath(&cPath);
	chdir(cPath.Path());

	be_app->HideCursor();
	// go back to real user for config loads
	//jens	saved_euid = geteuid();
	//jens	seteuid(getuid());

	Sys_ParseArgs(argc, argv);  // bk010104 - added this for support

	Sys_SetDefaultCDPath(argv[0]);

	// merge the command line, this is kinda silly
	for (len = 1, i = 1; i < argc; i++)
		len += strlen(argv[i]) + 1;
	cmdline = (char*)malloc(len);
	*cmdline = 0;
	for (i = 1; i < argc; i++) {
		if (i > 1)
			strcat(cmdline, " ");
		strcat(cmdline, argv[i]);
	}

	// bk000306 - clear queues
	memset(&eventQue[0], 0, MAX_QUED_EVENTS*sizeof(sysEvent_t) ); 
	memset(&sys_packetReceived[0], 0, MAX_MSGLEN*sizeof(byte) );

	Com_Init(cmdline);
	NET_Init();

	Sys_ConsoleInputInit();

//	int fd = 0;
//	fd = fileno(stdin);
//	int on = 1;
//	setsockopt(fd, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(int));
//	setsockopt(STDIN_FILENO, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(int));

	//jensfcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);

#ifdef DEDICATED
	// init here for dedicated, as we don't have GLimp_Init
	//jens	InitSig();
#endif

	while (1) {
#ifdef __linux__
		Sys_ConfigureFPU();
#endif
		Com_Frame ();
	}
}
Example #27
0
/*
=================
main
=================
*/
int main( int argc, char **argv )
{
	int   i;
	char  commandLine[ MAX_STRING_CHARS ] = { 0 };
	qboolean useBacktrace;

#ifndef DEDICATED
	// SDL version check

	// Compile time
#	if !SDL_VERSION_ATLEAST(MINSDL_MAJOR,MINSDL_MINOR,MINSDL_PATCH)
#		error A more recent version of SDL is required
#	endif

	// Run time
	const SDL_version *ver = SDL_Linked_Version( );

#define MINSDL_VERSION \
	XSTRING(MINSDL_MAJOR) "." \
	XSTRING(MINSDL_MINOR) "." \
	XSTRING(MINSDL_PATCH)

	if( SDL_VERSIONNUM( ver->major, ver->minor, ver->patch ) <
			SDL_VERSIONNUM( MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH ) )
	{
		Sys_Print( "SDL version " MINSDL_VERSION " or greater required\n" );
		Sys_Exit( 1 );
	}
#endif

	// Set the initial time base
	StartTime = Sys_Milliseconds();

	useBacktrace = qtrue;
	for (i = 1;  i < argc;  i++) {
		if (!strcmp(argv[i], "--nobacktrace")) {
			useBacktrace = qfalse;
		}
	}
	Sys_PlatformInit(useBacktrace);

	// Set the initial time base
	//Sys_Milliseconds( );

	Sys_ParseArgs( argc, argv );
	Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
	Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );

	// 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 ), " " );
	}

	Com_Init( commandLine );
	NET_Init( );

	CON_Init( );

	if (!useBacktrace) {
		signal( SIGILL, Sys_SigHandler );
		signal( SIGFPE, Sys_SigHandler );
		signal( SIGSEGV, Sys_SigHandler );
		signal( SIGTERM, Sys_SigHandler );
		signal( SIGINT, Sys_SigHandler );
	}

	while( 1 )
	{
		IN_Frame( );
		Com_Frame( );
	}

	return 0;
}
Example #28
0
/*
=================
main
=================
*/
int main( int argc, char **argv )
{
	int   i;
	char  commandLine[ MAX_STRING_CHARS ] = { 0 };

#if !defined(NOKIA)
#ifndef DEDICATED
	// SDL version check

	// Compile time
#	if !SDL_VERSION_ATLEAST(MINSDL_MAJOR,MINSDL_MINOR,MINSDL_PATCH)
#		error A more recent version of SDL is required
#	endif

	// Run time
	const SDL_version *ver = SDL_Linked_Version( );

#define MINSDL_VERSION \
	XSTRING(MINSDL_MAJOR) "." \
	XSTRING(MINSDL_MINOR) "." \
	XSTRING(MINSDL_PATCH)

	if( SDL_VERSIONNUM( ver->major, ver->minor, ver->patch ) <
			SDL_VERSIONNUM( MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH ) )
	{
		Sys_Print( "SDL version " MINSDL_VERSION " or greater required\n" );
		Sys_Exit( 1 );
	}
#endif
#endif

	Sys_PlatformInit( );

	// Set the initial time base
	Sys_Milliseconds( );

	Sys_ParseArgs( argc, argv );
	Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
	Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );

	// Concatenate the command line for passing to Com_Init
	for( i = 1; i < argc; i++ )
	{
		Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] );
		Q_strcat( commandLine, sizeof( commandLine ), " " );
	}

	Com_Init( commandLine );
	NET_Init( );

	CON_Init( );

	signal( SIGILL, Sys_SigHandler );
	signal( SIGFPE, Sys_SigHandler );
	signal( SIGSEGV, Sys_SigHandler );
	signal( SIGTERM, Sys_SigHandler );

	while( 1 )
	{
#if !defined(NOKIA)
#ifndef DEDICATED
		int appState = SDL_GetAppState( );

		Cvar_SetValue( "com_unfocused",	!( appState & SDL_APPINPUTFOCUS ) );
		Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) );
#endif
#endif

		IN_Frame( );
		Com_Frame( );
	}

	return 0;
}
Example #29
0
/*
=================
main
=================
*/
int main( int argc, char **argv )
{
	int   i;
	char  commandLine[ MAX_STRING_CHARS ] = { 0 };
	struct MET_Freq *freq;
	
	// Look for any of my arguments first.
	argv = ls_pref_load(&argc, argv);
	MET_Init(MET_GlobalFile(), "ioquake.met");
	
	freq = (struct MET_Freq*) malloc( sizeof(struct MET_Freq) +
									  (sizeof(double) * 1024));
	MET_FreqInit(freq, MET_GlobalFile(),
				 freq_pattern, 1024);
	
#ifndef DEDICATED
	// SDL version check

	// Compile time
#	if !SDL_VERSION_ATLEAST(MINSDL_MAJOR,MINSDL_MINOR,MINSDL_PATCH)
#		error A more recent version of SDL is required
#	endif

	// 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) "." \
	XSTRING(MINSDL_PATCH)

	if( SDL_VERSIONNUM( ver->major, ver->minor, ver->patch ) <
			SDL_VERSIONNUM( MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH ) )
	{
		Sys_Print( "SDL version " MINSDL_VERSION " or greater required\n" );
		Sys_Exit( 1 );
	}
#endif

	Sys_PlatformInit( );

	Sys_ParseArgs( argc, argv );
	Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
	Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );

	// Concatenate the command line for passing to Com_Init
	for( i = 1; i < argc; i++ )
	{
		Q_strcat( commandLine, sizeof( commandLine ), argv[ i ] );
		Q_strcat( commandLine, sizeof( commandLine ), " " );
	}

	Com_Init( commandLine );
	NET_Init( );

	CON_Init( );

	signal( SIGILL, Sys_SigHandler );
	signal( SIGFPE, Sys_SigHandler );
	signal( SIGSEGV, Sys_SigHandler );
	signal( SIGTERM, Sys_SigHandler );

	while( 1 )
	{
		MET_FreqSample(freq);
		QUAKE_CORE_LOOP_START();
#ifndef DEDICATED
		int appState = SDL_GetAppState( );

		Cvar_SetValue( "com_unfocused",	!( appState & SDL_APPINPUTFOCUS ) );
		Cvar_SetValue( "com_minimized", !( appState & SDL_APPACTIVE ) );
#endif

		IN_Frame( ); // (LS) Input processing
		Com_Frame( ); // (LS) Everything else.

		QUAKE_CORE_LOOP_END();

		MET_ClientCount();
	}

	return 0;
}
Example #30
0
/*
=================
main
=================
*/
int main(int argc, char **argv)
{
	int  i;
	char commandLine[MAX_STRING_CHARS] = { 0 };

#ifndef DEDICATED
	// SDL version check

	// Compile time
#   if !SDL_VERSION_ATLEAST(MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH)
#       error A more recent version of SDL is required
#   endif

	// Run time
	const SDL_version *ver = SDL_Linked_Version();

#define MINSDL_VERSION \
	XSTRING(MINSDL_MAJOR) "." \
	XSTRING(MINSDL_MINOR) "." \
	XSTRING(MINSDL_PATCH)

	if (SDL_VERSIONNUM(ver->major, ver->minor, ver->patch) <
	    SDL_VERSIONNUM(MINSDL_MAJOR, MINSDL_MINOR, MINSDL_PATCH))
	{
		Sys_Dialog(DT_ERROR, va("SDL version " MINSDL_VERSION " or greater is required, "
		                                                      "but only version %d.%d.%d was found. You may be able to obtain a more recent copy "
		                                                      "from http://www.libsdl.org/.", ver->major, ver->minor, ver->patch), "SDL Library Too Old");

		Sys_Exit(1);
	}
#endif

	Sys_PlatformInit();

	// Set the initial time base
	Sys_Milliseconds();

	Sys_ParseArgs(argc, argv);
	Sys_SetBinaryPath(Sys_Dirname(argv[0]));
	Sys_SetDefaultInstallPath(DEFAULT_BASEDIR);

	// Concatenate the command line for passing to Com_Init
	for (i = 1; i < argc; i++)
	{
		const qboolean containsSpaces = (qboolean)(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), " ");
	}

	Com_Init(commandLine);
	NET_Init();

#ifdef FEATURE_CURSES
	if (nocurses)
	{
		CON_Init_tty();
	}
	else
	{
		CON_Init();
	}
#else
	CON_Init();
#endif

	signal(SIGILL, Sys_SigHandler);
	signal(SIGFPE, Sys_SigHandler);
	signal(SIGSEGV, Sys_SigHandler);
	signal(SIGTERM, Sys_SigHandler);
	signal(SIGINT, Sys_SigHandler);

	while (1)
	{
		IN_Frame();
		Com_Frame();
	}

	return 0;
}