Example #1
0
void TEST_Init (void)
{
	try {
		com_aliasSysPool  = Mem_CreatePool("Common: Alias system");
		com_cmdSysPool    = Mem_CreatePool("Common: Command system");
		com_cmodelSysPool = Mem_CreatePool("Common: Collision model");
		com_cvarSysPool   = Mem_CreatePool("Common: Cvar system");
		com_fileSysPool   = Mem_CreatePool("Common: File system");
		com_genericPool   = Mem_CreatePool("Generic");

		Mem_Init();
		Cbuf_Init();
		Cmd_Init();
		Cvar_Init();
		FS_InitFilesystem(true);
		FS_AddGameDirectory("./unittest", false);
		FS_AddHomeAsGameDirectory("unittest", true);
		Swap_Init();
		SV_Init();
		NET_Init();

		FS_ExecAutoexec();

		OBJZERO(csi);
	} catch (comDrop_t const&) {
		Sys_Error("Error during initialization");
	}

	http_timeout = Cvar_Get("noname");
	http_proxy = Cvar_Get("noname");
	hwclass = Cvar_Get("hwclass", "5");
}
Example #2
0
void
FS_InitFilesystem(void)
{
	/* Register FS commands. */
	Cmd_AddCommand("path", FS_Path_f);
	Cmd_AddCommand("link", FS_Link_f);
	Cmd_AddCommand("dir", FS_Dir_f);

	/* basedir <path> Allows the game to run from outside the data tree.  */
	fs_basedir = Cvar_Get("basedir",
#ifdef SYSTEMWIDE
		SYSTEMDIR,
#else
		".",
#endif
		CVAR_NOSET);

	/* cddir <path> Logically concatenates the cddir after the basedir to
	   allow the game to run from outside the data tree. */
	fs_cddir = Cvar_Get("cddir", "", CVAR_NOSET);

	if (fs_cddir->string[0] != '\0')
	{
		FS_AddGameDirectory(va("%s/" BASEDIRNAME, fs_cddir->string));
	}

	/* Debug flag. */
	fs_debug = Cvar_Get("fs_debug", "0", 0);

	/* Game directory. */
	fs_gamedirvar = Cvar_Get("game", "", CVAR_LATCH | CVAR_SERVERINFO);

	/* Current directory. */
	fs_homepath = Cvar_Get("homepath", Sys_GetCurrentDirectory(), CVAR_NOSET);

	/* Add baseq2 to search path. */
	FS_AddGameDirectory(va("%s/" BASEDIRNAME, fs_basedir->string));
	FS_AddBinaryDirAsGameDirectory(BASEDIRNAME);
	FS_AddHomeAsGameDirectory(BASEDIRNAME);

	/* Any set gamedirs will be freed up to here. */
	fs_baseSearchPaths = fs_searchPaths;
	Q_strlcpy(fs_currentGame, BASEDIRNAME, sizeof(fs_currentGame));

	/* Check for game override. */
	if (fs_gamedirvar->string[0] != '\0')
	{
		FS_SetGamedir(fs_gamedirvar->string);
	}

	/* Create directory if it does not exist. */
	FS_CreatePath(fs_gamedir);

	Com_Printf("Using '%s' for writing.\n", fs_gamedir);
}
Example #3
0
/*
 * Sets the gamedir and path to a different directory.
 */
void
FS_SetGamedir(char *dir)
{
	int i;
	fsSearchPath_t *next;

	if (strstr(dir, "..") || strstr(dir, "/"))
	{
		Com_Printf("Gamedir should be a single filename, not a path.\n");
		return;
	}

	/* Free up any current game dir info. */
	while (fs_searchPaths != fs_baseSearchPaths)
	{
		if (fs_searchPaths->pack)
		{
			if (fs_searchPaths->pack->pak)
			{
				fclose(fs_searchPaths->pack->pak);
			}

#ifdef ZIP
			if (fs_searchPaths->pack->pk3)
			{
				unzClose(fs_searchPaths->pack->pk3);
			}
#endif

			Z_Free(fs_searchPaths->pack->files);
			Z_Free(fs_searchPaths->pack);
		}

		next = fs_searchPaths->next;
		Z_Free(fs_searchPaths);
		fs_searchPaths = next;
	}

	/* Close open files for game dir. */
	for (i = 0; i < MAX_HANDLES; i++)
	{
		if (strstr(fs_handles[i].name, dir) &&
			((fs_handles[i].file != NULL)
#ifdef ZIP
			  || (fs_handles[i].zip != NULL)
#endif
			))
		{
			FS_FCloseFile(i);
		}
	}

	/* Flush all data, so it will be forced to reload. */
	if ((dedicated != NULL) && (dedicated->value != 1))
	{
		Cbuf_AddText("vid_restart\nsnd_restart\n");
	}

	Com_sprintf(fs_gamedir, sizeof(fs_gamedir), "%s/%s",
			fs_basedir->string, dir);

	if ((strcmp(dir, BASEDIRNAME) == 0) || (*dir == 0))
	{
		Cvar_FullSet("gamedir", "", CVAR_SERVERINFO | CVAR_NOSET);
		Cvar_FullSet("game", "", CVAR_LATCH | CVAR_SERVERINFO);
	}
	else
	{
		Cvar_FullSet("gamedir", dir, CVAR_SERVERINFO | CVAR_NOSET);

		if (fs_cddir->string[0] == '\0')
		{
			FS_AddGameDirectory(va("%s/%s", fs_cddir->string, dir));
		}

#ifdef SYSTEMWIDE
		FS_AddSystemwideGameDirectory(dir);
#endif

		FS_AddGameDirectory(va("%s/%s", fs_basedir->string, dir));
		FS_AddHomeAsGameDirectory(dir);
	}
}