void SetPathSettings( ) { char pPathBuf[ MAX_PATH*32 ]; if ( GetVConfigRegistrySetting( "PATH", pPathBuf, sizeof(pPathBuf) ) ) { Q_FixSlashes( pPathBuf ); const char *pPath = pPathBuf; const char *pFound = Q_stristr( pPath, VPROJECT_BIN_PATH ); int nLen = Q_strlen( VPROJECT_BIN_PATH ); while ( pFound ) { if ( pFound[nLen] == '\\' ) { ++nLen; } if ( !pFound[nLen] || pFound[nLen] == ';' ) return; pPath += nLen; pFound = Q_stristr( pPath, VPROJECT_BIN_PATH ); } Q_strncat( pPathBuf, ";%VPROJECT%\\..\\bin", sizeof(pPathBuf) ); } else { Q_strncpy( pPathBuf, "%VPROJECT%\\..\\bin", sizeof(pPathBuf) ); } SetVConfigRegistrySetting( "PATH", pPathBuf, false ); }
//----------------------------------------------------------------------------- // Purpose: Starts the effect // Input : *pParticleMgr - // *pArgs - //----------------------------------------------------------------------------- void C_SmokeStack::Start(CParticleMgr *pParticleMgr, IPrototypeArgAccess *pArgs) { pParticleMgr->AddEffect( &m_ParticleEffect, this ); // Figure out the material name. char str[512] = "unset_material"; const model_t *pModel = modelinfo->GetModel( m_iMaterialModel ); if ( pModel ) { Q_strncpy( str, modelinfo->GetModelName( pModel ), sizeof( str ) ); // Get rid of the extension because the material system doesn't want it. char *pExt = Q_stristr( str, ".vmt" ); if ( pExt ) pExt[0] = 0; } m_MaterialHandle[0] = m_ParticleEffect.FindOrAddMaterial( str ); int iCount = 1; char szNames[512]; int iLength = Q_strlen( str ); str[iLength-1] = '\0'; Q_snprintf( szNames, sizeof( szNames ), "%s%d.vmt", str, iCount ); while ( filesystem->FileExists( VarArgs( "materials/%s", szNames ) ) && iCount < SMOKESTACK_MAX_MATERIALS ) { char *pExt = Q_stristr( szNames, ".vmt" ); if ( pExt ) pExt[0] = 0; m_MaterialHandle[iCount] = m_ParticleEffect.FindOrAddMaterial( szNames ); iCount++; } m_iMaxFrames = iCount-1; m_ParticleSpawn.Init( mat_reduceparticles.GetBool() ? m_Rate / 4 : m_Rate ); // Obey mat_reduceparticles in episodic m_InvLifetime = m_Speed / m_JetLength; m_pParticleMgr = pParticleMgr; // Figure out how we need to draw. IMaterial *pMaterial = pParticleMgr->PMaterialToIMaterial( m_MaterialHandle[0] ); if( pMaterial ) { m_Renderer.Init( pParticleMgr, pMaterial ); } QueueLightParametersInRenderer(); // For the first N seconds, always simulate so it can build up the smokestack. // Afterwards, we set it to freeze when it's not being rendered. m_ParticleEffect.SetAlwaysSimulate( true ); SetNextClientThink( gpGlobals->curtime + 5 ); }
void CHL2MP_Player::SetupPlayerSoundsByModel( const char *pModelName ) { if ( Q_stristr( pModelName, "models/human") ) m_iPlayerSoundType = (int)PLAYER_SOUNDS_CITIZEN; else if ( Q_stristr(pModelName, "police" ) ) m_iPlayerSoundType = (int)PLAYER_SOUNDS_METROPOLICE; else if ( Q_stristr(pModelName, "combine" ) ) m_iPlayerSoundType = (int)PLAYER_SOUNDS_COMBINESOLDIER; }
int MP3_GetPlaylistSongs(mp3_tracks_t *songList, char *filter) { int current, length, i; int playlist_size = 0, tracknum = 0, songCount = 0; char *s; if (!MP3_IsPlayerRunning()) return 0; MP3_GetPlaylistInfo(¤t, &length); for (i = 0 ; i < length; i ++) { s = qxmms_remote_get_playlist_title(XMMS_SESSION, i); if(!s) continue; if(!Q_stristr(s, filter)) { qg_free(s); continue; } qg_free(s); songCount++; } if(!songCount) return 0; songList->name = Z_TagMalloc (sizeof(char *) * songCount, TAG_MP3LIST); songList->num = Z_TagMalloc (sizeof(int) * songCount, TAG_MP3LIST); for (i = 0 ; i < length; i ++) { s = qxmms_remote_get_playlist_title(XMMS_SESSION, i); tracknum++; if(!s) continue; if(!Q_stristr(s, filter)) { qg_free(s); continue; } if (strlen(s) >= MP3_MAXSONGTITLE-1) s[MP3_MAXSONGTITLE-1] = 0; COM_MakePrintable(s); songList->num[playlist_size] = tracknum; songList->name[playlist_size++] = CopyString(va("%i. %s", tracknum, s), TAG_MP3LIST); qg_free(s); if(playlist_size >= songCount) break; } return playlist_size; }
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 StopSound( int iEntIndex, int iChannel, const char *pSample ) { if ( pSample && ( Q_stristr( pSample, ".wav" ) || Q_stristr( pSample, ".mp3" ) || pSample[0] == '!' ) ) { enginesound->StopSound( iEntIndex, iChannel, pSample ); TraceEmitSound( "StopSound: Raw wave stopped '%s' (ent %i)\n", pSample, iEntIndex ); } else { // Look it up in sounds.txt and ignore other parameters StopSound( iEntIndex, pSample ); } }
void CHL2MP_Player::SetPlayerTeamModel( void ) { const char *szModelName = NULL; szModelName = engine->GetClientConVarValue( engine->IndexOfEdict( edict() ), "cl_playermodel" ); int modelIndex = modelinfo->GetModelIndex( szModelName ); if ( modelIndex == -1 || ValidatePlayerModel( szModelName ) == false ) { szModelName = "models/Combine_Soldier.mdl"; m_iModelType = TEAM_COMBINE; char szReturnString[512]; Q_snprintf( szReturnString, sizeof (szReturnString ), "cl_playermodel %s\n", szModelName ); engine->ClientCommand ( edict(), szReturnString ); } if ( GetTeamNumber() == TEAM_COMBINE ) { if ( Q_stristr( szModelName, "models/human") ) { int nHeads = ARRAYSIZE( g_ppszRandomCombineModels ); g_iLastCombineModel = ( g_iLastCombineModel + 1 ) % nHeads; szModelName = g_ppszRandomCombineModels[g_iLastCombineModel]; } m_iModelType = TEAM_COMBINE; } else if ( GetTeamNumber() == TEAM_REBELS ) { if ( !Q_stristr( szModelName, "models/human") ) { int nHeads = ARRAYSIZE( g_ppszRandomCitizenModels ); g_iLastCitizenModel = ( g_iLastCitizenModel + 1 ) % nHeads; szModelName = g_ppszRandomCitizenModels[g_iLastCitizenModel]; } m_iModelType = TEAM_REBELS; } SetModel( szModelName ); SetupPlayerSoundsByModel( szModelName ); m_flNextModelChangeTime = gpGlobals->curtime + MODEL_CHANGE_INTERVAL; }
char* Q_stristr( char* pStr, char const* pSearch ) { AssertValidStringPtr( pStr ); AssertValidStringPtr( pSearch ); return (char*)Q_stristr( (char const*)pStr, pSearch ); }
void UpdateAvatarEffect(void) { if(!haptics->HasDevice()) return; Vector vel; Vector vvel; Vector evel; QAngle eye; C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer(); if(!pPlayer) return; eye = pPlayer->GetAbsAngles(); if(pPlayer->IsInAVehicle() && pPlayer->GetVehicle()) { pPlayer->GetVehicle()->GetVehicleEnt()->EstimateAbsVelocity(vvel); eye = pPlayer->GetVehicle()->GetVehicleEnt()->EyeAngles(); if(!Q_stristr(pPlayer->GetVehicle()->GetVehicleEnt()->GetClassname(),"choreo")) { eye[YAW] += 90; } } else { vel = pPlayer->GetAbsVelocity(); } Vector PlayerVel = pPlayer->GetAbsVelocity(); //Choreo vehicles use player avatar and don't produce their own velocity if(!pPlayer->GetVehicle() || abs(vvel.Length()) == 0 ) { vel = PlayerVel; } else vel = vvel; VectorYawRotate(vel, -90 -eye[YAW], vel ); vel.y = -vel.y; vel.z = -vel.z; switch(pPlayer->GetMoveType()) { case MOVETYPE_NOCLIP: vel *= hap_noclip_avatar_scale.GetFloat(); break; default: break; } haptics->UpdateAvatarVelocity(vel); }
void HandleMPIDisconnect( int procID, const char *pReason ) { int nLiveWorkers = VMPI_GetCurrentNumberOfConnections() - g_nDisconnects - 1; // We ran into the size limit before and it wasn't readily apparent that the size limit had // been breached, so make sure to show errors about invalid packet sizes.. bool bOldSuppress = g_bSuppressPrintfOutput; g_bSuppressPrintfOutput = ( Q_stristr( pReason, "invalid packet size" ) == 0 ); Warning( "\n\n--- WARNING: lost connection to '%s' (%s).\n", VMPI_GetMachineName( procID ), pReason ); if ( g_bMPIMaster ) { Warning( "%d workers remain.\n\n", nLiveWorkers ); ++g_nDisconnects; /* if ( VMPI_GetCurrentNumberOfConnections() - g_nDisconnects <= 1 ) { Error( "All machines disconnected!" ); } */ } else { VMPI_HandleAutoRestart(); Error( "Worker quitting." ); } g_bSuppressPrintfOutput = bOldSuppress; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_NPC_Puppet::AccumulateLayers( CStudioHdr *hdr, Vector pos[], Quaternion q[], float poseparam[], float currentTime, int boneMask ) { if ( m_hAnimationTarget == NULL ) return; C_BaseAnimatingOverlay *pTarget = dynamic_cast<C_BaseAnimatingOverlay *>( m_hAnimationTarget->GetBaseAnimating() ); if ( pTarget == NULL ) return; // resort the layers int layer[MAX_OVERLAYS]; int i; for (i = 0; i < MAX_OVERLAYS; i++) { layer[i] = MAX_OVERLAYS; } for (i = 0; i < pTarget->m_AnimOverlay.Count(); i++) { if (pTarget->m_AnimOverlay[i].m_nOrder < MAX_OVERLAYS) { layer[pTarget->m_AnimOverlay[i].m_nOrder] = i; } } int j; for (j = 0; j < MAX_OVERLAYS; j++) { i = layer[ j ]; if (i < pTarget->m_AnimOverlay.Count()) { float fWeight = pTarget->m_AnimOverlay[i].m_flWeight; if (fWeight > 0) { const char *pSequenceName = pTarget->GetSequenceName( pTarget->m_AnimOverlay[i].m_nSequence ); int nSequence = LookupSequence( pSequenceName ); if ( nSequence >= 0 ) { float fCycle = pTarget->m_AnimOverlay[ i ].m_flCycle; fCycle = ClampCycle( fCycle, IsSequenceLooping( nSequence ) ); if (fWeight > 1) fWeight = 1; AccumulatePose( hdr, NULL, pos, q, nSequence, fCycle, poseparam, boneMask, fWeight, currentTime ); #if _DEBUG if (Q_stristr( hdr->pszName(), r_sequence_debug.GetString()) != NULL) { DevMsgRT( "%6.2f : %30s : %5.3f : %4.2f : %1d\n", currentTime, hdr->pSeqdesc( nSequence ).pszLabel(), fCycle, fWeight, i ); } #endif } } } } }
bool DoesPathExistAlready( const char *pPathEnvVar, const char *pTestPath ) { // Fix the slashes in the input arguments. char correctedPathEnvVar[8192], correctedTestPath[MAX_PATH]; Q_strncpy( correctedPathEnvVar, pPathEnvVar, sizeof( correctedPathEnvVar ) ); Q_FixSlashes( correctedPathEnvVar ); pPathEnvVar = correctedPathEnvVar; Q_strncpy( correctedTestPath, pTestPath, sizeof( correctedTestPath ) ); Q_FixSlashes( correctedTestPath ); if ( strlen( correctedTestPath ) > 0 && PATHSEPARATOR( correctedTestPath[strlen(correctedTestPath)-1] ) ) correctedTestPath[ strlen(correctedTestPath) - 1 ] = 0; pTestPath = correctedTestPath; const char *pCurPos = pPathEnvVar; while ( 1 ) { const char *pTestPos = Q_stristr( pCurPos, pTestPath ); if ( !pTestPos ) return false; // Ok, we found pTestPath in the path, but it's only valid if it's followed by an optional slash and a semicolon. pTestPos += strlen( pTestPath ); if ( pTestPos[0] == 0 || pTestPos[0] == ';' || (PATHSEPARATOR( pTestPos[0] ) && pTestPos[1] == ';') ) return true; // Advance our marker.. pCurPos = pTestPos; } }
//----------------------------------------------------------------------------- // Purpose: Setup the patch // Input : nEntIndex - index of the edict that owns the sound channel // channel - This is a sound channel (CHAN_ITEM, CHAN_STATIC) // *pSoundName - string name of the wave "weapons/sound.wav" // attenuation - attenuation of this sound (not animated) //----------------------------------------------------------------------------- void CSoundPatch::Init( IRecipientFilter *pFilter, CBaseEntity *pEnt, int channel, const char *pSoundName, soundlevel_t soundlevel ) { m_hEnt = pEnt; m_entityChannel = channel; m_iszSoundName = AllocPooledString( pSoundName ); m_volume.SetValue( 0 ); m_soundlevel = soundlevel; m_pitch.SetValue( 0 ); m_isPlaying = false; m_shutdownTime = 0; m_flLastTime = 0; m_Filter.Init( pFilter ); // Get the volume from the script CSoundParameters params; if ( !Q_stristr( pSoundName, ".wav" ) && CBaseEntity::GetParametersForSound( pSoundName, params ) ) { m_flScriptVolume = params.volume; } else { m_flScriptVolume = 1.0; } #ifdef _DEBUG m_iszClassName = AllocPooledString( pEnt->GetClassname() ); #endif }
// Turn enum into string and vice versa int Interpolator_CurveTypeForName( const char *name ) { char sz[ 128 ]; Q_strncpy( sz, name, sizeof( sz ) ); int leftcurve = 0; int rightcurve = 0; int skip = Q_strlen( "curve_" ); if ( !Q_strnicmp( sz, "curve_", skip ) ) { char *p = sz + skip; char *second = Q_stristr( p, "_to_curve_" ); char save = *second; *second = 0; leftcurve = Interpolator_InterpolatorForName( p ); *second = save; p = second + Q_strlen( "_to_curve_" ); rightcurve = Interpolator_InterpolatorForName( p ); } return MAKE_CURVE_TYPE( leftcurve, rightcurve ); }
static qboolean GLW_StartDriverAndSetMode( const char *drivername, int mode, qboolean fullscreen ) { rserr_t err; // don't ever bother going into fullscreen with a voodoo card #if 1 // JDC: I reenabled this if ( Q_stristr( drivername, "Voodoo" ) ) { ri.Cvar_Set( "r_fullscreen", "0" ); r_fullscreen->modified = qfalse; fullscreen = qfalse; } #endif err = GLW_SetMode( drivername, mode, fullscreen ); switch ( err ) { case RSERR_INVALID_FULLSCREEN: ri.Printf( PRINT_ALL, "...WARNING: fullscreen unavailable in this mode\n" ); return qfalse; case RSERR_INVALID_MODE: ri.Printf( PRINT_ALL, "...WARNING: could not set the given mode (%d)\n", mode ); return qfalse; default: break; } return qtrue; }
char* fixBadWords(char *str) { char *at; char wordBuf[4096]; int cIndex; int i; for( i=0;i<numWords;++i ) { at = str; while( ( at = (char *)Q_stristr( at, badWords[i] ) ) ) { #ifndef min #define min(a, b) (a) < (b) ? a : b #endif cIndex = min( strspn( at, "ABCDEFGHIIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), sizeof( wordBuf ) - 1 ); memcpy( wordBuf, at, cIndex ); wordBuf[cIndex] = '\0'; if( ( Q_stricmp(badWords[i], wordBuf) == 0 ) && ( at == str || ( at[-1] == ' ' ) || ( at > ( str + 1 ) && at[-2] == '^' ) ) ) Com_Memset( at, ' ', cIndex ); ++at; } } return str; }
void HapticsEnteredVehicle(C_BaseEntity* vehicle, C_BaseCombatCharacter *pPassenger ) { if(!vehicle) return; // NVNT notify haptics system of navigation change. C_PropVehicleDriveable* drivable = dynamic_cast<C_PropVehicleDriveable*>(vehicle); bool hasgun = false; if(drivable) hasgun = drivable->HasGun(); if(Q_stristr(vehicle->GetClassname(),"airboat")) { haptics->ProcessHapticEvent(2,"Movement","airboat"); if(hasgun) haptics->SetNavigationClass("vehicle_gun"); else haptics->SetNavigationClass("vehicle_airboat"); } else if(Q_stristr(vehicle->GetClassname(),"jeepepisodic")) { haptics->ProcessHapticEvent(2,"Movement","BaseVehicle"); haptics->SetNavigationClass("vehicle_nogun"); } else if(Q_stristr(vehicle->GetClassname(),"jeep")) { haptics->ProcessHapticEvent(2,"Movement","BaseVehicle"); haptics->SetNavigationClass("vehicle_gun"); } else if(Q_stristr(vehicle->GetClassname(),"choreo")) { haptics->ProcessHapticEvent(2,"Movement","ChoreoVehicle"); haptics->SetNavigationClass("vehicle_gun_nofix");//Give this a bit of aiming } else { haptics->ProcessHapticEvent(2,"Movement","BaseVehicle"); haptics->SetNavigationClass("vehicle_nogun"); } Msg("VehicleType:%s:\n",vehicle->GetClassname()); }
void *EmitSound( const char *pSoundName ) { if ( developer.GetBool() ) { // Ensure the sound is valid int nSoundIndex = g_pSoundEmitterSystem->GetSoundIndex( pSoundName ); if ( !g_pSoundEmitterSystem->IsValidIndex( nSoundIndex ) ) { Log_Warning( LOG_GameUI, "Attempted to play invalid sound \"%s\"\n", pSoundName ); return NULL; } const char *pSourceFile = g_pSoundEmitterSystem->GetSourceFileForSound( nSoundIndex ); if ( !Q_stristr( pSourceFile, "game_sounds_ui.txt" ) ) { Log_Warning( LOG_GameUI, "Attempted to play invalid sound \"%s\". This sound must be defined\n" "in game_sounds_ui.txt but was defined in \"%s\" instead.\n", pSoundName, pSourceFile ); return NULL; } } // Pull data from parameters CSoundParameters params; HSOUNDSCRIPTHANDLE handle = SOUNDEMITTER_INVALID_HANDLE; if ( !soundemitterbase->GetParametersForSoundEx( pSoundName, handle, params, GENDER_NONE, true ) ) { Log_Warning( LOG_GameUI, "Attempted to play invalid sound \"%s\"\n", pSoundName ); return NULL; } if ( !params.soundname[0] ) { Log_Warning( LOG_GameUI, "Attempted to play invalid sound \"%s\", which has no .wav!\n", pSoundName ); return NULL; } float st = 0.0f; if ( params.delay_msec != 0.0f ) { st = gpGlobals->curtime + (float)params.delay_msec / 1000.f; } CLocalPlayerFilter filter; enginesound->EmitSound( filter, SOUND_FROM_LOCAL_PLAYER, params.channel, params.soundname, params.volume, (soundlevel_t)params.soundlevel, 0, // flags params.pitch, NULL, NULL, NULL, true, st ); return (void*)enginesound->GetGuidForLastSoundEmitted(); }
bool CHalfLife2Survival::IsAllowedToSpawn( CBaseEntity *pEntity ) { if ( !m_bActive ) return BaseClass::IsAllowedToSpawn( pEntity ); const char *pPickups = STRING( m_SurvivalSettings.m_szPickups ); if ( !pPickups ) return false; if ( Q_stristr( pPickups, "everything" ) ) return true; if ( Q_stristr( pPickups, pEntity->GetClassname() ) || Q_stristr( pPickups, STRING( pEntity->GetEntityName() ) ) ) return true; return false; }
bool GL_CheckForExtension(const char *ext) { const char *ptr = Q_stristr( glConfigExt.originalExtensionString, ext ); if (ptr == NULL) return false; ptr += strlen(ext); return ((*ptr == ' ') || (*ptr == '\0')); // verify it's complete string. }
static qboolean GLimp_HaveExtension(const char *ext) { const char *ptr = Q_stristr( (char *)qglGetString(GL_EXTENSIONS), ext ); if (ptr == NULL) return qfalse; ptr += strlen(ext); return ((*ptr == ' ') || (*ptr == '\0')); // verify it's complete string. }
void CDialog_PPEPrecache::OnCommand( const char *cmd ) { if ( !Q_stricmp( "add_effect", cmd ) ) { OpenFiledialog(); } else if ( Q_stristr( cmd, "del_effect_" ) == cmd ) { const char *pszIdStart = cmd + 11; const int index = atoi( pszIdStart ); Assert( index >= 0 && index < GetPPCache()->GetNumPostProcessingEffects() ); GetPPCache()->DeletePostProcessingEffect( index ); FillList(); } else if ( Q_stristr( cmd, "movedown_effect_" ) == cmd ) { const char *pszIdStart = cmd + 16; const int index = atoi( pszIdStart ); Assert( index >= 0 && index < GetPPCache()->GetNumPostProcessingEffects() ); GetPPCache()->MoveEffectAlongList( index, false ); FillList(); } else if ( Q_stristr( cmd, "moveup_effect_" ) == cmd ) { const char *pszIdStart = cmd + 14; const int index = atoi( pszIdStart ); Assert( index >= 0 && index < GetPPCache()->GetNumPostProcessingEffects() ); GetPPCache()->MoveEffectAlongList( index, true ); FillList(); } else { GetPPCache()->SavePrecacheFile(); BaseClass::OnCommand( cmd ); } }
static bool GLimp_HaveExtension(const char *ext) { const char *ptr = Q_stristr( glConfig.extensions_string, ext ); if (ptr == NULL) return false; ptr += strlen(ext); return ((*ptr == ' ') || (*ptr == '\0')); // verify it's complete string. }
static FSReturnCode_t TryLocateGameInfoFile( char *pOutDir, int outDirLen, bool bBubbleDir ) { // Retain a copy of suggested path for further attempts CArrayAutoPtr < char > spchCopyNameBuffer( new char [ outDirLen ] ); Q_strncpy( spchCopyNameBuffer.Get(), pOutDir, outDirLen ); spchCopyNameBuffer[ outDirLen - 1 ] = 0; // Make appropriate slashes ('/' - Linux style) for ( char *pchFix = spchCopyNameBuffer.Get(), *pchEnd = pchFix + outDirLen; pchFix < pchEnd; ++ pchFix ) { if ( '\\' == *pchFix ) { *pchFix = '/'; } } // Have a look in supplied path do { if ( DoesFileExistIn( pOutDir, GAMEINFO_FILENAME ) ) { return FS_OK; } if ( IsX360() && DoesFileExistIn( pOutDir, GAMEINFO_FILENAME_ALTERNATE ) ) { return FS_OK; } } while ( bBubbleDir && Q_StripLastDir( pOutDir, outDirLen ) ); // Make an attempt to resolve from "content -> game" directory Q_strncpy( pOutDir, spchCopyNameBuffer.Get(), outDirLen ); pOutDir[ outDirLen - 1 ] = 0; if ( char *pchContentFix = Q_stristr( pOutDir, "/content/" ) ) { sprintf( pchContentFix, "/game/" ); memmove( pchContentFix + 6, pchContentFix + 9, pOutDir + outDirLen - (pchContentFix + 9) ); // Try in the mapped "game" directory do { if ( DoesFileExistIn( pOutDir, GAMEINFO_FILENAME ) ) { return FS_OK; } if ( IsX360() && DoesFileExistIn( pOutDir, GAMEINFO_FILENAME_ALTERNATE ) ) { return FS_OK; } } while ( bBubbleDir && Q_StripLastDir( pOutDir, outDirLen ) ); } // Could not find it here return FS_MISSING_GAMEINFO_FILE; }
void Cache_Print_Sounds_And_Totals (void) { char buf[50]; cache_system_t *cd; cache_system_t *sortarray[MAX_SFX]; long i=0,j=0; long totalsndbytes=0; FileHandle_t file = g_pFileSystem->Open(mem_dbgfile.GetString(), "a"); int subtot=0; if (!file) return; memset(sortarray,sizeof(cache_system_t*)*MAX_SFX,0); //pack names into the array. for (cd = cache_head.next ; cd != &cache_head ; cd = cd->next) { if (Q_stristr(cd->name,".wav")) { sortarray[i++]=cd; } } qsort(sortarray,i,sizeof(cache_system_t*),CacheSystemCompare); if (!file) return; g_pFileSystem->FPrintf(file,"\nCACHED SOUNDS:\n"); //now process the sorted list. (totals by directory) for (j=0;j<i;j++) { g_pFileSystem->FPrintf(file, "\t%16.16s : %s\n", Q_pretifymem(sortarray[j]->size,buf),sortarray[j]->name); totalsndbytes+=sortarray[j]->size; #ifdef _WIN32 if (j+1==i || ComparePath1(sortarray[j]->name,sortarray[j+1]->name)==0) { char pathbuf[512]; _splitpath(sortarray[j]->name,NULL,pathbuf,NULL,NULL); g_pFileSystem->FPrintf(file, "\tTotal Bytes used in \"%s\": %s\n",pathbuf,Q_pretifymem(totalsndbytes-subtot,buf)); subtot=totalsndbytes; } #endif } g_pFileSystem->FPrintf(file,"Total bytes in cache used by sound: %s\n",Q_pretifymem(totalsndbytes,buf)); g_pFileSystem->Close(file); }
edict_t *G_SetPlayer(edict_t *ent, int arg) { edict_t *other, *match; int i, count; char *s; s = gi.argv(arg); // numeric values are just slot numbers if (COM_IsUint(s)) { i = atoi(s); if (i < 0 || i >= game.maxclients) { gi.cprintf(ent, PRINT_HIGH, "Bad client slot number: %d\n", i); return NULL; } other = &g_edicts[ i + 1 ]; if (!other->client || other->client->pers.connected <= CONN_CONNECTED) { gi.cprintf(ent, PRINT_HIGH, "Client %d is not active.\n", i); return NULL; } return other; } // check for a name match match = NULL; count = 0; for (i = 0; i < game.maxclients; i++) { other = &g_edicts[ i + 1 ]; if (!other->client) { continue; } if (other->client->pers.connected <= CONN_CONNECTED) { continue; } if (!Q_stricmp(other->client->pers.netname, s)) { return other; // exact match } if (Q_stristr(other->client->pers.netname, s)) { match = other; // partial match count++; } } if (!match) { gi.cprintf(ent, PRINT_HIGH, "No clients matching '%s' found.\n", s); return NULL; } if (count > 1) { gi.cprintf(ent, PRINT_HIGH, "'%s' matches multiple clients.\n", s); return NULL; } return match; }
static qboolean GLimp_HaveExtension(const char *ext) { // ZTM: FIXME: not elite force specific //const char *ptr = Q_stristr( glConfig.extensions_string, ext ); const char *ptr = Q_stristr( (char *) qglGetString (GL_EXTENSIONS), ext ); if (ptr == NULL) return qfalse; ptr += strlen(ext); return ((*ptr == ' ') || (*ptr == '\0')); // verify it's complete string. }
void CDialog_RendertargetList::OnCommand( const char *cmd ) { if ( !Q_stricmp( cmd, "new_rt" ) ) { CDialog_RendertargetSettings *pEditDiag = new CDialog_RendertargetSettings( this ); pEditDiag->AddActionSignalTarget( this ); pEditDiag->SetDefaults(); } else if ( Q_stristr( cmd, "del_rt_" ) == cmd ) { const char *pszNum = cmd + 7; int index = atoi( pszNum ); Assert( index >= 0 && index < GetRTManager()->GetNumRTs() ); GetRTManager()->GetRT( index )->FlagForDeletion(); FillList(); } else if ( Q_stristr( cmd, "edit_rt_" ) == cmd ) { const char *pszNum = cmd + 8; int index = atoi( pszNum ); Assert( index >= 0 && index < GetRTManager()->GetNumRTs() ); CDialog_RendertargetSettings *pEditDiag = new CDialog_RendertargetSettings( this ); pEditDiag->AddActionSignalTarget( this ); pEditDiag->InitFromRT( GetRTManager()->GetRT( index ) ); } else if ( !Q_stricmp( cmd, "apply" ) ) { GetRTManager()->UpdateRTsToMatSys(); GetRTManager()->SaveRTsToFile(); } else { GetRTManager()->UpdateRTsToMatSys(); GetRTManager()->SaveRTsToFile(); BaseClass::OnCommand( cmd ); } }
int CreateBrushVersionOfWorldVertexTransitionMaterial( int originalTexInfo ) { // Don't make cubemap tex infos for nodes if ( originalTexInfo == TEXINFO_NODE ) return originalTexInfo; texinfo_t *pTexInfo = &texinfo[originalTexInfo]; dtexdata_t *pTexData = GetTexData( pTexInfo->texdata ); const char *pOriginalMaterialName = TexDataStringTable_GetString( pTexData->nameStringTableID ); // Get out of here if the originalTexInfo is already a patched wvt material if ( Q_stristr( pOriginalMaterialName, "_wvt_patch" ) ) return originalTexInfo; char patchedMaterialName[1024]; GeneratePatchedMaterialName( pOriginalMaterialName, patchedMaterialName, 1024 ); // Warning( "GeneratePatchedMaterialName: %s %s\n", pMaterialName, patchedMaterialName ); // Make sure the texdata doesn't already exist. int nTexDataID = FindTexData( patchedMaterialName ); bool bHasTexData = (nTexDataID != -1); if( !bHasTexData ) { // Create the new vmt material file CreateWorldVertexTransitionPatchedMaterial( pOriginalMaterialName, patchedMaterialName ); // Make a new texdata nTexDataID = AddCloneTexData( pTexData, patchedMaterialName ); } Assert( nTexDataID != -1 ); texinfo_t newTexInfo; newTexInfo = *pTexInfo; newTexInfo.texdata = nTexDataID; int nTexInfoID = -1; // See if we need to make a new texinfo bool bHasTexInfo = false; if( bHasTexData ) { nTexInfoID = FindTexInfo( newTexInfo ); bHasTexInfo = (nTexInfoID != -1); } // Make a new texinfo if we need to. if( !bHasTexInfo ) { nTexInfoID = texinfo.AddToTail( newTexInfo ); } Assert( nTexInfoID != -1 ); return nTexInfoID; }
qboolean GLimp_HaveExtension( char *ext ) { char *ptr = Q_stristr(glConfig.extensions_string, ext); if (ptr == NULL) { return qfalse; } ptr += strlen(ext); return ((*ptr == ' ') || (*ptr == '\0')); }