Example #1
0
/*
   ===============
   Cmd_picdir
   ===============
 */
void Cmd_Picdir( void ){
	char filename[1024];

	GetScriptToken( false );
	strcpy( pic_prefix, token );
	// create the directory if needed
	sprintf( filename, "%sPics", g_outputDir );
	Q_mkdir( filename );
	sprintf( filename, "%sPics/%s", g_outputDir, pic_prefix );
	Q_mkdir( filename );
}
Example #2
0
/*
   ===============
   Cmd_Mipdir
   ===============
 */
void Cmd_Mipdir( void ){
	char filename[1024];

	GetToken( false );
	strcpy( mip_prefix, token );
	// create the directory if needed
	sprintf( filename, "%stextures", gamedir, mip_prefix );
	Q_mkdir( filename );
	sprintf( filename, "%stextures/%s", gamedir, mip_prefix );
	Q_mkdir( filename );
}
Example #3
0
void PrefsDlg::Init(){
	// m_global_rc_path has been set above
	// m_rc_path is for game specific preferences
	// takes the form: global-pref-path/gamename/prefs-file

	// this is common to win32 and Linux init now
	m_rc_path = g_string_new( m_global_rc_path->str );

	// game sub-dir
	g_string_append( m_rc_path, g_pGameDescription->mGameFile.c_str() );
	g_string_append( m_rc_path, "/" );
	Q_mkdir( m_rc_path->str );

	// then the ini file
	m_inipath = g_string_new( m_rc_path->str );
	g_string_append( m_inipath, PREFS_LOCAL_FILENAME );
}
Example #4
0
/*
============
CreatePath
============
*/
void CreatePath (char *path)
{
	char	*ofs, c;

	// strip the drive
	if (path[1] == ':')
		path += 2;

	for (ofs = path+1 ; *ofs ; ofs++)
	{
		c = *ofs;
		if (c == '/' || c == '\\')
		{	// create the directory
			*ofs = 0;
			Q_mkdir (path);
			*ofs = c;
		}
	}
}
Example #5
0
/*
============
CreatePath
============
*/
void CreatePath (char *path)
{
	char	*ofs, c;

	if (!path || !*path)
		return;

	ofs = path;
	if (HAS_DRIVE_SPEC(ofs))
		ofs = STRIP_DRIVE_SPEC(ofs);
	if (IS_DIR_SEPARATOR(*ofs))
		ofs++;

	for ( ; *ofs; ofs++)
	{
		c = *ofs;
		if (IS_DIR_SEPARATOR(c))
		{
			*ofs = 0;
			Q_mkdir (path);
			*ofs = c;
		}
	}
}
Example #6
0
void QE_InitVFS( void ){
	// VFS initialization -----------------------
	// we will call vfsInitDirectory, giving the directories to look in (for files in pk3's and for standalone files)
	// we need to call in order, the mod ones first, then the base ones .. they will be searched in this order
	// *nix systems have a dual filesystem in ~/.q3a, which is searched first .. so we need to add that too
	Str directory,prefabs;

	// TTimo: let's leave this to HL mode for now
	if ( g_pGameDescription->mGameFile == "hl.game" ) {
		// Hydra: we search the "gametools" path first so that we can provide editor
		// specific pk3's wads and misc files for use by the editor.
		// the relevant map compiler tools will NOT use this directory, so this helps
		// to ensure that editor files are not used/required in release versions of maps
		// it also helps keep your editor files all in once place, with the editor modules,
		// plugins, scripts and config files.
		// it also helps when testing maps, as you'll know your files won't/can't be used
		// by the game engine itself.

		// <gametools>
		directory = g_pGameDescription->mGameToolsPath;
		vfsInitDirectory( directory.GetBuffer() );
	}

	// NOTE TTimo about the mymkdir calls .. this is a bit dirty, but a safe thing on *nix

	// if we have a mod dir
	if ( *ValueForKey( g_qeglobals.d_project_entity, "gamename" ) != '\0' ) {

#if defined ( __linux__ ) || defined ( __APPLE__ )
		// ~/.<gameprefix>/<fs_game>
		directory = g_qeglobals.m_strHomeGame.GetBuffer();
		Q_mkdir( directory.GetBuffer(), 0775 );
		directory += ValueForKey( g_qeglobals.d_project_entity, "gamename" );
		Q_mkdir( directory.GetBuffer(), 0775 );
		vfsInitDirectory( directory.GetBuffer() );
		AddSlash( directory );
		prefabs = directory;
		// also create the maps dir, it will be used as prompt for load/save
		directory += "/maps";
		Q_mkdir( directory, 0775 );
		// and the prefabs dir
		prefabs += "/prefabs";
		Q_mkdir( prefabs, 0775 );

#endif

		// <fs_basepath>/<fs_game>
		directory = g_pGameDescription->mEnginePath;
		directory += ValueForKey( g_qeglobals.d_project_entity, "gamename" );
		Q_mkdir( directory.GetBuffer(), 0775 );
		vfsInitDirectory( directory.GetBuffer() );
		AddSlash( directory );
		prefabs = directory;
		// also create the maps dir, it will be used as prompt for load/save
		directory += "/maps";
		Q_mkdir( directory.GetBuffer(), 0775 );
		// and the prefabs dir
		prefabs += "/prefabs";
		Q_mkdir( prefabs, 0775 );
	}

#if defined ( __linux__ ) || defined ( __APPLE__ )
	// ~/.<gameprefix>/<fs_main>
	directory = g_qeglobals.m_strHomeGame.GetBuffer();
	directory += g_pGameDescription->mBaseGame;
	vfsInitDirectory( directory.GetBuffer() );
#endif

	// <fs_basepath>/<fs_main>
	directory = g_pGameDescription->mEnginePath;
	directory += g_pGameDescription->mBaseGame;
	vfsInitDirectory( directory.GetBuffer() );
}
Example #7
0
/*
   ===========
   QE_LoadProject
   NOTE: rather than bumping "version", consider bumping "template_version" (see above)
   NOTE: when QE_LoadProject is called, the prefs are updated with path to the latest project and saved on disk
   ===========
 */
bool QE_LoadProject( const char *projectfile ){
	char buf[1024];
	xmlDocPtr doc;
	xmlNodePtr node, project;

	Sys_Printf( "Loading project file: \"%s\"\n", projectfile );
	doc = ParseXMLFile( projectfile, true );

	if ( doc == NULL ) {
		return false;
	}

	node = doc->children;
	while ( node != NULL && node->type != XML_DTD_NODE ) node = node->next;
	if ( node == NULL || strcmp( (char*)node->name, "project" ) != 0 ) {
		Sys_FPrintf( SYS_ERR, "ERROR: invalid file type\n" );
		return false;
	}

	while ( node->type != XML_ELEMENT_NODE ) node = node->next;
	// <project>
	project = node;

	if ( g_qeglobals.d_project_entity != NULL ) {
		Entity_Free( g_qeglobals.d_project_entity );
	}
	g_qeglobals.d_project_entity = Entity_Alloc();

	for ( node = project->children; node != NULL; node = node->next )
	{
		if ( node->type != XML_ELEMENT_NODE ) {
			continue;
		}

		// <key>
		ReplaceTemplates( buf, (char*)node->properties->next->children->content );

		SetKeyValue( g_qeglobals.d_project_entity, (char*)node->properties->children->content, buf );
	}

	xmlFreeDoc( doc );

	// project file version checking
	// add a version checking to avoid people loading later versions of the project file and bitching
	int ver = IntForKey( g_qeglobals.d_project_entity, "version" );
	if ( ver > PROJECT_VERSION ) {
		char strMsg[1024];
		sprintf( strMsg, "This is a version %d project file. This build only supports <=%d project files.\n"
						 "Please choose another project file or upgrade your version of Radiant.", ver, PROJECT_VERSION );
		gtk_MessageBox( g_pParentWnd->m_pWidget, strMsg, "Can't load project file", MB_ICONERROR | MB_OK );
		// set the project file to nothing so we are sure we'll ask next time?
		g_PrefsDlg.m_strLastProject = "";
		g_PrefsDlg.SavePrefs();
		return false;
	}

	// set here some default project settings you need
	if ( strlen( ValueForKey( g_qeglobals.d_project_entity, "brush_primit" ) ) == 0 ) {
		SetKeyValue( g_qeglobals.d_project_entity, "brush_primit", "0" );
	}

	g_qeglobals.m_bBrushPrimitMode = IntForKey( g_qeglobals.d_project_entity, "brush_primit" );

	g_qeglobals.m_strHomeMaps = g_qeglobals.m_strHomeGame;
	const char* str = ValueForKey( g_qeglobals.d_project_entity, "gamename" );
	if ( str[0] == '\0' ) {
		str = g_pGameDescription->mBaseGame.GetBuffer();
	}
	g_qeglobals.m_strHomeMaps += str;
	g_qeglobals.m_strHomeMaps += '/';

	// don't forget to create the dirs
	Q_mkdir( g_qeglobals.m_strHomeGame.GetBuffer(), 0775 );
	Q_mkdir( g_qeglobals.m_strHomeMaps.GetBuffer(), 0775 );

	// usefull for the log file and debuggin f****d up configurations from users:
	// output the basic information of the .qe4 project file
	// SPoG
	// all these paths should be unix format, with a trailing slash at the end
	// if not.. to debug, check that the project file paths are set up correctly
	Sys_Printf( "basepath    : %s\n", ValueForKey( g_qeglobals.d_project_entity, "basepath" ) );
	Sys_Printf( "entitypath  : %s\n", ValueForKey( g_qeglobals.d_project_entity, "entitypath" ) );


	// check whether user_project key exists..
	// if not, save the current project under a new name
	if ( ValueForKey( g_qeglobals.d_project_entity, "user_project" )[0] == '\0' ) {
		Sys_Printf( "Loaded a template project file\n" );

		// create the user_project key
		SetKeyValue( g_qeglobals.d_project_entity, "user_project", "1" );

		if ( IntForKey( g_qeglobals.d_project_entity, "version" ) != PROJECT_VERSION ) {
			char strMsg[2048];
			sprintf( strMsg,
					 "The template project '%s' has version %d. The editor binary is configured for version %d.\n"
					 "This indicates a problem in your setup.\n"
					 "I will keep going with this project till you fix this",
					 projectfile, IntForKey( g_qeglobals.d_project_entity, "version" ), PROJECT_VERSION );
			gtk_MessageBox( g_pParentWnd->m_pWidget, strMsg, "Can't load project file", MB_ICONERROR | MB_OK );
		}

		// create the writable project file path
		strcpy( buf, g_qeglobals.m_strHomeGame.GetBuffer() );
		strcat( buf, g_pGameDescription->mBaseGame.GetBuffer() );
		strcat( buf, "/scripts/" );
		// while the filename is already in use, increment the number we add to the end
		int counter = 0;
		char pUser[PATH_MAX];
		while ( 1 )
		{
			sprintf( pUser, "%suser%d." PROJECT_FILETYPE, buf, counter );
			counter++;
			if ( access( pUser, R_OK ) != 0 ) {
				// this is the one
				strcpy( buf, pUser );
				break;
			}
		}
		// saving project will cause a save prefs
		g_PrefsDlg.m_strLastProject = buf;
		g_PrefsDlg.m_nLastProjectVer = IntForKey( g_qeglobals.d_project_entity, "version" );
		QE_SaveProject( buf );
	}
	else
	{
		// update preferences::LastProject with path of this successfully-loaded project
		// save preferences
		Sys_Printf( "Setting current project in prefs to \"%s\"\n", g_PrefsDlg.m_strLastProject.GetBuffer() );
		g_PrefsDlg.m_strLastProject = projectfile;
		g_PrefsDlg.SavePrefs();
	}

	return true;
}