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

}
Exemple #2
0
void rvlInitFat()
{
	// temporary init video, pad, console
	VIDEO_Init();
	WPAD_Init();
	rmode = VIDEO_GetPreferredMode(NULL);
	xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	CON_Init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
	// loop until either Home has been pressed, or an SD card has been found
	while(!fatInitDefault()) {
		WPAD_ScanPads();
		printf("\x1b[2;0HFAT initialization error!");
		printf("\x1b[3;0HPlease insert a SD card to continue or press Home to exit!");
		u32 pressed = WPAD_ButtonsDown(0);
		if(pressed & WPAD_BUTTON_HOME) {
			printf("\x1b[5;0HExiting...");
			exit(0);
		}
		VIDEO_WaitVSync();
	}
	printf("\x1b[2;0H");
	// set the app path
	strcpy(program.apppath, "sd:/apps/wii_azunyan8");
}
Console::Console(const std::string& font, Renderer& r)
{
    const auto screen = GetSdlSurface(r);

    mSdlConsole = CON_Init(font.c_str(), screen, LINE_COUNT,
                             { 0, 0,
                               static_cast<Uint16>(screen->w),
                               static_cast<Uint16>(screen->h * .75f) });
    if (!mSdlConsole) {
        throw "Unable to create console.";
    }

    CON_Alpha(mSdlConsole, ALPHA_LEVEL);
    CON_Topmost(mSdlConsole);

    CON_SetPrompt(mSdlConsole, "> ");
    CON_SetHideKey(mSdlConsole, SDLK_BACKQUOTE);

    CON_SetExecuteFunction(mSdlConsole, ConsoleCmdHandler);
    CON_SetTabCompletion(mSdlConsole, ConsoleTabHandler);

    r.RegisterPostRenderHook([&](void*){ CON_DrawConsole(mSdlConsole); });

    gConsoleMap[mSdlConsole] = this;
}
Exemple #4
0
int main(int argc, char **argv)
{
    //DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
    s8 ios_patched = 0;
    s32 ret = 0;

    CheckForGecko();
    VIDEO_Init();

    vmode = VIDEO_GetPreferredMode(NULL);
    xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));

    VIDEO_Configure(vmode);
    VIDEO_SetNextFramebuffer(xfb);
    VIDEO_SetBlack(false);
    VIDEO_Flush();

    VIDEO_WaitVSync();
    if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();

    int x = 20, y = 20, w, h;
    w = vmode->fbWidth - (x * 2);
    h = vmode->xfbHeight - (y + 20);

    // Initialize the console
    //Con_InitEX works better but for some odd reason doesn't show right when clearing screen...
    //CON_InitEx(vmode, x, y, w, h);
    CON_Init(xfb,x,y,w,h, vmode->fbWidth*VI_DISPLAY_PIX_SZ );
    printf("\n\n\n");
    VIDEO_ClearFrameBuffer(vmode, xfb, COLOR_BLACK);

    gprintf("resolution is %dx%d\n",vmode->viWidth,vmode->viHeight);
    //printf("\x1b[2J");
    /*sleep(3);
    gprintf("crashing...\n");
    free((void*)0x1);*/
    /*free((void*)0x1);
    free((void*)0x1);
    free((void*)0x1);
    memcpy((void*)0x0,(void*)0x1,5);*/
    //return 0;
    //reload ios so that IF the user started this with AHBPROT we lose everything from HBC. also, IOS36 is the most patched ios :')
    IOS_ReloadIOS(36);

    WPAD_Init();
    PAD_Init();

    printf("\nIOS %d rev %d\n\n",IOS_GetVersion(),IOS_GetRevision());
    if( (VERSION&0xFF) % 10 == 0 )
    {
#if BETAVERSION > 0
        printf("Priiloader v%d.%db%d(r0x%08x) Installation/Removal Tool\n\n\n\n\t",VERSION>>8, (VERSION&0xFF) / 10,BETAVERSION,GIT_REV);
#else
        printf("\t\tPriiloader v%d.%d(r0x%08x) Installation / Removal Tool\n\n\n\n\t",VERSION>>8, (VERSION&0xFF) / 10,GIT_REV);
#endif
    }
Exemple #5
0
void con_init_real(void)
{
    Console = CON_Init(SMALL_FONT, grdCurScreen, CON_NUM_LINES, 0, 0, SWIDTH, SHEIGHT / 2);

    Assert(Console);
    CON_SetExecuteFunction(Console, con_parse);
    con_background(CON_BG);
    con_initialized = 1;
    atexit(con_free);
}
ConsoleInformation*
RC_ConsoleInit(const char *font_name, SDL_Surface *display_screen, int lines, SDL_Rect rect)
{
    ConsoleInformation *ci = CON_Init(font_name, display_screen, lines, rect);
    CON_Position(ci, 0, 0);
    CON_Alpha(ci, 160);
    CON_Topmost(ci);
    CON_SetPrompt(ci, "-->");
    CON_SetHideKey(ci, 96 /*tilde*/);
    return ci;
}
Exemple #7
0
void Sys_SetUpConsoleAndSignals(void)
{
#ifndef USE_WINDOWS_CONSOLE
#ifdef FEATURE_CURSES
	if (nocurses)
	{
		CON_Init_tty();
	}
	else
	{
		CON_Init();
	}
#else
	CON_Init();
#endif
#endif

	signal(SIGILL, Sys_SigHandler);
	signal(SIGFPE, Sys_SigHandler);
	signal(SIGSEGV, Sys_SigHandler);
	signal(SIGTERM, Sys_SigHandler);
	signal(SIGINT, Sys_SigHandler);
}
int main(int argc, char **argv) {
	void *xfb[2];
	u32 type;
	int fbi = 0;

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

	rmode = VIDEO_GetPreferredMode(NULL);

	// double buffering, prevents flickering (is it needed for LCD TV? i don't have one to test)
	xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
	xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));

	VIDEO_Configure(rmode);
	VIDEO_SetNextFramebuffer(xfb);
	VIDEO_SetBlack(FALSE);
	VIDEO_Flush();
	VIDEO_WaitVSync();
	if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();

	SYS_SetResetCallback(reload);
	SYS_SetPowerCallback(shutdown);

	WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR);
	WPAD_SetVRes(0, rmode->fbWidth, rmode->xfbHeight);

	while(!doreload && !dooff) {
		CON_Init(xfb[fbi],0,0,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
		//VIDEO_ClearFrameBuffer(rmode,xfb[fbi],COLOR_BLACK);
		std::cout<<"\n\n\n";
		WPAD_ReadPending(WPAD_CHAN_ALL, countevs);
		int wiimote_connection_status = WPAD_Probe(0, &type);
		print_wiimote_connection_status(wiimote_connection_status);

		std::cout<<"  Event count: "<<evctr<<"\n";
		if(wiimote_connection_status == WPAD_ERR_NONE) {
			print_and_draw_wiimote_data(xfb[fbi]);
		}
		VIDEO_SetNextFramebuffer(xfb[fbi]);
		VIDEO_Flush();
		VIDEO_WaitVSync();
		fbi ^= 1;
	}
	if(doreload) return 0;
	if(dooff) SYS_ResetSystem(SYS_SHUTDOWN,0,0);

	return 0;
}
Exemple #9
0
/*
==================
CON_Resize

The window has just been resized, move everything back into place
==================
*/
static void CON_Resize(void)
{
#ifndef _WIN32
	struct winsize winsz = {0, };

	ioctl(fileno(stdout), TIOCGWINSZ, &winsz);
	if (winsz.ws_col < 12 || winsz.ws_row < 5)
		return;
	resizeterm(winsz.ws_row + 1, winsz.ws_col + 1);
	resizeterm(winsz.ws_row, winsz.ws_col);
	delwin(logwin);
	delwin(borderwin);
	delwin(inputwin);
	delwin(scrollwin);
	erase();
	wnoutrefresh(stdscr);
	CON_Init();
#endif
}
Exemple #10
0
int main()
{
#if GEKKO
    VIDEO_Init();
#if HW_RVL
    WPAD_Init();
#endif
    PAD_Init();

    rmode = VIDEO_GetPreferredMode(nullptr);
    xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));

    CON_Init(xfb, 20, 20, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * VI_DISPLAY_PIX_SZ);
    CON_EnableGecko(CARD_SLOTB, true);

    VIDEO_Configure(rmode);
    VIDEO_SetBlack(false);

    VIDEO_Flush();

    VIDEO_WaitVSync();
    if (rmode->viTVMode & VI_NON_INTERLACE)
        VIDEO_WaitVSync();

    athena::io::MemoryCopyReader test("sd:/test.dat");
    while(true)
    {
#if HW_RVL
        WPAD_ScanPads();
#endif
        PAD_ScanPads();
        if (PAD_ButtonsDown(0) & PAD_BUTTON_START)
            break;

#if HW_RVL
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
            break;
#endif
        VIDEO_WaitVSync();
    }
#endif
    return 0;
}
Exemple #11
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;
}
Exemple #12
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;
}
Exemple #13
0
void CON_SigCont(int signum)
{
    CON_Init();
}
Exemple #14
0
/*
==================
CON_SigCont
Reinitialize console input after receiving SIGCONT, as on Linux the terminal seems to lose all
set attributes if user did CTRL+Z and then does fg again.
==================
*/
void CON_SigCont(int signum)
{
	void CON_Init( void );
	CON_Init();
}
Exemple #15
0
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)){
		sysmkdialog(DT_ERROR,
			va(
				"SDL version " MINSDL_VERSION
				" or greater is required, "
				"but only version %d.%d.%d was found.",
			ver->major, ver->minor,
			ver->patch), "SDL library too old");
		Sys_Exit(1);
	}
	syssetenv("SDL_DISABLE_LOCK_KEYS", "1");
#endif
	Sys_PlatformInit( );
	/* Set the initial time base */
	sysmillisecs( );
	Sys_ParseArgs(argc, argv);
	Sys_SetBinaryPath(sysdirname(argv[ 0 ]));
	syssetdefaultinstallpath(DEFAULT_BASEDIR);

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

	cominit(commandLine);
	netinit();
	CON_Init();

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

	for(;;){
		IN_Frame();
		comframe();
	}
	return 0;
}
Exemple #16
0
/*
=================
main
=================
*/
int main( int argc, char **argv )
{
	int   i;
	char  commandLine[ MAX_STRING_CHARS ] = { 0 };

	extern void Sys_LaunchAutoupdater(int argc, char **argv);
	Sys_LaunchAutoupdater(argc, argv);

#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
	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 );
	}

	SDL_EventState( SDL_DROPFILE, SDL_ENABLE );
#endif

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

	CON_Init( );
	Com_Init( commandLine );
	NET_Init( );

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

#if !defined DEDICATED && !defined __APPLE__ && !defined WIN32
	// HACK: Before SDL 2.0.4, Linux (X11) did not set numlock or capslock state
	//       so I made the engine always assumed num lock was on.
	// NOTE: The SDL mod state on X11 is not set at this point even when it's fixed
	//       and will be corrected regardless of what is done here,
	//       but limit to SDL 2.0.3 and earlier so that the message isn't shown.
	if( SDL_VERSIONNUM( ver.major, ver.minor, ver.patch ) < SDL_VERSIONNUM( 2, 0, 4 ) ) {
		if ( !( SDL_GetModState() & KMOD_NUM ) ) {
			Com_Printf("INFO: Forcing NUMLOCK modifier state to enabled (actual state unknown)!\n");
			SDL_SetModState( SDL_GetModState() | KMOD_NUM );
		}
	}
#endif

	while( 1 )
	{
		Com_Frame( );
	}

	return 0;
}
Exemple #17
0
/*
=================
main
=================
*/
int main( int argc, char **argv )
{
	int   i;
	char  commandLine[ MAX_STRING_CHARS ] = { 0 };
	qboolean useBacktrace;
	qboolean useConsoleOutput;
	qboolean useDpiAware;
	qboolean demoNameAsArg;
	qboolean gotFirstArg;

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

#ifdef _WIN32
	InitializeCriticalSection(&printCriticalSection);
#endif

#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;
	useConsoleOutput = qfalse;
	useDpiAware = qtrue;
	demoNameAsArg = qtrue;
	for (i = 1;  i < argc;  i++) {
		if (!strcmp(argv[i], "--nobacktrace")) {
			useBacktrace = qfalse;
		} else if (!strcmp(argv[i], "--console-output")) {
			useConsoleOutput = qtrue;
		} else if (!strcmp(argv[i], "--no-dpi-aware")) {
			useDpiAware = qfalse;
		} else if (!strcmp(argv[i], "--no-demo-arg")) {
			demoNameAsArg = qfalse;
		}
	}
	Sys_PlatformInit(useBacktrace, useConsoleOutput, useDpiAware);

	// 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
	gotFirstArg = qfalse;
	for( i = 1; i < argc; i++ )
	{
		qboolean containsSpaces;

		if (!strcmp(argv[i], "--nobacktrace")) {
			continue;
		} else if (!strcmp(argv[i], "--console-output")) {
			continue;
		} else if (!strcmp(argv[i], "--no-dpi-aware")) {
			continue;
		} else if (!strcmp(argv[i], "--no-demo-arg")) {
			continue;
		}

		if (demoNameAsArg  &&  !gotFirstArg) {
			if (argv[i][0] != '+'  &&  argv[i][0] != '-') {
				Q_strcat(commandLine, sizeof(commandLine), "+demo \"");
				Q_strcat(commandLine, sizeof(commandLine), argv[i]);
				Q_strcat(commandLine, sizeof(commandLine), "\"");
				printf("demo: '%s'\n", argv[i]);
				continue;
			}
		}

		gotFirstArg = qtrue;
		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;
}
Exemple #18
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;
}
Exemple #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

	//SDL_Delay(7000); // Wait for debugger
	remove(".openarena/baseoa/pak7-android.pk3"); // If some server pushed old VM scripts to us - remove them

	Sys_PlatformInit( );

	// Set the initial time base
	Sys_Milliseconds( );

	Sys_ParseArgs( argc, argv );
	Sys_SetBinaryPath( Sys_Dirname( argv[ 0 ] ) );
	Sys_SetDefaultInstallPath( DEFAULT_BASEDIR );
#ifdef __ANDROID__
	if( getenv( "APPDIR" ) ) // Shared libraries on Android are inside /data/data/<java.app.name>/files, which is not on SD card.
		Sys_SetBinaryPath( getenv( "APPDIR" ) );
#endif

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

#ifndef __ANDROID__
	// Allow signals through, so Android native debugger will sohw us some stack trace
	signal( SIGILL, Sys_SigHandler );
	signal( SIGFPE, Sys_SigHandler );
	signal( SIGSEGV, Sys_SigHandler );
	signal( SIGTERM, Sys_SigHandler );
	signal( SIGINT, Sys_SigHandler );
#endif

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

	return 0;
}
Exemple #20
0
int main(int argc, char* argv[]){

    int len, i;
    char  *cmdline;
    eventQue = (sysEvent_t*)evenQue_ADDR;

    // go back to real user for config loads

    Sys_LoadDifferentImage(argv);

    seteuid(getuid());

    Sys_PlatformInit( );

    Sys_ThreadInit();

    Sys_ThreadMain();

    Com_InitParse();

//    Cvar_Init();



    Sys_ParseArgs(argc, argv);

    // 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 eventqueue
    memset( &eventQue[0], 0, MAX_QUED_EVENTS * sizeof( sysEvent_t ) );

    Sys_Milliseconds();

//    addrtest();

    Com_Init( cmdline );

    CON_Init();

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


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

    if(!PbServerInitialize()){
        Com_Printf("Unable to initialize PunkBuster.  PunkBuster is disabled.\n");
    }

//    GetVirtualFunctionArray();
//    Com_Quit_f();



    while ( 1 )
    {
        static int fpu_word = _FPU_DEFAULT;
        _FPU_SETCW( fpu_word );

        NET_Sleep(5);

        Com_Frame();

        PbServerProcessEvents();
    }

}
Exemple #21
0
//
// D_SRB2Main
//
void D_SRB2Main(void)
{
	INT32 p;
	char srb2[82]; // srb2 title banner
	char title[82];

	INT32 pstartmap = 1;
	boolean autostart = false;

	// keep error messages until the final flush(stderr)
#if !defined (PC_DOS) && !defined (_WIN32_WCE) && !defined(NOTERMIOS)
	if (setvbuf(stderr, NULL, _IOFBF, 1000))
		DEBPRINT("setvbuf didnt work\n");
#endif

#ifdef GETTEXT
	// initialise locale code
	M_StartupLocale();
#endif

	// get parameters from a response file (eg: srb2 @parms.txt)
	M_FindResponseFile();

	// MAINCFG is now taken care of where "OBJCTCFG" is handled
	G_LoadGameSettings();

	// identify the main IWAD file to use
	IdentifyVersion();

#if !defined (_WIN32_WCE) && !defined(NOTERMIOS)
	setbuf(stdout, NULL); // non-buffered output
#endif

#if defined (_WIN32_WCE) //|| defined (_DEBUG) || defined (GP2X)
	devparm = !M_CheckParm("-nodebug");
#else
	devparm = M_CheckParm("-debug");
#endif

	// for dedicated server
#if !defined (_WINDOWS) //already check in win_main.c
	dedicated = M_CheckParm("-dedicated") != 0;
#endif

	strcpy(title, "Sonic Robo Blast 2");
	strcpy(srb2, "Sonic Robo Blast 2");
	D_MakeTitleString(srb2);

#ifdef PC_DOS
	D_Titlebar(srb2, title);
#else
	CONS_Printf("SRB2"VERSIONSTRING"\n");
#endif

#if defined (__OS2__) && !defined (SDL)
	// set PM window title
	snprintf(pmData->title, sizeof (pmData->title),
		"Sonic Robo Blast 2" VERSIONSTRING ": %s",
		title);
	pmData->title[sizeof (pmData->title) - 1] = '\0';
#endif

	if (devparm)
		CONS_Printf("%s", M_GetText("Development mode ON.\n"));

	// default savegame
	strcpy(savegamename, SAVEGAMENAME"%u.ssg");

	{
		const char *userhome = D_Home(); //Alam: path to home

		if (!userhome)
		{
#if ((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__) && !defined (DC) && !defined (PSP) && !defined(GP2X)
			I_Error("%s", M_GetText("Please set $HOME to your home directory\n"));
#elif defined (_WIN32_WCE) && 0
			if (dedicated)
				snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/d"CONFIGFILENAME);
			else
				snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/"CONFIGFILENAME);
#else
			if (dedicated)
				snprintf(configfile, sizeof configfile, "d"CONFIGFILENAME);
			else
				snprintf(configfile, sizeof configfile, CONFIGFILENAME);
#endif
		}
		else
		{
			// use user specific config file
#ifdef DEFAULTDIR
			snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome);
			snprintf(downloaddir, sizeof downloaddir, "%s" PATHSEP "DOWNLOAD", srb2home);
			if (dedicated)
				snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home);
			else
				snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2home);

			// can't use sprintf since there is %u in savegamename
			strcatbf(savegamename, srb2home, PATHSEP);

			I_mkdir(srb2home, 0700);
#else
			snprintf(srb2home, sizeof srb2home, "%s", userhome);
			snprintf(downloaddir, sizeof downloaddir, "%s", userhome);
			if (dedicated)
				snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, userhome);
			else
				snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, userhome);

			// can't use sprintf since there is %u in savegamename
			strcatbf(savegamename, userhome, PATHSEP);
#endif
		}

		configfile[sizeof configfile - 1] = '\0';

#ifdef _arch_dreamcast
	strcpy(downloaddir, "/ram"); // the dreamcast's TMP
#endif
	}

	if (M_CheckParm("-password") && M_IsNextParm())
	{
		const char *pw = M_GetNextParm();
		strncpy(adminpassword, pw, 8);
		if (strlen(pw) < 8)
		{
			size_t z;
			for (z = strlen(pw); z < 8; z++)
				adminpassword[z] = 'a';
		}
	}
	else
	{
		size_t z;
		srand((unsigned int)time(NULL));
		for (z = 0; z < 8; z++)
			adminpassword[z] = (char)(rand() & 127);
	}
	adminpassword[8] = '\0';

	// add any files specified on the command line with -file wadfile
	// to the wad list
	if (!(M_CheckParm("-connect")))
	{
		if (M_CheckParm("-file"))
		{
			// the parms after p are wadfile/lump names,
			// until end of parms or another - preceded parm
			while (M_IsNextParm())
			{
				const char *s = M_GetNextParm();

				if (s) // Check for NULL?
				{
					if (!W_VerifyNMUSlumps(s))
						modifiedgame = true;
					D_AddFile(s);
				}
			}
		}
	}

	// get map from parms

	if (M_CheckParm("-server") || dedicated)
		netgame = server = true;

	if (M_CheckParm("-warp") && M_IsNextParm())
	{
		pstartmap = atoi(M_GetNextParm());
		if (!M_CheckParm("-server"))
			modifiedgame = true;
		autostart = true;
		savemoddata = false;
	}

	CONS_Printf("%s", M_GetText("Z_Init: Init zone memory allocation daemon. \n"));
	Z_Init();

	// adapt tables to SRB2's needs, including extra slots for dehacked file support
	P_PatchInfoTables();

	CONS_Printf("%s", M_GetText("W_Init: Init WADfiles.\n"));

	//---------------------------------------------------- READY TIME
	// we need to check for dedicated before initialization of some subsystems

	CONS_Printf("I_StartupTimer...\n");
	I_StartupTimer();

	// Make backups of some SOCcable tables.
	P_BackupTables();

	// load wad, including the main wad file
	if (!W_InitMultipleFiles(startupwadfiles))
#ifdef _DEBUG
		CONS_Error(M_GetText("A WAD file was not found or not valid\n"));
#else
		I_Error("%s", M_GetText("A WAD file was not found or not valid\n"));
#endif
	D_CleanFile();

	// Check MD5s of autoloaded files
	W_VerifyFileMD5(0, "1f698dd35bcedb04631568a84a97d72b"); // srb2.srb
	W_VerifyFileMD5(1, "86ae3f9179c64358d1c88060e41bd415"); // zones.dta
	W_VerifyFileMD5(2, "f699d4702b9b505db621e5ad5af4f352"); // sonic.plr
	W_VerifyFileMD5(3, "dfbbc38080485c70a84a57bb734ceee9"); // tails.plr
	W_VerifyFileMD5(4, "1ea958e2aee87b6995226a120ba3eaac"); // knux.plr
	W_VerifyFileMD5(5, "8f702416c15060cd3c53c71b91116914"); // rings.wpn
	W_VerifyFileMD5(6, "6b1cf9b41e41a46ac58606dc6e7c9e05"); // drill.dta
	W_VerifyFileMD5(7, "8d080c050ecf03691562aa7b60156fec"); // soar.dta

	// don't check music.dta because people like to modify it, and it doesn't matter if they do
	// ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.


	mainwads = 8; // there are 8 wads not to unload

/* TODO: incorporate this!
	CONS_Printf("%s", "===========================================================================\n"
	"                       Sonic Robo Blast II!\n"
	"                       by Sonic Team Junior\n"
	"                       http://www.srb2.org\n"
	"      This is a modified version. Go to our site for the original.\n"
	"===========================================================================\n");
*/

	// Check and print which version is executed.
	CONS_Printf("%s", "===========================================================================\n"
	"                   We hope you enjoy this game as\n"
	"                     much as we did making it!\n"
	"                            ...wait. =P\n"
	"===========================================================================\n");

	cht_Init();

	//---------------------------------------------------- READY SCREEN
	// we need to check for dedicated before initialization of some subsystems

	CONS_Printf("I_StartupGraphics...\n");
	I_StartupGraphics();

	//--------------------------------------------------------- CONSOLE
	// setup loading screen
	SCR_Startup();

	// we need the font of the console
	CONS_Printf("%s", M_GetText("HU_Init: Setting up heads up display.\n"));
	HU_Init();

	COM_Init();
	// libogc has a CON_Init function, we must rename SRB2's CON_Init in WII/libogc
#ifndef _WII
	CON_Init();
#else
	CON_InitWii();
#endif

	D_RegisterServerCommands();
	D_RegisterClientCommands(); // be sure that this is called before D_CheckNetGame
	R_RegisterEngineStuff();
	S_RegisterSoundStuff();

	I_RegisterSysCommands();

	//--------------------------------------------------------- CONFIG.CFG
	M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()"

	if (!M_CheckParm("-resetdata"))
		G_LoadGameData();

#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
	VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
#endif

	// set user default mode or mode set at cmdline
	SCR_CheckDefaultMode();

	wipegamestate = gamestate;

	P_InitMapHeaders();
	savedata.lives = 0; // flag this as not-used

	//------------------------------------------------ COMMAND LINE PARAMS

	// Initialize CD-Audio
	if (M_CheckParm("-usecd") && !dedicated)
		I_InitCD();

	if (M_CheckParm("-nodownloading"))
		COM_BufAddText("downloading 0\n");

	CONS_Printf("%s", M_GetText("M_Init: Init miscellaneous info.\n"));
	M_Init();

	CONS_Printf("%s", M_GetText("R_Init: Init SRB2 refresh daemon - "));
	R_Init();

	// setting up sound
	CONS_Printf("%s", M_GetText("S_Init: Setting up sound.\n"));
	if (M_CheckParm("-nosound"))
		nosound = true;
	if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic
		nomidimusic = nodigimusic = true;
	else
	{
		if (M_CheckParm("-nomidimusic"))
			nomidimusic = true; ; // WARNING: DOS version initmusic in I_StartupSound
		if (M_CheckParm("-nodigmusic"))
			nodigimusic = true; // WARNING: DOS version initmusic in I_StartupSound
	}
	I_StartupSound();
	I_InitMusic();
	S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value);

	CONS_Printf("%s", M_GetText("ST_Init: Init status bar.\n"));
	ST_Init();

	if (M_CheckParm("-internetserver"))
		CV_SetValue(&cv_internetserver, 1);

	// init all NETWORK
	CONS_Printf("%s", M_GetText("D_CheckNetGame: Checking network game status.\n"));
	if (D_CheckNetGame())
		autostart = true;

	// check for a driver that wants intermission stats
	// start the apropriate game based on parms
	if (M_CheckParm("-record") && M_IsNextParm())
	{
		G_RecordDemo(M_GetNextParm());
		autostart = true;
	}

	p = M_CheckParm("-timetic");
	if (p)
		CV_Set(&cv_timetic, "On");

	if (!autostart)
		M_PushSpecialParameters(); // push all "+" parameters at the command buffer

	// demo doesn't need anymore to be added with D_AddFile()
	p = M_CheckParm("-playdemo");
	if (!p)
		p = M_CheckParm("-timedemo");
	if (p && M_IsNextParm())
	{
		char tmp[MAX_WADPATH];
		// add .lmp to identify the EXTERNAL demo file
		// it is NOT possible to play an internal demo using -playdemo,
		// rather push a playdemo command.. to do.

		strcpy(tmp, M_GetNextParm());
		// get spaced filename or directory
		while (M_IsNextParm())
		{
			strcat(tmp, " ");
			strcat(tmp, M_GetNextParm());
		}

		FIL_DefaultExtension(tmp, ".lmp");

		CONS_Printf(M_GetText("Playing demo %s.\n"), tmp);

		if (M_CheckParm("-playdemo"))
		{
			singledemo = true; // quit after one demo
			G_DeferedPlayDemo(tmp);
		}
		else
			G_TimeDemo(tmp);

		G_SetGamestate(GS_NULL);
		wipegamestate = GS_NULL;
		return;
	}

	if (M_CheckParm("-ultimatemode"))
	{
		autostart = true;
		ultimatemode = true;
	}

	if (autostart || netgame || M_CheckParm("+connect") || M_CheckParm("-connect"))
	{
		gameaction = ga_nothing;

		CV_ClearChangedFlags();

		// Do this here so if you run SRB2 with eg +timelimit 5, the time limit counts
		// as having been modified for the first game.
		M_PushSpecialParameters(); // push all "+" parameter at the command buffer

		if (M_CheckParm("-gametype") && M_IsNextParm())
		{
			// from Command_Map_f
			INT32 j;
			INT16 newgametype = -1;
			const char *sgametype = M_GetNextParm();

			for (j = 0; gametype_cons_t[j].strvalue; j++)
				if (!strcasecmp(gametype_cons_t[j].strvalue, sgametype))
				{
					if (gametype_cons_t[j].value == GTF_TEAMMATCH)
					{
						newgametype = GT_MATCH;
						CV_SetValue(&cv_matchtype, 1);
					}
					else if (gametype_cons_t[j].value == GTF_CLASSICRACE)
					{
						newgametype = GT_RACE;
						CV_SetValue(&cv_racetype, 1);
					}
					else if (gametype_cons_t[j].value == GTF_HIDEANDSEEK)
					{
						newgametype = GT_TAG;
						CV_SetValue(&cv_tagtype, 1);
					}
					else
						newgametype = (INT16)gametype_cons_t[j].value;

					break;
				}
			if (!gametype_cons_t[j].strvalue) // reached end of the list with no match
			{
				j = atoi(sgametype); // assume they gave us a gametype number, which is okay too
				if (j >= 0 && j < NUMGAMETYPES)
					newgametype = (INT16)j;
			}

			if (newgametype != -1)
			{
				j = gametype;
				gametype = newgametype;
				D_GameTypeChanged(j);
			}
		}

		if (server && !M_CheckParm("+map") && !M_CheckParm("+connect")
			&& !M_CheckParm("-connect"))
		{
			D_MapChange(pstartmap, gametype, ultimatemode, 1, 0, false, false);
		}
	}
	else
		F_StartIntro(); // Tails 03-03-2002

	if (dedicated && server)
	{
		pagename = "TITLESKY";
		levelstarttic = gametic;
		G_SetGamestate(GS_LEVEL);
		if (!P_SetupLevel(gamemap, false))
			I_Quit(); // fail so reset game stuff
	}
}
Exemple #22
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;
}
Exemple #23
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;
}
Exemple #24
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;
}
Exemple #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;
}
Exemple #26
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;
}
Exemple #27
0
//
// D_SRB2Main
//
void D_SRB2Main(void)
{
    INT32 p;
    char srb2[82]; // srb2 title banner
    char title[82];

    INT32 pstartmap = 1;
    boolean autostart = false;

    // keep error messages until the final flush(stderr)
#if !defined (PC_DOS) && !defined (_WIN32_WCE) && !defined(NOTERMIOS)
    if (setvbuf(stderr, NULL, _IOFBF, 1000))
        I_OutputMsg("setvbuf didnt work\n");
#endif

#ifdef GETTEXT
    // initialise locale code
    M_StartupLocale();
#endif

    // get parameters from a response file (eg: srb2 @parms.txt)
    M_FindResponseFile();

    // MAINCFG is now taken care of where "OBJCTCFG" is handled
    G_LoadGameSettings();

    // Test Dehacked lists
    DEH_Check();

    // identify the main IWAD file to use
    IdentifyVersion();

#if !defined (_WIN32_WCE) && !defined(NOTERMIOS)
    setbuf(stdout, NULL); // non-buffered output
#endif

#if defined (_WIN32_WCE) //|| defined (_DEBUG) || defined (GP2X)
    devparm = !M_CheckParm("-nodebug");
#else
    devparm = M_CheckParm("-debug");
#endif

    // for dedicated server
#if !defined (_WINDOWS) //already check in win_main.c
    dedicated = M_CheckParm("-dedicated") != 0;
#endif

    strcpy(title, "Sonic Robo Blast 2");
    strcpy(srb2, "Sonic Robo Blast 2");
    D_MakeTitleString(srb2);

#ifdef PC_DOS
    D_Titlebar(srb2, title);
#endif

#if defined (__OS2__) && !defined (SDL)
    // set PM window title
    snprintf(pmData->title, sizeof (pmData->title),
             "Sonic Robo Blast 2" VERSIONSTRING ": %s",
             title);
    pmData->title[sizeof (pmData->title) - 1] = '\0';
#endif

    if (devparm)
        CONS_Printf(M_GetText("Development mode ON.\n"));

    // default savegame
    strcpy(savegamename, SAVEGAMENAME"%u.ssg");

    {
        const char *userhome = D_Home(); //Alam: path to home

        if (!userhome)
        {
#if ((defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON)) && !defined (__CYGWIN__) && !defined (DC) && !defined (PSP) && !defined(GP2X)
            I_Error("Please set $HOME to your home directory\n");
#elif defined (_WIN32_WCE) && 0
            if (dedicated)
                snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/d"CONFIGFILENAME);
            else
                snprintf(configfile, sizeof configfile, "/Storage Card/SRB2DEMO/"CONFIGFILENAME);
#else
            if (dedicated)
                snprintf(configfile, sizeof configfile, "d"CONFIGFILENAME);
            else
                snprintf(configfile, sizeof configfile, CONFIGFILENAME);
#endif
        }
        else
        {
            // use user specific config file
#ifdef DEFAULTDIR
            snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome);
            snprintf(downloaddir, sizeof downloaddir, "%s" PATHSEP "DOWNLOAD", srb2home);
            if (dedicated)
                snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home);
            else
                snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2home);

            // can't use sprintf since there is %u in savegamename
            strcatbf(savegamename, srb2home, PATHSEP);

            I_mkdir(srb2home, 0700);
#else
            snprintf(srb2home, sizeof srb2home, "%s", userhome);
            snprintf(downloaddir, sizeof downloaddir, "%s", userhome);
            if (dedicated)
                snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, userhome);
            else
                snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, userhome);

            // can't use sprintf since there is %u in savegamename
            strcatbf(savegamename, userhome, PATHSEP);
#endif
        }

        configfile[sizeof configfile - 1] = '\0';

#ifdef _arch_dreamcast
        strcpy(downloaddir, "/ram"); // the dreamcast's TMP
#endif
    }

    // rand() needs seeded regardless of password
    srand((unsigned int)time(NULL));

    if (M_CheckParm("-password") && M_IsNextParm())
        D_SetPassword(M_GetNextParm());
    else
    {
        size_t z;
        char junkpw[25];
        for (z = 0; z < 24; z++)
            junkpw[z] = (char)(rand() & 64)+32;
        junkpw[24] = '\0';
        D_SetPassword(junkpw);
    }

    // add any files specified on the command line with -file wadfile
    // to the wad list
    if (!(M_CheckParm("-connect")))
    {
        if (M_CheckParm("-file"))
        {
            // the parms after p are wadfile/lump names,
            // until end of parms or another - preceded parm
            while (M_IsNextParm())
            {
                const char *s = M_GetNextParm();

                if (s) // Check for NULL?
                {
                    if (!W_VerifyNMUSlumps(s))
                        G_SetGameModified(true);
                    D_AddFile(s);
                }
            }
        }
    }

    // get map from parms

    if (M_CheckParm("-server") || dedicated)
        netgame = server = true;

    if (M_CheckParm("-warp") && M_IsNextParm())
    {
        const char *word = M_GetNextParm();
        if (fastncmp(word, "MAP", 3))
            pstartmap = M_MapNumber(word[3], word[4]);
        else
            pstartmap = atoi(word);
        // Don't check if lump exists just yet because the wads haven't been loaded!
        // Just do a basic range check here.
        if (pstartmap < 1 || pstartmap > NUMMAPS)
            I_Error("Cannot warp to map %d (out of range)\n", pstartmap);
        else
        {
            if (!M_CheckParm("-server"))
                G_SetGameModified(true);
            autostart = true;
        }
    }

    CONS_Printf("Z_Init(): Init zone memory allocation daemon. \n");
    Z_Init();

    // adapt tables to SRB2's needs, including extra slots for dehacked file support
    P_PatchInfoTables();

    //---------------------------------------------------- READY TIME
    // we need to check for dedicated before initialization of some subsystems

    CONS_Printf("I_StartupTimer()...\n");
    I_StartupTimer();

    // Make backups of some SOCcable tables.
    P_BackupTables();

    // Setup default unlockable conditions
    M_SetupDefaultConditionSets();

    // load wad, including the main wad file
    CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n");
    if (!W_InitMultipleFiles(startupwadfiles))
#ifdef _DEBUG
        CONS_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n");
#else
        I_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n");
#endif
    D_CleanFile();

#if 1 // md5s last updated 3/15/14
    // Yes, you read that right, that's the day of release.
    // Aren't we batshit insane?

    // Check MD5s of autoloaded files
    W_VerifyFileMD5(0, "ac309fb3c7d4b5b685e2cd26beccf0e8"); // srb2.srb/srb2.wad
    W_VerifyFileMD5(1, "a894044b555dfcc71865cee16a996e88"); // zones.dta
    W_VerifyFileMD5(2, "4c410c1de6e0440cc5b2858dcca80c3e"); // player.dta
    W_VerifyFileMD5(3, "85901ad4bf94637e5753d2ac2c03ea26"); // rings.dta
    W_VerifyFileMD5(4, "c529930ee5aed6dbe33625dc8075520b"); // patch.dta

    // don't check music.dta because people like to modify it, and it doesn't matter if they do
    // ...except it does if they slip maps in there, and that's what W_VerifyNMUSlumps is for.
#endif

    mainwads = 5; // there are 5 wads not to unload

    cht_Init();

    //---------------------------------------------------- READY SCREEN
    // we need to check for dedicated before initialization of some subsystems

    CONS_Printf("I_StartupGraphics()...\n");
    I_StartupGraphics();

    //--------------------------------------------------------- CONSOLE
    // setup loading screen
    SCR_Startup();

    // we need the font of the console
    CONS_Printf("HU_Init(): Setting up heads up display.\n");
    HU_Init();

    COM_Init();
    // libogc has a CON_Init function, we must rename SRB2's CON_Init in WII/libogc
#ifndef _WII
    CON_Init();
#else
    CON_InitWii();
#endif

    D_RegisterServerCommands();
    D_RegisterClientCommands(); // be sure that this is called before D_CheckNetGame
    R_RegisterEngineStuff();
    S_RegisterSoundStuff();

    I_RegisterSysCommands();

    //--------------------------------------------------------- CONFIG.CFG
    M_FirstLoadConfig(); // WARNING : this do a "COM_BufExecute()"

    G_LoadGameData();

#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (SDL)
    VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
#endif

    // set user default mode or mode set at cmdline
    SCR_CheckDefaultMode();

    wipegamestate = gamestate;

    P_InitMapHeaders();
    savedata.lives = 0; // flag this as not-used

    //------------------------------------------------ COMMAND LINE PARAMS

    // Initialize CD-Audio
    if (M_CheckParm("-usecd") && !dedicated)
        I_InitCD();

    if (M_CheckParm("-noupload"))
        COM_BufAddText("downloading 0\n");

    CONS_Printf("M_Init(): Init miscellaneous info.\n");
    M_Init();

    CONS_Printf("R_Init(): Init SRB2 refresh daemon.\n");
    R_Init();

    // setting up sound
    CONS_Printf("S_Init(): Setting up sound.\n");
    if (M_CheckParm("-nosound"))
        nosound = true;
    if (M_CheckParm("-nomusic")) // combines -nomidimusic and -nodigmusic
        nomidimusic = nodigimusic = true;
    else
    {
        if (M_CheckParm("-nomidimusic"))
            nomidimusic = true; ; // WARNING: DOS version initmusic in I_StartupSound
        if (M_CheckParm("-nodigmusic"))
            nodigimusic = true; // WARNING: DOS version initmusic in I_StartupSound
    }
    I_StartupSound();
    I_InitMusic();
    S_Init(cv_soundvolume.value, cv_digmusicvolume.value, cv_midimusicvolume.value);

    CONS_Printf("ST_Init(): Init status bar.\n");
    ST_Init();

    if (M_CheckParm("-room"))
    {
        if (!M_IsNextParm())
            I_Error("usage: -room <room_id>\nCheck the Master Server's webpage for room ID numbers.\n");

#ifdef UPDATE_ALERT
        GetMODVersion_Console();
#endif

        ms_RoomId = atoi(M_GetNextParm());
    }

    // init all NETWORK
    CONS_Printf("D_CheckNetGame(): Checking network game status.\n");
    if (D_CheckNetGame())
        autostart = true;

    // check for a driver that wants intermission stats
    // start the apropriate game based on parms
    if (M_CheckParm("-metal"))
    {
        G_RecordMetal();
        autostart = true;
    }
    else if (M_CheckParm("-record") && M_IsNextParm())
    {
        G_RecordDemo(M_GetNextParm());
        autostart = true;
    }

    // user settings come before "+" parameters.
    if (dedicated)
        COM_ImmedExecute(va("exec \"%s"PATHSEP"adedserv.cfg\"\n", srb2home));
    else
        COM_ImmedExecute(va("exec \"%s"PATHSEP"autoexec.cfg\" -noerror\n", srb2home));

    if (!autostart)
        M_PushSpecialParameters(); // push all "+" parameters at the command buffer

    // demo doesn't need anymore to be added with D_AddFile()
    p = M_CheckParm("-playdemo");
    if (!p)
        p = M_CheckParm("-timedemo");
    if (p && M_IsNextParm())
    {
        char tmp[MAX_WADPATH];
        // add .lmp to identify the EXTERNAL demo file
        // it is NOT possible to play an internal demo using -playdemo,
        // rather push a playdemo command.. to do.

        strcpy(tmp, M_GetNextParm());
        // get spaced filename or directory
        while (M_IsNextParm())
        {
            strcat(tmp, " ");
            strcat(tmp, M_GetNextParm());
        }

        FIL_DefaultExtension(tmp, ".lmp");

        CONS_Printf(M_GetText("Playing demo %s.\n"), tmp);

        if (M_CheckParm("-playdemo"))
        {
            singledemo = true; // quit after one demo
            G_DeferedPlayDemo(tmp);
        }
        else
            G_TimeDemo(tmp);

        G_SetGamestate(GS_NULL);
        wipegamestate = GS_NULL;
        return;
    }

    if (M_CheckParm("-ultimatemode"))
    {
        autostart = true;
        ultimatemode = true;
    }

    if (autostart || netgame || M_CheckParm("+connect") || M_CheckParm("-connect"))
    {
        gameaction = ga_nothing;

        CV_ClearChangedFlags();

        // Do this here so if you run SRB2 with eg +timelimit 5, the time limit counts
        // as having been modified for the first game.
        M_PushSpecialParameters(); // push all "+" parameter at the command buffer

        if (M_CheckParm("-gametype") && M_IsNextParm())
        {
            // from Command_Map_f
            INT32 j;
            INT16 newgametype = -1;
            const char *sgametype = M_GetNextParm();

            for (j = 0; gametype_cons_t[j].strvalue; j++)
                if (!strcasecmp(gametype_cons_t[j].strvalue, sgametype))
                {
                    newgametype = (INT16)gametype_cons_t[j].value;
                    break;
                }
            if (!gametype_cons_t[j].strvalue) // reached end of the list with no match
            {
                j = atoi(sgametype); // assume they gave us a gametype number, which is okay too
                if (j >= 0 && j < NUMGAMETYPES)
                    newgametype = (INT16)j;
            }

            if (newgametype != -1)
            {
                j = gametype;
                gametype = newgametype;
                D_GameTypeChanged(j);
            }
        }

        if (server && !M_CheckParm("+map") && !M_CheckParm("+connect")
                && !M_CheckParm("-connect"))
        {
            // Prevent warping to nonexistent levels
            if (W_CheckNumForName(G_BuildMapName(pstartmap)) == LUMPERROR)
                I_Error("Could not warp to %s (map not found)\n", G_BuildMapName(pstartmap));
            // Prevent warping to locked levels
            // ... unless you're in a dedicated server.  Yes, technically this means you can view any level by
            // running a dedicated server and joining it yourself, but that's better than making dedicated server's
            // lives hell.
            else if (!dedicated && M_MapLocked(pstartmap))
                I_Error("You need to unlock this level before you can warp to it!\n");
            else
                D_MapChange(pstartmap, gametype, ultimatemode, true, 0, false, false);
        }
    }
    else if (M_CheckParm("-skipintro"))
    {
        CON_ToggleOff();
        CON_ClearHUD();
        F_StartTitleScreen();
    }
    else
        F_StartIntro(); // Tails 03-03-2002

    if (dedicated && server)
    {
        pagename = "TITLESKY";
        levelstarttic = gametic;
        G_SetGamestate(GS_LEVEL);
        if (!P_SetupLevel(false))
            I_Quit(); // fail so reset game stuff
    }
}
Exemple #28
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);

#ifndef DEDICATED
	SDL_version compiled;
	SDL_version linked;

	SDL_VERSION( &compiled );
	SDL_GetVersion( &linked );

	Com_Printf( "SDL Version Compiled: %d.%d.%d\n", compiled.major, compiled.minor, compiled.patch );
	Com_Printf( "SDL Version Linked: %d.%d.%d\n", linked.major, linked.minor, linked.patch );
#endif

	NET_Init();

	// main game loop
	while (1)
	{
		if ( com_busyWait->integer )
		{
			bool shouldSleep = false;

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

			if ( com_minimized->integer )
			{
				shouldSleep = true;
			}

			if ( shouldSleep )
			{
				Sys_Sleep( 5 );
			}
		}

		// run the game
		Com_Frame();
	}

	// never gets here
	return 0;
}