void RunProcessAtCommandLine( CUtlVector<char*> &newArgv, bool bShowAppWindow, bool bCreateSuspended, int iPriority ) { // current directory (use c:\\ because we don't want it to accidentally share // DLLs like vstdlib with us). PROCESS_INFORMATION pi; PROCESS_INFORMATION pi; if ( RunProcessFromArgs( newArgv, bShowAppWindow, bCreateSuspended, g_FileCachePath, &pi ) ) { if ( g_pConnMgr ) g_pConnMgr->SetAppState( VMPI_SERVICE_STATE_BUSY ); if ( newArgv.Count() > 0 && newArgv[0] ) { V_FileBase( newArgv[0], g_RunningProcess_ExeName, sizeof( g_RunningProcess_ExeName ) ); if ( V_stricmp( g_RunningProcess_ExeName, "vrad" ) == 0 || V_stricmp( g_RunningProcess_ExeName, "vvis" ) == 0 ) V_FileBase( newArgv[newArgv.Count()-1], g_RunningProcess_MapName, sizeof( g_RunningProcess_MapName ) ); } g_hRunningProcess = pi.hProcess; g_hRunningThread = pi.hThread; g_dwRunningProcessId = pi.dwProcessId; g_pPerfTracker->Init( g_dwRunningProcessId ); g_CurJobPriority = iPriority; g_CreateProcessTime = GetTickCount(); SendStartStatus( true ); } else { Msg( " - ERROR in CreateProcess (%s)!\n", GetLastErrorString() ); SendStartStatus( false ); g_CurJobPriority = -1; g_RunningProcess_ExeName[0] = 0; g_RunningProcess_MapName[0] = 0; } }
CUtlSymbolMsnTxt CASW_MissionTextSpec::SymbolForMissionFilename( const char *pMissionFilename, bool bCreateIfNotFound ) { if ( pMissionFilename == NULL || pMissionFilename[0] == 0 ) { return UTL_INVAL_SYMBOL; } else { char buf[256]; V_FileBase( pMissionFilename, buf, 255 ); return bCreateIfNotFound ? SymTab().AddString( pMissionFilename ) : SymTab().Find( pMissionFilename ) ; } }
//----------------------------------------------------------------------------- // Purpose: Generate a list of file matching mask //----------------------------------------------------------------------------- int CScriptLib::FindFiles( char* pFileMask, bool bRecurse, CUtlVector<fileList_t> &fileList ) { char dirPath[MAX_PATH]; char pattern[MAX_PATH]; char extension[MAX_PATH]; // get path only strcpy( dirPath, pFileMask ); V_StripFilename( dirPath ); // get pattern only V_FileBase( pFileMask, pattern, sizeof( pattern ) ); V_ExtractFileExtension( pFileMask, extension, sizeof( extension ) ); if ( extension[0] ) { strcat( pattern, "." ); strcat( pattern, extension ); } if ( !bRecurse ) { GetFileList( dirPath, pattern, fileList ); } else { // recurse and get the tree CUtlVector< fileList_t > tempList; CUtlVector< CUtlString > dirList; RecurseFileTree_r( dirPath, 0, dirList ); for ( int i=0; i<dirList.Count(); i++ ) { // iterate each directory found tempList.Purge(); tempList.EnsureCapacity( dirList.Count() ); GetFileList( dirList[i].String(), pattern, tempList ); int start = fileList.AddMultipleToTail( tempList.Count() ); for ( int j=0; j<tempList.Count(); j++ ) { fileList[start+j] = tempList[j]; } } } return fileList.Count(); }
bool CommandMenu::LoadFromKeyValues( KeyValues * params ) { if ( !params ) return false; V_snprintf( m_CurrentTeam, 4, "%i", GetLocalPlayerTeam() ); V_FileBase( engine->GetLevelName(), m_CurrentMap, sizeof(m_CurrentMap) ); if ( params != m_MenuKeys ) { if ( m_MenuKeys ) m_MenuKeys->deleteThis(); m_MenuKeys = params->MakeCopy(); // save keyvalues } // iterate through all menu items KeyValues * subkey = m_MenuKeys->GetFirstSubKey(); while ( subkey ) { if ( subkey->GetDataType() == KeyValues::TYPE_NONE ) { if ( !LoadFromKeyValuesInternal( subkey, 0 ) ) // recursive call return false; } subkey = subkey->GetNextKey(); } UpdateMenu(); return true; }
bool F_Compose_File_Path(PCHARS szProjFilePath, PCHARS fileExtensionWithDot, ANSICHAR (&destBuf)[BUF_SIZE]) { AssertPtr( szProjFilePath ); AssertPtr( destBuf ); StaticAssert( BUF_SIZE > 0 ); // pure name (e.g. "MyProject") ANSICHAR projName[ 128 ]; V_FileBase( szProjFilePath, projName, NUMBER_OF(projName) ); // path relative to exe (e.g. "Projects/MyProject/") ANSICHAR projFilePath[ FS_MAX_PATH ]; VRET_FALSE_IF_NOT( V_ExtractFilePath( szProjFilePath, projFilePath, NUMBER_OF(projFilePath) ) ); // path to .INI file relative to exe (e.g. "Projects/MyProject/MyProject.INI") ANSICHAR outFilePath[ FS_MAX_PATH ]; V_ComposeFileName( projFilePath, projName, outFilePath, NUMBER_OF(outFilePath) ); V_SetExtension( outFilePath, fileExtensionWithDot, NUMBER_OF(outFilePath) ); mxStrCpyNAnsi( destBuf, outFilePath, NUMBER_OF(destBuf) ); return true; }
//----------------------------------------------------------------------------- // BugDlg_Submit // //----------------------------------------------------------------------------- bool BugDlg_Submit( HWND hWnd ) { char title[1024]; char miscInfo[1024]; char basename[MAX_PATH]; char filename[MAX_PATH]; char positionName[MAX_PATH]; char orientationName[MAX_PATH]; char buildName[MAX_PATH]; char mapName[MAX_PATH]; bool bSuccess = false; sprintf( positionName, "%f %f %f", g_bug_mapInfo.position[0], g_bug_mapInfo.position[1], g_bug_mapInfo.position[2] ); SetDlgItemText( g_bug_hWnd, IDC_BUG_POSITION_LABEL, positionName ); sprintf( orientationName, "%f %f %f", g_bug_mapInfo.angle[0], g_bug_mapInfo.angle[1], g_bug_mapInfo.angle[2] ); SetDlgItemText( g_bug_hWnd, IDC_BUG_ORIENTATION_LABEL, orientationName ); sprintf( buildName, "%d", g_bug_mapInfo.build ); SetDlgItemText( g_bug_hWnd, IDC_BUG_BUILD_LABEL, buildName ); V_FileBase( g_bug_mapInfo.mapPath, mapName, sizeof( mapName ) ); char *pExtension = V_stristr( mapName, ".bsp" ); if ( pExtension ) { *pExtension = '\0'; } pExtension = V_stristr( mapName, ".360" ); if ( pExtension ) { *pExtension = '\0'; } V_snprintf( miscInfo, sizeof( miscInfo ), "skill %d", g_bug_mapInfo.skill ); // Stuff bug data files up to server g_bug_pReporter->StartNewBugReport(); g_bug_pReporter->SetOwner( g_bug_pReporter->GetUserNameForDisplayName( g_bug_szOwner ) ); g_bug_pReporter->SetSubmitter( NULL ); if ( mapName[0] ) V_snprintf( title, sizeof( title ), "%s: %s", mapName, g_bug_szTitle ); else V_snprintf( title, sizeof( title ), "%s", g_bug_szTitle ); g_bug_pReporter->SetTitle( title ); g_bug_pReporter->SetDescription( g_bug_szDescription ); g_bug_pReporter->SetLevel( mapName ); g_bug_pReporter->SetPosition( positionName ); g_bug_pReporter->SetOrientation( orientationName ); g_bug_pReporter->SetBuildNumber( buildName ); g_bug_pReporter->SetSeverity( g_bug_szSeverity ); g_bug_pReporter->SetPriority( g_bug_szPriority ); g_bug_pReporter->SetArea( g_bug_szArea ); g_bug_pReporter->SetMapNumber( g_bug_szMapNumber ); g_bug_pReporter->SetReportType( g_bug_szReportType ); g_bug_pReporter->SetMiscInfo( miscInfo ); g_bug_pReporter->SetDriverInfo( "" ); g_bug_pReporter->SetExeName( "" ); g_bug_pReporter->SetGameDirectory( "" ); g_bug_pReporter->SetRAM( 0 ); g_bug_pReporter->SetCPU( 0 ); g_bug_pReporter->SetProcessor( "" ); g_bug_pReporter->SetDXVersion( 0, 0, 0, 0 ); g_bug_pReporter->SetOSVersion( "" ); g_bug_pReporter->ResetIncludedFiles(); g_bug_pReporter->SetZipAttachmentName( "" ); if ( g_bug_szScreenshot[0] ) { if ( g_bug_bCompressScreenshot ) { BugDlg_CompressScreenshot(); } // strip the fully qualified path into filename only Sys_StripPath( g_bug_szScreenshot, basename, sizeof( basename ) ); V_snprintf( filename, sizeof( filename ), "%s/BugId/%s", GetRepositoryURL(), basename ); Sys_NormalizePath( filename, false ); g_bug_pReporter->SetScreenShot( filename ); } if ( g_bug_szSavegame[0] ) { // strip the fully qualified path into filename only Sys_StripPath( g_bug_szSavegame, basename, sizeof( basename ) ); V_snprintf( filename, sizeof( filename ), "%s/BugId/%s", GetRepositoryURL(), basename ); Sys_NormalizePath( filename, false ); g_bug_pReporter->SetSaveGame( filename ); } if ( g_bug_szBSPName[0] ) { // strip the fully qualified path into filename only Sys_StripPath( g_bug_szBSPName, basename, sizeof( basename ) ); V_snprintf( filename, sizeof( filename ), "%s/BugId/%s", GetRepositoryURL(), basename ); Sys_NormalizePath( filename, false ); g_bug_pReporter->SetBSPName( filename ); } int bugID = -1; bSuccess = g_bug_pReporter->CommitBugReport( bugID ); if ( bSuccess ) { if ( !BugDlg_UploadBugSubmission( bugID, g_bug_szSavegame, g_bug_szScreenshot, g_bug_szBSPName, NULL ) ) { Sys_MessageBox( BUG_ERRORTITLE, "Unable to upload files to bug repository!\n" ); bSuccess = false; } } else { Sys_MessageBox( BUG_ERRORTITLE, "Unable to post bug report to database!\n" ); } if ( bSuccess ) { if ( g_Games[g_bug_GameType].bUsesSystem1 ) { ConsoleWindowPrintf( BUG_COLOR, "Bug Reporter: PVCS submission succeeded for bug! (%d)\n", bugID ); } else { ConsoleWindowPrintf( BUG_COLOR, "Bug Reporter: BugBait submission succeeded for bug!\n" ); } } else { ConsoleWindowPrintf( XBX_CLR_RED, "Bug Reporter: Submission failed\n" ); } return bSuccess; }
//----------------------------------------------------------------------------- // Generate a tree containing files from a reslist. Returns TRUE if successful. //----------------------------------------------------------------------------- bool LoadReslist( const char *pReslistName, CUtlRBTree< CUtlString, int > *pTree ) { CUtlBuffer buffer; if ( !scriptlib->ReadFileToBuffer( pReslistName, buffer, true ) ) { return false; } char szBasename[MAX_PATH]; V_FileBase( pReslistName, szBasename, sizeof( szBasename ) ); characterset_t breakSet; CharacterSetBuild( &breakSet, "" ); // parse reslist char szToken[MAX_PATH]; char szBspName[MAX_PATH]; szBspName[0] = '\0'; for ( ;; ) { int nTokenSize = buffer.ParseToken( &breakSet, szToken, sizeof( szToken ) ); if ( nTokenSize <= 0 ) { break; } // reslists are pc built, filenames can be sloppy V_strlower( szToken ); V_FixSlashes( szToken ); V_RemoveDotSlashes( szToken ); // can safely cull filetypes that are ignored by queued loader at runtime bool bKeep = false; const char *pExt = V_GetFileExtension( szToken ); if ( !pExt ) { // unknown continue; } else if ( !V_stricmp( pExt, "vmt" ) || !V_stricmp( pExt, "vhv" ) || !V_stricmp( pExt, "mdl" ) || !V_stricmp( pExt, "raw" ) || !V_stricmp( pExt, "wav" ) ) { bKeep = true; } else if ( !V_stricmp( pExt, "mp3" ) ) { // change to .wav V_SetExtension( szToken, ".wav", sizeof( szToken ) ); bKeep = true; } else if ( !V_stricmp( pExt, "bsp" ) ) { // reslists erroneously have multiple bsps if ( !V_stristr( szToken, szBasename ) ) { // wrong one, cull it continue; } else { // right one, save it strcpy( szBspName, szToken ); bKeep = true; } } if ( bKeep ) { FindOrAddFileToResourceList( szToken, pTree ); } } if ( !szBspName[0] ) { // reslist is not bsp derived, nothing more to do return true; } CUtlVector< CUtlString > bspList; bool bOK = GetDependants_BSP( szBspName, &bspList ); if ( !bOK ) { return false; } // add all the bsp dependants to the resource list for ( int i=0; i<bspList.Count(); i++ ) { FindOrAddFileToResourceList( bspList[i].String(), pTree ); } // iterate all the models in the resource list, get all their dependents CUtlVector< CUtlString > modelList; for ( int i = pTree->FirstInorder(); i != pTree->InvalidIndex(); i = pTree->NextInorder( i ) ) { const char *pExt = V_GetFileExtension( pTree->Element( i ).String() ); if ( !pExt || V_stricmp( pExt, "mdl" ) ) { continue; } if ( !GetDependants_MDL( pTree->Element( i ).String(), &modelList ) ) { return false; } } // add all the model dependents to the resource list for ( int i=0; i<modelList.Count(); i++ ) { FindOrAddFileToResourceList( modelList[i].String(), pTree ); } // check for optional commentary, include wav dependencies char szCommentaryName[MAX_PATH]; V_ComposeFileName( g_szGamePath, szBspName, szCommentaryName, sizeof( szCommentaryName ) ); V_StripExtension( szCommentaryName, szCommentaryName, sizeof( szCommentaryName ) ); V_strncat( szCommentaryName, "_commentary.txt", sizeof( szCommentaryName ) ); CUtlBuffer commentaryBuffer; if ( ReadFileToBuffer( szCommentaryName, commentaryBuffer, true, true ) ) { // any single token may be quite large to due to text char szCommentaryToken[8192]; for ( ;; ) { int nTokenSize = commentaryBuffer.ParseToken( &breakSet, szCommentaryToken, sizeof( szCommentaryToken ) ); if ( nTokenSize < 0 ) { break; } if ( nTokenSize > 0 && !V_stricmp( szCommentaryToken, "commentaryfile" ) ) { // get the commentary file nTokenSize = commentaryBuffer.ParseToken( &breakSet, szCommentaryToken, sizeof( szCommentaryToken ) ); if ( nTokenSize > 0 ) { // skip past sound chars char *pName = szCommentaryToken; while ( *pName && IsSoundChar( *pName ) ) { pName++; } char szWavFile[MAX_PATH]; V_snprintf( szWavFile, sizeof( szWavFile ), "sound/%s", pName ); FindOrAddFileToResourceList( szWavFile, pTree ); } } } } // check for optional blacklist char szBlacklist[MAX_PATH]; V_ComposeFileName( g_szGamePath, "reslistfixes_xbox.xsc", szBlacklist, sizeof( szBlacklist ) ); CUtlBuffer blacklistBuffer; if ( ReadFileToBuffer( szBlacklist, blacklistBuffer, true, true ) ) { for ( ;; ) { int nTokenSize = blacklistBuffer.ParseToken( &breakSet, szToken, sizeof( szToken ) ); if ( nTokenSize <= 0 ) { break; } bool bAdd; if ( !V_stricmp( szToken, "-" ) ) { bAdd = false; } else if ( !V_stricmp( szToken, "+" ) ) { bAdd = true; } else { // bad syntax, skip line Msg( "Bad Syntax, expecting '+' or '-' as first token in reslist fixup file '%s'.\n", szBlacklist ); continue; } // get entry nTokenSize = blacklistBuffer.ParseToken( &breakSet, szToken, sizeof( szToken ) ); if ( nTokenSize <= 0 ) { break; } if ( bAdd ) { FindOrAddFileToResourceList( szToken, pTree ); } else { RemoveFileFromResourceList( szToken, pTree ); } } } return true; }
bool CASW_Briefing::CheckMissionRequirements() { if ( ASWGameRules() && ASWGameRules()->GetGameState() < ASW_GS_DEBRIEF && ASWGameResource() ) { if ( ASWGameRules()->m_bMissionRequiresTech ) { bool bTech = false; for (int i=0;i<ASWGameResource()->GetMaxMarineResources();i++) { C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource(i); if (pMR && pMR->GetProfile() && pMR->GetProfile()->CanHack()) bTech = true; } if (!bTech) { // have the server print a message about needing a tech, so all can see engine->ClientCmd("cl_needtech"); return false; } } C_ASW_Equip_Req* pReq = C_ASW_Equip_Req::FindEquipReq(); if (pReq) { if (pReq && !pReq->AreRequirementsMet()) { // have the server print a message about needing equip, so all can see engine->ClientCmd("cl_needequip"); return false; } } if ( !ASWGameResource()->AtLeastOneMarine() ) { return false; } if ( ASWGameResource() && !asw_ignore_need_two_player_requirement.GetBool() ) { CASW_Campaign_Info *pCampaign = ASWGameRules()->GetCampaignInfo(); char mapname[64]; V_FileBase( engine->GetLevelName(), mapname, sizeof( mapname ) ); if ( pCampaign && pCampaign->GetMissionByMapName( mapname ) ) { bool bNeedsMoreThanOneMarine = pCampaign->GetMissionByMapName( mapname )->m_bNeedsMoreThanOneMarine; if ( bNeedsMoreThanOneMarine ) { // how many marines do we have? int numMarines = 0; for (int i=0;i<ASWGameResource()->GetMaxMarineResources();i++) { C_ASW_Marine_Resource *pMR = ASWGameResource()->GetMarineResource(i); if ( pMR && pMR->GetProfileIndex() >= 0 ) numMarines++; } if ( numMarines < 2 ) { engine->ClientCmd("cl_needtwoplayers"); return false; } } } } } return true; }
BOOL WINAPI Hook_MiniDumpWriteDump(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam) { BOOL result; if(DumpType != MiniDumpNormal) return TRUE; #if 0 Gamma_Restore(); ExtDLL_Release(); #endif if (g_pInterface->CommandLine->CheckParm("-nomdmp")) return FALSE; #if 0 if (!VideoMode_IsWindowed()) VID_SwitchFullScreen(false); VID_HideWindow(); VID_CloseWindow(); #endif if (BugReport_CreateWindow()) BugReport_MainLoop(); result = g_pfnMiniDumpWriteDump(hProcess, ProcessId, hFile, DumpType, ExceptionParam, UserStreamParam, CallbackParam); if (result && (g_bSendBugReport || g_bDeleteThisMDMP)) { POBJECT_NAME_INFORMATION pa = NULL; char cInfoBuffer[0x10000]; ULONG ulSize; PWSTR ObjectName; if (NT_SUCCESS(NtQueryObject0(hFile, (OBJECT_INFORMATION_CLASS)1, cInfoBuffer, sizeof(cInfoBuffer), &ulSize))) { pa = (POBJECT_NAME_INFORMATION)cInfoBuffer; ObjectName = pa->Name.Buffer; char filebase[MAX_PATH]; char *filename = UnicodeToANSI(ObjectName); char filepath[MAX_PATH], direcotry[MAX_PATH]; DWORD dwFileSize; V_FileBase(filename, filebase, sizeof(filebase)); GetCurrentDirectory(sizeof(direcotry), direcotry); sprintf(filepath, "%s\\%s.mdmp", direcotry, filebase); dwFileSize = GetFileSize(hFile, NULL); CloseHandle(hFile); if (g_bSendBugReport) { if (dwFileSize < (1024 * 1024 * 5)) { CSmtp mail; bool isError = false; try { mail.SetSMTPServer(XorStr<0x13, 12, 0x139F41BA>("\x60\x79\x61\x66\x39\x69\x68\x34\x78\x73\x70" + 0x139F41BA).s, 25); // smtp.qq.com mail.SetSecurityType(NO_SECURITY); mail.SetLogin(XorStr<0xB3, 23, 0x6AF33DDC>("\xD0\xC7\xD7\xC2\xD2\xE7\xDB\xCF\xDC\xCF\xD8\xD0\xDB\xA5\xB3\x82\xB2\xB5\xEB\xA5\xA8\xA5" + 0x6AF33DDC).s); // [email protected] mail.SetPassword(XorStr<0xF6, 11, 0x7680F353>("\xB3\xB3\xCA\xC9\xCF\xC3\xB9\xBE\xCD\xBB" + 0x7680F353).s); // ED2058EC3D mail.SetSenderName(XorStr<0xBB, 16, 0xDB9F59C9>("\xD8\xCF\xDF\xCA\xDA\x9F\xA3\xB7\xA4\xB7\xA0\xA8\xA3\xAD\xBB" + 0xDB9F59C9).s); // csbte_bugsender mail.SetSenderMail(XorStr<0x8E, 23, 0x30E98F1A>("\xED\xFC\xF2\xE5\xF7\xCC\xF6\xE0\xF1\xE4\xFD\xF7\xFE\xFE\xEE\xDD\xEF\xEE\x8E\xC2\xCD\xCE" + 0x30E98F1A).s); // [email protected] mail.SetReplyTo(XorStr<0x33, 23, 0x2E1BA643>("\x50\x47\x57\x42\x52\x67\x5B\x4F\x5C\x4F\x58\x50\x5B\x25\x33\x02\x32\x35\x6B\x25\x28\x25" + 0x2E1BA643).s); // [email protected] mail.SetSubject(filebase); mail.AddRecipient(XorStr<0x23, 23, 0x0DA12156>("\x40\x57\x47\x52\x42\x77\x4B\x5F\x4C\x5E\x48\x5E\x40\x42\x45\x72\x42\x45\x1B\x55\x58\x55" + 0x0DA12156).s); // [email protected] mail.SetXPriority(XPRIORITY_HIGH); mail.SetXMailer(XorStr<0x4A, 30, 0xA907EBF5>("\x1E\x23\x29\x6D\x0C\x2E\x24\x70\x72\x7B\x22\x66\x78\x67\x6A\x70\x7A\x0B\x2E\x32\x38\x3A\x13\x12\x0B\x0C\x0A\x04\x0A" + 0xA907EBF5).s); // The Bat! (v3.02) Professional char msg[64]; sprintf(msg, "此错误报告生成于 BTE Final %s", __DATE__); mail.AddMsgLine(msg); mail.AddMsgLine(""); mail.AddMsgLine(g_szBugReportDesc); mail.AddAttachment(filepath); mail.Send(); } catch (ECSmtp e) { if (!strcmp(g_szLanguage, "schinese")) MessageBox(NULL, e.GetErrorText().c_str(), "错误报告", MB_ICONERROR); else MessageBox(NULL, e.GetErrorText().c_str(), "Bug Report", MB_ICONERROR); isError = true; } if (!isError) { if (!strcmp(g_szLanguage, "schinese")) MessageBox(NULL, "非常感谢您的支持,我们将尽快修复此问题!", "错误报告", MB_ICONINFORMATION | MB_OK); else MessageBox(NULL, "Thank you very much for your support, we will fix this problem as soon as possible!", "Bug Report", MB_ICONINFORMATION | MB_OK); } } } if (g_bDeleteThisMDMP) { DeleteFile(filepath); } } } if (g_bRestartGame) { HANDLE hObject = CreateMutex(NULL, FALSE, "ValveHalfLifeLauncherMutex"); if (hObject) { ReleaseMutex(hObject); CloseHandle(hObject); } STARTUPINFO SI; PROCESS_INFORMATION PI; memset(&SI, 0, sizeof(SI)); memset(&PI, 0, sizeof(PI)); SI.cb = sizeof(STARTUPINFO); CreateProcess(NULL, (LPSTR)g_pInterface->CommandLine->GetCmdLine(), NULL, NULL, FALSE, CREATE_NEW_PROCESS_GROUP | NORMAL_PRIORITY_CLASS, NULL, NULL, &SI, &PI); TerminateProcess(GetCurrentProcess(), 1); gEngfuncs.pfnClientCmd("_restart"); } return result; }
//----------------------------------------------------------------------------- // ExcludePathsDlg_Populate // // Generate a path table. //----------------------------------------------------------------------------- void ExcludePathsDlg_Populate( HWND hWnd, bool bRefresh ) { struct GamePath_t { CUtlString pathName; bool bIsModPath; }; CUtlVector< GamePath_t > gamePaths; // can skip the time consuming directory scan, unless forced if ( bRefresh || !g_PathTable.Count() ) { g_PathTable.Purge(); for ( int i = 0; i < ARRAYSIZE( g_GameNames ); i++ ) { char szTargetPath[MAX_PATH]; V_strncpy( szTargetPath, g_localPath, sizeof( szTargetPath ) ); V_AppendSlash( szTargetPath, sizeof( szTargetPath ) ); V_strncat( szTargetPath, g_GameNames[i].pName, sizeof( szTargetPath ) ); GamePath_t gamePath; gamePath.pathName = szTargetPath; gamePath.bIsModPath = g_GameNames[i].bIsModPath; gamePaths.AddToTail( gamePath ); } // iterate all game paths for ( int i = 0; i < gamePaths.Count(); i++ ) { CUtlVector< CUtlString > dirList; RecurseFileTree_r( g_localPath, gamePaths[i].pathName.String(), 0, dirList, gamePaths[i].bIsModPath ); } } // reset the tree HWND hWndTree = GetDlgItem( hWnd, IDC_PATHS_TREE ); TreeView_DeleteAllItems( hWndTree ); // reset and add root // only the root is at depth 0 AddItemToTree( hWndTree, ROOT_NAME, 0, false ); // build the tree view for ( int iIndex = g_PathTable.FirstInorder(); iIndex != g_PathTable.InvalidIndex(); iIndex = g_PathTable.NextInorder( iIndex ) ) { // due to sorting, number of slashes is depth const char *pString = g_PathTable[iIndex].pathName.String(); int depth = 0; for ( int j = 0; j < (int)strlen( pString ); j++ ) { if ( pString[j] == '\\' ) { depth++; } } if ( !depth ) { depth = 1; } char szPath[MAX_PATH]; V_FileBase( pString, szPath, sizeof( szPath ) ); AddItemToTree( hWndTree, szPath, depth, g_PathTable[iIndex].bIsModPath ); } HTREEITEM hTreeRoot = TreeView_GetRoot( hWndTree ); for ( int i = 0; i < g_ExcludePaths.Count(); i++ ) { HTREEITEM hTree = ExcludePathsDlg_Find_r( hWndTree, hTreeRoot, 0, "", g_ExcludePaths[i].String() ); if ( hTree ) { ExcludePathsDlg_SetCheckState_r( hWndTree, hTree, 0, true ); } } // expand the root node to show state ExcludePathsDlg_ExpandToShowState_r( hWndTree, hTreeRoot, 0 ); }
void AppendPlayerInformation(ISteamHTTP *pSteamHttp, HTTPRequestHandle httpRequest, CSteamAPIContext *pSteamAPIContext, CBasePlayer *pPlayer, bool bAnonymous) { // Local DS time_t rawtime; struct tm* timeinfo; time(&rawtime); timeinfo = localtime(&rawtime); char* local_ds = asctime(timeinfo); char* newLine = strstr(local_ds, "\n"); if (newLine) { *newLine = 0; } pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "localdatetime", local_ds); // Build DS char build_ds[64]; Q_snprintf(build_ds, sizeof(build_ds), "%s,%s", __DATE__, __TIME__); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "builddatetime", build_ds); // DxLevel pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "dxlevel", ConVarRef("mat_dxlevel").GetString()); if (pPlayer) { // Position char player_position[32]; Vector player_pos = pPlayer->GetLocalOrigin(); Q_snprintf(player_position, sizeof(player_position), "%.2f,%.2f,%.2f", player_pos.x, player_pos.y, player_pos.z); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "position", player_position); // Angles char player_angles[32]; QAngle player_ang = pPlayer->GetLocalAngles(); Q_snprintf(player_angles, sizeof(player_angles), "%.2f,%.2f,%.2f", player_ang.x, player_ang.y, player_ang.z); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "angles", player_angles); // Health char player_health[16]; Q_snprintf(player_health, sizeof(player_health), "%i", pPlayer->GetHealth()); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "health", player_health); // Weapon CBaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon(); if (pWeapon) { pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "weapon", pWeapon->GetClassname()); } } // Cheats char cheats_enabled[8]; Q_snprintf(cheats_enabled, sizeof(cheats_enabled), "%i", (ConVarRef("sv_cheats").GetBool() || ConVarRef("developer").GetBool())); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "cheats", cheats_enabled); // Map #ifdef CLIENT_DLL char mapname[256]; V_FileBase(engine->GetLevelName(), mapname, sizeof(mapname)); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "level", mapname); #else pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "level", gpGlobals->mapname.ToCStr()); #endif if (pSteamAPIContext) { // Language pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "language", pSteamAPIContext->SteamUtils()->GetSteamUILanguage()); } // Platform char * platform = "unknown"; if (IsPC()) platform = "pc"; if (IsOSX()) platform = "osx"; if (IsLinux()) platform = "linux"; if (IsX360()) platform = "360"; if (IsPS3()) platform = "ps3"; pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "platform", platform); // Player ID if (bAnonymous == false) { if (ae_uniqueplayerid.GetInt() == 0) GenerateUniquePlayerId(pSteamAPIContext); pSteamHttp->SetHTTPRequestGetOrPostParameter(httpRequest, "playerid", ae_uniqueplayerid.GetString()); } }
CUtlString CUtlString::GetBaseFilename() const { char szTemp[MAX_PATH]; V_FileBase( String(), szTemp, sizeof( szTemp ) ); return CUtlString( szTemp ); }