Ejemplo n.º 1
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 ();
    }
}
Ejemplo n.º 2
0
void init( void ) {

	valuetx1 = valuetx2 = valuetx3 = 0;
	Lin_Init(NULL);
	Lin_InitChannel(LIN_CTRL_A, &LinChannelConfigData[0]);
	LinIf_Init(NULL);
	PduR_Init(&PduR_Config);
	LinSM_Init(NULL);
	Com_Init(&ComConfiguration);
	LinSM_RequestComMode(0,COMM_FULL_COMMUNICATION);
	LinSM_ScheduleRequest(0,1);
	TerminateTask();

}
Ejemplo n.º 3
0
/**
 * @brief The entry point of the program.
 */
int32_t main(int32_t argc, char *argv[]) {
	static uint32_t old_time;
	uint32_t msec;

	printf("Quetoo %s %s %s\n", VERSION, __DATE__, BUILD_HOST);

	memset(&quetoo, 0, sizeof(quetoo));

	quetoo.Init = Init;
	quetoo.Shutdown = Shutdown;

	signal(SIGINT, Sys_Signal);
	signal(SIGILL, Sys_Signal);
	signal(SIGABRT, Sys_Signal);
	signal(SIGFPE, Sys_Signal);
	signal(SIGSEGV, Sys_Signal);
	signal(SIGTERM, Sys_Signal);
#ifndef _WIN32
	signal(SIGHUP, Sys_Signal);
	signal(SIGQUIT, Sys_Signal);
#endif

	Com_Init(argc, argv); // let's get it started in here

	jmp_set = true;

	while (true) { // this is our main loop

		if (setjmp(env)) { // an ERROR_DROP was thrown
			Com_Warn("Error detected, recovering..\n");
			continue;
		}

		if (time_scale->modified) {
			time_scale->modified = false;
			time_scale->value = Clamp(time_scale->value, 0.1, 3.0);
		}

		do {
			quetoo.ticks = SDL_GetTicks();
			msec = (quetoo.ticks - old_time) * time_scale->value;
		} while (msec < 1);

		Frame(msec);

		old_time = quetoo.ticks;
	}

	return 0;
}
Ejemplo n.º 4
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 ();
    }
}
Ejemplo n.º 5
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 ();
    }
}
Ejemplo n.º 6
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 ();
    }
}
Ejemplo n.º 7
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( );
	}
}
Ejemplo n.º 8
0
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;
}
Ejemplo n.º 9
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( );
	}
}
Ejemplo n.º 10
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;
}
Ejemplo n.º 11
0
void PortableInit(int argc,const char ** argv){

	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 = (char*)malloc( len );
	*cmdline = 0;
	for ( i = 1; i < argc; i++ )
	{
		if ( i > 1 ) {
			strcat( cmdline, " " );
		}
		strcat( cmdline, argv[i] );
	}
	Com_Init(cmdline);

	NET_Init();

	srand (time(NULL));


}
Ejemplo n.º 12
0
void PrepareGame(void)
{

    // 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();

    Com_Init("");
    NET_Init();

    //_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 );
    }
}
Ejemplo n.º 13
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
}
void EcuM_AL_DriverInitTwo(const EcuM_ConfigType* ConfigPtr)
{
	(void)ConfigPtr;

#if defined(USE_SPI)
	// Setup SPI
	Spi_Init(ConfigPtr->SpiConfig);
#endif

#if defined(USE_EEP)
	// Setup EEP
	NO_DRIVER(Eep_Init(ConfigPtr->EepConfig));
#endif

#if defined(USE_FLS)
	// Setup Flash
	NO_DRIVER(Fls_Init(ConfigPtr->FlashConfig));
#endif

#if defined(USE_FEE)
	// Setup FEE
	NO_DRIVER(Fee_Init());
#endif

#if defined(USE_EA)
	// Setup EA
	NO_DRIVER(Ea_Init());
#endif

#if defined(USE_NVM)
	// Setup NVRAM Manager and start the read all job
	NO_DRIVER(NvM_Init());
	NO_DRIVER(NvM_ReadAll());
#endif


#if defined(USE_LIN)
    // Setup Lin driver
	Lin_Init(ConfigPtr->LinConfig);
#endif

#if defined(USE_LINIF)
    // Setup LinIf
	LinIf_Init(ConfigPtr->LinIfConfig);
#endif

#if defined(USE_LINSM)
    // Setup LinSM
	LinSM_Init(ConfigPtr->LinSMConfig);
#endif

	// Setup CAN tranceiver
	// NOTE: Add when adding supoprt for CanTranceiver

#if defined(USE_CAN)
	// Setup Can driver
	Can_Init(ConfigPtr->CanConfig);
#endif

#if defined(USE_CANIF)
	// Setup CanIf
	NO_DRIVER(CanIf_Init(ConfigPtr->PostBuildConfig->CanIf_ConfigPtr));
#endif

#if defined(USE_CANTP)
	// Setup CAN TP
	NO_DRIVER(CanTp_Init(ConfigPtr->PostBuildConfig->CanTp_ConfigPtr));
#endif

#if defined(USE_CANSM)
	NO_DRIVER(CanSM_Init(ConfigPtr->CanSMConfig));
#endif

#if defined(USE_J1939TP)
	// Setup J1939Tp
	NO_DRIVER(J1939Tp_Init(ConfigPtr->J1939TpConfig));
#endif

#if defined(USE_PDUR)
	// Setup PDU Router
	NO_DRIVER(PduR_Init(ConfigPtr->PostBuildConfig->PduR_ConfigPtr));
#endif

#if defined(USE_CANNM)
    // Setup Can Network Manager
	NO_DRIVER(CanNm_Init(ConfigPtr->PostBuildConfig->CanNm_ConfigPtr));
#endif

#if defined(USE_UDPNM)
        // Setup Udp Network Manager
	NO_DRIVER(UdpNm_Init(ConfigPtr->UdpNmConfig));
#endif

#if defined(USE_NM)
        // Setup Network Management Interface
	NO_DRIVER(Nm_Init());
#endif

#if defined(USE_COM)
	// Setup COM layer
	NO_DRIVER(Com_Init(ConfigPtr->PostBuildConfig->ComConfigurationPtr));
#endif

#if defined(USE_DCM)
	// Setup DCM
	NO_DRIVER(Dcm_Init(ConfigPtr->DcmConfig));
#endif

#if defined(USE_IOHWAB)
	// Setup IO hardware abstraction layer
	IoHwAb_Init();
#endif

#if defined(USE_XCP)
	// Setup XCP
	NO_DRIVER(Xcp_Init(ConfigPtr->XcpConfig));
#endif

}
Ejemplo n.º 15
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
}
Ejemplo n.º 16
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	char commandLine[MAX_STRING_CHARS] = { 0 };
	char cwd[MAX_OSPATH];
	// should never get a previous instance in Win32
	if (hPrevInstance)
	{
		return EXIT_FAILURE;
	}

#ifdef EXCEPTION_HANDLER
	WinSetExceptionVersion(Q3_VERSION);
#endif

	g_wv.hInstance = hInstance;

#if 1
	commandLine[0] = '\0';
	Sys_ParseArgs(__argc, __argv);
	Sys_BuildCommandLine(__argc, __argv, commandLine, sizeof(commandLine));
#else
	Q_strncpyz(commandLine, lpCmdLine, sizeof(commandLine));
#endif

#ifndef DEDICATED
	Sys_SetProcessProperties();

	//show the splash screen
	Sys_Splash(qtrue);
#endif

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

#ifdef DEDICATED
	Sys_ShowConsoleWindow(1, qtrue);
#endif

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

	// get the initial time base
	Sys_Milliseconds();
	Com_Init(commandLine);
	NET_Init();

	Sys_Splash(qfalse);

	_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
#ifndef LEGACY_DEBUG
	if (!com_dedicated->integer && !com_viewlog->integer)
	{
		Sys_ShowConsoleWindow(0, qfalse);
	}
#endif

	// main game loop
	Sys_GameLoop();

	// never gets here
	return EXIT_SUCCESS;
}
Ejemplo n.º 17
0
/*
 * @brief
 */
int32_t main(int32_t argc, char **argv) {
	struct sockaddr_in address, from;
	struct timeval delay;
	socklen_t from_len;
	fd_set set;
	char buffer[16384];

	printf("Quake2World Master Server %s %s %s\n", VERSION, __DATE__, BUILD_HOST);

	memset(&quake2world, 0, sizeof(quake2world));

	quake2world.Init = Init;
	quake2world.Shutdown = Shutdown;

	signal(SIGHUP, Sys_Signal);
	signal(SIGINT, Sys_Signal);
	signal(SIGQUIT, Sys_Signal);
	signal(SIGILL, Sys_Signal);
	signal(SIGTRAP, Sys_Signal);
	signal(SIGFPE, Sys_Signal);
	signal(SIGSEGV, Sys_Signal);
	signal(SIGTERM, Sys_Signal);

	Com_Init(argc, argv);

	ms_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);

	memset(&address, 0, sizeof(address));

	address.sin_family = AF_INET;
	address.sin_port = htons(PORT_MASTER);
	address.sin_addr.s_addr = INADDR_ANY;

	if ((bind(ms_sock, (struct sockaddr *) &address, sizeof(address))) == -1) {
		Com_Print("Failed to bind port %i\n", PORT_MASTER);
		return 1;
	}

	Com_Print("Listening on %i\n", PORT_MASTER);

	while (true) {
		FD_ZERO(&set);
		FD_SET(ms_sock, &set);

		memset(&delay, 0, sizeof(struct timeval));
		delay.tv_sec = 1;
		delay.tv_usec = 0;

		if (select(ms_sock + 1, &set, NULL, NULL, &delay) > 0) {
			if (FD_ISSET(ms_sock, &set)) {

				from_len = sizeof(from);
				memset(buffer, 0, sizeof(buffer));

				const ssize_t len = recvfrom(ms_sock, buffer, sizeof(buffer), 0,
						(struct sockaddr *) &from, &from_len);

				if (len > 0) {
					if (len > 4)
						Ms_ParseMessage(&from, buffer);
					else
						Com_Print("Invalid packet from %s:%d\n", inet_ntoa(from.sin_addr),
								ntohs(from.sin_port));
				} else {
					Com_Print("Socket error from %s:%d (%s)\n", inet_ntoa(from.sin_addr),
							ntohs(from.sin_port), strerror(errno));
				}
			}
		}

		Ms_RunFrame();
	}
}
Ejemplo n.º 18
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;
}
Ejemplo n.º 19
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;
}
Ejemplo n.º 20
0
void EcuM_Callout_DriverInitListTwo(void)
{
  /* status of NvM initialization */
  NvM_RequestResultType Result;
  BswM_Init(BswM_ConfigPtr);
  
  
  Fls_Init(NULL_PTR);
#ifdef BASE_EA_ENABLED
  EA_INIT_FUNC();
#endif
#ifdef BASE_FEE_ENABLED
  FEE_INIT_FUNC();
  
  /* wait for FEE to complete the init sequence */
  do
  {
    Fee_MainFunction();
    Fls_MainFunction();
  }
  while (MEMIF_IDLE != Fee_GetStatus());

#endif
#ifdef BASE_NVM_ENABLED
  NVM_INIT_FUNC();
  NvM_ReadAll();
  
  /* wait for the NvM_ReadAll() to complete - some of the remaining
     modules need valid NvRam data...       */
  do
  {
    NvM_MainFunction();
    Fee_MainFunction();
    Fls_MainFunction();

    (void)NvM_GetErrorStatus(NvMConf_NvMBlockDescriptor_NvMBlock_ConfigID, &Result);
  }
  while (Result == NVM_REQ_PENDING);

#endif
  LinEmuUart_Init();
  
  Can_InitMemory();
  Can_Init(&CanConfigSet);

  CanIf_InitMemory();
  CanIf_Init(&CanIf_Config);
  //CanNm_Init(&CanNmGlobalConfig);
  //Nm_Init(&Nm_Configuration0);
  PduR_InitMemory();
  PduR_Init(&PduRGlobalConfig);
  Com_InitMemory();
  Com_Init(&ComConfig);
  CanSM_InitMemory();
  CanSM_Init();
  CanTp_InitMemory();
  CanTp_Init();  
  ComM_InitMemory();
  ComM_Init(&ComMConfig);
  Xcp_Init(NULL);
  FiM_Init(&FiM_Config_0);
  DiagMeas_Init();
  DiagCtrl_Init();
  SCI_B6Bridge_Init();
    SCI_Pfc_Init();
  SCI_IOHW_Init();
  
#ifdef BASE_DEM_ENABLED
  DEM_INIT_FUNC();
  /* start the standard operation cycle */
  /* (void) Dem_SetOperationCycleState(DEM_OPCYC_POWER, DEM_CYCLE_STATE_START); */
#endif  
  Dcm_Init();
}
Ejemplo n.º 21
0
int main ( int argc, char* argv[] )
{
  // 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();

  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

#ifdef _PANDORA_
#ifndef DEDICATED

	if(!x11)
		PND_Setup_Controls();
#endif
#endif

	while (1)
	{
#ifdef __linux__
		Sys_ConfigureFPU();
#endif
		Com_Frame ();
	}

#ifdef _PANDORA_
#ifndef DEDICATED
	if(!x11)
		PND_Close_Controls();
#endif
#endif
}
Ejemplo n.º 22
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;
}
Ejemplo n.º 23
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 ();
	}
}
Ejemplo n.º 24
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();
	}
}
Ejemplo n.º 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;
}
Ejemplo n.º 26
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;
}
Ejemplo n.º 27
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;
}
Ejemplo n.º 28
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;
}
Ejemplo n.º 29
0
/*
=================
main
=================
*/
int main(int argc, char **argv)
{
	char commandLine[MAX_STRING_CHARS] = { 0 };

	Sys_PlatformInit();

	// Set the initial time base
	Sys_Milliseconds();

#ifdef __APPLE__
	// 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);

#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
	Sys_BuildCommandLine(argc, argv, commandLine, sizeof(commandLine));

	Com_Init(commandLine);
	NET_Init();

	Sys_SetUpConsoleAndSignals();

	Sys_GameLoop();

	return 0;
}
Ejemplo n.º 30
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;
}