示例#1
0
int main (int argc, char **argv)
{
	quakeparms_t	parms;
	double			newtime, time, oldtime;
	static	char	cwd[1024];
	struct timeval	timeout;
	fd_set			fdset;
	int				t;

	COM_InitArgv (argc, argv);
	
	parms.argc = com_argc;
	parms.argv = com_argv;

	parms.memsize = 16*1024*1024;

	if ((t = COM_CheckParm ("-heapsize")) != 0 &&
		t + 1 < com_argc)
		parms.memsize = Q_atoi (com_argv[t + 1]) * 1024;

	if ((t = COM_CheckParm ("-mem")) != 0 &&
		t + 1 < com_argc)
		parms.memsize = Q_atoi (com_argv[t + 1]) * 1024 * 1024;

	parms.membase = malloc (parms.memsize);

	if (!parms.membase)
		Sys_Error("Insufficient memory.\n");

	parms.basedir = ".";
	parms.cachedir = NULL;

	SV_Init (&parms);

// run one frame immediately for first heartbeat
	SV_Frame (0.1);		

//
// main loop
//
	oldtime = Sys_DoubleTime () - 0.1;
	while (1)
	{
	// select on the net socket and stdin
	// the only reason we have a timeout at all is so that if the last
	// connected client times out, the message would not otherwise
	// be printed until the next event.
		FD_ZERO(&fdset);
		FD_SET(net_socket, &fdset);
		timeout.tv_sec = 0;
		timeout.tv_usec = 100;
		if (select (net_socket+1, &fdset, NULL, NULL, &timeout) == -1)
			continue;

	// find time passed since last cycle
		newtime = Sys_DoubleTime ();
		time = newtime - oldtime;
		oldtime = newtime;
		
		SV_Frame (time);				
	}	

	return true;
}
示例#2
0
/*
================
main
================
*/
int
main ( int c, char **v )
{
	extern void (*dos_error_func)(char *, ...);
	double			time, oldtime, newtime;
	static char		cwd[1024];

	printf ("Quake v%s\n", VERSION);

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

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

	COM_InitArgv (c, v);

	quakeparms.argc = com_argc;
	quakeparms.argv = com_argv;

	dos_error_func = Sys_Error;

	Sys_DetectWin95 ();
	Sys_PageInProgram ();
	Sys_GetMemory ();

	atexit (Sys_AtExit);	// in case we crash

	getwd (cwd);
	if (cwd[Q_strlen(cwd)-1] == '/') cwd[Q_strlen(cwd)-1] = 0;
	quakeparms.basedir = cwd;	//"f:/quake";

	isDedicated = (COM_CheckParm ("-dedicated") != 0);

	Sys_Init ();

	if (!isDedicated)
		dos_registerintr(9, TrapKey);

//	Sys_InitStackCheck ();

	Host_Init(&quakeparms);

//	Sys_StackCheck ();

//	Con_Printf ("Top of stack: 0x%x\n", &time);
	oldtime = Sys_DoubleTime ();
	while (1)
	{
		newtime = Sys_DoubleTime ();
		time = newtime - oldtime;

		if (cls.state == ca_dedicated && (time<sys_ticrate->value))
			continue;

		Host_Frame (time);

//		Sys_StackCheck ();

		oldtime = newtime;
	}
}
示例#3
0
void Host_Init (int argc, char **argv, int default_memsize)
{
	vfsfile_t *vf;
	cvar_t *v;

	char cfg[MAX_PATH] = {0};
	int i;
	char *cfg_name;

	COM_InitArgv (argc, argv);
	COM_StoreOriginalCmdline(argc, argv);

#ifdef WITH_DP_MEM
	Memory2_Init ();
#endif
	Host_InitMemory (default_memsize);

#ifdef WITH_TCL
	// interpreter should be initialized
	// before any cvar definitions
	TCL_InterpInit ();
#endif
	Cbuf_Init ();
	Cmd_Init ();
	Cvar_Init ();
	COM_Init ();
	Key_Init ();

#ifdef WITH_DP_MEM
	Memory2_Init_Commands ();
#endif
	Cache_Init_Commands ();

	FS_InitFilesystem ();
	NET_Init ();

	Commands_For_Configs_Init ();
	ConfigManager_Init();
	ResetBinds();

	i = COM_CheckParm("+cfg_load");

	if (i && (i + 1 < COM_Argc())) {
		cfg_name = COM_Argv(i + 1);
	}
	else {
		cfg_name = MAIN_CONFIG_FILENAME;
	}
	snprintf(cfg, sizeof(cfg), "%s", cfg_name);
	COM_ForceExtensionEx (cfg, ".cfg", sizeof (cfg));
	Cbuf_AddText(va("cfg_load %s\n", cfg));
	Cbuf_Execute();

	Cbuf_AddEarlyCommands ();
	Cbuf_Execute ();

	Con_Init ();
	NET_InitClient ();
	Netchan_Init ();

#if (!defined WITH_PNG_STATIC || !defined WITH_JPEG_STATIC || defined WITH_MP3_PLAYER)
	QLib_Init();
#endif

	Sys_Init ();
	CM_Init ();
	PM_Init ();
	Mod_Init ();

	SV_Init ();
	CL_Init ();

	Cvar_CleanUpTempVars ();

	SYSINFO_Init();

#ifdef WITH_TCL
	if (!TCL_InterpLoaded())
		Com_Printf_State (PRINT_FAIL, "Could not load "TCL_LIB_NAME", embedded Tcl disabled\n");
#endif

	Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
	host_hunklevel = Hunk_LowMark ();

	host_initialized = true;

	// walk through all vars and forse OnChange event if cvar was modified,
	// also apply that to variables which mirrored in userinfo because of cl_parsefunchars was't applyed as this moment,
	// same for serverinfo and may be this fix something also.
	for ( v = NULL; (v = Cvar_Next ( v )); ) {
		char val[2048];

//		if ( !v->modified )
//			continue; // not modified even that strange at this moment

		if ( Cvar_GetFlags( v ) & (CVAR_ROM | CVAR_INIT) )
			continue;

		snprintf(val, sizeof(val), "%s", v->string);
		Cvar_Set(v, val);
	}
	
	Hud_262LoadOnFirstStart();

	Com_Printf_State (PRINT_INFO, "Exe: "__TIME__" "__DATE__"\n");
	Com_Printf_State (PRINT_INFO, "Hunk allocation: %4.1f MB.\n", (float) host_memsize / (1024 * 1024));

	Com_Printf ("\nezQuake %s\n\n", VersionString());
	Com_Printf(Host_PrintBars("ezQuake\x9c" "SourceForge\x9c" "net", 38));
	Com_Printf(Host_PrintBars("ezQuake Initialized", 38));
	Com_Printf("\n");
	Com_Printf ("\nType /help to access the manual.\nUse /describe to learn about commands.\n", VersionString());

	if ((vf = FS_OpenVFS("autoexec.cfg", "rb", FS_ANY))) {
		Cbuf_AddText ("exec autoexec.cfg\n");
		VFS_CLOSE(vf);
	}

	Cmd_StuffCmds_f ();		// process command line arguments
	Cbuf_AddText ("cl_warncmd 1\n");

	#ifdef WIN32
	//
	// Verify that ezQuake is associated with the QW:// protocl handler.
	//
	{
		extern qbool CL_CheckIfQWProtocolHandler();
		extern cvar_t cl_verify_qwprotocol;

		if (cl_verify_qwprotocol.integer >= 2)
		{
			// Always register the qw:// protocol.
			Cbuf_AddText("register_qwurl_protocol\n");
		}
		else if (cl_verify_qwprotocol.integer == 1 && !CL_CheckIfQWProtocolHandler())
		{
			// Check if the running exe is the one associated with the qw:// protocol.

			Com_PrintVerticalBar(0.8 * vid.conwidth / 8);
			Com_Printf("\n");
			Com_Printf("This ezQuake is not associated with the "); 
			Com_Printf("\x02QW:// protocol.\n");
			Com_Printf("Register it using "); 
			Com_Printf("\x02/register_qwurl_protocol\n");
			Com_Printf("(set ");
			Com_Printf("\x02 cl_verify_qwprotocol ");
			Com_Printf("to 0 to hide this warning)\n");
			Com_PrintVerticalBar(0.8 * vid.conwidth / 8);
			Com_Printf("\n");
		}
	}
	#endif // WIN32

	// Check if a qtv/demo file is specified as the first argument, in that case play that
	// otherwise, do some more checks of what to show at startup.
	{
		char cmd[1024] = {0};

		if (COM_CheckArgsForPlayableFiles(cmd, sizeof(cmd)))
		{
			Cbuf_AddText(cmd);
		}
		else
		{
			Startup_Place();
		}
	}

#ifdef _WIN32
	SetForegroundWindow(mainwindow);
	SetActiveWindow(mainwindow);
#endif

	host_everything_loaded = true;
}
示例#4
0
int main(int argc, char *argv[])
{
	int		t;
	double		time, oldtime, newtime;

	host_parms = &parms;
	parms.basedir = ".";

	parms.argc = argc;
	parms.argv = argv;

	COM_InitArgv(parms.argc, parms.argv);

	isDedicated = (COM_CheckParm("-dedicated") != 0);

	Sys_CheckSDL ();

	Sys_Init();

	// default memory size
	// TODO: less mem, eg. 16 mb, for dedicated server??
	parms.memsize = DEFAULT_MEMORY;

	if (COM_CheckParm("-heapsize"))
	{
		t = COM_CheckParm("-heapsize") + 1;
		if (t < com_argc)
			parms.memsize = Q_atoi(com_argv[t]) * 1024;
	}

	parms.membase = malloc (parms.memsize);

	if (!parms.membase)
		Sys_Error ("Not enough memory free; check disk space\n");

	Sys_Printf("Quake %1.2f (c) id Software\n", VERSION);
	Sys_Printf("GLQuake %1.2f (c) id Software\n", GLQUAKE_VERSION);
	Sys_Printf("FitzQuake %1.2f (c) John Fitzgibbons\n", FITZQUAKE_VERSION);
	Sys_Printf("FitzQuake SDL port (c) SleepwalkR, Baker\n");
	Sys_Printf("QuakeSpasm %1.2f.%d (c) Ozkan Sezer, Stevenaaus\n", FITZQUAKE_VERSION, QUAKESPASM_VER_PATCH);
	Sys_Printf("RiftQuake %1.2f\n", RIFTQUAKE_VERSION);

	Sys_Printf("Host_Init\n");
	Host_Init();

	oldtime = Sys_DoubleTime();
	if (isDedicated)
	{
		while (1)
		{
			newtime = Sys_DoubleTime ();
			time = newtime - oldtime;

			while (time < sys_ticrate.value )
			{
				SDL_Delay(1);
				newtime = Sys_DoubleTime ();
				time = newtime - oldtime;
			}

			Host_Frame (time);
			oldtime = newtime;
		}
	}
	else
	while (1)
	{
		appState = SDL_GetAppState();
		/* If we have no input focus at all, sleep a bit */
		if ( !(appState & (SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS)) || cl.paused)
		{
			SDL_Delay(16);
		}
		/* If we're minimised, sleep a bit more */
		if ( !(appState & SDL_APPACTIVE) )
		{
			scr_skipupdate = 1;
			SDL_Delay(32);
		}
		else
		{
			scr_skipupdate = 0;
		}
		newtime = Sys_DoubleTime ();
		time = newtime - oldtime;

		Host_Frame (time);

		if (time < sys_throttle.value)
			SDL_Delay(1);

		oldtime = newtime;
	}

	return 0;
}
示例#5
0
文件: sys_linux.c 项目: ACIIL/Quake
int main (int c, char **v)
{

	double		time, oldtime, newtime;
	quakeparms_t parms;
	extern int vcrFile;
	extern int recording;
	int j;

//	static char cwd[1024];

//	signal(SIGFPE, floating_point_exception_handler);
	signal(SIGFPE, SIG_IGN);

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

	COM_InitArgv(c, v);
	parms.argc = com_argc;
	parms.argv = com_argv;

#ifdef GLQUAKE
	parms.memsize = 16*1024*1024;
#else
	parms.memsize = 8*1024*1024;
#endif

	j = COM_CheckParm("-mem");
	if (j)
		parms.memsize = (int) (Q_atof(com_argv[j+1]) * 1024 * 1024);
	parms.membase = malloc (parms.memsize);

	parms.basedir = basedir;
// caching is disabled by default, use -cachedir to enable
//	parms.cachedir = cachedir;

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

    Host_Init(&parms);

	Sys_Init();

	if (COM_CheckParm("-nostdout"))
		nostdout = 1;
	else {
		fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
		printf ("Linux Quake -- Version %0.3f\n", LINUX_VERSION);
	}

    oldtime = Sys_FloatTime () - 0.1;
    while (1)
    {
// find time spent rendering last frame
        newtime = Sys_FloatTime ();
        time = newtime - oldtime;

        if (cls.state == ca_dedicated)
        {   // play vcrfiles at max speed
            if (time < sys_ticrate.value && (vcrFile == -1 || recording) )
            {
				usleep(1);
                continue;       // not time to run a server only tic yet
            }
            time = sys_ticrate.value;
        }

        if (time > sys_ticrate.value*2)
            oldtime = newtime;
        else
            oldtime += time;

        Host_Frame (time);

// graphic debugging aids
        if (sys_linerefresh.value)
            Sys_LineRefresh ();
    }

}
示例#6
0
/*
=============
main
=============
*/
int
main ( int argc, char *argv[] )
{
	double			time, oldtime, newtime;
	quakeparms_t	parms;
	fd_set	fdset;
	extern	int		net_socket;
	struct timeval timeout;
	int j;

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

	COM_InitArgv (argc, argv);
	parms.argc = com_argc;
	parms.argv = com_argv;

	parms.memsize = 16*1024*1024;

	j = COM_CheckParm("-mem");
	if (j)
		parms.memsize = (int) (Q_atof(com_argv[j+1]) * 1024 * 1024);
	if ((parms.membase = malloc (parms.memsize)) == NULL)
		Sys_Error("Can't allocate %ld\n", parms.memsize);

	parms.basedir = ".";

	SV_Init (&parms);

// run one frame immediately for first heartbeat
	SV_Frame (0.1);

//
// main loop
//
	oldtime = Sys_DoubleTime () - 0.1;
	while (1)
	{
	// select on the net socket and stdin
	// the only reason we have a timeout at all is so that if the last
	// connected client times out, the message would not otherwise
	// be printed until the next event.
		FD_ZERO(&fdset);
		if (do_stdin)
			FD_SET(0, &fdset);
		FD_SET(net_socket, &fdset);
		timeout.tv_sec = 1;
		timeout.tv_usec = 0;
		if (select (net_socket+1, &fdset, NULL, NULL, &timeout) == -1)
			continue;
		stdin_ready = FD_ISSET(0, &fdset);

	// find time passed since last cycle
		newtime = Sys_DoubleTime ();
		time = newtime - oldtime;
		oldtime = newtime;

		SV_Frame (time);

	// extrasleep is just a way to generate a f****d up connection on purpose
		if (sys_extrasleep->value)
			usleep (sys_extrasleep->value);
	}
	exit(0);
}
示例#7
0
int
main(int c, char **v)
{
    double time, oldtime, newtime;
    quakeparms_t parms;
    int j;

//      signal(SIGFPE, floating_point_exception_handler);
    signal(SIGFPE, SIG_IGN);

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

    COM_InitArgv(c, v);
    parms.argc = com_argc;
    parms.argv = com_argv;

#ifdef GLQUAKE
    parms.memsize = 16 * 1024 * 1024;
#else
    parms.memsize = 8 * 1024 * 1024;
#endif

    j = COM_CheckParm("-mem");
    if (j)
	parms.memsize = (int)(Q_atof(com_argv[j + 1]) * 1024 * 1024);
    parms.membase = malloc(parms.memsize);
    parms.basedir = stringify(QBASEDIR);
// caching is disabled by default, use -cachedir to enable
//      parms.cachedir = cachedir;

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

    Host_Init(&parms);

    Sys_Init();

    if (COM_CheckParm("-nostdout"))
	nostdout = true;

    // Make stdin non-blocking
    // FIXME - check both return values
    if (!noconinput)
	fcntl(STDIN_FILENO, F_SETFL,
	      fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK);
    if (!nostdout)
	printf("TyrQuake -- Version %s\n", stringify(TYR_VERSION));

    oldtime = Sys_DoubleTime() - 0.1;
    while (1) {
// find time spent rendering last frame
	newtime = Sys_DoubleTime();
	time = newtime - oldtime;

	if (cls.state == ca_dedicated) {
	    if (time < sys_ticrate.value) {
		usleep(1);
		continue;	// not time to run a server only tic yet
	    }
	    time = sys_ticrate.value;
	}

	if (time > sys_ticrate.value * 2)
	    oldtime = newtime;
	else
	    oldtime += time;

	Host_Frame(time);

// graphic debugging aids
	if (sys_linerefresh.value)
	    Sys_LineRefresh();
    }
}
示例#8
0
void Sys_InitArgv(char *lpCmdLine)
{
	static char *argv[MAX_COMMAND_LINE_PARAMS];
	unsigned char c;
#ifdef REHLDS_FIXES
	bool inQuotes;
#endif

	argv[0] = "";
	c = *lpCmdLine;
	for (host_parms.argc = 1; c && host_parms.argc < MAX_COMMAND_LINE_PARAMS; c = *(++lpCmdLine))
	{
#ifdef REHLDS_FIXES
		// Skip whitespace
		while (c && c <= ' ')
		{
			lpCmdLine++;
			c = *lpCmdLine;
		}
		if (!c)
		{
			break;
		}

		// TODO: Add MultiByteToWideChar conversion under Windows, to correctly get UTF8, but need to alloc memory to store it
		// Store arg pointer
		argv[host_parms.argc] = lpCmdLine;
		host_parms.argc++;

		// Find end of the argument
		inQuotes = false;
		while (c > ' ' || (c && inQuotes))	// FIXED: Do not break quoted arguments
		{
			if (c == '"')
			{
				inQuotes = !inQuotes;
			}
			lpCmdLine++;
			c = *lpCmdLine;
		}
#else // REHLDS_FIXES
		// Skip whitespace and UTF8
		while (c && (c <= ' ' || c > '~'))
		{
			lpCmdLine++;
			c = *lpCmdLine;
		}
		if (!c)
		{
			break;
		}

		// Store arg pointer
		argv[host_parms.argc] = lpCmdLine;
		host_parms.argc++;

		// Find end of the argument
		while (c > ' ' && c <= '~')
		{
			lpCmdLine++;
			c = *lpCmdLine;
		}
#endif // REHLDS_FIXES
		if (!c)
		{
			break;
		}
		*lpCmdLine = 0;
	}

	host_parms.argv = argv;
	COM_InitArgv(host_parms.argc, argv);
	host_parms.argc = com_argc;
	host_parms.argv = com_argv;
}
示例#9
0
文件: sys_sdl.c 项目: PGGB/NullQuake
int main (int argc, char **argv)
{
    SDL_Window *window;
    double newtime, oldtime;
    int previous_key_dest = 0;

    if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
        printf("SDL_Init error: %s\n", SDL_GetError());
        return 1;
    }

    window = SDL_CreateWindow("NullQuake", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, 0);
    if (window == NULL) {
        Con_Printf("SDL_CreateWindow error: %s\n", SDL_GetError());
        SDL_Quit();
        return 1;
    }
    windowID = SDL_GetWindowID(window);
    SDL_DisableScreenSaver();

	static quakeparms_t parms;

	parms.memsize = 8*1024*1024;
	parms.membase = malloc (parms.memsize);

    char *base_path = SDL_GetBasePath();
    if (base_path) {
        parms.basedir = SDL_strdup(base_path);
        SDL_free(base_path);
    } else {
        parms.basedir = SDL_strdup("./");
    }

	COM_InitArgv (argc, argv);

	parms.argc = com_argc;
	parms.argv = com_argv;

	printf ("Host_Init\n");
	Host_Init (&parms);

    oldtime = Sys_FloatTime();
	while (1)
	{
        // release mouse cursor in menus
        if (previous_key_dest != key_dest) {
            if (key_dest == key_game) {
                SDL_SetRelativeMouseMode(SDL_TRUE);
            } else {
                SDL_SetRelativeMouseMode(SDL_FALSE);
            }
            previous_key_dest = key_dest;
        }
        // throttle in background
        if (!isFocused) {
            SDL_Delay(32);
        }
		newtime = Sys_FloatTime();
        Host_Frame(newtime - oldtime);
        oldtime = newtime;
	}

    return 0;
}
示例#10
0
文件: common.c 项目: chrisnew/quake2
/*
=================
Qcommon_Init
=================
*/
void Qcommon_Init (int argc, char **argv)
{
	static const char	*apVersion = APPLICATION " v" VERSION " " CPUSTRING " " __DATE__ " " BUILDSTRING;

	if (setjmp (abortframe) )
		Sys_Error ("Error during initialization");

	z_chain.next = z_chain.prev = &z_chain;

	// prepare enough of the subsystems to handle
	// cvar and command buffer management
	COM_InitArgv (argc, argv);

	Swap_Init ();
	Cbuf_Init ();

	Cmd_Init ();
	Cvar_Init ();

	Key_Init ();

	// we need to add the early commands twice, because
	// a basedir or cddir needs to be set before execing
	// config files, but we want other parms to override
	// the settings of the config files
	Cbuf_AddEarlyCommands (false);
	Cbuf_Execute();

	FS_InitFilesystem ();

	Cbuf_AddText ("exec default.cfg\n");
	Cbuf_Execute();
	Cbuf_AddText ("exec aprconfig.cfg\n");
	Cbuf_Execute();
	FS_ExecConfig("autoexec.cfg");
	Cbuf_Execute();

	Cbuf_AddEarlyCommands (true);
	Cbuf_Execute();

	Cmd_AddCommand ("echo", Cmd_Echo_f);
	// init commands and vars
    Cmd_AddCommand ("z_stats", Z_Stats_f);
	Cmd_AddCommand( "z_check", Z_Check );

	host_speeds = Cvar_Get ("host_speeds", "0", 0);
	developer = Cvar_Get ("developer", "0", 0);
	timescale = Cvar_Get ("timescale", "1", CVAR_CHEAT);
	fixedtime = Cvar_Get ("fixedtime", "0", CVAR_CHEAT);
	logfile_active = Cvar_Get ("logfile", "0", 0);
	showtrace = Cvar_Get ("showtrace", "0", 0);
#ifdef DEDICATED_ONLY
	dedicated = Cvar_Get ("dedicated", "1", CVAR_ROM);
#else
	dedicated = Cvar_Get ("dedicated", "0", CVAR_NOSET);
#endif

	timescale->OnChange = OnChange_Timescale;
	OnChange_Timescale(timescale, timescale->resetString);

	Cvar_Get ("version", apVersion, CVAR_SERVERINFO|CVAR_ROM);

	Cmd_AddMacro( "date", Com_Date_m );
	Cmd_AddMacro( "time", Com_Time_m );

	if (dedicated->integer)
		Cmd_AddCommand ("quit", Com_Quit);

#ifndef NDEBUG
	Cmd_AddCommand( "error", Com_Error_f );
	Cmd_AddCommand( "errordrop", Com_ErrorDrop_f );
	Cmd_AddCommand( "freeze", Com_Freeze_f );
	Cmd_AddCommand( "crash", Com_Crash_f );
#endif

	Sys_Init ();

	srand(Sys_Milliseconds());

	NET_Init ();
	Netchan_Init ();

	SV_Init ();
	CL_Init ();

	ComInitialized = true;

	Cbuf_InsertFromDefer(); //Execute commands which was initialized after loading autoexec (ignore, highlight etc)
	FS_ExecConfig ("postinit.cfg");
	Cbuf_Execute();

	// add + commands from command line
	if (!Cbuf_AddLateCommands ())
	{	// if the user didn't give any commands, run default action
		if (!dedicated->integer)
			Cbuf_AddText ("toggleconsole\n");
		else
			Cbuf_AddText ("dedicated_start\n");
		Cbuf_Execute();
	}
	else
	{	// the user asked for something explicit
		// so drop the loading plaque
		SCR_EndLoadingPlaque();
	}

	Com_Printf ("====== " APPLICATION " Initialized ======\n\n");	
}
示例#11
0
int
main(int c, const char **v)
{
    double time, oldtime, newtime;
    quakeparms_t parms;
    int j;

    signal(SIGFPE, SIG_IGN);

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

    COM_InitArgv(c, v);
    parms.argc = com_argc;
    parms.argv = com_argv;

    parms.memsize = 16 * 1024 * 1024;

    j = COM_CheckParm("-mem");
    if (j)
	parms.memsize = (int)(Q_atof(com_argv[j + 1]) * 1024 * 1024);
    parms.membase = malloc(parms.memsize);
    parms.basedir = stringify(QBASEDIR);

    if (COM_CheckParm("-noconinput"))
	noconinput = true;
    if (COM_CheckParm("-nostdout"))
	nostdout = true;

    // Make stdin non-blocking
    // FIXME - check both return values
    if (!noconinput)
	fcntl(STDIN_FILENO, F_SETFL,
	      fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK);
    if (!nostdout)
#ifdef NQ_HACK
	printf("Quake -- TyrQuake Version %s\n", stringify(TYR_VERSION));
#endif
#ifdef QW_HACK
	printf("QuakeWorld -- TyrQuake Version %s\n", stringify(TYR_VERSION));
#endif

    Sys_Init();
    Host_Init(&parms);

#ifdef NQ_HACK
    oldtime = Sys_DoubleTime() - 0.1;
#endif
#ifdef QW_HACK
    oldtime = Sys_DoubleTime();
#endif
    while (1) {
// find time spent rendering last frame
	newtime = Sys_DoubleTime();
	time = newtime - oldtime;

#ifdef NQ_HACK
	if (cls.state == ca_dedicated) {
	    if (time < sys_ticrate.value) {
		usleep(1);
		continue;	// not time to run a server only tic yet
	    }
	    time = sys_ticrate.value;
	}
	if (time > sys_ticrate.value * 2)
	    oldtime = newtime;
	else
	    oldtime += time;
#endif
#ifdef QW_HACK
	oldtime = newtime;
#endif

	Host_Frame(time);
    }

    return 0;
}
示例#12
0
/*
* Qcommon_Init
*/
void Qcommon_Init( int argc, char **argv )
{
	if( setjmp( abortframe ) )
		Sys_Error( "Error during initialization: %s", com_errormsg );

	QThreads_Init();

	com_print_mutex = QMutex_Create();

	// initialize memory manager
	Memory_Init();

	// prepare enough of the subsystems to handle
	// cvar and command buffer management
	COM_InitArgv( argc, argv );

	Cbuf_Init();

	// initialize cmd/cvar/dynvar tries
	Cmd_PreInit();
	Cvar_PreInit();
	Dynvar_PreInit();

	// create basic commands and cvars
	Cmd_Init();
	Cvar_Init();
	Dynvar_Init();
	dynvars_initialized = true;

	wswcurl_init();

	Key_Init();

	// we need to add the early commands twice, because
	// a basepath or cdpath needs to be set before execing
	// config files, but we want other parms to override
	// the settings of the config files
	Cbuf_AddEarlyCommands( false );
	Cbuf_Execute();

	// wsw : aiwa : create dynvars (needs to be completed before .cfg scripts are executed)
	Dynvar_Create( "sys_uptime", true, Com_Sys_Uptime_f, DYNVAR_READONLY );
	Dynvar_Create( "frametick", false, DYNVAR_WRITEONLY, DYNVAR_READONLY );
	Dynvar_Create( "quit", false, DYNVAR_WRITEONLY, DYNVAR_READONLY );
	Dynvar_Create( "irc_connected", false, Irc_GetConnected_f, Irc_SetConnected_f );

	Sys_InitDynvars();
	CL_InitDynvars();

#ifdef TV_SERVER_ONLY
	tv_server = Cvar_Get( "tv_server", "1", CVAR_NOSET );
	Cvar_ForceSet( "tv_server", "1" );
#else
	tv_server = Cvar_Get( "tv_server", "0", CVAR_NOSET );
#endif

#ifdef DEDICATED_ONLY
	dedicated =	    Cvar_Get( "dedicated", "1", CVAR_NOSET );
	Cvar_ForceSet( "dedicated", "1" );
#else
	dedicated =	    Cvar_Get( "dedicated", "0", CVAR_NOSET );
#endif

	FS_Init();

	Cbuf_AddText( "exec default.cfg\n" );
	if( !dedicated->integer )
	{
		Cbuf_AddText( "exec config.cfg\n" );
		Cbuf_AddText( "exec autoexec.cfg\n" );
	}
	else if( tv_server->integer )
	{
		Cbuf_AddText( "exec tvserver_autoexec.cfg\n" );
	}
	else
	{
		Cbuf_AddText( "exec dedicated_autoexec.cfg\n" );
	}

	Cbuf_AddEarlyCommands( true );
	Cbuf_Execute();

	//
	// init commands and vars
	//
	Memory_InitCommands();

	Qcommon_InitCommands();

	host_speeds =	    Cvar_Get( "host_speeds", "0", 0 );
	log_stats =	    Cvar_Get( "log_stats", "0", 0 );
	developer =	    Cvar_Get( "developer", "0", 0 );
	timescale =	    Cvar_Get( "timescale", "1.0", CVAR_CHEAT );
	fixedtime =	    Cvar_Get( "fixedtime", "0", CVAR_CHEAT );
	if( tv_server->integer )
		logconsole =	    Cvar_Get( "logconsole", "tvconsole.log", CVAR_ARCHIVE );
	else if( dedicated->integer )
		logconsole =	    Cvar_Get( "logconsole", "wswconsole.log", CVAR_ARCHIVE );
	else
		logconsole =	    Cvar_Get( "logconsole", "", CVAR_ARCHIVE );
	logconsole_append = Cvar_Get( "logconsole_append", "1", CVAR_ARCHIVE );
	logconsole_flush =  Cvar_Get( "logconsole_flush", "0", CVAR_ARCHIVE );
	logconsole_timestamp =	Cvar_Get( "logconsole_timestamp", "0", CVAR_ARCHIVE );

	com_showtrace =	    Cvar_Get( "com_showtrace", "0", 0 );
	com_introPlayed3 =   Cvar_Get( "com_introPlayed3", "0", CVAR_ARCHIVE );

	Cvar_Get( "irc_server", "irc.quakenet.org", CVAR_ARCHIVE );
	Cvar_Get( "irc_port", "6667", CVAR_ARCHIVE );
	Cvar_Get( "irc_nick", APPLICATION "Player", CVAR_ARCHIVE );
	Cvar_Get( "irc_user", APPLICATION "User", CVAR_ARCHIVE );
	Cvar_Get( "irc_password", "", CVAR_ARCHIVE );

	Cvar_Get( "gamename", APPLICATION, CVAR_READONLY );
	versioncvar = Cvar_Get( "version", APP_VERSION_STR " " CPUSTRING " " __DATE__ " " BUILDSTRING, CVAR_SERVERINFO|CVAR_READONLY );
	revisioncvar = Cvar_Get( "revision", SVN_RevString(), CVAR_READONLY );

	Sys_Init();

	NET_Init();
	Netchan_Init();

	CM_Init();

#if APP_STEAMID
	Steam_LoadLibrary();
#endif

	Com_ScriptModule_Init();

	MM_Init();

	SV_Init();
	CL_Init();

	SCR_EndLoadingPlaque();

	if( !dedicated->integer )
		Cbuf_AddText( "exec autoexec_postinit.cfg\n" );
	else if( tv_server->integer )
		Cbuf_AddText( "exec tvserver_autoexec_postinit.cfg\n" );
	else
		Cbuf_AddText( "exec dedicated_autoexec_postinit.cfg\n" );

	// add + commands from command line
	if( !Cbuf_AddLateCommands() )
	{
		// if the user didn't give any commands, run default action

		if( !dedicated->integer )
		{
			// only play the introduction sequence once
			if( !com_introPlayed3->integer )
			{
				Cvar_ForceSet( com_introPlayed3->name, "1" );
#if !defined(__MACOSX__) && (!defined(__ANDROID__) || defined (__i386__) || defined (__x86_64__))
				Cbuf_AddText( "cinematic intro.roq\n" );
#endif
			}
		}
	}
	else
	{
		// the user asked for something explicit
		// so drop the loading plaque
		SCR_EndLoadingPlaque();
	}

	Com_Printf( "\n====== %s Initialized ======\n", APPLICATION );

	Cbuf_Execute();
}
示例#13
0
文件: sys_dos.c 项目: Blzut3/Engoo
int main (int c, char **v)
{
	double			time, oldtime, newtime;
	extern void (*dos_error_func)(char *, ...);
	static	char	cwd[1024];
	byte	screen[80*25*2];

		COM_InitArgv (c, v);
	inthedos = 1; // leilei - stupid hack to let the engine know we're in dos
	quakeparms.argc = com_argc;
	quakeparms.argv = com_argv;
	// moved parm checking up here to get the bottom working...
	// title image
//	char			ver[6];
//	int			i;
//	loadedfile_t	*fileinfo;	
//	host_parms = *parms;
//	Host_Init(&quakeparms);
#ifdef BENCH
	    clrscr();
	textattr((BLUE<<4)+YELLOW);
	  clreol();
			printf ("                           Lite Engoo Bencher v%4.2f                            \n",VERSION);
textattr((BLUE<<4)+DARKGRAY);
#else


			    clrscr();
	SetYourBlues(); 
			//	COM_Init (parms->basedir);
	if (COM_CheckParm ("-hipnotic"))
	{
			textattr((BLUE<<4)+YELLOW);
			clreol();
			printf ("                 Quake Mission Pack 1:  Scourge of Armagon v%4.2f               \n",VERSION);
			clreol();
			printf ("                (C)1996 id software (C) 1997 Ritual Entertainment               \n",VERSION);

	}
		else 	if (COM_CheckParm ("-rogue")){
			textattr((RED<<4)+WHITE);
	    	clreol();
			printf ("              Quake Mission Pack 2:  Dissolution of Eternity v%4.2f             \n",VERSION);
			clreol();
			printf ("                (C)1996 id software (C) 1997 Rogue Entertainment                \n",VERSION);
		}
		else 	if (COM_CheckParm ("qsr")){
			SetYourBlues(); 			
			textattr((BLUE<<4)+YELLOW);
	    	clreol();
			printf ("                                 HELLSMASH                                      \n",VERSION);
			//clreol();
		}

		// The notable commercial Quake TCs get their own startup bar ;) 
			else 	if (COM_CheckParm ("malice")){
			textattr((DARKGRAY<<4)+LIGHTRED);
	    		clreol();
			printf ("                                  Malice v%4.2f                                 \n",VERSION);
			textattr((DARKGRAY<<4)+WHITE);
			clreol();
			printf ("                         Copyright C) 1997 Ratloop, Inc.                        \n",VERSION);
		}
			else 	if (COM_CheckParm ("shrak")){
			textattr((CYAN<<4)+WHITE);
	    		clreol();
			printf ("                                   Shrak v%4.2f                                 \n",VERSION);
		    	clreol();
			printf ("                        Copyright C) 1997 Quantum Axcess                        \n",VERSION);
		}
			else 	if (COM_CheckParm ("xmen")){
			textattr((MAGENTA<<4)+YELLOW);
	    		clreol();
			printf ("                       X-MEN: Ravages of Apocalypse v%4.2f                      \n",VERSION);
		    	clreol();
			printf ("               Copyright C) 1997 Zero Gravity / MARVEL Interactive              \n",VERSION);
		}
		else 	if (COM_CheckParm ("laser")){
			textattr((MAGENTA<<4)+YELLOW);
	    		clreol();
			printf ("                                    LASER ARENA                                 \n",VERSION);
		    	clreol();
			printf ("               Copyright (C) 2000 Trainwreck Studios / 2015 Inc.                \n",VERSION);
		}
		else 	if (COM_CheckParm ("basetf")){
			textattr((RED<<4)+YELLOW);
	    	clreol();
			printf (" TRANSFUSION RELEASE %4.2f ["__DATE__"] --                   \n",VERSION);
		}
		else	if (COM_CheckParm ("grass")){
			textattr((BLACK<<4)+YELLOW);
	    		clreol();
			printf ("                                Watching Grass Grow                             \n",VERSION);
		}
		
		else{

			//	textattr((1<<4)+2); // was yellow
			textattr((BLUE<<4)+YELLOW);
	  clreol();
	//		printf ("                                 Quake v%4.2f                                   \n",VERSION);
	//clreol();
	//		printf ("                         Copyright(C)1996 id software                           \n",VERSION);
			printf (" ENGOO %4.2f ["__DATE__"] --                           \n",VERSION);
	}

#endif
  // printf ("Build: __DATE__"\n");
    //textattr((BLACK<<4)+WHITE);
	  // clreol();
	//printf ("Quake v%4.2f\n", VERSION);
/*

// ANSI start screen never could work so I left it out. Bummer
	
//	byte	*d;	// 2001-09-12 Returning information about loaded file by Maddes


		fileinfo = COM_LoadHunkFile ("start.bin");
	//	fileinfo = COM_LoadHunkFile ("end1.bin");

	if (fileinfo)
		memcpy (screen, fileinfo->data, sizeof(screen));

// write the version number directly to the end screen
	sprintf (ver, " v%4.2f", VERSION);
	for (i=0 ; i<6 ; i++)
		screen[0*80*2 + 72*2 + i*2] = ver[i];

	if (fileinfo)
	{
		memcpy ((void *)real2ptr(0xb8000), screen,80*25*2);

	// set text pos
		regs.x.ax = 0x0200;
		regs.h.bh = 0;
		regs.h.dl = 0;
		regs.h.dh = 22;
		dos_int86 (0x10);
	}
	else
	{
			

	}
//	printf ("WELCOME TO YOUR DOOM!\n");
*/

// Do the GPLv2 notice
	printf ("================================================================================");
	printf ("This engine comes with ABSOLUTELY NO WARRANTY;this is Free Software, and you are");
   	printf (" welcome to redistribute it under certain conditions; see 'COPYING' for details.");
	printf ("================================================================================");


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

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



	dos_error_func = Sys_Error;

	Sys_DetectWin95 ();
	Sys_PageInProgram ();
	Sys_GetMemory ();

	if (COM_CheckParm ("-nolookups"))
	printf ("!!!!!Generation of lookup tables will be skipped!!!!!\nStuff will not blend and colored lighting will be disabled.\n");


// Prototype stuff

	atexit (Sys_AtExit);	// in case we crash

	getwd (cwd);
	if (cwd[strlen(cwd)-1] == '/') cwd[strlen(cwd)-1] = 0;
	quakeparms.basedir = cwd; //"f:/quake";

	isDedicated = (COM_CheckParm ("-dedicated") != 0);

	Sys_Init ();

	if (!isDedicated)
		dos_registerintr(9, TrapKey);

//Sys_InitStackCheck ();

	Host_Init(&quakeparms);

//Sys_StackCheck ();

//Con_Printf ("Top of stack: 0x%x\n", &time);
	oldtime = Sys_FloatTime ();
	while (1)
	{
		newtime = Sys_FloatTime ();
		time = newtime - oldtime;

		if (cls.state == ca_dedicated && (time<sys_ticrate->value))
			continue;

		Host_Frame (time);

//Sys_StackCheck ();

		oldtime = newtime;
	}
}
示例#14
0
bool retro_load_game(const struct retro_game_info *info)
{
   quakeparms_t parms;

   extract_directory(g_rom_dir, info->path, sizeof(g_rom_dir));

   snprintf(g_pak_path, sizeof(g_pak_path), "%s", info->path);

   MEMSIZE_MB = DEFAULT_MEMSIZE_MB;

   if (strstr(info->path, "hipnotic") || strstr(info->path, "rogue")
         || strstr(info->path, "HIPNOTIC")
         || strstr(info->path, "ROGUE"))
   {
#if defined(HW_RVL) || defined(_XBOX1)
      MEMSIZE_MB = 16;
#endif
      extract_directory(g_rom_dir, g_rom_dir, sizeof(g_rom_dir));
   }

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

   COM_InitArgv(0, NULL);

   parms.argc = com_argc;
   parms.argv = com_argv;
   parms.basedir = g_rom_dir;
   parms.memsize = MEMSIZE_MB * 1024 * 1024;

   heap = (unsigned char*)malloc(parms.memsize);

   parms.membase = heap;

#ifdef NQ_HACK
   fprintf(stderr, "Quake Libretro -- TyrQuake Version %s\n", stringify(TYR_VERSION));
#endif
#ifdef QW_HACK
   fprintf(stderr, "QuakeWorld Libretro -- TyrQuake Version %s\n", stringify(TYR_VERSION));
#endif

   Sys_Init();
   Host_Init(&parms);

   Cvar_Set("cl_bob", "0.02");
   Cvar_Set("crosshair", "0");
   Cvar_Set("viewsize", "100");
   Cvar_Set("showram", "0");
   Cvar_Set("dither_filter", "1");
   Cvar_RegisterVariable(&framerate);
   Cvar_Set("framerate", "60");

   enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
   if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
   {
      fprintf(stderr, "RGB565 is not supported.\n");
      return false;
   }

   /* set keyboard callback */

   //struct retro_keyboard_callback cb = { keyboard_cb };
   //environ_cb(RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK, &cb);

#ifdef NQ_HACK
   oldtime = Sys_DoubleTime() - 0.1;
#endif
#ifdef QW_HACK
   oldtime = Sys_DoubleTime();
#endif

   return true;
}
示例#15
0
void AndroidInit2(int width, int height)
{
  PMPLOG(("AndroidInit2 %d,%d", width, height));

  gInitialized = true;
  PMPBEGIN(("AndroidInit2"));
  quakeparms_t parms;
  int j;
  int c = 0;
  const char* v[] = {"quake", (char*) 0};

  scr_width = width;
  scr_height = height;

//	static char cwd[1024];

//	signal(SIGFPE, floating_point_exception_handler);
//  signal(SIGFPE, SIG_IGN);

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

  if (gArgc) {
      COM_InitArgv(gArgc, (const char**) gArgv);
  }
  else {
      COM_InitArgv(c, (const char**) v);
  }

  parms.argc = com_argc;
  parms.argv = com_argv;

  parms.memsize = 16*1024*1024;

  j = COM_CheckParm("-mem");
  if (j)
    parms.memsize = (int) (Q_atof(com_argv[j+1]) * 1024 * 1024);
  parms.membase = malloc (parms.memsize);

  const char* basedir = basedir2;
  if(direxists(basedir1))
  {
    basedir = basedir1;
  }
  else if(direxists(basedir2))
  {
    basedir = basedir2;
  }
  else
  {
    Sys_Error("Could not find data directories %s or %s", basedir1, basedir2);
  }
  parms.basedir = basedir;

  CheckGLCacheVersion(basedir);

// caching is disabled by default, use -cachedir to enable
//	parms.cachedir = cachedir;

#if 0 // FNDELAY not implemented
  noconinput = COM_CheckParm("-noconinput");
  if (!noconinput)
    fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
#endif

  if (COM_CheckParm("-nostdout"))
    nostdout = 1;

  Sys_Init();

    Host_Init(&parms);

    g_oldtime = Sys_FloatTime ();
  PMPEND(("AndroidInit2"));
}
示例#16
0
文件: sv_sys_win.c 项目: deurk/mvdsv
int APIENTRY WinMain(   HINSTANCE   hInstance,
						HINSTANCE   hPrevInstance,
						LPSTR       lpCmdLine,
						int         nCmdShow)
{
	static MSG			msg;
	static double		newtime, time, oldtime;
	register int		sleep_msec;

	static qbool		disable_gpf = false;

	ParseCommandLine(lpCmdLine);

	COM_InitArgv (argc, argv);

	// create main window
	if (!CreateMainWindow(hInstance, nCmdShow))
		return 1;

	if (COM_CheckParm("-noerrormsgbox"))
		disable_gpf = true;

	if (COM_CheckParm ("-d"))
	{
		isdaemon = disable_gpf = true;
		//close(0); close(1); close(2);
	}

	if (disable_gpf)
	{
		DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
		SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);
	}
	
	Host_Init(argc, argv, DEFAULT_MEM_SIZE);

	// if stared miminize update notify icon message (with correct port)
	if (minimized)
		UpdateNotifyIconMessage(va(SERVER_NAME ":%d", NET_UDPSVPort()));

	// run one frame immediately for first heartbeat
	SV_Frame (0.1);

	//
	// main loop
	//
	oldtime = Sys_DoubleTime () - 0.1;

	while(1)
	{
		// get messeges sent to windows
		if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
		{
			if( !GetMessage( &msg, NULL, 0, 0 ) )
				break;
			if(!IsDialogMessage(DlgHwnd, &msg))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}

		CheckIdle();

		// server frame

		sleep_msec = (int)sys_sleep.value;
		if (sleep_msec > 0)
		{
			if (sleep_msec > 13)
				sleep_msec = 13;
			Sleep (sleep_msec);
		}

		// select on the net socket and stdin
		// the only reason we have a timeout at all is so that if the last
		// connected client times out, the message would not otherwise
		// be printed until the next event.
		if (!sys_simulation.value) {
			NET_Sleep((int)sys_select_timeout.value / 1000, false);
		}

		// find time passed since last cycle
		newtime = Sys_DoubleTime ();
		time = newtime - oldtime;
		oldtime = newtime;

		curtime = newtime;
		SV_Frame (time);
	}


	Sys_Exit(msg.wParam);

	return msg.wParam;
}
示例#17
0
		static void* main_thread_function(void*)
		{
			u32 level, real_heap_size;

			// hope the parms are all set by now
			COM_InitArgv(parms_number, parms_array);

			_CPU_ISR_Disable(level);
			heap = (char *)align32(SYS_GetArena2Lo());
			real_heap_size = heap_size - ((u32)heap - (u32)SYS_GetArena2Lo());
			if ((u32)heap + real_heap_size > (u32)SYS_GetArena2Hi())
			{
				_CPU_ISR_Restore(level);
				Sys_Error("heap + real_heap_size > (u32)SYS_GetArena2Hi()");
			}	
			else
			{
				SYS_SetArena2Lo(heap + real_heap_size);
				_CPU_ISR_Restore(level);
			}

			VIDEO_SetBlack(TRUE);

			// Initialise the Host module.
			quakeparms_t parms;
			memset(&parms, 0, sizeof(parms));
			parms.argc		= com_argc;
			parms.argv		= com_argv;
			parms.basedir	= QUAKE_WII_BASEDIR;
			parms.memsize	= real_heap_size;
			parms.membase	= heap;
			if (parms.membase == 0)
			{
				Sys_Error("Heap allocation failed");
			}
			memset(parms.membase, 0, parms.memsize);
			Host_Init(&parms);

#if TIME_DEMO
			Cbuf_AddText("map start\n");
			Cbuf_AddText("wait\n");
			Cbuf_AddText("timedemo demo1\n");
#endif
#if TEST_CONNECTION
			Cbuf_AddText("connect 192.168.0.2");
#endif

			SYS_SetResetCallback(reset_system);
			SYS_SetPowerCallback(shutdown_system);

			VIDEO_SetBlack(FALSE);

			// Run the main loop.
			u64 last_time = gettime();
			for (;;)
			{
				if (want_to_reset)
					Sys_Reset();
				if (want_to_shutdown)
					Sys_Shutdown();

				// Get the frame time in ticks.
				const u64		current_time	= gettime();
				const u64		time_delta		= current_time - last_time;
				const double	seconds	= time_delta * (0.001f / TB_TIMER_CLOCK);
				last_time = current_time;

				// Run the frame.
				Host_Frame(seconds);
			};

			// Quit (this code is never reached).
			Sys_Quit();
			return 0;
		}
示例#18
0
文件: host.c 项目: matatk/agrip
/*
====================
Host_Init
====================
*/
void Host_Init (int argc, char **argv, int default_memsize)
{
	COM_InitArgv (argc, argv);

#if !defined(CLIENTONLY) && !defined(SERVERONLY)
	if (COM_CheckParm("-dedicated"))
		dedicated = true;
#endif

	Host_InitMemory (default_memsize);

	Cbuf_Init ();
	Cmd_Init ();
	Cvar_Init ();
	COM_Init ();
	Key_Init ();

	FS_InitFilesystem ();
	COM_CheckRegistered ();

	Con_Init ();

	if (!dedicated) {
		Cbuf_AddText ("exec default.cfg\n");
		Cbuf_AddText ("exec config.cfg\n");
		Cbuf_Execute ();
	}

	Cbuf_AddEarlyCommands ();
	Cbuf_Execute ();

	NET_Init ();
	Netchan_Init ();
	Sys_Init ();
	CM_Init ();
	PM_Init ();
	Host_InitLocal ();

	SV_Init ();
	CL_Init ();

	Cvar_CleanUpTempVars ();

	Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
	host_hunklevel = Hunk_LowMark ();

	host_initialized = true;

	Com_Printf ("Exe: "__TIME__" "__DATE__"\n");
	Com_Printf ("%4.1f megs RAM used.\n", host_memsize / (1024*1024.0));
	Com_Printf ("\n========= " PROGRAM " Initialized =========\n");


	if (dedicated)
	{
		Cbuf_AddText ("exec server.cfg\n");
		Cmd_StuffCmds_f ();		// process command line arguments
		Cbuf_Execute ();

	// if a map wasn't specified on the command line, spawn start map
		if (!com_serveractive)
			Cmd_ExecuteString ("map start");
		if (!com_serveractive)
			Host_Error ("Couldn't spawn a server");
	}
	else
	{
		Cbuf_AddText ("exec autoexec.cfg\n");
		Cmd_StuffCmds_f ();		// process command line arguments
		Cbuf_AddText ("cl_warncmd 1\n");
	}
}