Esempio n. 1
0
static int Sys_Main(int argc, char **argv)
{
    // fix current directory to point to the basedir
    if (!fix_current_directory()) {
        return 1;
    }

#if (_MSC_VER >= 1400)
    // work around strftime given invalid format string
    // killing the whole f*****g process :((
    _set_invalid_parameter_handler(msvcrt_sucks);
#endif

    Qcommon_Init(argc, argv);

    // main program loop
    while (1) {
        Qcommon_Frame();
        if (shouldExit) {
#if USE_WINSVC
            if (shouldExit == SE_FULL)
#endif
                Com_Quit(NULL, ERR_DISCONNECT);
            break;
        }
    }

    // may get here when our service stops
    return 0;
}
Esempio n. 2
0
/*
=================
main
=================
*/
int main(int argc, char **argv)
{
    if (argc > 1) {
        if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) {
            fprintf(stderr, "%s\n", com_version_string);
            return EXIT_SUCCESS;
        }
        if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
            fprintf(stderr, "Usage: %s [+command arguments] [...]\n", argv[0]);
            return EXIT_SUCCESS;
        }
    }

    if (!getuid() || !geteuid()) {
        fprintf(stderr, "You can not run " PRODUCT " as superuser "
                "for security reasons!\n");
        return EXIT_FAILURE;
    }

    Qcommon_Init(argc, argv);
    while (!terminate) {
        Qcommon_Frame();
    }

    Com_Quit(NULL, ERR_DISCONNECT);
    return EXIT_FAILURE; // never gets here
}
Esempio n. 3
0
int main (int argc, char **argv)
{
	int 	time, oldtime, newtime;

	// go back to real user for config loads
	saved_euid = geteuid();
	seteuid(getuid());
	
	printf ("Quake 2 -- Version %s\n", LINUX_VERSION);

	Qcommon_Init(argc, argv);

	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);	
	}
	oldtime = Sys_Milliseconds ();
	while (1)
	{
// find time spent rendering last frame
		do {
			newtime = Sys_Milliseconds ();
			time = newtime - oldtime;
		} while (time < 1);
		Qcommon_Frame (time);
		oldtime = newtime;
	}
}
Esempio n. 4
0
int main (int argc, char **argv)
{
	int 	time, oldtime, newtime;

#if 0
	int newargc;
	char **newargv;
	int i;

	// force dedicated
	newargc = argc;
	newargv = malloc((argc + 3) * sizeof(char *));
	newargv[0] = argv[0];
	newargv[1] = "+set";
	newargv[2] = "dedicated";
	newargv[3] = "1";
	for (i = 1; i < argc; i++)
		newargv[i + 3] = argv[i];
	newargc += 3;

	Qcommon_Init(newargc, newargv);
#else
	Qcommon_Init(argc, argv);
#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);
	}

    oldtime = Sys_Milliseconds ();
    while (1)
    {
// find time spent rendering last frame
		do {
			newtime = Sys_Milliseconds ();
			time = newtime - oldtime;
		} while (time < 1);
        Qcommon_Frame (time);
		oldtime = newtime;
    }

}
Esempio n. 5
0
/**
 * @brief The entry point for Android server and client.
 * Initializes the program and calls @c Qcommon_Frame in an infinite loop.
 */
int SDL_main (int argc, const char **argv)
{
	Sys_ConsoleInit();
	Qcommon_Init(argc, argv);

	while (1)
		Qcommon_Frame();
}
Esempio n. 6
0
static void main( int argc, char **argv )
{
	Qcommon_Init( argc, argv );

	while( 1 )
	{
		Qcommon_Frame( 0.1 );
	}
}
Esempio n. 7
0
int main (int argc, const char **argv)
{
	Sys_ConsoleInit();
	Qcommon_Init(argc, argv);

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

	while (1)
		Qcommon_Frame();
}
Esempio n. 8
0
int main(int argc, char **argv){
	int time, oldtime, newtime;
	
#ifdef SOL8_XIL_WORKAROUND
	
	{
		extern cinematics_t cin;
		
		if((xil_state = xil_open()) == NULL){
			fprintf(stderr, "Can't open XIL\n");
			exit(1);
		}
		memset(&cin, 0, sizeof(cin));
	}
#endif
	
	/* save the contents of the DISPLAY environment variable.
	 * if we don't, it gets overwritten after reloading
	 * the renderer libraries(solaris) */
	{
		char * tmp_name = getenv("DISPLAY");
		if(tmp_name == NULL){
			display_name[0] = '\0';
		} else {
			strncpy(display_name, tmp_name, sizeof(display_name));
		}
	}
	
	/* go back to real user for config loads */
	saved_euid = geteuid();
	seteuid(getuid());
	
	printf("QuakeIIForge %s\n", VERSION);
	
	Qcommon_Init(argc, argv);
	
	/* sys_irix.c had this and the fcntl line 3 lines down commented out */
	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);
		
	/* main loop */
	oldtime = Sys_Milliseconds();
	while(1){
		/* find time spent rendering last frame */
		do {
			newtime = Sys_Milliseconds();
			time = newtime - oldtime;
		} while(time < 1);
		Qcommon_Frame(time);
		oldtime = newtime;
	}
}
Esempio n. 9
0
void android_main( struct android_app *app )
{
	int ident, events;
	struct android_poll_source *source;
	unsigned int oldtime, newtime, time;

	app_dummy();

	sys_android_app = app;
	app->inputPollSource.process = Sys_Android_ProcessInput;
	ANativeActivity_setWindowFlags( app->activity, AWINDOW_FLAG_KEEP_SCREEN_ON, 0 ); // flags must be set before window creation

	app->onAppCmd = Sys_Android_WaitOnAppCmd;
	while( !sys_android_initialized )
	{
		Sys_Sleep( 0 );
		while( ( ident = ALooper_pollAll( 0, NULL, &events, ( void ** )( &source ) ) ) >= 0 )
		{
			if ( source )
				source->process( app, source );
		}
	}

	Sys_Android_Init();
	Qcommon_Init( 0, NULL );

	oldtime = Sys_Milliseconds();
	for( ;; )
	{
		if( dedicated && dedicated->integer )
			Sys_Sleep( 1 );

		while( ( ident = ALooper_pollAll( 0, NULL, &events, ( void ** )( &source ) ) ) >= 0 )
		{
			if( source )
				source->process( app, source );
		}

		for( ;; )
		{
			newtime = Sys_Milliseconds();
			time = newtime - oldtime;
			if( time > 0 )
				break;
			Sys_Sleep( 0 );
		}
		oldtime = newtime;

		Sys_Android_ExecuteIntent();
		Qcommon_Frame( time );
	}
}
Esempio n. 10
0
void main (int argc, char **argv)
{
	// Init libxenon
	xenos_init(VIDEO_MODE_AUTO);
	console_init();

	xenon_make_it_faster(XENON_SPEED_FULL);

#if 0
	threading_init();
	network_init_sys();
#endif

	usb_init();
	usb_do_poll();

	xenon_ata_init();

	xenon_atapi_init();

	fatInitDefault();
#ifdef CAPS	
	fatMountSimple("udb", &usb2mass_ops_1);
	printf("CAPTURE BUILD !!!\n");
#endif	
	// Quake II
	
	char * newargv[] = {
		"uda:/q3.elf",
		//"+set", "game", "baseq2", "+set", "cddir", "uda:/baseq2/"
		"+set", "basedir" , "uda:/",
		"+set", "cddir", "uda:/baseq2/",
		"+set", "cl_maxfps", "400"
	};
	int newargc = sizeof (newargv) / sizeof (char *);
	
	Qcommon_Init (newargc, newargv);
	
	console_close();

	int	time, oldtime, newtime;
	oldtime = Sys_Milliseconds();
	while (1)
	{
		do {
			newtime = Sys_Milliseconds ();
			time = newtime - oldtime;
		} while (time < 1);
		Qcommon_Frame (time);
		oldtime = newtime;
	}
}
Esempio n. 11
0
jint EXPORT_ME
Java_com_jeyries_quake2_Quake2_Quake2Init( JNIEnv* env,
                                                  jobject thiz )
{
	int argc =1; char *argv[] ={ "quake2" };

	/// check for static init problem (see below)
	static int init_state = 0;
	if (init_state!=0)
		return 1;
	init_state = 1;

	//int argc =4; char *argv[] ={ "quake2", "+set", "developer", "1" };








    __android_log_print(ANDROID_LOG_ERROR, "quake2-jni.c", "native code : Quake2Init enter\n");
    __android_log_print(ANDROID_LOG_INFO, "quake2-jni.c", "Quake 2 JNI -- Version %s\n", QUAKE2_JNI_VERSION);
    
    /* HAVE_NEON is defined in Android.mk ! */
#ifdef HAVE_NEON
/*
    if ((features & ANDROID_CPU_ARM_FEATURE_NEON) == 0) {
        strlcat(buffer, "CPU doesn't support NEON !\n", sizeof buffer);
        goto EXIT;
    }*/
    __android_log_print(ANDROID_LOG_INFO, "quake2-jni.c", "Program compiled with ARMv7 support !\n");
#else /* !HAVE_NEON */
    __android_log_print(ANDROID_LOG_INFO, "quake2-jni.c", "Program *NOT* compiled with ARMv7 support !\n");
#endif /* !HAVE_NEON */
   
    
	//Cvar_Set("developer","1");


	Qcommon_Init(argc, argv);


	oldtime = Sys_Milliseconds ();

	__android_log_print(ANDROID_LOG_DEBUG, "quake2-jni.c", "native code : Quake2Init exit\n");

	return 0;
}
Esempio n. 12
0
int main (int argc, char **argv)
{
	double time, oldtime, newtime;

	printf ("Quake 2 DOS v%4.2f\n", VERSION);

// make sure there's an FPU
	signal(SIGNOFP, Sys_NoFPUExceptionHandler);
	signal(SIGABRT, Sys_DefaultExceptionHandler);
	signal(SIGALRM, Sys_DefaultExceptionHandler);
	signal(SIGKILL, Sys_DefaultExceptionHandler);
	signal(SIGQUIT, Sys_DefaultExceptionHandler);
	signal(SIGINT, Sys_DefaultExceptionHandler);

	if (fptest_temp >= 0.0)
		fptest_temp += 0.1;

	Sys_ParseEarlyArgs(argc, argv);
	Sys_DetectLFN();
	Sys_DetectWin95 ();
	Sys_PageInProgram ();

	_crt0_startup_flags &= ~_CRT0_FLAG_UNIX_SBRK; /* FS: We walked through all the data, now remove the sbrk flag so Win9x doesn't barf. */

	Sys_Init();

	Qcommon_Init (argc, argv);

	oldtime = Sys_Milliseconds ();

	if (!dedicated || !dedicated->value)
	{
		dos_registerintr(9, TrapKey);
	}

    /* main window message loop */
	while (1)
	{
		do
		{
			newtime = Sys_Milliseconds ();
			time = newtime - oldtime;
		}
		while (time < 1);

		Qcommon_Frame (time);
		oldtime = newtime;
	}
}
Esempio n. 13
0
/**
 * @brief This is the function that is called directly from main()
 * @sa main
 * @sa Qcommon_Init
 * @sa Qcommon_Shutdown
 * @sa SV_Frame
 * @sa CL_Frame
 */
void Qcommon_Frame (void)
{
	try {
		/* If the next event is due... */
		ScheduleEventPtr event = Dequeue_Event(Sys_Milliseconds());
		if (event) {
			/* Dispatch the event */
			event->func(event->when, event->data);
		}
	} catch (comRestart_t const& restart) {
		SV_Shutdown("Restart.", false);
		CL_Shutdown();
		Qcommon_Shutdown();
		CL_FilterEventQueue(&Event_FilterAll);
		if (restart.gamedir != nullptr) {
			const char* restartArgv[] = {"", "+set", "fs_gamedir", restart.gamedir};
			Qcommon_Init(4, const_cast<char** >(restartArgv));
		} else {
			Qcommon_Init(0, nullptr);
		}
	} catch (comDrop_t const&) {
		return;
	}

	/* Now we spend time_to_next milliseconds working on whatever
	 * IO is ready (but always try at least once, to make sure IO
	 * doesn't stall) */
	int time_to_next;
	do {
		time_to_next = !eventQueue.empty() ? (eventQueue.begin()->get()->when - Sys_Milliseconds()) : 1000;
		if (time_to_next < 0)
			time_to_next = 0;

		NET_Wait(time_to_next);
	} while (time_to_next > 0);
}
Esempio n. 14
0
int main( int argc, char **argv )
{
	unsigned int oldtime, newtime, time;

	InitSig();

#if defined ( __MACOSX__ ) && !defined (DEDICATED_ONLY)
	char resourcesPath[MAXPATHLEN];
	CFURLGetFileSystemRepresentation(CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()), 1, (UInt8 *)resourcesPath, MAXPATHLEN);
	chdir(resourcesPath);
	
	SDL_Init( SDL_INIT_VIDEO );
#endif

	Qcommon_Init( argc, argv );

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

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

	oldtime = Sys_Milliseconds();
	while( true )
	{
		// find time spent rendering last frame
		do
		{
			newtime = Sys_Milliseconds();
			time = newtime - oldtime;
			if( time > 0 )
				break;
#ifdef PUTCPU2SLEEP
			Sys_Sleep( 0 );
#endif
		}
		while( 1 );
		oldtime = newtime;

		Qcommon_Frame( time );
	}
#if defined ( __MACOSX__ ) && !defined (DEDICATED_ONLY)
	SDL_Quit();
#endif
}
Esempio n. 15
0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
	global_hInstance = hInstance;

	Sys_ConsoleInit();

	/* always change to the current working dir */
	FixWorkingDirectory();

	Qcommon_Init(__argc, __argv);

	/* main window message loop */
	while (1)
		Qcommon_Frame();

	/* never gets here */
	return FALSE;
}
Esempio n. 16
0
int main( int argc, char **argv )
{
	unsigned int oldtime, newtime, time;

	InitSig();

#if defined ( __MACOSX__ ) && !defined (DEDICATED_ONLY)
	SDL_Init( 0 );
	SDL_EnableUNICODE( SDL_ENABLE );
#endif

	Qcommon_Init( argc, argv );

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

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

	oldtime = Sys_Milliseconds();
	while( qtrue )
	{
		// find time spent rendering last frame
		do
		{
			newtime = Sys_Milliseconds();
			time = newtime - oldtime;
			if( time > 0 )
				break;
#ifdef PUTCPU2SLEEP
			Sys_Sleep( 0 );
#endif
		}
		while( 1 );
		oldtime = newtime;

		Qcommon_Frame( time );
	}
#if defined ( __MACOSX__ ) && !defined (DEDICATED_ONLY)
	SDL_Quit();
#endif
}
Esempio n. 17
0
int main (int argc, char **argv)
{
	int 	time, oldtime, newtime;

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

	printf ("\n");	
	printf ("========= Initialization =================\n");
	printf ("KMQuake2 -- Version 0.20\n");
	printf ("Linux Port by QuDos\n");
	printf ("http://qudos.quakedev.com/\n");
	printf ("Compiled: "__DATE__" -- "__TIME__"\n");
	printf ("==========================================\n\n");	

	Qcommon_Init(argc, argv);

	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 II -- Version %0.3f\n", KMQUAKE2_VERSION);
	}

    oldtime = Sys_Milliseconds ();
    while (1)
    {
// find time spent rendering last frame
		do {
			newtime = Sys_Milliseconds ();
			time = newtime - oldtime;
		} while (time < 1);
        Qcommon_Frame (time);
		oldtime = newtime;
    }

}
Esempio n. 18
0
int main( int argc, char **argv )
{
    unsigned int oldtime, newtime, time;

#if defined( __APPLE__ ) && !defined( DEDICATED_ONLY )
    char resourcesPath[MAXPATHLEN];
    CFURLGetFileSystemRepresentation( CFBundleCopyResourcesDirectoryURL( CFBundleGetMainBundle() ), 1, (UInt8 *)resourcesPath, MAXPATHLEN );
    chdir( resourcesPath );
#endif

#if defined( __WIN32__ )
#if defined( _DEBUG )
    SDL_SetHint( SDL_HINT_ALLOW_TOPMOST, "0" );
#endif
#endif

    SDL_Init( SDL_INIT_VIDEO );

    Qcommon_Init( argc, argv );

    oldtime = Sys_Milliseconds();
    while( true ) {
        // find time spent rendering last frame
        do {
            newtime = Sys_Milliseconds();
            time = newtime - oldtime;
            if( time > 0 )
                break;
            Sys_Sleep( 0 );
        } while( 1 );
        oldtime = newtime;

        Qcommon_Frame( time );
    }

    SDL_Quit();
}
Esempio n. 19
0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	/* previous instances do not exist in Win32 */
	if (hPrevInstance)
		return 0;

	global_hInstance = hInstance;

	ParseCommandLine(lpCmdLine);

	Sys_ConsoleInit();

	/* always change to the current working dir */
	FixWorkingDirectory();

	Qcommon_Init(argc, argv);

	/* main window message loop */
	while (1)
		Qcommon_Frame();

	/* never gets here */
	return FALSE;
}
Esempio n. 20
0
/*
 * Windows main function. Containts the
 * initialization code and the main loop
 */
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  MSG msg;
  long long oldtime, newtime;

  /* Previous instances do not exist in Win32 */
  if (hPrevInstance) {
    return 0;
  }

  /* Make the current instance global */
  global_hInstance = hInstance;

  /* Setup FPU if necessary */
  Sys_SetupFPU();

  /* Force DPI awareness */
  Sys_SetHighDPIMode();

  /* Parse the command line arguments */
  ParseCommandLine(lpCmdLine);

  /* Are we portable? */
  for (int i = 0; i < argc; i++) {
    if (strcmp(argv[i], "-portable") == 0) {
      is_portable = true;
    }
  }

/* Need to redirect stdout before anything happens. */
#ifndef DEDICATED_ONLY
  Sys_RedirectStdout();
#endif

  /* Seed PRNG */
  randk_seed();

  /* Call the initialization code */
  Qcommon_Init(argc, argv);

  /* Save our time */
  oldtime = Sys_Microseconds();

  /* The legendary main loop */
  while (1) {
    /* If at a full screen console, don't update unless needed */
    if (Minimized || (dedicated && dedicated->value)) {
      Sleep(1);
    }

    while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
      if (!GetMessage(&msg, NULL, 0, 0)) {
        Com_Quit();
      }

      sys_msg_time = msg.time;
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }

    // Throttle the game a little bit
    Sys_Nanosleep(5000);

    newtime = Sys_Microseconds();
    Qcommon_Frame(newtime - oldtime);
    oldtime = newtime;
  }

  /* never gets here */
  return TRUE;
}
Esempio n. 21
0
/*
 * Windows main function. Containts the
 * initialization code and the main loop
 */
int WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
		LPSTR lpCmdLine, int nCmdShow)
{
	MSG msg;
	long long oldtime, newtime;

	/* Previous instances do not exist in Win32 */
	if (hPrevInstance)
	{
		return 0;
	}

	/* Make the current instance global */
	global_hInstance = hInstance;

	/* Setup FPU if necessary */
	Sys_SetupFPU();

	/* Force DPI awareness */
	Sys_SetHighDPIMode();

	/* Parse the command line arguments */
	ParseCommandLine(lpCmdLine);

	/* Are we portable? */
	for (int i = 0; i < argc; i++) {
		if (strcmp(argv[i], "-portable") == 0) {
			is_portable = true;
		}
	}

	/* Need to redirect stdout before anything happens. */
#ifndef DEDICATED_ONLY
	Sys_RedirectStdout();
#endif

	printf("Yamagi Quake II v%s\n", YQ2VERSION);
	printf("=====================\n\n");

#ifndef DEDICATED_ONLY
	printf("Client build options:\n");
#ifdef SDL2
	printf(" + SDL2\n");
#else
	printf(" - SDL2 (using 1.2)\n");
#endif
#ifdef CDA
	printf(" + CD audio\n");
#else
	printf(" - CD audio\n");
#endif
#ifdef OGG
	printf(" + OGG/Vorbis\n");
#else
	printf(" - OGG/Vorbis\n");
#endif
#ifdef USE_OPENAL
	printf(" + OpenAL audio\n");
#else
	printf(" - OpenAL audio\n");
#endif
#ifdef ZIP
	printf(" + Zip file support\n");
#else
	printf(" - Zip file support\n");
#endif
#endif

	printf("Platform: %s\n", YQ2OSTYPE);
	printf("Architecture: %s\n", YQ2ARCH);


	/* Seed PRNG */
	randk_seed();

	/* Call the initialization code */
	Qcommon_Init(argc, argv);

	/* Save our time */
	oldtime = Sys_Microseconds();

	/* The legendary main loop */
	while (1)
	{
		/* If at a full screen console, don't update unless needed */
		if (Minimized || (dedicated && dedicated->value))
		{
			Sleep(1);
		}

		while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
		{
			if (!GetMessage(&msg, NULL, 0, 0))
			{
				Com_Quit();
			}

			sys_msg_time = msg.time;
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		// Throttle the game a little bit
		Sys_Nanosleep(5000);

		newtime = Sys_Microseconds();
		Qcommon_Frame(newtime - oldtime);
		oldtime = newtime;
	}

	/* never gets here */
	return TRUE;
}
Esempio n. 22
0
int main( int argc, char **argv )
{
#ifdef DEDICATED_ONLY
	int newargc;
	char **newargv;
	int i;
#endif
	int 	time, oldtime, newtime;
	sigset_t sigs;

#if defined(SOL8_XIL_WORKAROUND) && !defined(DEDICATED_ONLY)
	{
	  extern cinematics_t cin;

	  if( (xil_state = xil_open()) == NULL ) {
	    fprintf( stderr, "can't open XIL\n" );
	    exit( 1 );
	  }
	  memset( &cin, 0, sizeof( cin ) );
	}
#endif

	/*
	 * Save the contents of the DISPLAY environment variable.
	 * if we don't, it gets overwritten after reloading the
	 * renderer libraries.
	 */
	{
	  char *tmp_name = getenv( "DISPLAY" );
	  if( tmp_name == NULL ) {
	    display_name[ 0 ] = 0;
	  }
	  else {
	    strncpy( display_name, tmp_name, sizeof( display_name ) );
	  }
	}

	/* block the SIGPOLL signal so that only the audio thread gets it */
	sigemptyset( &sigs );
	sigaddset( &sigs, SIGPOLL );
	pthread_sigmask( SIG_BLOCK, &sigs, NULL );

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

	base_hrtime = gethrtime();

#ifdef DEDICATED_ONLY

	// force dedicated
	newargc = argc;
	newargv = malloc((argc + 3) * sizeof(char *));
	newargv[0] = argv[0];
	newargv[1] = "+set";
	newargv[2] = "dedicated";
	newargv[3] = "1";
	for (i = 1; i < argc; i++)
		newargv[i + 3] = argv[i];
	newargc += 3;

	Qcommon_Init(newargc, newargv);
#else
	Qcommon_Init(argc, argv);
#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 ("Solaris Quake 2 -- Version %0.3f\n", SOLARIS_VERSION);
	}

    oldtime = Sys_Milliseconds ();
    while (1)
    {
// find time spent rendering last frame
		do {
			newtime = Sys_Milliseconds ();
			time = newtime - oldtime;
		} while (time < 1);
        Qcommon_Frame (time);
		oldtime = newtime;
    }

}
Esempio n. 23
0
int main (int argc, char **argv)
{
#if WRITE_LOG
	FILE *log = NULL;
#endif
	u32 ticks_per_s;
	int oldtime;

	SetupCallbacks();

#if WRITE_LOG
	// Wipe log file.
	log = fopen("log.txt", "w");
	if (log != NULL)
	{
		fputs("LOG START\n\n", log);
		fclose(log);
		log = NULL;
	}
#endif

	// Calculate the clock resolution.
	sceRtcGetCurrentTick(&first_ticks);
	ticks_per_s = sceRtcGetTickResolution();
	ticks_per_ms = ticks_per_s / 1000.0;

	// TODO Move elsewhere.
	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);

	// Initialise Quake.
	Qcommon_Init (argc, argv);

	oldtime = Sys_Milliseconds();

	// Run the main loop.
	while (go)
	{
		SceCtrlData pad;

		curtime = Sys_Milliseconds();
		sys_frame_time = curtime;

		if (curtime < oldtime)
		{
			Sys_Error("curtime (%d) < oldtime (%d)\n", curtime, oldtime);
		}

		sceCtrlPeekBufferPositive(&pad, 1);
		if (pad.Buttons & PSP_CTRL_CROSS)
		{
			go = false;
		}

		if (curtime != oldtime)
		{
			Qcommon_Frame(curtime - oldtime);

			oldtime = curtime;
		}
	}

	sceKernelExitGame();

	return 0;
}
Esempio n. 24
0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    MSG				msg;
	unsigned int	time, oldtime, newtime;
//	char			*cddir;

    /* previous instances do not exist in Win32 */
    if (hPrevInstance)
        return 0;

	global_hInstance = hInstance;

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

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

	ParseCommandLine (lpCmdLine);

	FixWorkingDirectory ();

	// if we find the CD, add a +set cddir xxx command line
#if 0
	cddir = Sys_ScanForCD ();
	if (cddir && argc < MAX_NUM_ARGVS - 3)
	{
		int		i;

		// don't override a cddir on the command line
		for (i=0 ; i<argc ; i++)
			if (!strcmp(argv[i], "cddir"))
				break;
		if (i == argc)
		{
			argv[argc++] = "+set";
			argv[argc++] = "cddir";
			argv[argc++] = cddir;
		}
	}
#endif
	#ifdef USE_DBGHELP
#ifdef _MSC_VER
	__try {
#else
	__try1( Sys_ExceptionHandler );
#endif
#endif /* USE_DBGHELP */
	Qcommon_Init (argc, argv);
	oldtime = Sys_Milliseconds ();

	//Com_Error (ERR_FATAL, "Testing");

	if (dedicated->integer) {
		Sys_ShowConsole(1, false);
	}
	else if(!win_consolelogging->integer) {
		qDedConsole = false;
		Sys_DestroyConsole();
	}


	//_controlfp( _PC_24, _MCW_PC );

    /* main window message loop */
	while (1)
	{
		// if at a full screen console, don't update unless needed
		if (!ActiveApp || dedicated->integer)
			Sleep (3);

		while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) {
			sys_msg_time = msg.time;
			TranslateMessage(&msg);
   			DispatchMessage(&msg);
		}

		do
		{
			newtime = Sys_Milliseconds ();
			time = newtime - oldtime;
		} while (time < 1);

		_controlfp( _PC_24, _MCW_PC );
		Qcommon_Frame( time );

		oldtime = newtime;
	}
#ifdef USE_DBGHELP
#ifdef _MSC_VER
	} __except( Sys_ExceptionHandler( GetExceptionCode(), GetExceptionInformation() ) ) {
		return 1;
	}
#else
	__except1;
#endif
#endif /* USE_DBGHELP */
	// never gets here
    return 0;
}
Esempio n. 25
0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	MSG			msg;
	double				time, oldtime, newtime;
	char			*cddir;

    /* previous instances do not exist in Win32 */
    if (hPrevInstance)
        return 0;

	global_hInstance = hInstance;

	ParseCommandLine (lpCmdLine);

	// if we find the CD, add a +set cddir xxx command line
	cddir = Sys_ScanForCD ();
	if (cddir && argc < MAX_NUM_ARGVS - 3)
	{
		int		i;

		// don't override a cddir on the command line
		for (i=0 ; i<argc ; i++)
			if (!strcmp(argv[i], "cddir"))
				break;
		if (i == argc)
		{
			argv[argc++] = "+set";
			argv[argc++] = "cddir";
			argv[argc++] = cddir;
		}
	}

	Detect_WinNT();
	Qcommon_Init (argc, argv);
	oldtime = Sys_Milliseconds ();

    /* main window message loop */
	while (1)
	{
		// if at a full screen console, don't update unless needed
		if (Minimized || (dedicated && dedicated->value) )
		{
			Sleep (1);
		}

		while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
		{
			if (!GetMessage (&msg, NULL, 0, 0))
				Com_Quit ();
			sys_msg_time = (double)msg.time;
			TranslateMessage (&msg);
			DispatchMessage (&msg);
		}

		do
		{
			newtime = Sys_Milliseconds ();
			time = newtime - oldtime;
		} while (time < 1);
//			Con_Printf ("time:%5.2f - %5.2f = %5.2f\n", newtime, oldtime, time);

		//	_controlfp( ~( _EM_ZERODIVIDE /*| _EM_INVALID*/ ), _MCW_EM );
		_controlfp( _PC_24, _MCW_PC );
		Qcommon_Frame (time);

		oldtime = newtime;
	}

	// never gets here
    return TRUE;
}
Esempio n. 26
0
/*
 * Windows main function. Containts the
 * initialization code and the main loop
 */
int
main(int argc, char **argv)
{
	// Setup FPU if necessary.
	Sys_SetupFPU();

	// Force DPI awareness.
	Sys_SetHighDPIMode();

	// crappy argument parser can't parse.
	for (int i = 0; i < argc; i++)
	{
		// Are we portable?
		if (strcmp(argv[i], "-portable") == 0)
		{
			is_portable = true;
		}

		// Inject a custom data dir.
		if (strcmp(argv[i], "-datadir") == 0)
		{
			// Mkay, did the user give us an argument?
			if (i != (argc - 1))
			{
				DWORD attrib;
				WCHAR wpath[MAX_OSPATH];

				MultiByteToWideChar(CP_UTF8, 0, argv[i + 1], -1, wpath, MAX_OSPATH);
				attrib = GetFileAttributesW(wpath);

				if (attrib != INVALID_FILE_ATTRIBUTES)
				{
					if (!(attrib & FILE_ATTRIBUTE_DIRECTORY))
					{
						printf("-datadir %s is not a directory\n", argv[i + 1]);
						return 1;
					}

					Q_strlcpy(datadir, argv[i + 1], MAX_OSPATH);
				}
				else
				{
					printf("-datadir %s could not be found\n", argv[i + 1]);
					return 1;
				}
			}
			else
			{
				printf("-datadir needs an argument\n");
				return 1;
			}
		}
	}

	// Need to redirect stdout before anything happens.
#ifndef DEDICATED_ONLY
	Sys_RedirectStdout();
#endif

	// Call the initialization code.
	// Never returns.
	Qcommon_Init(argc, argv);

	return 0;
}