void SP_target_speaker( gentity_t *ent ) { char buffer[MAX_QPATH]; char *s; G_SpawnFloat( "wait", "0", &ent->wait ); G_SpawnFloat( "random", "0", &ent->random ); if ( G_SpawnString ( "soundSet", "", &s ) ) { // this is a sound set ent->s.soundSetIndex = G_SoundSetIndex(s); ent->s.eFlags = EF_PERMANENT; VectorCopy( ent->s.origin, ent->s.pos.trBase ); trap->LinkEntity ((sharedEntity_t *)ent); return; } if ( !G_SpawnString( "noise", "NOSOUND", &s ) ) { // NONONONONO... just kill the ent and move along, please. --eez // trap->Error( ERR_DROP, "target_speaker without a noise key at %s", vtos( ent->s.origin ) ); Com_Printf("^3WARNING: target_speaker (%i) without a noise key at %s\n", ent->s.number, vtos( ent->s.origin ) ); return; } // force all client reletive sounds to be "activator" speakers that // play on the entity that activates it if ( s[0] == '*' ) { ent->spawnflags |= 8; } Q_strncpyz( buffer, s, sizeof(buffer) ); ent->noise_index = G_SoundIndex(buffer); // a repeating speaker can be done completely client side ent->s.eType = ET_SPEAKER; ent->s.eventParm = ent->noise_index; ent->s.frame = ent->wait * 10; ent->s.clientNum = ent->random * 10; // check for prestarted looping sound if ( ent->spawnflags & 1 ) { ent->s.loopSound = ent->noise_index; ent->s.loopIsSoundset = qfalse; } ent->use = Use_Target_Speaker; if (ent->spawnflags & 4) { ent->r.svFlags |= SVF_BROADCAST; } VectorCopy( ent->s.origin, ent->s.pos.trBase ); // must link the entity so we get areas and clusters so // the server can determine who to send updates to trap->LinkEntity( (sharedEntity_t *)ent ); }
void G_PrecacheSoundsets( void ) { gentity_t *ent = NULL; int i; int countedSets = 0; for ( i = 0; i < MAX_GENTITIES; i++ ) { ent = &g_entities[i]; if ( ent->inuse && ent->soundSet && ent->soundSet[0] ) { if ( countedSets >= MAX_AMBIENT_SETS ) { Com_Error( ERR_DROP, "MAX_AMBIENT_SETS was exceeded! (too many soundsets)\n" ); } ent->s.soundSetIndex = G_SoundSetIndex( ent->soundSet ); countedSets++; } } }