//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_TEWorldDecal::PostDataUpdate( DataUpdateType_t updateType ) { VPROF( "C_TEWorldDecal::PostDataUpdate" ); if ( r_decals.GetInt() ) { C_BaseEntity *ent = cl_entitylist->GetEnt( 0 ); if ( ent ) { bool bNoBlood = UTIL_IsLowViolence(); bool bIsBlood = false; if ( bNoBlood ) { const char *pchDecalName = decalsystem->GetDecalNameForIndex( m_nIndex ); if ( pchDecalName && V_stristr( pchDecalName, "blood" ) ) { bIsBlood = true; } } if ( !( bNoBlood && bIsBlood ) ) { effects->DecalShoot( m_nIndex, 0, ent->GetModel(), ent->GetAbsOrigin(), ent->GetAbsAngles(), m_vecOrigin, 0, 0 ); } } } RecordWorldDecal( &m_vecOrigin, m_nIndex ); }
char* V_stristr( char* pStr, char const* pSearch ) { AssertValidStringPtr( pStr ); AssertValidStringPtr( pSearch ); return (char*)V_stristr( (char const*)pStr, pSearch ); }
bool IsTheTarget(CTFPlayer *player) { if (player->GetTeamNumber() != TF_TEAM_RED) return false; if (V_stristr(player->GetPlayerName(), cvar_name.GetString()) == nullptr) return false; return true; }
static void FileSystem_AddLoadedSearchPath( CFSSearchPathsInit &initInfo, const char *pPathID, const char *fullLocationPath, bool bLowViolence ) { // Check for mounting LV game content in LV builds only if ( V_stricmp( pPathID, "game_lv" ) == 0 ) { // Not in LV build, don't mount if ( !initInfo.m_bLowViolence ) return; // Mount, as a game path pPathID = "game"; } // Check for mounting HD game content if enabled if ( V_stricmp( pPathID, "game_hd" ) == 0 ) { // Not in LV build, don't mount if ( !initInfo.m_bMountHDContent ) return; // Mount, as a game path pPathID = "game"; } // Special processing for ordinary game folders if ( V_stristr( fullLocationPath, ".vpk" ) == NULL && Q_stricmp( pPathID, "game" ) == 0 ) { if ( CommandLine()->FindParm( "-tempcontent" ) != 0 ) { char szPath[MAX_PATH]; Q_snprintf( szPath, sizeof(szPath), "%s_tempcontent", fullLocationPath ); initInfo.m_pFileSystem->AddSearchPath( szPath, pPathID, PATH_ADD_TO_TAIL ); } } if ( initInfo.m_pLanguage && Q_stricmp( initInfo.m_pLanguage, "english" ) && V_strstr( fullLocationPath, "_english" ) != NULL ) { char szPath[MAX_PATH]; char szLangString[MAX_PATH]; // Need to add a language version of this path first Q_snprintf( szLangString, sizeof(szLangString), "_%s", initInfo.m_pLanguage); V_StrSubst( fullLocationPath, "_english", szLangString, szPath, sizeof( szPath ), true ); initInfo.m_pFileSystem->AddSearchPath( szPath, pPathID, PATH_ADD_TO_TAIL ); } initInfo.m_pFileSystem->AddSearchPath( fullLocationPath, pPathID, PATH_ADD_TO_TAIL ); }
//----------------------------------------------------------------------------- // small helper function shared by lots of modules //----------------------------------------------------------------------------- bool V_IsAbsolutePath( const char *pStr ) { bool bIsAbsolute = ( pStr[0] && pStr[1] == ':' ) || pStr[0] == '/' || pStr[0] == '\\'; if ( IsX360() && !bIsAbsolute ) { bIsAbsolute = ( V_stristr( pStr, ":" ) != NULL ); } return bIsAbsolute; }
// Returns true if it completed successfully. // If it would overflow pOut, it fills as much as it can and returns false. bool V_StrSubst( const char *pIn, const char *pMatch, const char *pReplaceWith, char *pOut, int outLen, bool bCaseSensitive ) { int replaceFromLen = strlen( pMatch ); int replaceToLen = strlen( pReplaceWith ); const char *pInStart = pIn; char *pOutPos = pOut; pOutPos[0] = 0; while ( 1 ) { int nRemainingOut = outLen - (pOutPos - pOut); const char *pTestPos = ( bCaseSensitive ? strstr( pInStart, pMatch ) : V_stristr( pInStart, pMatch ) ); if ( pTestPos ) { // Found an occurence of pMatch. First, copy whatever leads up to the string. int copyLen = pTestPos - pInStart; if ( !CopyToMaxChars( pOutPos, nRemainingOut, pInStart, copyLen ) ) return false; // Did we hit the end of the output string? if ( copyLen > nRemainingOut-1 ) return false; pOutPos += strlen( pOutPos ); nRemainingOut = outLen - (pOutPos - pOut); // Now add the replacement string. if ( !CopyToMaxChars( pOutPos, nRemainingOut, pReplaceWith, replaceToLen ) ) return false; pInStart += copyLen + replaceFromLen; pOutPos += replaceToLen; } else { // We're at the end of pIn. Copy whatever remains and get out. int copyLen = strlen( pInStart ); V_strncpy( pOutPos, pInStart, nRemainingOut ); return ( copyLen <= nRemainingOut-1 ); } } }
void EmitAmbientSound(int entindex, const Vector &origin, const char *pSample, float volume, soundlevel_t soundlevel, int flags, int pitch, float soundtime /*= 0.0f*/, float *duration /*=NULL*/) { #ifdef STAGING_ONLY if ( sv_snd_filter.GetString()[ 0 ] && !V_stristr( pSample, sv_snd_filter.GetString() )) { return; } #endif // STAGING_ONLY #if !defined( CLIENT_DLL ) CUtlVector< Vector > dummyorigins; // Loop through all registered microphones and tell them the sound was just played // NOTE: This means that pitch shifts/sound changes on the original ambient will not be reflected in the re-broadcasted sound bool bSwallowed = CEnvMicrophone::OnSoundPlayed( entindex, pSample, soundlevel, volume, flags, pitch, &origin, soundtime, dummyorigins); if (bSwallowed) return; #endif if (pSample && (Q_stristr(pSample, ".wav") || Q_stristr(pSample, ".mp3"))) { #if defined( CLIENT_DLL ) enginesound->EmitAmbientSound( pSample, volume, pitch, flags, soundtime ); #else engine->EmitAmbientSound(entindex, origin, pSample, volume, soundlevel, flags, pitch, soundtime); #endif if (duration) { *duration = enginesound->GetSoundDuration(pSample); } TraceEmitSound("EmitAmbientSound: Raw wave emitted '%s' (ent %i)\n", pSample, entindex); } else { EmitAmbientSound(entindex, origin, pSample, volume, flags, pitch, soundtime, duration); } }
void V_SplitString2( const char *pString, const char **pSeparators, int nSeparators, CUtlVector<char*> &outStrings ) { outStrings.Purge(); const char *pCurPos = pString; while ( 1 ) { int iFirstSeparator = -1; const char *pFirstSeparator = 0; for ( int i=0; i < nSeparators; i++ ) { const char *pTest = V_stristr( pCurPos, pSeparators[i] ); if ( pTest && (!pFirstSeparator || pTest < pFirstSeparator) ) { iFirstSeparator = i; pFirstSeparator = pTest; } } if ( pFirstSeparator ) { // Split on this separator and continue on. int separatorLen = strlen( pSeparators[iFirstSeparator] ); if ( pFirstSeparator > pCurPos ) { outStrings.AddToTail( AllocString( pCurPos, pFirstSeparator-pCurPos ) ); } pCurPos = pFirstSeparator + separatorLen; } else { // Copy the rest of the string if ( strlen( pCurPos ) ) { outStrings.AddToTail( AllocString( pCurPos, -1 ) ); } return; } } }
//----------------------------------------------------------------------------- // Models require specialized group handling to generate intermediate lod culled // versions that are then used as the the source for target conversion. //----------------------------------------------------------------------------- bool PreprocessModelFiles( CUtlVector<fileList_t> &fileList ) { if ( !InitStudioByteSwap() ) { return false; } CUtlVector< CUtlString > updateList; CUtlRBTree< CUtlString, int > visitedModels( 0, 0, ModelNamesLessFunc ); char szSourcePath[MAX_PATH]; strcpy( szSourcePath, g_szSourcePath ); V_StripFilename( szSourcePath ); if ( !szSourcePath[0] ) strcpy( szSourcePath, "." ); V_AppendSlash( szSourcePath, sizeof( szSourcePath ) ); char szModelName[MAX_PATH]; for ( int i=0; i<fileList.Count(); i++ ) { V_strncpy( szModelName, fileList[i].fileName.String(), sizeof( szModelName ) ); if ( V_stristr( szModelName, ".360." ) ) { // must ignore any target files continue; } // want only model related files char *pExtension = V_stristr( szModelName, ".mdl" ); if ( !pExtension ) { pExtension = V_stristr( szModelName, ".dx90.vtx" ); if ( !pExtension ) { pExtension = V_stristr( szModelName, ".vvd" ); if ( !pExtension ) { pExtension = V_stristr( szModelName, ".ani" ); if ( !pExtension ) { pExtension = V_stristr( szModelName, ".phy" ); if ( !pExtension ) { pExtension = V_stristr( szModelName, ".vsi" ); if ( !pExtension ) { continue; } } } } } } *pExtension = '\0'; V_strncat( szModelName, ".mdl", sizeof( szModelName ) ); if ( visitedModels.Find( szModelName ) != visitedModels.InvalidIndex() ) { // already processed continue; } visitedModels.Insert( szModelName ); // resolve to full source path const char *ptr = szModelName; if ( !strnicmp( ptr, ".\\", 2 ) ) ptr += 2; else if ( !strnicmp( ptr, szSourcePath, strlen( szSourcePath ) ) ) ptr += strlen( szSourcePath ); char szCleanName[MAX_PATH]; strcpy( szCleanName, szSourcePath ); strcat( szCleanName, ptr ); char szFullSourcePath[MAX_PATH]; _fullpath( szFullSourcePath, szCleanName, sizeof( szFullSourcePath ) ); // any one dirty component generates the set of all expected files if ( ModelNeedsUpdate( szFullSourcePath ) ) { int index = updateList.AddToTail(); updateList[index].Set( szFullSourcePath ); } } Msg( "\n" ); Msg( "Model Pre Pass: Updating %d Models.\n", updateList.Count() ); for ( int i = 0; i < updateList.Count(); i++ ) { if ( !GenerateModelFiles( updateList[i].String() ) ) { int error = g_errorList.AddToTail(); g_errorList[error].result = false; g_errorList[error].fileName.Set( updateList[i].String() ); } } // iterate error list if ( g_errorList.Count() ) { Msg( "\n" ); for ( int i = 0; i < g_errorList.Count(); i++ ) { Msg( "ERROR: could not pre-process model: %s\n", g_errorList[i].fileName.String() ); } } return true; }
void EmitSound(IRecipientFilter& filter, int entindex, const EmitSound_t & ep) { VPROF("CSoundEmitterSystem::EmitSound (calls engine)"); #ifdef STAGING_ONLY if ( sv_snd_filter.GetString()[ 0 ] && !V_stristr( ep.m_pSoundName, sv_snd_filter.GetString() )) { return; } #endif // STAGING_ONLY if (ep.m_pSoundName && (Q_stristr(ep.m_pSoundName, ".wav") || Q_stristr(ep.m_pSoundName, ".mp3") || ep.m_pSoundName[0] == '!')) { #if !defined( CLIENT_DLL ) bool bSwallowed = CEnvMicrophone::OnSoundPlayed( entindex, ep.m_pSoundName, ep.m_SoundLevel, ep.m_flVolume, ep.m_nFlags, ep.m_nPitch, ep.m_pOrigin, ep.m_flSoundTime, ep.m_UtlVecSoundOrigin); if (bSwallowed) return; #endif if (ep.m_bWarnOnDirectWaveReference && Q_stristr(ep.m_pSoundName, ".wav")) { WaveTrace(ep.m_pSoundName, "Emitsound"); } #if defined( _DEBUG ) && !defined( CLIENT_DLL ) if ( !enginesound->IsSoundPrecached( ep.m_pSoundName ) ) { Msg( "Sound %s was not precached\n", ep.m_pSoundName ); } #endif enginesound->EmitSound( filter, entindex, ep.m_nChannel, ep.m_pSoundName, ep.m_flVolume, ep.m_SoundLevel, ep.m_nFlags, ep.m_nPitch, ep.m_nSpecialDSP, ep.m_pOrigin, NULL, &ep.m_UtlVecSoundOrigin, true, ep.m_flSoundTime, ep.m_nSpeakerEntity); if (ep.m_pflSoundDuration) { *ep.m_pflSoundDuration = enginesound->GetSoundDuration(ep.m_pSoundName); } TraceEmitSound("EmitSound: Raw wave emitted '%s' (ent %i)\n", ep.m_pSoundName, entindex); return; } if (ep.m_hSoundScriptHandle == SOUNDEMITTER_INVALID_HANDLE) { ep.m_hSoundScriptHandle = (HSOUNDSCRIPTHANDLE) soundemitterbase->GetSoundIndex(ep.m_pSoundName); } if (ep.m_hSoundScriptHandle == -1) return; EmitSoundByHandle(filter, entindex, ep, ep.m_hSoundScriptHandle); }
void EmitSoundByHandle(IRecipientFilter& filter, int entindex, const EmitSound_t & ep, HSOUNDSCRIPTHANDLE& handle) { // Pull data from parameters CSoundParameters params; // Try to deduce the actor's gender gender_t gender = GENDER_NONE; CBaseEntity *ent = CBaseEntity::Instance(entindex); if (ent) { char const *actorModel = STRING(ent->GetModelName()); gender = soundemitterbase->GetActorGender(actorModel); } if (!soundemitterbase->GetParametersForSoundEx(ep.m_pSoundName, handle, params, gender, true)) { return; } if (!params.soundname[0]) return; #ifdef STAGING_ONLY if ( sv_snd_filter.GetString()[ 0 ] && !V_stristr( params.soundname, sv_snd_filter.GetString() )) { return; } #endif // STAGING_ONLY if (!Q_strncasecmp(params.soundname, "vo", 2) && !(params.channel == CHAN_STREAM || params.channel == CHAN_VOICE || params.channel == CHAN_VOICE2)) { DevMsg("EmitSound: Voice wave file %s doesn't specify CHAN_VOICE, CHAN_VOICE2 or CHAN_STREAM for sound %s\n", params.soundname, ep.m_pSoundName); } // handle SND_CHANGEPITCH/SND_CHANGEVOL and other sound flags.etc. if (ep.m_nFlags & SND_CHANGE_PITCH) { params.pitch = ep.m_nPitch; } if (ep.m_nFlags & SND_CHANGE_VOL) { params.volume = ep.m_flVolume; } #if !defined( CLIENT_DLL ) bool bSwallowed = CEnvMicrophone::OnSoundPlayed( entindex, params.soundname, params.soundlevel, params.volume, ep.m_nFlags, params.pitch, ep.m_pOrigin, ep.m_flSoundTime, ep.m_UtlVecSoundOrigin); if (bSwallowed) return; #endif #if defined( _DEBUG ) && !defined( CLIENT_DLL ) if ( !enginesound->IsSoundPrecached( params.soundname ) ) { Msg( "Sound %s:%s was not precached\n", ep.m_pSoundName, params.soundname ); } #endif float st = ep.m_flSoundTime; if (!st && params.delay_msec != 0) { st = gpGlobals->curtime + (float) params.delay_msec / 1000.f; } enginesound->EmitSound( filter, entindex, params.channel, params.soundname, params.volume, (soundlevel_t) params.soundlevel, ep.m_nFlags, params.pitch, ep.m_nSpecialDSP, ep.m_pOrigin, NULL, &ep.m_UtlVecSoundOrigin, true, st, ep.m_nSpeakerEntity); if (ep.m_pflSoundDuration) { *ep.m_pflSoundDuration = enginesound->GetSoundDuration(params.soundname); } TraceEmitSound("EmitSound: '%s' emitted as '%s' (ent %i)\n", ep.m_pSoundName, params.soundname, entindex); // Don't caption modulations to the sound if (!(ep.m_nFlags & (SND_CHANGE_PITCH | SND_CHANGE_VOL))) { EmitCloseCaption(filter, entindex, params, ep); } #if defined( WIN32 ) // NVNT notify the haptics system of this sound HapticProcessSound(ep.m_pSoundName, entindex); #endif }
//----------------------------------------------------------------------------- // BugDlg_GetChanges // //----------------------------------------------------------------------------- bool BugDlg_GetChanges( HWND hWnd ) { int curSel; // title GetDlgItemText( hWnd, IDC_BUG_TITLE, g_bug_szTitle, sizeof( g_bug_szTitle ) ); // description GetDlgItemText( hWnd, IDC_BUG_DESCRIPTION, g_bug_szDescription, sizeof( g_bug_szDescription ) ); // owner curSel = SendDlgItemMessage( hWnd, IDC_BUG_OWNER, CB_GETCURSEL, 0, 0 ); if ( curSel == CB_ERR ) { g_bug_szOwner[0] = '\0'; } else { strncpy( g_bug_szOwner, g_bug_pReporter->GetDisplayName( curSel ), sizeof( g_bug_szOwner ) ); g_bug_szOwner[sizeof( g_bug_szOwner )-1] = '\0'; if ( V_stristr( g_bug_szOwner, "unassigned" ) ) { g_bug_szOwner[0] = '\0'; } } // severity curSel = SendDlgItemMessage( hWnd, IDC_BUG_SEVERITY, CB_GETCURSEL, 0, 0 ); if ( curSel == CB_ERR ) { g_bug_szSeverity[0] = '\0'; } else { V_strncpy( g_bug_szSeverity, g_bug_pReporter->GetSeverity( curSel ), sizeof( g_bug_szSeverity ) ); } // report type curSel = SendDlgItemMessage( hWnd, IDC_BUG_REPORTTYPE, CB_GETCURSEL, 0, 0 ); if ( curSel == CB_ERR ) { g_bug_szReportType[0] = '\0'; } else { V_strncpy( g_bug_szReportType, g_bug_pReporter->GetReportType( curSel ), sizeof( g_bug_szReportType ) ); } // priority curSel = SendDlgItemMessage( hWnd, IDC_BUG_PRIORITY, CB_GETCURSEL, 0, 0 ); if ( curSel == CB_ERR ) { g_bug_szPriority[0] = '\0'; } else { V_strncpy( g_bug_szPriority, g_bug_pReporter->GetPriority( curSel ), sizeof( g_bug_szPriority ) ); } // area curSel = SendDlgItemMessage( hWnd, IDC_BUG_AREA, CB_GETCURSEL, 0, 0 ); int areaIndex = 0; if ( curSel == CB_ERR ) { g_bug_szArea[0] = '\0'; } else { V_strncpy( g_bug_szArea, g_bug_pReporter->GetArea( curSel ), sizeof( g_bug_szArea ) ); areaIndex = curSel; } if ( !g_Games[g_bug_GameType].bUsesSystem1 ) { // map number curSel = SendDlgItemMessage( hWnd, IDC_BUG_MAPNUMBER, CB_GETCURSEL, 0, 0 ); if ( curSel == CB_ERR ) { g_bug_szMapNumber[0] = '\0'; } else { V_strncpy( g_bug_szMapNumber, g_bug_pReporter->GetLevel( areaIndex, curSel ), sizeof( g_bug_szMapNumber ) ); } } g_bug_bCompressScreenshot = ( IsDlgButtonChecked( hWnd, IDC_BUG_COMPRESS_SCREENSHOT ) != 0 ); BugDlg_CheckSubmit( hWnd ); // success return true; }
//========================================================= //========================================================= CSingleplayRules::CSingleplayRules( void ) { RefreshSkillData( true ); const char *cfgfile = defaultcfgfile.GetString(); if (cfgfile && cfgfile[0]) { char szCommand[256]; Log("Executing default gamemode config file %s\n", cfgfile); Q_snprintf(szCommand, sizeof(szCommand), "exec %s\n", cfgfile); engine->ServerCommand(szCommand); } char mapcfg[256]; Q_snprintf(mapcfg, sizeof(mapcfg), "cfg/%s.cfg", STRING(gpGlobals->mapname)); Q_FixSlashes(mapcfg); Q_strlower(mapcfg); if (mapcfg) { char szCommandMap[256]; Log("Executing map config file %s\n", mapcfg); Q_snprintf(szCommandMap, sizeof(szCommandMap), "exec %s\n", mapcfg); engine->ServerCommand(szCommandMap); } char mapname[256]; #if !defined( CLIENT_DLL ) Q_snprintf(mapname, sizeof(mapname), "maps/%s", STRING(gpGlobals->mapname)); #else Q_strncpy(mapname, engine->GetLevelName(), sizeof(mapname)); #endif Q_FixSlashes(mapname); Q_strlower(mapname); if (V_stristr(mapname, "cf")) { SetGamemode(FIREFIGHT_PRIMARY_COMBINEFIREFIGHT); Log("Automatically setting the gamemode to COMBINE FIREFIGHT due to mapname.\n"); } else if (V_stristr(mapname, "xi")) { SetGamemode(FIREFIGHT_PRIMARY_XENINVASION); Log("Automatically setting the gamemode to XEN INVASION due to mapname.\n"); } else if (V_stristr(mapname, "aa")) { SetGamemode(FIREFIGHT_PRIMARY_ANTLIONASSAULT); Log("Automatically setting the gamemode to ANTLION ASSAULT due to mapname.\n"); } else if (V_stristr(mapname, "zs")) { SetGamemode(FIREFIGHT_PRIMARY_ZOMBIESURVIVAL); Log("Automatically setting the gamemode to ZOMBIE SURVIVAL due to mapname.\n"); } else if (V_stristr(mapname, "fr")) { SetGamemode(FIREFIGHT_PRIMARY_FIREFIGHTRUMBLE); Log("Automatically setting the gamemode to FIREFIGHT RUMBLE due to mapname.\n"); } if (GetGamemode() == FIREFIGHT_PRIMARY_DEFAULT) { if (bHasRandomized) { bHasRandomized = false; iRandomGamemode = 0; } Log("No gamemode defined! Randomizing gamemodes.\n"); SetGamemodeRandom(FIREFIGHT_PRIMARY_COMBINEFIREFIGHT, FIREFIGHT_PRIMARY_FIREFIGHTRUMBLE, true); bHasRandomized = true; } if (bHasRandomized) { if (iRandomGamemode == FIREFIGHT_PRIMARY_COMBINEFIREFIGHT) { // listen server const char *cfgfilecf = combinefirefightcfgfile.GetString(); if (cfgfilecf && cfgfilecf[0]) { char szCommand[256]; Log("Executing COMBINE FIREFIGHT gamemode config file %s\n", cfgfilecf); Q_snprintf(szCommand, sizeof(szCommand), "exec %s\n", cfgfilecf); engine->ServerCommand(szCommand); } } else if (iRandomGamemode == FIREFIGHT_PRIMARY_XENINVASION) { // listen server const char *cfgfilexi = xeninvasioncfgfile.GetString(); if (cfgfilexi && cfgfilexi[0]) { char szCommand[256]; Log("Executing XEN INVASION gamemode config file %s\n", cfgfilexi); Q_snprintf(szCommand, sizeof(szCommand), "exec %s\n", cfgfilexi); engine->ServerCommand(szCommand); } } else if (iRandomGamemode == FIREFIGHT_PRIMARY_ANTLIONASSAULT) { // listen server const char *cfgfileaa = antlionassaultcfgfile.GetString(); if (cfgfileaa && cfgfileaa[0]) { char szCommand[256]; Log("Executing ANTLION ASSAULT gamemode config file %s\n", cfgfileaa); Q_snprintf(szCommand, sizeof(szCommand), "exec %s\n", cfgfileaa); engine->ServerCommand(szCommand); } } else if (iRandomGamemode == FIREFIGHT_PRIMARY_ZOMBIESURVIVAL) { // listen server const char *cfgfilezs = zombiesurvivalcfgfile.GetString(); if (cfgfilezs && cfgfilezs[0]) { char szCommand[256]; Log("Executing ZOMBIE SURVIVAL gamemode config file %s\n", cfgfilezs); Q_snprintf(szCommand, sizeof(szCommand), "exec %s\n", cfgfilezs); engine->ServerCommand(szCommand); } } else if (iRandomGamemode == FIREFIGHT_PRIMARY_FIREFIGHTRUMBLE) { // listen server const char *cfgfilefr = firefightrumblecfgfile.GetString(); if (cfgfilefr && cfgfilefr[0]) { char szCommand[256]; Log("Executing FIREFIGHT RUMBLE gamemode config file %s\n", cfgfilefr); Q_snprintf(szCommand, sizeof(szCommand), "exec %s\n", cfgfilefr); engine->ServerCommand(szCommand); } } } else { if (GetGamemode() == FIREFIGHT_PRIMARY_COMBINEFIREFIGHT) { // listen server const char *cfgfilecf = combinefirefightcfgfile.GetString(); if (cfgfilecf && cfgfilecf[0]) { char szCommand[256]; Log("Executing COMBINE FIREFIGHT gamemode config file %s\n", cfgfilecf); Q_snprintf(szCommand, sizeof(szCommand), "exec %s\n", cfgfilecf); engine->ServerCommand(szCommand); } } else if (GetGamemode() == FIREFIGHT_PRIMARY_XENINVASION) { // listen server const char *cfgfilexi = xeninvasioncfgfile.GetString(); if (cfgfilexi && cfgfilexi[0]) { char szCommand[256]; Log("Executing XEN INVASION gamemode config file %s\n", cfgfilexi); Q_snprintf(szCommand, sizeof(szCommand), "exec %s\n", cfgfilexi); engine->ServerCommand(szCommand); } } else if (GetGamemode() == FIREFIGHT_PRIMARY_ANTLIONASSAULT) { // listen server const char *cfgfileaa = antlionassaultcfgfile.GetString(); if (cfgfileaa && cfgfileaa[0]) { char szCommand[256]; Log("Executing ANTLION ASSAULT gamemode config file %s\n", cfgfileaa); Q_snprintf(szCommand, sizeof(szCommand), "exec %s\n", cfgfileaa); engine->ServerCommand(szCommand); } } else if (GetGamemode() == FIREFIGHT_PRIMARY_ZOMBIESURVIVAL) { // listen server const char *cfgfilezs = zombiesurvivalcfgfile.GetString(); if (cfgfilezs && cfgfilezs[0]) { char szCommand[256]; Log("Executing ZOMBIE SURVIVAL gamemode config file %s\n", cfgfilezs); Q_snprintf(szCommand, sizeof(szCommand), "exec %s\n", cfgfilezs); engine->ServerCommand(szCommand); } } else if (GetGamemode() == FIREFIGHT_PRIMARY_FIREFIGHTRUMBLE) { // listen server const char *cfgfilefr = firefightrumblecfgfile.GetString(); if (cfgfilefr && cfgfilefr[0]) { char szCommand[256]; Log("Executing FIREFIGHT RUMBLE gamemode config file %s\n", cfgfilefr); Q_snprintf(szCommand, sizeof(szCommand), "exec %s\n", cfgfilefr); engine->ServerCommand(szCommand); } } } }
//----------------------------------------------------------------------------- // 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; }
//----------------------------------------------------------------------------- // rc_MapInfo // // Sent from application with bug dialog info //----------------------------------------------------------------------------- int rc_MapInfo( char* commandPtr ) { char* cmdToken; int errCode; int infoAddr; int retVal; int retAddr; char buff[128]; // success errCode = 0; // get address of data cmdToken = GetToken( &commandPtr ); if ( !cmdToken[0] ) goto cleanUp; sscanf( cmdToken, "%x", &infoAddr ); // get retAddr cmdToken = GetToken( &commandPtr ); if ( !cmdToken[0] ) goto cleanUp; sscanf( cmdToken, "%x", &retAddr ); // get the caller's info data DmGetMemory( ( void* )infoAddr, sizeof( xrMapInfo_t ), &g_bug_mapInfo, NULL ); // swap the structure BigFloat( &g_bug_mapInfo.position[0], &g_bug_mapInfo.position[0] ); BigFloat( &g_bug_mapInfo.position[1], &g_bug_mapInfo.position[1] ); BigFloat( &g_bug_mapInfo.position[2], &g_bug_mapInfo.position[2] ); BigFloat( &g_bug_mapInfo.angle[0], &g_bug_mapInfo.angle[0] ); BigFloat( &g_bug_mapInfo.angle[1], &g_bug_mapInfo.angle[1] ); BigFloat( &g_bug_mapInfo.angle[2], &g_bug_mapInfo.angle[2] ); g_bug_mapInfo.build = BigDWord( g_bug_mapInfo.build ); g_bug_mapInfo.skill = BigDWord( g_bug_mapInfo.skill ); Sys_NormalizePath( g_bug_mapInfo.savePath, false ); Sys_NormalizePath( g_bug_mapInfo.mapPath, false ); if ( g_bug_hWnd ) { if ( g_bug_mapInfo.mapPath[0] ) { Sys_StripPath( g_bug_mapInfo.mapPath, buff, sizeof( buff ) ); SetDlgItemText( g_bug_hWnd, IDC_BUG_MAP_LABEL, buff ); if ( !g_Games[g_bug_GameType].bUsesSystem1 ) { char *pExtension = V_stristr( buff, ".bsp" ); if ( pExtension ) { *pExtension = '\0'; } pExtension = V_stristr( buff, ".360" ); if ( pExtension ) { *pExtension = '\0'; } V_strncpy( g_bug_szMapNumber, buff, sizeof( g_bug_szMapNumber ) ); int curSel = SendDlgItemMessage( g_bug_hWnd, IDC_BUG_MAPNUMBER, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)(LPCSTR)g_bug_szMapNumber ); if ( curSel == CB_ERR ) curSel = 0; SendDlgItemMessage( g_bug_hWnd, IDC_BUG_MAPNUMBER, CB_SETCURSEL, curSel, 0 ); } sprintf( buff, "%.2f %.2f %.2f", g_bug_mapInfo.position[0], g_bug_mapInfo.position[1], g_bug_mapInfo.position[2] ); SetDlgItemText( g_bug_hWnd, IDC_BUG_POSITION_LABEL, buff ); sprintf( buff, "%.2f %.2f %.2f", g_bug_mapInfo.angle[0], g_bug_mapInfo.angle[1], g_bug_mapInfo.angle[2] ); SetDlgItemText( g_bug_hWnd, IDC_BUG_ORIENTATION_LABEL, buff ); } else { SetDlgItemText( g_bug_hWnd, IDC_BUG_MAP_LABEL, "" ); SetDlgItemText( g_bug_hWnd, IDC_BUG_POSITION_LABEL, "" ); SetDlgItemText( g_bug_hWnd, IDC_BUG_ORIENTATION_LABEL, "" ); } sprintf( buff, "%d", g_bug_mapInfo.build ); SetDlgItemText( g_bug_hWnd, IDC_BUG_BUILD_LABEL, buff ); EnableWindow( GetDlgItem( g_bug_hWnd, IDC_BUG_SAVEGAME ), g_bug_mapInfo.savePath[0] != '\0' && g_bug_mapInfo.mapPath[0] != '\0' ); EnableWindow( GetDlgItem( g_bug_hWnd, IDC_BUG_INCLUDEBSP ), g_bug_mapInfo.mapPath[0] != '\0' ); } // return the result retVal = 0; int xboxRetVal = BigDWord( retVal ); DmSetMemory( ( void* )retAddr, sizeof( int ), &xboxRetVal, NULL ); DebugCommand( "0x%8.8x = MapInfo( 0x%8.8x )\n", retVal, infoAddr ); cleanUp: return errCode; }
static void FileSystem_AddLoadedSearchPath( CFSSearchPathsInit &initInfo, const char *pPathID, bool *bFirstGamePath, const char *pBaseDir, const char *pLocation, bool bLowViolence ) { char fullLocationPath[MAX_PATH]; Q_MakeAbsolutePath( fullLocationPath, sizeof( fullLocationPath ), pLocation, pBaseDir ); // Now resolve any ./'s. V_FixSlashes( fullLocationPath ); if ( !V_RemoveDotSlashes( fullLocationPath ) ) Error( "FileSystem_AddLoadedSearchPath - Can't resolve pathname for '%s'", fullLocationPath ); // Add language, mod, and gamebin search paths automatically. if ( Q_stricmp( pPathID, "game" ) == 0 ) { bool bDoAllPaths = true; #if defined( _X360 ) && defined( LEFT4DEAD ) // hl2 is a vestigal mistake due to shaders, xbox needs to prevent any search path bloat if ( V_stristr( fullLocationPath, "\\hl2" ) ) { bDoAllPaths = false; } #endif // add the language path, needs to be topmost, generally only contains audio // and the language localized movies (there are 2 version one normal, one LV) // this trumps the LV english movie as desired for the language if ( initInfo.m_pLanguage && bDoAllPaths ) { AddLanguageGameDir( initInfo.m_pFileSystem, fullLocationPath, initInfo.m_pLanguage ); } // next add the low violence path if ( bLowViolence && bDoAllPaths ) { char szPath[MAX_PATH]; Q_snprintf( szPath, sizeof(szPath), "%s_lv", fullLocationPath ); initInfo.m_pFileSystem->AddSearchPath( szPath, pPathID, PATH_ADD_TO_TAIL ); } if ( CommandLine()->FindParm( "-tempcontent" ) != 0 && bDoAllPaths ) { char szPath[MAX_PATH]; Q_snprintf( szPath, sizeof(szPath), "%s_tempcontent", fullLocationPath ); initInfo.m_pFileSystem->AddSearchPath( szPath, pPathID, PATH_ADD_TO_TAIL ); } // mark the first "game" dir as the "MOD" dir if ( *bFirstGamePath ) { *bFirstGamePath = false; initInfo.m_pFileSystem->AddSearchPath( fullLocationPath, "MOD", PATH_ADD_TO_TAIL ); Q_strncpy( initInfo.m_ModPath, fullLocationPath, sizeof( initInfo.m_ModPath ) ); } if ( bDoAllPaths ) { // add the game bin AddGameBinDir( initInfo.m_pFileSystem, fullLocationPath ); } } initInfo.m_pFileSystem->AddSearchPath( fullLocationPath, pPathID, PATH_ADD_TO_TAIL ); }
PLUGIN_RESULT ManiWeaponMgr::CanBuy(player_t *player_ptr, const char *alias_name) { int reason, limit, ratio; if ((!gpManiGameType->IsGameType(MANI_GAME_CSS)) && (!gpManiGameType->IsGameType(MANI_GAME_CSGO))) return PLUGIN_CONTINUE; if (war_mode) return PLUGIN_CONTINUE; if (gpManiWarmupTimer->KnivesOnly()) return PLUGIN_STOP; char lower_alias[32]; int length = strlen(alias_name); length = ( length > 30 ) ? 30 : length; // cut off any attempts to do a weapon name > 30 characters for (int i = 0; i <= length; i++) { lower_alias[i] = tolower(alias_name[i]); } MWeapon *weapon = NULL; std::map <BasicStr, MWeapon *>::iterator itr; bool more_than_one_weapon = false; for (itr = alias_list.begin(); itr != alias_list.end(); ++itr) { if ( FStrEq(itr->first.str, lower_alias) ) { weapon = itr->second; more_than_one_weapon = false; break; } if (V_stristr(itr->first.str, lower_alias) != NULL) { if (weapon == NULL) { // Found first weapon match weapon = itr->second; } else { // Another weapon alias matched, check if the MWeapon ptr // found matches the previous one if (weapon != itr->second) { // Two different weapons found in buy string more_than_one_weapon = true; break; } } } } if (weapon == NULL) { // need to check for items here: kevlar, kevlar + helmet, nightvision and difuse kit // vest - kevlar // vesthelm - helmet // nvgs - nightvision // defuser - defuse kit if ( V_stristr( lower_alias, "vest" ) || V_stristr( lower_alias, "vesthelm" ) || V_stristr( lower_alias, "nvgs" ) || V_stristr( lower_alias, "defuser" ) || V_stristr( lower_alias, "kevlar" ) || V_stristr( lower_alias, "helmet" ) || V_stristr( lower_alias, "nightvision" ) || V_stristr( lower_alias, "defuse" ) || V_stristr( lower_alias, "kit" ) || V_stristr( lower_alias, "assaultsuit" )) return PLUGIN_CONTINUE; return PLUGIN_STOP; //obviously not a valid weapon } // If player tried to have multiple weapons in the buy string then stop // the transaction from happening if (more_than_one_weapon) { ProcessPlayActionSound(player_ptr, MANI_ACTION_SOUND_RESTRICTWEAPON); return PLUGIN_STOP; } // Check if player has enough cash anyway CCSWeaponInfo *weapon_info = (CCSWeaponInfo *) CCSGetFileWeaponInfoFromHandle(weapon->GetWeaponIndex()); if (weapon_info) { int cash = Prop_GetVal(player_ptr->entity, MANI_PROP_ACCOUNT,0); if (cash < weapon_info->standard_price) { // Not enough money so continue anyway return PLUGIN_CONTINUE; } } if (weapon->CanBuy(player_ptr, 0, reason, limit, ratio)) { return PLUGIN_CONTINUE; } ProcessPlayActionSound(player_ptr, MANI_ACTION_SOUND_RESTRICTWEAPON); ShowRestrictReason(player_ptr, weapon, reason, limit, ratio); return PLUGIN_STOP; }
void EmitAmbientSound(int entindex, const Vector& origin, const char *soundname, float flVolume, int iFlags, int iPitch, float soundtime /*= 0.0f*/, float *duration /*=NULL*/) { // Pull data from parameters CSoundParameters params; if (!soundemitterbase->GetParametersForSound(soundname, params, GENDER_NONE)) { return; } #ifdef STAGING_ONLY if ( sv_snd_filter.GetString()[ 0 ] && !V_stristr( params.soundname, sv_snd_filter.GetString() )) { return; } #endif // STAGING_ONLY if (iFlags & SND_CHANGE_PITCH) { params.pitch = iPitch; } if (iFlags & SND_CHANGE_VOL) { params.volume = flVolume; } #if defined( CLIENT_DLL ) enginesound->EmitAmbientSound( params.soundname, params.volume, params.pitch, iFlags, soundtime ); #else engine->EmitAmbientSound(entindex, origin, params.soundname, params.volume, params.soundlevel, iFlags, params.pitch, soundtime); #endif bool needsCC = !(iFlags & (SND_STOP | SND_CHANGE_VOL | SND_CHANGE_PITCH)); float soundduration = 0.0f; if (duration || needsCC) { soundduration = enginesound->GetSoundDuration(params.soundname); if (duration) { *duration = soundduration; } } TraceEmitSound("EmitAmbientSound: '%s' emitted as '%s' (ent %i)\n", soundname, params.soundname, entindex); // We only want to trigger the CC on the start of the sound, not on any changes or halting of the sound if (needsCC) { CRecipientFilter filter; filter.AddAllPlayers(); filter.MakeReliable(); CUtlVector< Vector > dummy; EmitCloseCaption(filter, entindex, false, soundname, dummy, soundduration, false); } }
void CSplitString::Construct( const char *pString, const char **pSeparators, int nSeparators ) { ////////////////////////////////////////////////////////////////////////// // make a duplicate of the original string. We'll use pieces of this duplicate to tokenize the string // and create NULL-terminated tokens of the original string // int nOriginalStringLength = V_strlen(pString); m_szBuffer = new char[nOriginalStringLength + 1]; memcpy(m_szBuffer, pString, nOriginalStringLength + 1); this->Purge(); const char *pCurPos = pString; while ( 1 ) { int iFirstSeparator = -1; const char *pFirstSeparator = 0; for ( int i=0; i < nSeparators; i++ ) { const char *pTest = V_stristr( pCurPos, pSeparators[i] ); if ( pTest && (!pFirstSeparator || pTest < pFirstSeparator) ) { iFirstSeparator = i; pFirstSeparator = pTest; } } if ( pFirstSeparator ) { // Split on this separator and continue on. int separatorLen = strlen( pSeparators[iFirstSeparator] ); if ( pFirstSeparator > pCurPos ) { ////////////////////////////////////////////////////////////////////////// /// Cut the token out of the duplicate string char *pTokenInDuplicate = m_szBuffer + (pCurPos - pString); int nTokenLength = pFirstSeparator-pCurPos; Assert(nTokenLength > 0 && !memcmp(pTokenInDuplicate,pCurPos,nTokenLength)); pTokenInDuplicate[nTokenLength] = '\0'; this->AddToTail( pTokenInDuplicate /*AllocString( pCurPos, pFirstSeparator-pCurPos )*/ ); } pCurPos = pFirstSeparator + separatorLen; } else { // Copy the rest of the string int nTokenLength = strlen( pCurPos ); if ( nTokenLength ) { ////////////////////////////////////////////////////////////////////////// // There's no need to cut this token, because there's no separator after it. // just add its copy in the buffer to the tail char *pTokenInDuplicate = m_szBuffer + (pCurPos - pString); Assert(!memcmp(pTokenInDuplicate, pCurPos, nTokenLength)); this->AddToTail( pTokenInDuplicate/*AllocString( pCurPos, -1 )*/ ); } return; } } }
//----------------------------------------------------------------------------- // 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; }
//-------------------------------------------------------------------------------------------------------- // Return true if this cost applies to the given actor bool CFuncNavCost::IsApplicableTo( CBaseCombatCharacter *who ) const { if ( !who ) { return false; } if ( m_team > 0 ) { if ( who->GetTeamNumber() != m_team ) { return false; } } #ifdef TF_DLL // TODO: Make group comparison efficient and move to base combat character CTFBot *bot = ToTFBot( who ); if ( bot ) { if ( bot->HasTheFlag() ) { if ( HasTag( "bomb_carrier" ) ) { return true; } // check custom bomb_carrier tags for this bot for( int i=0; i<m_tags.Count(); ++i ) { const char* pszTag = m_tags[i]; if ( V_stristr( pszTag, "bomb_carrier" ) ) { if ( bot->HasTag( pszTag ) ) { return true; } } } // the bomb carrier only pays attention to bomb_carrier costs return false; } if ( bot->HasMission( CTFBot::MISSION_DESTROY_SENTRIES ) ) { if ( HasTag( "mission_sentry_buster" ) ) { return true; } } if ( bot->HasMission( CTFBot::MISSION_SNIPER ) ) { if ( HasTag( "mission_sniper" ) ) { return true; } } if ( bot->HasMission( CTFBot::MISSION_SPY ) ) { if ( HasTag( "mission_spy" ) ) { return true; } } if ( bot->HasMission( CTFBot::MISSION_REPROGRAMMED ) ) { return false; } if ( !bot->IsOnAnyMission() ) { if ( HasTag( "common" ) ) { return true; } } if ( HasTag( bot->GetPlayerClass()->GetName() ) ) { return true; } // check custom tags for this bot for( int i=0; i<m_tags.Count(); ++i ) { if ( bot->HasTag( m_tags[i] ) ) { return true; } } // this cost doesn't apply to me return false; } #endif return false; }
//----------------------------------------------------------------------------- // A Scene image file contains all the compiled .XCD //----------------------------------------------------------------------------- bool CSceneImage::CreateSceneImageFile( CUtlBuffer &targetBuffer, char const *pchModPath, bool bLittleEndian, bool bQuiet, ISceneCompileStatus *pStatus ) { CUtlVector<fileList_t> vcdFileList; CUtlSymbolTable vcdSymbolTable( 0, 32, true ); Msg( "\n" ); // get all the VCD files according to the seacrh paths char searchPaths[512]; g_pFullFileSystem->GetSearchPath( "GAME", false, searchPaths, sizeof( searchPaths ) ); char *pPath = strtok( searchPaths, ";" ); while ( pPath ) { int currentCount = vcdFileList.Count(); char szPath[MAX_PATH]; V_ComposeFileName( pPath, "scenes/*.vcd", szPath, sizeof( szPath ) ); scriptlib->FindFiles( szPath, true, vcdFileList ); Msg( "Scenes: Searching '%s' - Found %d scenes.\n", szPath, vcdFileList.Count() - currentCount ); pPath = strtok( NULL, ";" ); } if ( !vcdFileList.Count() ) { Msg( "Scenes: No Scene Files found!\n" ); return false; } // iterate and convert all the VCD files bool bGameIsTF = V_stristr( pchModPath, "\\tf" ) != NULL; for ( int i=0; i<vcdFileList.Count(); i++ ) { const char *pFilename = vcdFileList[i].fileName.String(); const char *pSceneName = V_stristr( pFilename, "scenes\\" ); if ( !pSceneName ) { continue; } if ( !bLittleEndian && bGameIsTF && V_stristr( pSceneName, "high\\" ) ) { continue; } // process files in order they would be found in search paths // i.e. skipping later processed files that match an earlier conversion UtlSymId_t symbol = vcdSymbolTable.Find( pSceneName ); if ( symbol == UTL_INVAL_SYMBOL ) { vcdSymbolTable.AddString( pSceneName ); pStatus->UpdateStatus( pFilename, bQuiet, i, vcdFileList.Count() ); if ( !CreateTargetFile_VCD( pFilename, "", false, bLittleEndian ) ) { Error( "CreateSceneImageFile: Failed on '%s' conversion!\n", pFilename ); } } } if ( !g_SceneFiles.Count() ) { // nothing to do return true; } Msg( "Scenes: Finalizing %d unique scenes.\n", g_SceneFiles.Count() ); // get the string pool CUtlVector< unsigned int > stringOffsets; CUtlBuffer stringPool; g_ChoreoStringPool.GetTableAndPool( stringOffsets, stringPool ); if ( !bQuiet ) { Msg( "Scenes: String Table: %d bytes\n", stringOffsets.Count() * sizeof( int ) ); Msg( "Scenes: String Pool: %d bytes\n", stringPool.TellMaxPut() ); } // first header, then lookup table, then string pool blob int stringPoolStart = sizeof( SceneImageHeader_t ) + stringOffsets.Count() * sizeof( int ); // then directory int sceneEntryStart = stringPoolStart + stringPool.TellMaxPut(); // then variable sized summaries int sceneSummaryStart = sceneEntryStart + g_SceneFiles.Count() * sizeof( SceneImageEntry_t ); // then variable sized compiled binary scene data int sceneDataStart = 0; // construct header SceneImageHeader_t imageHeader = { 0 }; imageHeader.nId = SCENE_IMAGE_ID; imageHeader.nVersion = SCENE_IMAGE_VERSION; imageHeader.nNumScenes = g_SceneFiles.Count(); imageHeader.nNumStrings = stringOffsets.Count(); imageHeader.nSceneEntryOffset = sceneEntryStart; if ( !bLittleEndian ) { imageHeader.nId = BigLong( imageHeader.nId ); imageHeader.nVersion = BigLong( imageHeader.nVersion ); imageHeader.nNumScenes = BigLong( imageHeader.nNumScenes ); imageHeader.nNumStrings = BigLong( imageHeader.nNumStrings ); imageHeader.nSceneEntryOffset = BigLong( imageHeader.nSceneEntryOffset ); } targetBuffer.Put( &imageHeader, sizeof( imageHeader ) ); // header is immediately followed by string table and pool for ( int i = 0; i < stringOffsets.Count(); i++ ) { unsigned int offset = stringPoolStart + stringOffsets[i]; if ( !bLittleEndian ) { offset = BigLong( offset ); } targetBuffer.PutInt( offset ); } Assert( stringPoolStart == targetBuffer.TellMaxPut() ); targetBuffer.Put( stringPool.Base(), stringPool.TellMaxPut() ); // construct directory CUtlSortVector< SceneImageEntry_t, CSceneImageEntryLessFunc > imageDirectory; imageDirectory.EnsureCapacity( g_SceneFiles.Count() ); // build directory // directory is linear sorted by filename checksum for later binary search for ( int i = 0; i < g_SceneFiles.Count(); i++ ) { SceneImageEntry_t imageEntry = { 0 }; // name needs to be normalized for determinstic later CRC name calc // calc crc based on scenes\anydir\anyscene.vcd char szCleanName[MAX_PATH]; V_strncpy( szCleanName, g_SceneFiles[i].fileName.String(), sizeof( szCleanName ) ); V_strlower( szCleanName ); V_FixSlashes( szCleanName ); char *pName = V_stristr( szCleanName, "scenes\\" ); if ( !pName ) { // must have scenes\ in filename Error( "CreateSceneImageFile: Unexpected lack of scenes prefix on %s\n", g_SceneFiles[i].fileName.String() ); } CRC32_t crcFilename = CRC32_ProcessSingleBuffer( pName, strlen( pName ) ); imageEntry.crcFilename = crcFilename; // temp store an index to its file, fixup later, necessary to access post sort imageEntry.nDataOffset = i; if ( imageDirectory.Find( imageEntry ) != imageDirectory.InvalidIndex() ) { // filename checksums must be unique or runtime binary search would be bogus Error( "CreateSceneImageFile: Unexpected filename checksum collision!\n" ); } imageDirectory.Insert( imageEntry ); } // determine sort order and start of data after dynamic summaries CUtlVector< int > writeOrder; writeOrder.EnsureCapacity( g_SceneFiles.Count() ); sceneDataStart = sceneSummaryStart; for ( int i = 0; i < imageDirectory.Count(); i++ ) { // reclaim offset, indicates write order of scene file int iScene = imageDirectory[i].nDataOffset; writeOrder.AddToTail( iScene ); // march past each variable sized summary to determine start of scene data int numSounds = g_SceneFiles[iScene].soundList.Count(); sceneDataStart += sizeof( SceneImageSummary_t ) + ( numSounds - 1 ) * sizeof( int ); } // finalize and write directory Assert( sceneEntryStart == targetBuffer.TellMaxPut() ); int nSummaryOffset = sceneSummaryStart; int nDataOffset = sceneDataStart; for ( int i = 0; i < imageDirectory.Count(); i++ ) { int iScene = writeOrder[i]; imageDirectory[i].nDataOffset = nDataOffset; imageDirectory[i].nDataLength = g_SceneFiles[iScene].compiledBuffer.TellMaxPut(); imageDirectory[i].nSceneSummaryOffset = nSummaryOffset; if ( !bLittleEndian ) { imageDirectory[i].crcFilename = BigLong( imageDirectory[i].crcFilename ); imageDirectory[i].nDataOffset = BigLong( imageDirectory[i].nDataOffset ); imageDirectory[i].nDataLength = BigLong( imageDirectory[i].nDataLength ); imageDirectory[i].nSceneSummaryOffset = BigLong( imageDirectory[i].nSceneSummaryOffset ); } targetBuffer.Put( &imageDirectory[i], sizeof( SceneImageEntry_t ) ); int numSounds = g_SceneFiles[iScene].soundList.Count(); nSummaryOffset += sizeof( SceneImageSummary_t ) + (numSounds - 1) * sizeof( int ); nDataOffset += g_SceneFiles[iScene].compiledBuffer.TellMaxPut(); } // finalize and write summaries Assert( sceneSummaryStart == targetBuffer.TellMaxPut() ); for ( int i = 0; i < imageDirectory.Count(); i++ ) { int iScene = writeOrder[i]; int msecs = g_SceneFiles[iScene].msecs; int soundCount = g_SceneFiles[iScene].soundList.Count(); if ( !bLittleEndian ) { msecs = BigLong( msecs ); soundCount = BigLong( soundCount ); } targetBuffer.PutInt( msecs ); targetBuffer.PutInt( soundCount ); for ( int j = 0; j < g_SceneFiles[iScene].soundList.Count(); j++ ) { int soundId = g_SceneFiles[iScene].soundList[j]; if ( !bLittleEndian ) { soundId = BigLong( soundId ); } targetBuffer.PutInt( soundId ); } } // finalize and write data Assert( sceneDataStart == targetBuffer.TellMaxPut() ); for ( int i = 0; i < imageDirectory.Count(); i++ ) { int iScene = writeOrder[i]; targetBuffer.Put( g_SceneFiles[iScene].compiledBuffer.Base(), g_SceneFiles[iScene].compiledBuffer.TellMaxPut() ); } if ( !bQuiet ) { Msg( "Scenes: Final size: %.2f MB\n", targetBuffer.TellMaxPut() / (1024.0f * 1024.0f ) ); } // cleanup g_SceneFiles.Purge(); return true; }