This is somewhat of an experiment in which I try to add global looping sounds ...

... this possible solution has not been tested yet.
This commit is contained in:
Walter Julius Hennecke 2013-07-18 00:24:44 +02:00
parent 5742263b89
commit 1fdd793215
4 changed files with 32 additions and 2 deletions

View file

@ -110,7 +110,25 @@ static void CG_EntityEffects( centity_t *cent ) {
CG_SetEntitySoundPosition( cent );
// add loop sound
if ( cent->currentState.loopSound && cent->currentState.loopSound < 256 ) {
if(cent->currentState.eType == ET_GLOBALSPEAKER) {
// This is an attempt to create global loop sounds. We'll the if it works ...
// The idea is to use the player as sound source for any loopsoung marked as global.
// This way it should be ensured that the player always hears the sound.
if(cent->currentState.loopSound && cent->currentState.loopSound < 256) {
centity_t* c = NULL;
int i = 0;
for( ; i < MAX_CLIENTS; i++) {
c = &cg_entities[i];
if(c->currentState.clientNum == cg.snap->ps.clientNum) {
break;
}
}
trap_S_AddLoopingSound(c->currentState.number, c->lerpOrigin, vec3_origin, cgs.gameSounds[cent->currentState.loopSound]);
}
} else if ( cent->currentState.loopSound && cent->currentState.loopSound < 256) {
trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin,
cgs.gameSounds[ cent->currentState.loopSound ] );
}
@ -931,6 +949,7 @@ static void CG_AddCEntity( centity_t *cent ) {
CG_Portal( cent );
break;
case ET_SPEAKER:
case ET_GLOBALSPEAKER:
CG_Speaker( cent );
break;
case ET_LASER:

View file

@ -1010,6 +1010,7 @@ typedef enum {
ET_BEAM,
ET_PORTAL,
ET_SPEAKER,
ET_GLOBALSPEAKER,
ET_PUSH_TRIGGER,
ET_TELEPORT_TRIGGER,
ET_INVISIBLE,

View file

@ -647,6 +647,9 @@ void Svcmd_EntityList_f (void) {
case ET_SPEAKER:
G_Printf("ET_SPEAKER ");
break;
case ET_GLOBALSPEAKER:
G_Printf("ET_GLOBALSPEAKER ");
break;
case ET_PUSH_TRIGGER:
G_Printf("ET_PUSH_TRIGGER ");
break;
@ -692,6 +695,9 @@ void Svcmd_EntityList_f (void) {
case ET_SPEAKER:
G_Printf("ET_SPEAKER ");
break;
case ET_GLOBALSPEAKER:
G_Printf("ET_GLOBALSPEAKER ");
break;
case ET_PUSH_TRIGGER:
G_Printf("ET_PUSH_TRIGGER ");
break;

View file

@ -302,7 +302,11 @@ void SP_target_speaker( gentity_t *ent ) {
}
// a repeating speaker can be done completely client side
ent->s.eType = ET_SPEAKER;
if((ent->spawnflags & 4) != 0) {
ent->s.eType = ET_GLOBALSPEAKER;
} else {
ent->s.eType = ET_SPEAKER;
}
ent->s.eventParm = ent->noise_index;
ent->s.frame = (int)(ent->wait * 10);
ent->s.clientNum = (int)(ent->random * 10);