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); } }
void Map_Snapshot(){ CString strMsg; // I hope the modified flag is kept correctly up to date if ( !modified ) { return; } // we need to do the following // 1. make sure the snapshot directory exists (create it if it doesn't) // 2. find out what the lastest save is based on number // 3. inc that and save the map CString strOrgPath, strOrgFile; ExtractPath_and_Filename( currentmap, strOrgPath, strOrgFile ); AddSlash( strOrgPath ); strOrgPath += "snapshots"; bool bGo = true; struct stat Stat; if ( stat( strOrgPath, &Stat ) == -1 ) { #ifdef _WIN32 bGo = ( _mkdir( strOrgPath ) != -1 ); #endif #if defined ( __linux__ ) || defined ( __APPLE__ ) bGo = ( mkdir( strOrgPath,0755 ) != -1 ); #endif } AddSlash( strOrgPath ); if ( bGo ) { int nCount = 0; long lSize = 0; CString strNewPath; strNewPath = strOrgPath; strNewPath += strOrgFile; CString strFile; while ( bGo ) { char buf[PATH_MAX]; sprintf( buf, "%s.%i", strNewPath.GetBuffer(), nCount ); strFile = buf; bGo = DoesFileExist( strFile, lSize ); nCount++; } // strFile has the next available slot Map_SaveFile( strFile, false ); // it is still a modified map (we enter this only if this is a modified map) Sys_SetTitle( currentmap ); Sys_MarkMapModified(); if ( lSize > 12 * 1024 * 1024 ) { // total size of saves > 4 mb Sys_Printf( "The snapshot files in %s total more than 4 megabytes. You might consider cleaning up.", strOrgPath.GetBuffer() ); } } else { strMsg.Format( "Snapshot save failed.. unabled to create directory\n%s", strOrgPath.GetBuffer() ); gtk_MessageBox( g_pParentWnd->m_pWidget, strMsg ); } strOrgPath = ""; strOrgFile = ""; }
/* ======================================================================================================================= ======================================================================================================================= */ void Map_Snapshot() { CString strMsg; // // we need to do the following 1. make sure the snapshot directory exists (create // it if it doesn't) 2. find out what the lastest save is based on number 3. inc // that and save the map // CString strOrgPath, strOrgFile; ExtractPath_and_Filename(currentmap, strOrgPath, strOrgFile); AddSlash(strOrgPath); strOrgPath += "snapshots"; bool bGo = true; struct _stat Stat; if (_stat(strOrgPath, &Stat) == -1) { bGo = (_mkdir(strOrgPath) != -1); } AddSlash(strOrgPath); if (bGo) { int nCount = 0; long lSize = 0; CString strNewPath = strOrgPath; strNewPath += strOrgFile; CString strFile; while (bGo) { strFile.Format("%s.%i", strNewPath, nCount); bGo = DoesFileExist(strFile, lSize); nCount++; } // strFile has the next available slot Map_SaveFile(strFile.GetBuffer(0), false); Sys_SetTitle(currentmap); if (lSize > 12 * 1024 * 1024) { // total size of saves > 4 mb common->Printf ( "The snapshot files in the [%s] directory total more than 4 megabytes. You might consider cleaning the directory up.", strOrgPath ); } } else { strMsg.Format("Snapshot save failed.. unabled to create directory\n%s", strOrgPath); g_pParentWnd->MessageBox(strMsg); } }
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 ); } }
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 }
void Map_Snapshot(){ CString strMsg; // I hope the modified flag is kept correctly up to date if ( !modified ) { return; } // we need to do the following // 1. make sure the snapshot directory exists (create it if it doesn't) // 2. find out what the lastest save is based on number // 3. inc that and save the map CString strOrgPath, strOrgFile; ExtractPath_and_Filename( currentmap, strOrgPath, strOrgFile ); AddSlash( strOrgPath ); strOrgPath += "snapshots"; bool bGo = true; struct stat Stat; if ( stat( strOrgPath, &Stat ) == -1 ) { #ifdef _WIN32 bGo = ( _mkdir( strOrgPath ) != -1 ); #endif #if defined ( __linux__ ) || defined ( __APPLE__ ) bGo = ( mkdir( strOrgPath,0755 ) != -1 ); #endif } AddSlash( strOrgPath ); if ( bGo ) { int nCount = 0; long lSize = 0; CString strNewPath; strNewPath = strOrgPath; strNewPath += strOrgFile; // QB - snapshots now follow the format: <mapname>.<snapnum>.<ext> // **NOTE** atm snapshots must end with a .map (or .xmap) ext (this is why they were broken) CString strOldEXT = "map"; //default to .map const char* type = strrchr( strOrgFile.GetBuffer(),'.' ); if ( type != NULL ) { strOldEXT = ++type; }; // get the ext for later. StripExtension(strNewPath); // then strip it from the new path // CString strFile; while ( bGo ) { char buf[PATH_MAX]; //sprintf( buf, "%s.%i", strNewPath.GetBuffer(), nCount ); // snapshot will now end with a known ext. sprintf( buf, "%s.%i.%s", strNewPath.GetBuffer(), nCount, strOldEXT.GetBuffer() ); strFile = buf; bGo = DoesFileExist( strFile, lSize ); nCount++; } // strFile has the next available slot Map_SaveFile( strFile, false ); // it is still a modified map (we enter this only if this is a modified map) Sys_SetTitle( currentmap ); Sys_MarkMapModified(); if ( lSize > 12 * 1024 * 1024 ) { // total size of saves > 4 mb Sys_Printf( "The snapshot files in %s total more than 4 megabytes. You might consider cleaning up.", strOrgPath.GetBuffer() ); } } else { strMsg.Format( "Snapshot save failed.. unabled to create directory\n%s", strOrgPath.GetBuffer() ); gtk_MessageBox( g_pParentWnd->m_pWidget, strMsg ); } strOrgPath = ""; strOrgFile = ""; }
/* =========== 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; }