本文整理汇总了C++中STRING函数的典型用法代码示例。如果您正苦于以下问题:C++ STRING函数的具体用法?C++ STRING怎么用?C++ STRING使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STRING函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cbVMDeath
/* Callback for JVMTI_EVENT_VM_DEATH */
static void JNICALL
cbVMDeath(jvmtiEnv *jvmti, JNIEnv *env)
{
enter_critical_section(jvmti); {
jclass klass;
jfieldID field;
/* The VM has died. */
stdout_message("VMDeath\n");
/* Disengage calls in MTRACE_class. */
klass = (*env)->FindClass(env, STRING(MTRACE_class));
if ( klass == NULL ) {
fatal_error("ERROR: JNI: Cannot find %s with FindClass\n",
STRING(MTRACE_class));
}
field = (*env)->GetStaticFieldID(env, klass, STRING(MTRACE_engaged), "I");
if ( field == NULL ) {
fatal_error("ERROR: JNI: Cannot get field from %s\n",
STRING(MTRACE_class));
}
(*env)->SetStaticIntField(env, klass, field, 0);
/* The critical section here is important to hold back the VM death
* until all other callbacks have completed.
*/
/* Since this critical section could be holding up other threads
* in other event callbacks, we need to indicate that the VM is
* dead so that the other callbacks can short circuit their work.
* We don't expect any further events after VmDeath but we do need
* to be careful that existing threads might be in our own agent
* callback code.
*/
gdata->vm_is_dead = JNI_TRUE;
/* Dump out stats */
stdout_message("Begin Class Stats\n");
if ( gdata->ccount > 0 ) {
int cnum;
/* Sort table (in place) by number of method calls into class. */
/* Note: Do not use this table after this qsort! */
qsort(gdata->classes, gdata->ccount, sizeof(ClassInfo),
&class_compar);
/* Dump out gdata->max_count most called classes */
for ( cnum=gdata->ccount-1 ;
cnum >= 0 && cnum >= gdata->ccount - gdata->max_count;
cnum-- ) {
ClassInfo *cp;
int mnum;
cp = gdata->classes + cnum;
stdout_message("Class %s %d calls\n", cp->name, cp->calls);
if ( cp->calls==0 ) continue;
/* Sort method table (in place) by number of method calls. */
/* Note: Do not use this table after this qsort! */
qsort(cp->methods, cp->mcount, sizeof(MethodInfo),
&method_compar);
for ( mnum=cp->mcount-1 ; mnum >= 0 ; mnum-- ) {
MethodInfo *mp;
mp = cp->methods + mnum;
if ( mp->calls==0 ) continue;
stdout_message("\tMethod %s %s %d calls %d returns\n",
mp->name, mp->signature, mp->calls, mp->returns);
}
}
}
stdout_message("End Class Stats\n");
(void)fflush(stdout);
} exit_critical_section(jvmti);
}
示例2: entindex
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
void CAmbientGeneric::Activate( void )
{
BaseClass::Activate();
// Initialize sound source. If no source was given, or source can't be found
// then this is the source
if (m_hSoundSource == NULL)
{
if (m_sSourceEntName != NULL_STRING)
{
m_hSoundSource = gEntList.FindEntityByName( NULL, m_sSourceEntName );
if ( m_hSoundSource != NULL )
{
m_nSoundSourceEntIndex = m_hSoundSource->entindex();
}
}
if (m_hSoundSource == NULL)
{
m_hSoundSource = this;
m_nSoundSourceEntIndex = entindex();
}
else
{
if ( !FBitSet( m_spawnflags, SF_AMBIENT_SOUND_EVERYWHERE ) )
{
AddEFlags( EFL_FORCE_CHECK_TRANSMIT );
}
}
}
#ifdef PORTAL
// This is the only way we can silence the radio sound from the first room without touching them map -- jdw
if ( PortalGameRules() && PortalGameRules()->ShouldRemoveRadio() )
{
if ( V_strcmp( STRING( gpGlobals->mapname ), "testchmb_a_00" ) == 0 ||
V_strcmp( STRING( gpGlobals->mapname ), "testchmb_a_11" ) == 0 ||
V_strcmp( STRING( gpGlobals->mapname ), "testchmb_a_14" ) == 0 )
{
if ( V_strcmp( STRING( GetEntityName() ), "radio_sound" ) == 0 )
{
UTIL_Remove( this );
return;
}
}
}
#endif // PORTAL
// If active start the sound
if ( m_fActive )
{
int flags = SND_SPAWNING;
// If we are loading a saved game, we can't write into the init/signon buffer here, so just issue
// as a regular sound message...
if ( gpGlobals->eLoadType == MapLoad_Transition ||
gpGlobals->eLoadType == MapLoad_LoadGame ||
g_pGameRules->InRoundRestart() )
{
flags = SND_NOFLAGS;
}
// Tracker 76119: 8/12/07 ywb:
// Make sure pitch and volume are set up to the correct value (especially after restoring a .sav file)
flags |= ( SND_CHANGE_PITCH | SND_CHANGE_VOL );
// Don't bother sending over to client if volume is zero, though
if ( m_dpv.vol > 0 )
{
SendSound( (SoundFlags_t)flags );
}
SetNextThink( gpGlobals->curtime + 0.1f );
}
}
示例3: VectorITransform
entityIndex = (short)trace.m_pEnt ? trace.m_pEnt->entindex() : 0;
if ( entityIndex )
{
CBaseEntity *ent = trace.m_pEnt;
if ( ent )
{
modelIndex = ent->GetModelIndex();
VectorITransform( GetAbsOrigin(), ent->EntityToWorldTransform(), position );
canDraw = ( modelIndex != 0 );
if ( !canDraw )
{
Warning( "Suppressed StaticDecal which would have hit entity %i (class:%s, name:%s) with modelindex = 0\n",
ent->entindex(),
ent->GetClassname(),
STRING( ent->GetEntityName() ) );
}
}
}
if ( canDraw )
{
engine->StaticDecal( position, m_nTexture, entityIndex, modelIndex, m_bLowPriority );
}
SUB_Remove();
}
bool CDecal::KeyValue( const char *szKeyName, const char *szValue )
{
示例4: Precache
void CWorld :: Precache( void )
{
g_pLastSpawn = NULL;
#if 1
CVAR_SET_STRING("sv_gravity", "800"); // 67ft/sec
CVAR_SET_STRING("sv_stepsize", "18");
#else
CVAR_SET_STRING("sv_gravity", "384"); // 32ft/sec
CVAR_SET_STRING("sv_stepsize", "24");
#endif
CVAR_SET_STRING("room_type", "0");// clear DSP
// QUAKECLASSIC
// Set various physics cvars to Quake's values
CVAR_SET_STRING("sv_friction", "4");
CVAR_SET_STRING("sv_maxspeed", "400");
CVAR_SET_STRING("sv_airaccelerate", "0.7");
// Set up game rules
if (g_pGameRules)
{
delete g_pGameRules;
}
g_pGameRules = InstallGameRules( );
//!!!UNDONE why is there so much Spawn code in the Precache function? I'll just keep it here
InitBodyQue();
// init sentence group playback stuff from sentences.txt.
// ok to call this multiple times, calls after first are ignored.
SENTENCEG_Init();
// init texture type array from materials.txt
TEXTURETYPE_Init();
// the area based ambient sounds MUST be the first precache_sounds
// player precaches
W_Precache (); // get weapon precaches
ClientPrecache();
// QUAKECLASSIC
QuakeClassicPrecache();
// sounds used from C physics code
PRECACHE_SOUND("common/null.wav"); // clears sound channels
PRECACHE_SOUND( "items/suitchargeok1.wav" );//!!! temporary sound for respawning weapons.
PRECACHE_SOUND( "items/gunpickup2.wav" );// player picks up a gun.
PRECACHE_SOUND( "common/bodydrop3.wav" );// dead bodies hitting the ground (animation events)
PRECACHE_SOUND( "common/bodydrop4.wav" );
g_Language = (int)CVAR_GET_FLOAT( "sv_language" );
if ( g_Language == LANGUAGE_GERMAN )
{
PRECACHE_MODEL( "models/germangibs.mdl" );
}
else
{
PRECACHE_MODEL( "models/hgibs.mdl" );
PRECACHE_MODEL( "models/agibs.mdl" );
}
PRECACHE_SOUND ("weapons/ric1.wav");
PRECACHE_SOUND ("weapons/ric2.wav");
PRECACHE_SOUND ("weapons/ric3.wav");
PRECACHE_SOUND ("weapons/ric4.wav");
PRECACHE_SOUND ("weapons/ric5.wav");
//
// Setup light animation tables. 'a' is total darkness, 'z' is maxbright.
//
// 0 normal
LIGHT_STYLE(0, "m");
// 1 FLICKER (first variety)
LIGHT_STYLE(1, "mmnmmommommnonmmonqnmmo");
// 2 SLOW STRONG PULSE
LIGHT_STYLE(2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
// 3 CANDLE (first variety)
LIGHT_STYLE(3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
// 4 FAST STROBE
LIGHT_STYLE(4, "mamamamamama");
// 5 GENTLE PULSE 1
LIGHT_STYLE(5,"jklmnopqrstuvwxyzyxwvutsrqponmlkj");
// 6 FLICKER (second variety)
LIGHT_STYLE(6, "nmonqnmomnmomomno");
//.........这里部分代码省略.........
示例5: Warning
//-----------------------------------------------------------------------------
// Purpose: Fill out a prop's with base data parsed from the propdata file
//-----------------------------------------------------------------------------
int CPropData::ParsePropFromBase( CBaseEntity *pProp, const char *pszPropData )
{
if ( !m_bPropDataLoaded )
return PARSE_FAILED_NO_DATA;
IBreakableWithPropData *pBreakableInterface = dynamic_cast<IBreakableWithPropData*>(pProp);
if ( !pBreakableInterface )
{
return PARSE_FAILED_BAD_DATA;
}
if ( !m_pKVPropData )
{
return PARSE_FAILED_BAD_DATA;
}
// Find the specified propdata
KeyValues *pSection = m_pKVPropData->FindKey( pszPropData );
if ( !pSection )
{
Warning("%s '%s' has a base specified as '%s', but there is no matching entry in propdata.txt.\n", pProp->GetClassname(), STRING( pProp->GetModelName() ), pszPropData );
return PARSE_FAILED_BAD_DATA;
}
// Store off the first base data for debugging
if ( pBreakableInterface->GetBasePropData() == NULL_STRING )
{
pBreakableInterface->SetBasePropData( AllocPooledString( pszPropData ) );
}
return ParsePropFromKV( pProp, pSection, pSection );
}
示例6: PlayLockSounds
//-----------------------------------------------------------------------------
// Purpose: play door or button locked or unlocked sounds.
// NOTE: this routine is shared by doors and buttons
// Input : pEdict -
// pls -
// flocked - if true, play 'door is locked' sound, otherwise play 'door
// is unlocked' sound.
// fbutton -
//-----------------------------------------------------------------------------
void PlayLockSounds(CBaseEntity *pEdict, locksound_t *pls, int flocked, int fbutton)
{
if ( pEdict->HasSpawnFlags( SF_DOOR_SILENT ) )
{
return;
}
float flsoundwait = ( fbutton ) ? BUTTON_SOUNDWAIT : DOOR_SOUNDWAIT;
if ( flocked )
{
int fplaysound = (pls->sLockedSound != NULL_STRING && gpGlobals->curtime > pls->flwaitSound);
int fplaysentence = (pls->sLockedSentence != NULL_STRING && !pls->bEOFLocked && gpGlobals->curtime > pls->flwaitSentence);
float fvol = ( fplaysound && fplaysentence ) ? 0.25f : 1.0f;
// if there is a locked sound, and we've debounced, play sound
if (fplaysound)
{
// play 'door locked' sound
CPASAttenuationFilter filter( pEdict );
EmitSound_t ep;
ep.m_nChannel = CHAN_ITEM;
ep.m_pSoundName = (char*)STRING(pls->sLockedSound);
ep.m_flVolume = fvol;
ep.m_SoundLevel = SNDLVL_NORM;
CBaseEntity::EmitSound( filter, pEdict->entindex(), ep );
pls->flwaitSound = gpGlobals->curtime + flsoundwait;
}
// if there is a sentence, we've not played all in list, and we've debounced, play sound
if (fplaysentence)
{
// play next 'door locked' sentence in group
int iprev = pls->iLockedSentence;
pls->iLockedSentence = SENTENCEG_PlaySequentialSz( pEdict->edict(),
STRING(pls->sLockedSentence),
0.85f,
SNDLVL_NORM,
0,
100,
pls->iLockedSentence,
FALSE);
pls->iUnlockedSentence = 0;
// make sure we don't keep calling last sentence in list
pls->bEOFLocked = (iprev == pls->iLockedSentence);
pls->flwaitSentence = gpGlobals->curtime + DOOR_SENTENCEWAIT;
}
}
else
{
// UNLOCKED SOUND
int fplaysound = (pls->sUnlockedSound != NULL_STRING && gpGlobals->curtime > pls->flwaitSound);
int fplaysentence = (pls->sUnlockedSentence != NULL_STRING && !pls->bEOFUnlocked && gpGlobals->curtime > pls->flwaitSentence);
float fvol;
// if playing both sentence and sound, lower sound volume so we hear sentence
fvol = ( fplaysound && fplaysentence ) ? 0.25f : 1.0f;
// play 'door unlocked' sound if set
if (fplaysound)
{
CPASAttenuationFilter filter( pEdict );
EmitSound_t ep;
ep.m_nChannel = CHAN_ITEM;
ep.m_pSoundName = (char*)STRING(pls->sUnlockedSound);
ep.m_flVolume = fvol;
ep.m_SoundLevel = SNDLVL_NORM;
CBaseEntity::EmitSound( filter, pEdict->entindex(), ep );
pls->flwaitSound = gpGlobals->curtime + flsoundwait;
}
// play next 'door unlocked' sentence in group
if (fplaysentence)
{
int iprev = pls->iUnlockedSentence;
pls->iUnlockedSentence = SENTENCEG_PlaySequentialSz(pEdict->edict(), STRING(pls->sUnlockedSentence),
0.85, SNDLVL_NORM, 0, 100, pls->iUnlockedSentence, FALSE);
pls->iLockedSentence = 0;
// make sure we don't keep calling last sentence in list
pls->bEOFUnlocked = (iprev == pls->iUnlockedSentence);
pls->flwaitSentence = gpGlobals->curtime + DOOR_SENTENCEWAIT;
}
//.........这里部分代码省略.........
示例7: UTIL_ValidateSoundName
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CBaseDoor::Precache( void )
{
//Fill in a default value if necessary
if ( IsRotatingDoor() )
{
UTIL_ValidateSoundName( m_NoiseMoving, "RotDoorSound.DefaultMove" );
UTIL_ValidateSoundName( m_NoiseArrived, "RotDoorSound.DefaultArrive" );
UTIL_ValidateSoundName( m_ls.sLockedSound, "RotDoorSound.DefaultLocked" );
UTIL_ValidateSoundName( m_ls.sUnlockedSound,"DoorSound.Null" );
}
else
{
UTIL_ValidateSoundName( m_NoiseMoving, "DoorSound.DefaultMove" );
UTIL_ValidateSoundName( m_NoiseArrived, "DoorSound.DefaultArrive" );
#ifndef HL1_DLL
UTIL_ValidateSoundName( m_ls.sLockedSound, "DoorSound.DefaultLocked" );
#endif
UTIL_ValidateSoundName( m_ls.sUnlockedSound,"DoorSound.Null" );
}
#ifdef HL1_DLL
if( m_ls.sLockedSound != NULL_STRING && strlen((char*)STRING(m_ls.sLockedSound)) < 4 )
{
// Too short to be ANYTHING ".wav", so it must be an old index into a long-lost
// array of sound choices. slam it to a known "deny" sound. We lose the designer's
// original selection, but we don't get unresponsive doors.
m_ls.sLockedSound = AllocPooledString("buttons/button2.wav");
}
#endif//HL1_DLL
//Precache them all
PrecacheScriptSound( (char *) STRING(m_NoiseMoving) );
PrecacheScriptSound( (char *) STRING(m_NoiseArrived) );
PrecacheScriptSound( (char *) STRING(m_NoiseMovingClosed) );
PrecacheScriptSound( (char *) STRING(m_NoiseArrivedClosed) );
PrecacheScriptSound( (char *) STRING(m_ls.sLockedSound) );
PrecacheScriptSound( (char *) STRING(m_ls.sUnlockedSound) );
//Get sentence group names, for doors which are directly 'touched' to open
switch (m_bLockedSentence)
{
case 1: m_ls.sLockedSentence = AllocPooledString("NA"); break; // access denied
case 2: m_ls.sLockedSentence = AllocPooledString("ND"); break; // security lockout
case 3: m_ls.sLockedSentence = AllocPooledString("NF"); break; // blast door
case 4: m_ls.sLockedSentence = AllocPooledString("NFIRE"); break; // fire door
case 5: m_ls.sLockedSentence = AllocPooledString("NCHEM"); break; // chemical door
case 6: m_ls.sLockedSentence = AllocPooledString("NRAD"); break; // radiation door
case 7: m_ls.sLockedSentence = AllocPooledString("NCON"); break; // gen containment
case 8: m_ls.sLockedSentence = AllocPooledString("NH"); break; // maintenance door
case 9: m_ls.sLockedSentence = AllocPooledString("NG"); break; // broken door
default: m_ls.sLockedSentence = NULL_STRING; break;
}
switch (m_bUnlockedSentence)
{
case 1: m_ls.sUnlockedSentence = AllocPooledString("EA"); break; // access granted
case 2: m_ls.sUnlockedSentence = AllocPooledString("ED"); break; // security door
case 3: m_ls.sUnlockedSentence = AllocPooledString("EF"); break; // blast door
case 4: m_ls.sUnlockedSentence = AllocPooledString("EFIRE"); break; // fire door
case 5: m_ls.sUnlockedSentence = AllocPooledString("ECHEM"); break; // chemical door
case 6: m_ls.sUnlockedSentence = AllocPooledString("ERAD"); break; // radiation door
case 7: m_ls.sUnlockedSentence = AllocPooledString("ECON"); break; // gen containment
case 8: m_ls.sUnlockedSentence = AllocPooledString("EH"); break; // maintenance door
default: m_ls.sUnlockedSentence = NULL_STRING; break;
}
}
示例8: FireTargets
void CBaseEntity::SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float value)
{
if (!FStringNull(pev->target))
FireTargets(STRING(pev->target), pActivator, this, useType, value);
}
示例9: COMPILE_TIME_ASSERT
const char *variant_t::ToString( void ) const
{
COMPILE_TIME_ASSERT( sizeof(string_t) == sizeof(int) );
static char szBuf[512];
switch (fieldType)
{
case FIELD_STRING:
{
return(STRING(iszVal));
}
case FIELD_BOOLEAN:
{
if (bVal == 0)
{
Q_strncpy(szBuf, "false",sizeof(szBuf));
}
else
{
Q_strncpy(szBuf, "true",sizeof(szBuf));
}
return(szBuf);
}
case FIELD_INTEGER:
{
Q_snprintf( szBuf, sizeof( szBuf ), "%i", iVal );
return(szBuf);
}
case FIELD_FLOAT:
{
Q_snprintf(szBuf,sizeof(szBuf), "%g", flVal);
return(szBuf);
}
case FIELD_COLOR32:
{
Q_snprintf(szBuf,sizeof(szBuf), "%d %d %d %d", (int)rgbaVal.r, (int)rgbaVal.g, (int)rgbaVal.b, (int)rgbaVal.a);
return(szBuf);
}
case FIELD_VECTOR:
{
Q_snprintf(szBuf,sizeof(szBuf), "[%g %g %g]", (double)vecVal[0], (double)vecVal[1], (double)vecVal[2]);
return(szBuf);
}
case FIELD_VOID:
{
szBuf[0] = '\0';
return(szBuf);
}
case FIELD_EHANDLE:
{
const char *pszName = (Entity()) ? STRING(Entity()->GetEntityName()) : "<<null entity>>";
Q_strncpy( szBuf, pszName, 512 );
return (szBuf);
}
}
return("No conversion to string");
}
示例10: Msg
//-----------------------------------------------------------------------------
// Purpose: Hook for the sound system to tell us when a sound's been played
//-----------------------------------------------------------------------------
MicrophoneResult_t CEnvMicrophone::SoundPlayed( int entindex, const char *soundname, soundlevel_t soundlevel, float flVolume, int iFlags, int iPitch, const Vector *pOrigin, float soundtime, CUtlVector< Vector >& soundorigins )
{
if ( m_bAvoidFeedback )
return MicrophoneResult_Ok;
// Don't hear sounds that have already been heard by a microphone to avoid feedback!
if ( iFlags & SND_SPEAKER )
return MicrophoneResult_Ok;
#ifdef DEBUG_MICROPHONE
Msg("%s heard %s: ", STRING(GetEntityName()), soundname );
#endif
if ( !CanHearSound( entindex, soundlevel, flVolume, pOrigin ) )
return MicrophoneResult_Ok;
// We've heard it. Play it out our speaker. If our speaker's gone away, we're done.
if ( !m_hSpeaker )
{
// First time, find our speaker. Done here, because finding it in Activate() wouldn't
// find players, and we need to be able to specify !player for a speaker.
if ( m_iszSpeakerName != NULL_STRING )
{
m_hSpeaker = gEntList.FindEntityByName(NULL, STRING(m_iszSpeakerName) );
if ( !m_hSpeaker )
{
Warning( "EnvMicrophone %s specifies a non-existent speaker name: %s\n", STRING(GetEntityName()), STRING(m_iszSpeakerName) );
m_iszSpeakerName = NULL_STRING;
}
}
if ( !m_hSpeaker )
{
return MicrophoneResult_Remove;
}
}
m_bAvoidFeedback = true;
// Add the speaker flag. Detected at playback and applies the speaker filter.
iFlags |= SND_SPEAKER;
CPASAttenuationFilter filter( m_hSpeaker );
EmitSound_t ep;
ep.m_nChannel = CHAN_STATIC;
ep.m_pSoundName = soundname;
ep.m_flVolume = flVolume;
ep.m_SoundLevel = soundlevel;
ep.m_nFlags = iFlags;
ep.m_nPitch = iPitch;
ep.m_pOrigin = &m_hSpeaker->GetAbsOrigin();
ep.m_flSoundTime = soundtime;
ep.m_nSpeakerEntity = entindex;
CBaseEntity::EmitSound( filter, m_hSpeaker->entindex(), ep );
Q_strncpy( m_szLastSound, soundname, sizeof(m_szLastSound) );
m_OnRoutedSound.FireOutput( this, this, 0 );
m_bAvoidFeedback = false;
// Copy emitted origin to soundorigins array
for ( int i = 0; i < ep.m_UtlVecSoundOrigin.Count(); ++i )
{
soundorigins.AddToTail( ep.m_UtlVecSoundOrigin[ i ] );
}
// Do we want to allow the original sound to play?
if ( m_spawnflags & SF_MICROPHONE_SWALLOW_ROUTED_SOUNDS )
{
return MicrophoneResult_Swallow;
}
return MicrophoneResult_Ok;
}
示例11: EmitCloseCaption
void EmitCloseCaption( IRecipientFilter& filter, int entindex, bool fromplayer, char const *token, CUtlVector< Vector >& originlist, float duration, bool warnifmissing /*= false*/ )
{
// No close captions in multiplayer...
if ( gpGlobals->maxClients > 1 || (gpGlobals->maxClients==1 && !g_pClosecaption->GetBool()))
{
return;
}
// A negative duration means fill it in from the wav file if possible
if ( duration < 0.0f )
{
char const *wav = soundemitterbase->GetWavFileForSound( token, GENDER_NONE );
if ( wav )
{
duration = enginesound->GetSoundDuration( wav );
}
else
{
duration = 2.0f;
}
}
char lowercase[ 256 ];
Q_strncpy( lowercase, token, sizeof( lowercase ) );
Q_strlower( lowercase );
if ( Q_strstr( lowercase, "\\" ) )
{
Hack_FixEscapeChars( lowercase );
}
// NOTE: We must make a copy or else if the filter is owned by a SoundPatch, we'll end up destructively removing
// all players from it!!!!
CRecipientFilter filterCopy;
filterCopy.CopyFrom( (CRecipientFilter &)filter );
// Remove any players who don't want close captions
CBaseEntity::RemoveRecipientsIfNotCloseCaptioning( (CRecipientFilter &)filterCopy );
#if !defined( CLIENT_DLL )
{
// Defined in sceneentity.cpp
bool AttenuateCaption( const char *token, const Vector& listener, CUtlVector< Vector >& soundorigins );
if ( filterCopy.GetRecipientCount() > 0 )
{
int c = filterCopy.GetRecipientCount();
for ( int i = c - 1 ; i >= 0; --i )
{
CBasePlayer *player = UTIL_PlayerByIndex( filterCopy.GetRecipientIndex( i ) );
if ( !player )
continue;
Vector playerOrigin = player->GetAbsOrigin();
if ( AttenuateCaption( lowercase, playerOrigin, originlist ) )
{
filterCopy.RemoveRecipient( player );
}
}
}
}
#endif
// Anyone left?
if ( filterCopy.GetRecipientCount() > 0 )
{
#if !defined( CLIENT_DLL )
byte byteflags = 0;
if ( warnifmissing )
{
byteflags |= CLOSE_CAPTION_WARNIFMISSING;
}
if ( fromplayer )
{
byteflags |= CLOSE_CAPTION_FROMPLAYER;
}
CBaseEntity *pActor = CBaseEntity::Instance( entindex );
if ( pActor )
{
char const *pszActorModel = STRING( pActor->GetModelName() );
gender_t gender = soundemitterbase->GetActorGender( pszActorModel );
if ( gender == GENDER_MALE )
{
byteflags |= CLOSE_CAPTION_GENDER_MALE;
}
else if ( gender == GENDER_FEMALE )
{
byteflags |= CLOSE_CAPTION_GENDER_FEMALE;
}
}
// Send caption and duration hint down to client
UserMessageBegin( filterCopy, "CloseCaption" );
WRITE_STRING( lowercase );
WRITE_SHORT( MIN( 255, (int)( duration * 10.0f ) ) ),
WRITE_BYTE( byteflags ),
MessageEnd();
//.........这里部分代码省略.........
示例12: EmitSoundByHandle
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;
}
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 );
}
#endif // STAGING_ONLY
// 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 );
}
//.........这里部分代码省略.........
示例13: cbClassFileLoadHook
/* Callback for JVMTI_EVENT_CLASS_FILE_LOAD_HOOK */
static void JNICALL
cbClassFileLoadHook(jvmtiEnv *jvmti, JNIEnv* env,
jclass class_being_redefined, jobject loader,
const char* name, jobject protection_domain,
jint class_data_len, const unsigned char* class_data,
jint* new_class_data_len, unsigned char** new_class_data)
{
enter_critical_section(jvmti); {
/* It's possible we get here right after VmDeath event, be careful */
if ( !gdata->vm_is_dead ) {
const char *classname;
/* Name could be NULL */
if ( name == NULL ) {
classname = java_crw_demo_classname(class_data, class_data_len,
NULL);
if ( classname == NULL ) {
fatal_error("ERROR: No classname inside classfile\n");
}
} else {
classname = strdup(name);
if ( classname == NULL ) {
fatal_error("ERROR: Out of malloc memory\n");
}
}
*new_class_data_len = 0;
*new_class_data = NULL;
/* The tracker class itself? */
if ( interested((char*)classname, "", gdata->include, gdata->exclude)
&& strcmp(classname, STRING(MTRACE_class)) != 0 ) {
jint cnum;
int system_class;
unsigned char *new_image;
long new_length;
ClassInfo *cp;
/* Get unique number for every class file image loaded */
cnum = gdata->ccount++;
/* Save away class information */
if ( gdata->classes == NULL ) {
gdata->classes = (ClassInfo*)malloc(
gdata->ccount*sizeof(ClassInfo));
} else {
gdata->classes = (ClassInfo*)
realloc((void*)gdata->classes,
gdata->ccount*sizeof(ClassInfo));
}
if ( gdata->classes == NULL ) {
fatal_error("ERROR: Out of malloc memory\n");
}
cp = gdata->classes + cnum;
cp->name = (const char *)strdup(classname);
if ( cp->name == NULL ) {
fatal_error("ERROR: Out of malloc memory\n");
}
cp->calls = 0;
cp->mcount = 0;
cp->methods = NULL;
/* Is it a system class? If the class load is before VmStart
* then we will consider it a system class that should
* be treated carefully. (See java_crw_demo)
*/
system_class = 0;
if ( !gdata->vm_is_started ) {
system_class = 1;
}
new_image = NULL;
new_length = 0;
/* Call the class file reader/write demo code */
java_crw_demo(cnum,
classname,
class_data,
class_data_len,
system_class,
STRING(MTRACE_class), "L" STRING(MTRACE_class) ";",
STRING(MTRACE_entry), "(II)V",
STRING(MTRACE_exit), "(II)V",
NULL, NULL,
NULL, NULL,
&new_image,
&new_length,
NULL,
&mnum_callbacks);
/* If we got back a new class image, return it back as "the"
* new class image. This must be JVMTI Allocate space.
*/
if ( new_length > 0 ) {
unsigned char *jvmti_space;
jvmti_space = (unsigned char *)allocate(jvmti, (jint)new_length);
(void)memcpy((void*)jvmti_space, (void*)new_image, (int)new_length);
//.........这里部分代码省略.........
示例14: PrecacheModel
//=========================================================
// Precache - precaches all resources this NPC needs
//=========================================================
void CGenericActor::Precache()
{
PrecacheModel( STRING( GetModelName() ) );
}
示例15: GetAbsOrigin
//-----------------------------------------------------------------------------
// Purpose: Returns whether or not it is OK to make an NPC at this instant.
//-----------------------------------------------------------------------------
bool CBaseNPCMaker::CanMakeNPC( bool bIgnoreSolidEntities )
{
if( ai_inhibit_spawners.GetBool() )
return false;
if ( m_nMaxLiveChildren > 0 && m_nLiveChildren >= m_nMaxLiveChildren )
{// not allowed to make a new one yet. Too many live ones out right now.
return false;
}
if ( m_iszIngoreEnt != NULL_STRING )
{
m_hIgnoreEntity = gEntList.FindEntityByName( NULL, m_iszIngoreEnt );
}
Vector mins = GetAbsOrigin() - Vector( 34, 34, 0 );
Vector maxs = GetAbsOrigin() + Vector( 34, 34, 0 );
maxs.z = GetAbsOrigin().z;
// If we care about not hitting solid entities, look for 'em
if ( !bIgnoreSolidEntities )
{
CBaseEntity *pList[128];
int count = UTIL_EntitiesInBox( pList, 128, mins, maxs, FL_CLIENT|FL_NPC );
if ( count )
{
//Iterate through the list and check the results
for ( int i = 0; i < count; i++ )
{
//Don't build on top of another entity
if ( pList[i] == NULL )
continue;
//If one of the entities is solid, then we may not be able to spawn now
if ( ( pList[i]->GetSolidFlags() & FSOLID_NOT_SOLID ) == false )
{
// Since the outer method doesn't work well around striders on account of their huge bounding box.
// Find the ground under me and see if a human hull would fit there.
trace_t tr;
UTIL_TraceHull( GetAbsOrigin() + Vector( 0, 0, 2 ),
GetAbsOrigin() - Vector( 0, 0, 8192 ),
NAI_Hull::Mins(HULL_HUMAN),
NAI_Hull::Maxs(HULL_HUMAN),
MASK_NPCSOLID,
m_hIgnoreEntity,
COLLISION_GROUP_NONE,
&tr );
if( !HumanHullFits( tr.endpos + Vector( 0, 0, 1 ) ) )
{
return false;
}
}
}
}
}
// Do we need to check to see if the player's looking?
if ( HasSpawnFlags( SF_NPCMAKER_HIDEFROMPLAYER ) )
{
for ( int i = 1; i <= gpGlobals->maxClients; i++ )
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex(i);
if ( pPlayer )
{
// Only spawn if the player's looking away from me
if( pPlayer->FInViewCone( GetAbsOrigin() ) && pPlayer->FVisible( GetAbsOrigin() ) )
{
if ( !(pPlayer->GetFlags() & FL_NOTARGET) )
return false;
DevMsg( 2, "Spawner %s spawning even though seen due to notarget\n", STRING( GetEntityName() ) );
}
}
}
}
return true;
}