コード例 #1
0
ファイル: Win_main.cpp プロジェクト: Izhido/qrevpak
void DLLBuildDone()
{
  g_hToolThread = NULL;
  CTime tEnd = CTime::GetCurrentTime();
  CTimeSpan tElapsed = tEnd - g_tBegin;
  CString strElapsed;
  strElapsed.Format("Run time was %i hours, %i minutes and %i seconds", tElapsed.GetHours(), tElapsed.GetMinutes(), tElapsed.GetSeconds());
	Sys_Printf(strElapsed.GetBuffer(0));
	Pointfile_Check();

  if (g_PrefsDlg.m_bRunQuake == TRUE)
  {
    char cCurDir[1024];
    GetCurrentDirectory(1024, cCurDir);
    CString strExePath = g_PrefsDlg.m_strQuake2;
    CString strOrgPath;
    CString strOrgFile;
    ExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);
    if (g_PrefsDlg.m_bSetGame == TRUE) // run in place with set game.. don't copy map
    {
	    CString strBasePath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
      strExePath += " +set game ";
      strExePath += strBasePath;
      WinExec(strExePath, SW_SHOW);
    }
    else
    {
      CString strCopyPath = strExePath;
      char* pBuffer = strCopyPath.GetBufferSetLength(_MAX_PATH + 1);
      pBuffer[strCopyPath.ReverseFind('\\') + 1] = '\0';
      strCopyPath.ReleaseBuffer();
      SetCurrentDirectory(strCopyPath);
      CString strOrgPath;
      CString strOrgFile;
      ExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile);
      AddSlash(strCopyPath);
      FindReplace(strOrgFile, ".map", ".bsp");
      strCopyPath += "\\baseq2\\maps\\";
      strCopyPath += strOrgFile;
      AddSlash(strOrgPath);
      strOrgPath += strOrgFile;
      bool bRun = (strOrgPath.CompareNoCase(strCopyPath) == 0);
      if (!bRun)
        bRun = (CopyFile(strOrgPath, strCopyPath, FALSE) == TRUE);
      if (bRun)
      {
        FindReplace(strOrgFile, ".bsp", "");
        strExePath += " +map ";
        strExePath += strOrgFile;
        WinExec(strExePath, SW_SHOW);
      }
    }
    SetCurrentDirectory(cCurDir);
  }

}
コード例 #2
0
ファイル: StrOp.cpp プロジェクト: JeffreyWest/FuzzyLogic
    void StrOp::main(int argc, char** argv) {
        std::string x = "Esto es= que y=o diga t=d=o= sin ='s =D";
        FL_LOG(x);
        FindReplace(x,"="," = ");
        FL_LOG(x);

    }
コード例 #3
0
ファイル: LLOutputC.cpp プロジェクト: thradams/tklgen
static void PrintOutputInterface(std::wostream& os, Grammar& g)
{
    std::wstring ws(STR_HEADER);

    std::wstring upperfile = MakeUpper(g.GetModuleName() + L".h");
    FindReplace(upperfile, L".", L"_");

    PrintGeneratedFileHeader(os);

    os << L"#ifndef " << upperfile << "" << std::endl;
    os << L"#define " << upperfile << "" << std::endl;
    os << std::endl;
    os << std::endl;

    find_replace(ws, L"{DATE}", __WDATE__);
    find_replace(ws, L"{GRAMMAR}", g.GetLanguageName());

    os << L"#include \"Result.h\"\n";
    os << L"#include " << "\"" << g.GetLanguageName() << ".h\"\n";

    std::wostringstream ss;

    PrintActions(ss, g, false);
    find_replace(ws, L"{ACTIONS}", ss.str());

    os << ws;

    os << std::endl;
    os << L"#endif" << std::endl;
}
コード例 #4
0
ファイル: Win_qe3.cpp プロジェクト: OnlyTheGhosts/OWEngine
void CheckBspProcess( void )
{
	char    outputpath[1024];
	char    temppath[512];
	DWORD   exitcode;
	char*   out;
	BOOL    ret;
	
	if ( !bsp_process )
		return;
		
	ret = GetExitCodeProcess( bsp_process, &exitcode );
	if ( !ret )
		Error( "GetExitCodeProcess failed" );
	if ( exitcode == STILL_ACTIVE )
		return;
		
	bsp_process = 0;
	
	GetTempPath( 512, temppath );
	sprintf( outputpath, "%sjunk.txt", temppath );
	
	LoadFile( outputpath, ( void** )&out );
	Sys_Printf( "%s", out );
	Sys_Printf( "\ncompleted.\n" );
	free( out );
	
	CTime tEnd = CTime::GetCurrentTime();
	CTimeSpan tElapsed = tEnd - g_tBegin;
	CString strElapsed;
	strElapsed.Format( "Run time was %i hours, %i minutes and %i seconds", tElapsed.GetHours(), tElapsed.GetMinutes(), tElapsed.GetSeconds() );
	Sys_Printf( strElapsed.GetBuffer( 0 ) );
	
	
	Sys_Beep();
	Pointfile_Check();
	// run game if no PointFile and pref is set
	//++timo needs to stop after BSP if leaked .. does run through vis and light instead ..
	if ( g_PrefsDlg.m_bRunQuake == TRUE  && !g_qeglobals.d_pointfile_display_list )
	{
		char cCurDir[1024];
		GetCurrentDirectory( 1024, cCurDir );
		CString strExePath = "../../qio.exe";
		//= g_PrefsDlg.m_strQuake2;
		CString strOrgPath;
		CString strOrgFile;
		ExtractPath_and_Filename( currentmap, strOrgPath, strOrgFile );
		if ( g_PrefsDlg.m_bSetGame == TRUE )  // run in place with set game.. don't copy map
		{
			CString strBasePath = ValueForKey( g_qeglobals.d_project_entity, "basepath" );
			strExePath += " +set game ";
			strExePath += strBasePath;
			WinExec( strExePath, SW_SHOW );
		}
		else
		{
			CString strCopyPath = strExePath;
			char* pBuffer = strCopyPath.GetBufferSetLength( _MAX_PATH + 1 );
			pBuffer[strCopyPath.ReverseFind( '\\' ) + 1] = '\0';
			strCopyPath.ReleaseBuffer();
			SetCurrentDirectory( strCopyPath );
			CString strOrgPath;
			CString strOrgFile;
			ExtractPath_and_Filename( currentmap, strOrgPath, strOrgFile );
			AddSlash( strCopyPath );
			FindReplace( strOrgFile, ".map", ".bsp" );
			//++timo modified for Quake3 !!
			strCopyPath += "baseq3\\maps\\";
			strCopyPath += strOrgFile;
			AddSlash( strOrgPath );
			strOrgPath += strOrgFile;
			bool bRun = ( strOrgPath.CompareNoCase( strCopyPath ) == 0 );
			if ( !bRun )
				bRun = ( CopyFile( strOrgPath, strCopyPath, FALSE ) == TRUE );
			if ( bRun )
			{
				FindReplace( strOrgFile, ".bsp", "" );
				strExePath += " +map ";
				strExePath += strOrgFile;
				WinExec( strExePath, SW_SHOW );
			}
		}
		SetCurrentDirectory( cCurDir );
	}
}
コード例 #5
0
ファイル: Win_main.cpp プロジェクト: OnlyTheGhosts/OWEngine
void RunBsp( char* command )
{
	char    sys[2048];
	char    batpath[2048];
	char    outputpath[2048];
	char    temppath[1024];
	char    name[2048];
	char    cWork[2048];
	FILE*   hFile;
	BOOL    ret;
	PROCESS_INFORMATION ProcessInformation;
	STARTUPINFO startupinfo;
	HWND hwndPClient = NULL;
	
	g_hWnd = g_pParentWnd->GetSafeHwnd();
	SetInspectorMode( W_CONSOLE );
	g_tBegin = CTime::GetCurrentTime();
	
	
	DWORD   dwExitcode;
	ret = GetExitCodeProcess( g_hToolThread, &dwExitcode );
	if ( dwExitcode != STILL_ACTIVE )
		g_hToolThread = NULL;
		
	if ( bsp_process || g_hToolThread )
	{
		Sys_Printf( "BSP is still going...\n" );
		return;
	}
	
	outputpath[0] = '\0';
	GetTempPath( 512, temppath );
	
	CString strOutFile = temppath;
	AddSlash( strOutFile );
	strOutFile += "junk.txt";
	
	sprintf( outputpath, " >>%s\r\n", strOutFile );
	
	strcpy( name, currentmap );
	if ( region_active )
	{
		Map_SaveFile( name, false );
		StripExtension( name );
		strcat( name, ".reg" );
	}
	
	Map_SaveFile( name, region_active );
	
	// FIXME: this code just gets worse and worse
	CString strPath, strFile;
	
	char* rsh = ValueForKey( g_qeglobals.d_project_entity, "rshcmd" );
	if ( rsh == NULL )
	{
		ExtractPath_and_Filename( name, strPath, strFile );
		AddSlash( strPath );
		BuildShortPathName( strPath, cWork, 1024 );
		strcat( cWork, strFile );
	}
	else
	{
		strcpy( cWork, name );
	}
	
	hwndPClient = FindWindow( NULL, "Q3Map Process Client" );
	if ( hwndPClient == NULL )
	{
		hwndPClient = FindAnyWindow( "Q3Map Process Client" );
	}
	
	Sys_Printf( "Window info for Process Client %i\n", reinterpret_cast<int>( hwndPClient ) );
	
	bool processServer = ( rsh && strlen( rsh ) > 0 && hwndPClient );
	
	QE_ExpandBspString( command, sys, cWork, processServer );
	
	// if we can find the q3map process server running
	// we will submit maps to it instead of via createprocess
	//
	if ( processServer )
	{
		CString str;
		char cBuff[2048];
		char* pStart = sys;
		char* pEnd = strstr( pStart, "&&" );
		while ( pEnd )
		{
			int nLen = pEnd - pStart - 1;
			strncpy( cBuff, pStart, nLen );
			cBuff[nLen] = 0;
			str = cBuff;
			FindReplace( str, rsh, "" );
			str.TrimLeft( ' ' );
			str.TrimRight( ' ' );
			ATOM a = GlobalAddAtom( str );
			PostMessage( hwndPClient, wm_AddCommand, 0, ( LPARAM )a );
			pStart = pEnd + 2;
			pEnd = strstr( pStart, "&&" );
		}
		str = pStart;
		FindReplace( str, rsh, "" );
		str.TrimLeft( ' ' );
		str.TrimRight( ' ' );
		ATOM a = GlobalAddAtom( str );
		PostMessage( hwndPClient, wm_AddCommand, 0, ( LPARAM )a );
		Sys_Printf( "Commands sent to Q3Map Process Client\n" );
		return;
	}
	
	CString strSys = sys;
	
	FindReplace( strSys, "&&", outputpath );
	strcpy( sys, strSys );
	strcat( sys, outputpath );
	
	
	Sys_ClearPrintf();
	Sys_Printf( "==================\nRunning bsp command...\n" );
	Sys_Printf( "\n%s\n", sys );
	
	//++timo removed the old way BSP commands .. dumping to junk.txt doesn't work on my win98 box
	// FIXME : will most likely break Quake2 BSP commands, is fitted to a one-lined sys command
	//
	// write qe3bsp.bat
	//
	//const char *basePath = ValueForKey(g_qeglobals.d_project_entity, "basepath");
	//if(basePath) {
	//const char *mapName =
	//sprintf(batpath,"%s/maps/%s.bat",basePath,mapName);
	strcpy( batpath, currentmap );
	char* dot = strchr( batpath, '.' );
	strcpy( dot, ".bat" );
	//} else {
	//  sprintf (batpath, "%sqe3bsp.bat", temppath);
	//}
	hFile = fopen( batpath, "w" );
	if ( !hFile )
		Error( "Can't write to %s", batpath );
	fprintf( hFile, sys );
	fclose( hFile );
	
	Pointfile_Delete();
	
	// delete junk.txt file
	remove( strOutFile );
	
	GetStartupInfo( &startupinfo );
	
	ret = CreateProcess(
			  batpath,
			  NULL,
			  NULL,
			  NULL,
			  FALSE,
			  0,
			  NULL,
			  NULL,
			  &startupinfo,
			  &ProcessInformation
		  );
		  
	if ( !ret )
		Error( "CreateProcess failed" );
		
	bsp_process = ProcessInformation.hProcess;
	
	Sleep( 100 );   // give the new process a chance to open it's window
	
	BringWindowToTop( g_qeglobals.d_hwndMain ); // pop us back on top
#if 0
	//
	// write qe3bsp.bat
	//
	sprintf( batpath, "%sqe3bsp.bat", temppath );
	hFile = fopen( batpath, "w" );
	if ( !hFile )
		Error( "Can't write to %s", batpath );
	fprintf( hFile, sys );
	fclose( hFile );
	
	//
	// write qe3bsp2.bat
	//
	sprintf( batpath, "%sqe3bsp2.bat", temppath );
	hFile = fopen( batpath, "w" );
	if ( !hFile )
		Error( "Can't write to %s", batpath );
	fprintf( hFile, "%sqe3bsp.bat > %s", temppath, outputpath );
	fclose( hFile );
	
	Pointfile_Delete();
	
	GetStartupInfo( &startupinfo );
	
	ret = CreateProcess(
			  batpath,      // pointer to name of executable module
			  NULL,         // pointer to command line string
			  NULL,         // pointer to process security attributes
			  NULL,         // pointer to thread security attributes
			  FALSE,            // handle inheritance flag
			  0 /*DETACHED_PROCESS*/,       // creation flags
			  NULL,         // pointer to new environment block
			  NULL,         // pointer to current directory name
			  &startupinfo, // pointer to STARTUPINFO
			  &ProcessInformation   // pointer to PROCESS_INFORMATION
		  );
		  
	if ( !ret )
		Error( "CreateProcess failed" );
		
	bsp_process = ProcessInformation.hProcess;
	
	Sleep( 100 );   // give the new process a chance to open it's window
	
	//BringWindowToTop( g_qeglobals.d_hwndMain );   // pop us back on top
	//SetFocus (g_qeglobals.d_hwndCamera);
#endif
	
}
コード例 #6
0
int PakLoadAnyFile(const char *filename, void **bufferptr)
{
  char cWork[WORK_LEN];
  if (g_bPK3)
  {
    PK3FileInfo *pInfo;
    Str strKey;
    // need to lookup the file without the base/texture path on it
    Str strBase(g_strBasePath);
    AddSlash(strBase);
    __ConvertDOSToUnixName(cWork, strBase);
    Str strFile(filename);
    __ConvertDOSToUnixName(strFile, strFile);
    strFile.MakeLower();
    strlwr(cWork);
    FindReplace(strFile, cWork, "");

    PK3FileInfo infoFind;
    infoFind.m_pName = __StrDup(strFile.GetBuffer());
    PK3List *pList = g_PK3Files.Find(&infoFind);
    if (pList)
    {
      pInfo = pList->Ptr();
      memcpy(pInfo->m_zFile, &pInfo->m_zInfo, sizeof(unz_s));
      if (unzOpenCurrentFile(pInfo->m_zFile) == UNZ_OK)
      {
        void *buffer = __qblockmalloc(pInfo->m_lSize+1);
        int n = unzReadCurrentFile(pInfo->m_zFile , buffer, pInfo->m_lSize);
        *bufferptr = buffer;
        unzCloseCurrentFile(pInfo->m_zFile);
        return n;
      }
    }
#ifdef LOG_PAKFAIL
    sprintf(cWork, "PAK failed on %s\n", filename);
    g_LogFile.Log(cWork);
#endif
    return -1;
  }

	for (int i = 0; i < dirsize; i++)
	{
		if(!stricmp(filename, pakdirptr[i].name))
		{
			if (fseek(pakfile[m_nPAKIndex], pakdirptr[i].offset, SEEK_SET) >= 0)
      {
	      void *buffer = __qmalloc (pakdirptr[i].size+1);
	      ((char *)buffer)[pakdirptr[i].size] = 0;
			  if (fread(buffer, 1, pakdirptr[i].size, pakfile[m_nPAKIndex]) == pakdirptr[i].size)
        {
          *bufferptr = buffer;
          return pakdirptr[i].size;
        }
      }
		}
	}
#ifdef LOG_PAKFAIL
    sprintf(cWork, "PAK failed on %s\n", filename);
    g_LogFile.Log(cWork);
#endif
  return -1;
}
コード例 #7
0
//-----------------------------------------------------------------------------
// Purpose: Called when they hit the Find, the Replace, or the Replace All button.
// Input  : uCmd - The ID of the button the user hit, IDC_FIND_NEXT or IDC_REPLACE.
// Output : Returns TRUE to indicate that the message was handled.
//-----------------------------------------------------------------------------
BOOL CSearchReplaceDlg::OnFindReplace(UINT uCmd)
{
	CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
	if (!pDoc)
	{
		return TRUE;
	}

	static FindObject_t FindObject;
	static CMapClass *pLastFound = NULL;
	static nReplaceCount = 0;

	bool bDone = false;

	do
	{
		CMapClass *pObject = NULL;

		if (m_bNewSearch)
		{
			//
			// New search. Fetch the data from the controls.
			//
			UpdateData();
			GetFindCriteria(FindObject, pDoc);

			//
			// We have to keep track of the last object in the iteration for replacement,
			// because replacement is done when me advance to the next object.
			//
			pLastFound = NULL;
			nReplaceCount = 0;

			pObject = FindFirstObject(FindObject);
		}
		else
		{
			pObject = FindNextObject(FindObject);
		}

		//
		// Replace All is undone as single operation. Mark the undo position the first time
		// we find a match during a Replace All.
		//
		if (m_bNewSearch && (uCmd == IDC_REPLACE_ALL) && pObject)
		{
			GetHistory()->MarkUndoPosition(pDoc->Selection_GetList(), "Replace Text");
		}

		//
		// If we have an object to do the replace on, do the replace.
		//
		if (pLastFound && ((uCmd == IDC_REPLACE) || (uCmd == IDC_REPLACE_ALL)))
		{
			if (uCmd == IDC_REPLACE)
			{
				// Allow for undo each time we do a Replace.
				GetHistory()->MarkUndoPosition(NULL, "Replace Text");
			}

			//
			// Do the replace on the last matching object we found. This lets the user see what
			// object will be modified before it is done.
			//
			GetHistory()->Keep(pLastFound);
			nReplaceCount += FindReplace((CMapEntity *)pLastFound, FindObject, m_strReplaceText);

			GetDlgItem(IDCANCEL)->SetWindowText("Close");
		}

		if (pObject)
		{
			//
			// We found an object that satisfies our search.
			//
			if ((uCmd == IDC_FIND_NEXT) || (uCmd == IDC_REPLACE))
			{
				//
				// Highlight the match.
				//
				pDoc->SelectObject(pObject, CMapDoc::scClear | CMapDoc::scSelect);
				pDoc->CenterSelection();
			}

			//
			// Stop after one match unless we are doing a Replace All.
			//
			if (uCmd != IDC_REPLACE_ALL)
			{
				bDone = true;
			}

			m_bNewSearch = false;
			pLastFound = pObject;
		}
		else
		{
			//
			// No more objects in the search set match our criteria.
			//
			if ((m_bNewSearch) || (uCmd != IDC_REPLACE_ALL))
			{
				CString str;
				str.Format("Finished searching for '%s'.", m_strFindText);
				MessageBox(str, "Find/Replace Text", MB_OK);

				// TODO: put the old selection back
			}
			else if (uCmd == IDC_REPLACE_ALL)
			{
				CString str;
				str.Format("Replaced %d occurrences of the string '%s' with '%s'.", nReplaceCount, m_strFindText, m_strReplaceText);
				MessageBox(str, "Find/Replace Text", MB_OK);
			}

			m_bNewSearch = true;
			bDone = true;
		}

	} while (!bDone);

	return TRUE;
}
コード例 #8
0
ファイル: watchbsp.cpp プロジェクト: TTimo/GtkRadiant
void CWatchBSP::RunQuake() {

	// build the command line
	Str cmd;

	cmd = g_pGameDescription->mExecutablesPath.GetBuffer();
	// this is game dependant
	if ( !strcmp( ValueForKey( g_qeglobals.d_project_entity, "gamemode" ),"mp" ) ) {
		// MP
		cmd += g_pGameDescription->mMultiplayerEngine.GetBuffer();
	}
	else
	{
		// SP
		cmd += g_pGameDescription->mEngine.GetBuffer();
	}
#ifdef _WIN32
	// NOTE: we are using unix pathnames and CreateProcess doesn't like / in the program path
	// FIXME: This isn't true anymore, doesn't it?
	FindReplace( cmd, "/", "\\" );
#endif
	Str cmdline;
	if ( g_pGameDescription->idTech2 ) {
		cmdline = "+exec radiant.cfg +map ";
		cmdline += m_sBSPName;
	}
	else
	// NOTE: idTech3 specific - there used to be some logic depending on engine breed here
	{
		cmdline = "+set sv_pure 0 ";
		// TTimo: a check for vm_* but that's all fine
		//cmdline = "+set sv_pure 0 +set vm_ui 0 +set vm_cgame 0 +set vm_game 0 ";
		if ( *ValueForKey( g_qeglobals.d_project_entity, "gamename" ) != '\0' ) {
			cmdline += "+set fs_game ";
			cmdline += ValueForKey( g_qeglobals.d_project_entity, "gamename" );
			cmdline += " ";
		}
		//!\todo Read the start-map args from a config file.
		if ( g_pGameDescription->mGameFile == "wolf.game" ) {
			if ( !strcmp( ValueForKey( g_qeglobals.d_project_entity, "gamemode" ),"mp" ) ) {
				// MP
				cmdline += "+devmap ";
				cmdline += m_sBSPName;
			}
			else
			{
				// SP
				cmdline += "+set nextmap \"spdevmap ";
				cmdline += m_sBSPName;
				cmdline += "\"";
			}
		}
		else
		{
			cmdline += "+devmap ";
			cmdline += m_sBSPName;
		}
	}

	Sys_Printf( "%s %s\n", cmd.GetBuffer(), cmdline.GetBuffer() );

	// execute now
	if ( !Q_Exec( cmd.GetBuffer(), (char *)cmdline.GetBuffer(), g_pGameDescription->mEnginePath.GetBuffer(), false ) ) {
		CString msg;
		msg = "Failed to execute the following command: ";
		msg += cmd; msg += cmdline;
		Sys_Printf( msg );
		gtk_MessageBox( g_pParentWnd->m_pWidget,  msg, _( "BSP monitoring" ), MB_OK | MB_ICONERROR );
	}
}
コード例 #9
0
ファイル: qe3.cpp プロジェクト: FS-NulL/Q3Radiant
/*
===========
QE_LoadProject
FIXME: the BuildShortPathName calls should be removed, it would get much more cleaner
  I don't have time to modify something so deep in the system, but this lead to a bug when loading .md3
	see Win_ent.cpp AssignModel
===========
*/
qboolean QE_LoadProject (char *projectfile)
{
	char	*data;
	Sys_Printf ("QE_LoadProject (%s)\n", projectfile);
	
	if ( LoadFileNoCrash (projectfile, (void **)&data) == -1)
		return false;
	
	g_strProject = projectfile;
	
	CString strData = data;
	free(data);
	
	CString strQ2Path = g_PrefsDlg.m_strQuake2;
	CString strQ2File;
	ExtractPath_and_Filename(g_PrefsDlg.m_strQuake2, strQ2Path, strQ2File);
	AddSlash(strQ2Path);
	
	
	char* pBuff = new char[1024];
	
	//BuildShortPathName(strQ2Path, pBuff, 1024);
	strcpy_s(pBuff, 1024,strQ2Path);	// Jonathan: strcpy_s replaces BuildShortPathName
	FindReplace(strData, "__Q2PATH", pBuff);
	//BuildShortPathName(g_strAppPath, pBuff, 1024);
	strcpy_s(pBuff, 1024,g_strAppPath);	// Jonathan: strcpy_s replaces BuildShortPathName
	FindReplace(strData, "__QERPATH", pBuff);
	
	char* pFile;
	if (GetFullPathName(projectfile, 1024, pBuff, &pFile))
	{
		g_PrefsDlg.m_strLastProject = pBuff;
		//BuildShortPathName(g_PrefsDlg.m_strLastProject, pBuff, 1024);
		g_PrefsDlg.m_strLastProject = pBuff;
		g_PrefsDlg.SavePrefs();
		
		ExtractPath_and_Filename(pBuff, strQ2Path, strQ2File);
		int nLen = strQ2Path.GetLength();
		if (nLen > 0)
		{
			if (strQ2Path[nLen - 1] == '\\')
				strQ2Path.SetAt(nLen-1,'\0');
			char* pBuffer = strQ2Path.GetBufferSetLength(_MAX_PATH + 1);
			int n = strQ2Path.ReverseFind('\\');
			if (n >=0 )
				pBuffer[n + 1] = '\0';
			strQ2Path.ReleaseBuffer();
			FindReplace(strData, "__QEPROJPATH", strQ2Path);
		}
	}
	
	
	StartTokenParsing (strData.GetBuffer(0));
	g_qeglobals.d_project_entity = Entity_Parse (true);
	if (!g_qeglobals.d_project_entity)
		Error ("Couldn't parse project file: %s", projectfile);

  // add a version checking to avoid people loading later versions of the project file and bitching against me
  int ver = IntForKey( g_qeglobals.d_project_entity, "version" );
  if (ver != 0)
  {
    char strMsg[1024];
    sprintf( strMsg, "This is a version %d project file. This build only supports <=0 project files.\n"
      "Please choose another project file or upgrade your version of Radiant.", ver );
    MessageBox( NULL, strMsg, "Can't load project file", MB_ICONERROR | MB_OK );
    return false;
  }

  for (int i = 0; i < g_nPathFixupCount; i++)
  {
    char *pPath = ValueForKey (g_qeglobals.d_project_entity, g_pPathFixups[i]);
    if (pPath[0] != '\\' && pPath[0] != '/')
    {
	    if (GetFullPathName(pPath, 1024, pBuff, &pFile))
      {
        SetKeyValue(g_qeglobals.d_project_entity, g_pPathFixups[i], pBuff);
      }
    }
  }

	delete []pBuff;

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

  // usefull for the log file and debuggin f****d up configurations from users:
  // output the basic information of the .qe4 project file
  Sys_Printf("basepath    : %s\n", ValueForKey( g_qeglobals.d_project_entity, "basepath") );
  Sys_Printf("mapspath    : %s\n", ValueForKey( g_qeglobals.d_project_entity, "mapspath") );
//  the rsh command code is probably broken in these builds .. I would need ppl that actually use it ..
//  Sys_Printf("rshcmd         : %s\n", ValueForKey( g_qeglobals.d_project_entity, "rshcmd" ) );
//  Sys_Printf("remotebasepath : %s\n", ValueForKey( g_qeglobals.d_project_entity, "remotebasepath" ) );
  Sys_Printf("entitypath  : %s\n", ValueForKey( g_qeglobals.d_project_entity, "entitypath" ) );
  Sys_Printf("texturepath : %s\n", ValueForKey( g_qeglobals.d_project_entity, "texturepath" ) );

	Eclass_InitForSourceDirectory (ValueForKey (g_qeglobals.d_project_entity, "entitypath"));
	FillClassList();		// list in entity window
	
	Map_New();
	
	
	FillTextureMenu();
	FillBSPMenu();
	
	return true;
}