コード例 #1
0
ファイル: files.c プロジェクト: qbism/qbq2
/*
================
FS_InitFilesystem
================
*/
void FS_InitFilesystem(void)
{
	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", ".", CVAR_NOSET);

	//
	// cddir <path>
	// Logically concatenates the cddir after the basedir for 
	// allows the game to run from outside the data tree
	//
	fs_cddir = Cvar_Get("cddir", "", CVAR_NOSET);
	if (fs_cddir->string[0])
		FS_AddGameDirectory(va("%s/"BASEDIRNAME, fs_cddir->string));

	//
	// start up with baseq2 by default
	//
	FS_AddGameDirectory(va("%s/"BASEDIRNAME, fs_basedir->string));

	// any set gamedirs will be freed up to here
	fs_base_searchpaths = fs_searchpaths;

	// check for game override
	fs_gamedirvar = Cvar_Get("game", "", CVAR_LATCH | CVAR_SERVERINFO);
	if (fs_gamedirvar->string[0])
		FS_SetGamedir(fs_gamedirvar->string);
}
コード例 #2
0
ファイル: cvar.c プロジェクト: turol/webquake2
/*
============
Cvar_GetLatchedVars

Any variables with latched values will now be updated
============
*/
void Cvar_GetLatchedVars (void)
{
	cvar_t	*var;
	char	*old_string;

	for (var = cvar_vars ; var ; var = var->next)
	{
		if (!var->latched_string)
			continue;

		old_string = var->string;

		var->string = var->latched_string;
		var->latched_string = NULL;
		var->value = (float)atof(var->string);
		var->intvalue = (int)var->value;

		//r1: fix 0 case
		if (!var->intvalue && FLOAT_NE_ZERO(var->value))
			var->intvalue = 1;

		if (var->changed)
			var->changed (var, old_string, var->string);

		Z_Free (old_string);

		if (!strcmp(var->name, "game"))
		{
			FS_SetGamedir (var->string);
			if (!Cvar_IntValue ("dedicated"))
				FS_ExecConfig ("autoexec.cfg");
		}
	}
}
コード例 #3
0
ファイル: sv_ccmds.c プロジェクト: jogi1/camquake
//Sets the gamedir and path to a different directory.
void SV_Gamedir_f (void) {
	char *dir;

	if (Cmd_Argc() == 1) {
		Com_Printf ("Current gamedir: %s\n", com_gamedirfile);
		return;
	}

	if (Cmd_Argc() != 2) {
		Com_Printf ("Usage: gamedir <newdir>\n");
		return;
	}

	dir = Cmd_Argv(1);

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

#ifndef SERVERONLY
	if (CL_ClientState()) {
		Com_Printf ("you must disconnect before changing gamedir\n");
		return;
	}
#endif

	FS_SetGamedir (dir);
	Info_SetValueForStarKey (svs.info, "*gamedir", dir, MAX_SERVERINFO_STRING);
}
コード例 #4
0
ファイル: filesystem.c プロジェクト: Clever-Boy/yquake2
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);
}
コード例 #5
0
ファイル: files.c プロジェクト: Slipyx/r1q2
/*
================
FS_InitFilesystem
================
*/
void FS_InitFilesystem (void)
{
	current_filename = "unknown";

	Cmd_AddCommand ("path", FS_Path_f);
	Cmd_AddCommand ("link", FS_Link_f);
	Cmd_AddCommand ("dir", FS_Dir_f );

	//r1: search for a file
	Cmd_AddCommand ("whereis", FS_WhereIs_f);

	//r1: allow manual cache flushing
	Cmd_AddCommand ("fsflushcache", FS_FlushCache);

	//r1: fs stats
	Cmd_AddCommand ("fs_stats", FS_Stats_f);

	//r1: binary tree filesystem cache
	FS_InitCache ();

	//r1: init fs cache
	//FS_FlushCache ();

	//
	// basedir <path>
	// allows the game to run from outside the data tree
	//
	fs_basedir = Cvar_Get ("basedir", ".", CVAR_NOSET);
	fs_cache = Cvar_Get ("fs_cache", "7", 0);
	fs_noextern = Cvar_Get ("fs_noextern", "0", 0);

	//
	// start up with baseq2 by default
	//
	FS_AddGameDirectory (va("%s/"BASEDIRNAME, fs_basedir->string) );

	// any set gamedirs will be freed up to here
	fs_base_searchpaths = fs_searchpaths;

	// check for game override
	fs_gamedirvar = Cvar_Get ("game", "", CVAR_LATCH|CVAR_SERVERINFO);
	if (fs_gamedirvar->string[0])
		FS_SetGamedir (fs_gamedirvar->string);
}
コード例 #6
0
ファイル: cvar.c プロジェクト: Jaegermeiste/quake2_322
/*
============
Cvar_GetLatchedVars

Any variables with latched values will now be updated
============
*/
void Cvar_GetLatchedVars (void)
{
	cvar_t	*var;

	for (var = cvar_vars ; var ; var = var->next)
	{
		if (!var->latched_string)
			continue;
		Z_Free (var->string);
		var->string = var->latched_string;
		var->latched_string = NULL;
		var->value = atof(var->string);
		if (!strcmp(var->name, "game"))
		{
			FS_SetGamedir (var->string);
			FS_ExecAutoexec ();
		}
	}
}
コード例 #7
0
ファイル: files.c プロジェクト: dschimmer/omega-q2-engine
/*
================
FS_InitFilesystem
================
*/
void FS_InitFilesystem (void)
{
	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", ".", CVAR_NOSET);

	//
	// cddir <path>
	// Logically concatenates the cddir after the basedir for 
	// allows the game to run from outside the data tree
	//
	fs_cddir = Cvar_Get ("cddir", "", CVAR_NOSET);
	if (fs_cddir->string[0])
		FS_AddGameDirectory (va("%s/"BASEDIRNAME, fs_cddir->string) );

	//
	// start up with baseq2 by default
	//
	FS_AddGameDirectory (va("%s/"BASEDIRNAME, fs_basedir->string) );
	
#ifdef ANDROID
    FS_AddGameDirectory(va("/sdcard/"BASEDIRNAME));
    FS_AddGameDirectory(va("/"BASEDIRNAME));
    FS_AddGameDirectory(va("/storage/emulated/0/"BASEDIRNAME));
    FS_AddGameDirectory(va("/data/data/com.example.quake2/files/"BASEDIRNAME));
    FS_AddGameDirectory(va("/storage/emulated/0/Android/data/com.example.quake2/files/"BASEDIRNAME));
    FS_AddGameDirectory(va("/sdcard/Android/data/com.example.quake2/files/"BASEDIRNAME));
#endif

	// any set gamedirs will be freed up to here
	fs_base_searchpaths = fs_searchpaths;
Com_Printf("search-path: %s", fs_base_searchpaths);
	// check for game override
	fs_gamedirvar = Cvar_Get ("game", "", CVAR_LATCH|CVAR_SERVERINFO);
	if (fs_gamedirvar->string[0])
		FS_SetGamedir (fs_gamedirvar->string);
}
コード例 #8
0
/**
 * \brief Initialize file system.
 */
PUBLIC void FS_InitFilesystem( void )
{
    char path[1024];

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

	//
	// cddir <path>
	// Logically concatenates the cddir after the basedir. This 
	// allows the game to run from outside the data tree.
	//
	fs_cddir = Cvar_Get( "cddir", "", CVAR_ROM );
	if( fs_cddir->string[ 0 ] )
	{
        com_snprintf( path, sizeof(path), "%s%c%s", fs_cddir->string, PATH_SEP, BASE_DIRECTORY );
		FS_AddGameDirectory( path );
	}

	//
	// start up with BASEDIRNAME by default
	//    
    com_snprintf( path, sizeof(path), "%s%c%s", fs_basedir->string, PATH_SEP, BASE_DIRECTORY );
    FS_AddGameDirectory( path ); 

	// any set gamedirs will be freed up to here
	fs_base_searchpaths = fs_searchpaths;

	// check for game override
	fs_gamedirvar = Cvar_Get( "game", "", CVAR_LATCH | CVAR_SERVERINFO );
	if( fs_gamedirvar->string[ 0 ] )
	{
		FS_SetGamedir( fs_gamedirvar->string );
	}
}
コード例 #9
0
ファイル: cl_parse.c プロジェクト: Slipyx/r1q2
/*
==================
CL_ParseServerData
==================
*/
qboolean CL_ParseServerData (void)
{
	char	*str;
	int		i;
	int		newVersion;
	cvar_t	*gameDirHack;
//
// wipe the client_state_t struct
//
	CL_ClearState ();
	cls.state = ca_connected;

// parse protocol version number
	i = MSG_ReadLong (&net_message);
	cls.serverProtocol = i;

	cl.servercount = MSG_ReadLong (&net_message);
	cl.attractloop = MSG_ReadByte (&net_message);

	if (i != PROTOCOL_ORIGINAL && i != PROTOCOL_R1Q2 && !cl.attractloop)
		Com_Error (ERR_HARD, "Server is using unknown protocol %d.", i);

	// game directory
	str = MSG_ReadString (&net_message);
	strncpy (cl.gamedir, str, sizeof(cl.gamedir)-1);

	// set gamedir, f*****g christ this is messy!
	if ((str[0] && (!fs_gamedirvar->string || !fs_gamedirvar->string[0] || strcmp(fs_gamedirvar->string, str))) ||
		(!str[0] && (fs_gamedirvar->string || fs_gamedirvar->string[0])))
	{
		if (strcmp(fs_gamedirvar->string, str))
		{
			if (cl.attractloop)
			{
				Cvar_ForceSet ("game", str);
				FS_SetGamedir (str);
			}
			else
			{
				Cvar_Set("game", str);
			}
		}
	}

	Cvar_ForceSet ("$game", str);

	gameDirHack = Cvar_FindVar ("game");
	gameDirHack->flags |= CVAR_NOSET;

	// parse player entity number
	cl.playernum = MSG_ReadShort (&net_message);

	// get the full level name
	str = MSG_ReadString (&net_message);

	if (cls.serverProtocol == PROTOCOL_R1Q2)
	{
		cl.enhancedServer = MSG_ReadByte (&net_message);

		newVersion = MSG_ReadShort (&net_message);
		if (newVersion != MINOR_VERSION_R1Q2)
		{
			if (cl.attractloop)
			{
				if (newVersion < MINOR_VERSION_R1Q2)
					Com_Printf ("This demo was recorded with an earlier version of the R1Q2 protocol. It may not play back properly.\n", LOG_CLIENT);
				else
					Com_Printf ("This demo was recorded with a later version of the R1Q2 protocol. It may not play back properly. Please update your R1Q2 client.\n", LOG_CLIENT);
			}
			else
			{
				if (newVersion > MINOR_VERSION_R1Q2)
					Com_Printf ("Server reports a higher R1Q2 protocol number than your client supports. Some features will be unavailable until you update your R1Q2 client.\n", LOG_CLIENT);
				else
					Com_Printf ("Server reports a lower R1Q2 protocol number. The server admin needs to update their server!\n", LOG_CLIENT);
			}

			//cap if server is above us just to be safe
			if (newVersion > MINOR_VERSION_R1Q2)
				newVersion = MINOR_VERSION_R1Q2;
		}

		if (newVersion >= 1903)
		{
			MSG_ReadByte (&net_message);	//was ad
			cl.strafeHack = MSG_ReadByte (&net_message);
		}
		else
		{
			cl.strafeHack = false;
		}
		
		cls.protocolVersion = newVersion;
	}
	else
	{
		cl.enhancedServer = false;
		cl.strafeHack = false;
		cls.protocolVersion = 0;
	}

	Com_DPrintf ("Serverdata packet received. protocol=%d, servercount=%d, attractloop=%d, clnum=%d, game=%s, map=%s, enhanced=%d\n", cls.serverProtocol, cl.servercount, cl.attractloop, cl.playernum, cl.gamedir, str, cl.enhancedServer);

	if (cl.playernum == -1)
	{	// playing a cinematic or showing a pic, not a level
		//SCR_PlayCinematic (str);
		// tell the server to advance to the next map / cinematic
		MSG_WriteByte (clc_stringcmd);
		MSG_Print (va("nextserver %i\n", cl.servercount));
		MSG_EndWriting (&cls.netchan.message);
	}
	else
	{
		// seperate the printfs so the server message can have a color
		Com_Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n", LOG_CLIENT);
		Com_Printf ("\2%s\n", LOG_CLIENT, str);

		// need to prep refresh at next oportunity
		cl.refresh_prepped = false;
	}

	//CL_FixCvarCheats();
	return true;
}
コード例 #10
0
ファイル: cvar.c プロジェクト: Jaegermeiste/quake2_322
/*
============
Cvar_Set2
============
*/
cvar_t *Cvar_Set2 (char *var_name, char *value, int force)
{
	cvar_t	*var;

	var = Cvar_FindVar (var_name);
	if (!var)
	{	// create it
		return Cvar_Get (var_name, value, 0);
	}

	if (var->flags & (CVAR_USERINFO | CVAR_SERVERINFO))
	{
		if (!Cvar_InfoValidate (value))
		{
			Com_Printf("invalid info cvar value\n");
			return var;
		}
	}

	if (!force)
	{
		if (var->flags & CVAR_NOSET)
		{
			Com_Printf ("%s is write protected.\n", var_name);
			return var;
		}

		if (var->flags & CVAR_LATCH)
		{
			if (var->latched_string)
			{
				if (strcmp(value, var->latched_string) == 0)
					return var;
				Z_Free (var->latched_string);
			}
			else
			{
				if (strcmp(value, var->string) == 0)
					return var;
			}

			if (Com_ServerState())
			{
				Com_Printf ("%s will be changed for next game.\n", var_name);
				var->latched_string = CopyString(value);
			}
			else
			{
				var->string = CopyString(value);
				var->value = atof (var->string);
				if (!strcmp(var->name, "game"))
				{
					FS_SetGamedir (var->string);
					FS_ExecAutoexec ();
				}
			}
			return var;
		}
	}
	else
	{
		if (var->latched_string)
		{
			Z_Free (var->latched_string);
			var->latched_string = NULL;
		}
	}

	if (!strcmp(value, var->string))
		return var;		// not changed

	var->modified = 1;

	if (var->flags & CVAR_USERINFO)
		userinfo_modified = 1;	// transmit at next oportunity
	
	Z_Free (var->string);	// free the old value string
	
	var->string = CopyString(value);
	var->value = atof (var->string);

	return var;
}
コード例 #11
0
ファイル: cvar.c プロジェクト: turol/webquake2
/*
============
Cvar_Set2
============
*/
static cvar_t *Cvar_Set2 (const char *var_name, const char *value, qboolean force)
{
	cvar_t	*var;
	char *old_string;

	Q_assert (var_name != NULL);
	Q_assert (value != NULL);
	
	if (var_name[0] == '$' && !force)
	{
		Com_Printf ("%s is write protected.\n", LOG_GENERAL, var_name);
		return NULL;
	}

	var = Cvar_FindVar (var_name);
	if (!var)
	{	// create it
		return Cvar_Get (var_name, value, 0);
	}

	if (var->flags & (CVAR_USERINFO | CVAR_SERVERINFO))
	{
		if (!Cvar_InfoValidate (value))
		{
			Com_Printf("invalid info cvar value\n", LOG_GENERAL);
			return var;
		}
	}

	if (!force)
	{
#ifdef _DEBUG
		if (var->flags & CVAR_NOSET && !Cvar_IntValue ("developer"))
#else
		if (var->flags & CVAR_NOSET)
#endif
		{
			Com_Printf ("%s is write protected.\n", LOG_GENERAL, var_name);
			return var;
		}

		if (var->flags & CVAR_LATCH)
		{
			if (var->latched_string)
			{
				if (strcmp(value, var->latched_string) == 0)
					return var;
				Z_Free (var->latched_string);
			}
			else
			{
				if (strcmp(value, var->string) == 0)
					return var;
			}

			if (Com_ServerState())
			{
				Com_Printf ("%s will be changed for next map.\n", LOG_GENERAL, var_name);
				var->latched_string = CopyString(value, TAGMALLOC_CVAR);
			}
			else
			{
				//memleak fix, thanks Maniac-
				Z_Free (var->string);
				var->string = CopyString(value, TAGMALLOC_CVAR);
				var->value = (float)atof (var->string);
				var->intvalue = (int)var->value;

				//r1: fix 0 case
				if (!var->intvalue && FLOAT_NE_ZERO(var->value))
					var->intvalue = 1;

				if (!strcmp(var->name, "game"))
				{
					FS_SetGamedir (var->string);
					if (!Cvar_IntValue ("dedicated"))
						FS_ExecConfig ("autoexec.cfg");
				}
			}
			return var;
		}
	}
	else
	{
		if (var->latched_string)
		{
			Z_Free (var->latched_string);
			var->latched_string = NULL;
		}
	}

	if (!strcmp(value, var->string))
		return var;		// not changed

	old_string = var->string;
	var->string = CopyString(value, TAGMALLOC_CVAR);

	var->value = (float)atof (var->string);
	var->intvalue = (int)var->value;

	//r1: fix 0 case
	if (!var->intvalue && FLOAT_NE_ZERO(var->value))
		var->intvalue = 1;

	var->modified = true;

	if (var->changed)
		var->changed (var, old_string, var->string);

	if (var->flags & CVAR_USERINFO)
		userinfo_modified = true;	// transmit at next oportunity
	
	Z_Free (old_string);	// free the old value string

	return var;
}