From 0080fe29f9aff2ba235fba176f86c244db49e432 Mon Sep 17 00:00:00 2001 From: Walter Julius Hennecke Date: Sat, 20 Jul 2013 23:10:39 +0200 Subject: [PATCH] Added global loop sounds ... --- code/cgame/cg_ents.c | 16 +++++++++++++--- code/game/bg_public.h | 1 + code/game/g_svcmds.c | 3 +++ code/game/g_target.c | 6 +++++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/code/cgame/cg_ents.c b/code/cgame/cg_ents.c index 32bcbed..d8f5fbd 100644 --- a/code/cgame/cg_ents.c +++ b/code/cgame/cg_ents.c @@ -111,8 +111,13 @@ static void CG_EntityEffects( centity_t *cent ) { // add loop sound if ( cent->currentState.loopSound && cent->currentState.loopSound < 256 ) { - trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, - cgs.gameSounds[ cent->currentState.loopSound ] ); + if(cent->currentState.eType == ET_GLOBALSPEAKER) { + trap_S_AddLoopingSound( cent->currentState.number, cg.snap->ps.origin, vec3_origin, + cgs.gameSounds[ cent->currentState.loopSound] ); + } else { + trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, + cgs.gameSounds[ cent->currentState.loopSound ] ); + } } @@ -323,7 +328,11 @@ static void CG_Speaker( centity_t *cent ) { return; } - trap_S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.gameSounds[cent->currentState.eventParm] ); + if(cent->currentState.eType == ET_SPEAKER) { + trap_S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.gameSounds[cent->currentState.eventParm] ); + } else { + trap_S_StartSound (NULL, cent->currentState.number, CHAN_AUTO, cgs.gameSounds[cent->currentState.eventParm] ); + } cent->miscTime = cg.time + cent->currentState.frame * 100 + cent->currentState.clientNum * 100 * crandom(); } @@ -931,6 +940,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: diff --git a/code/game/bg_public.h b/code/game/bg_public.h index fd395a7..686dd32 100644 --- a/code/game/bg_public.h +++ b/code/game/bg_public.h @@ -1010,6 +1010,7 @@ typedef enum { ET_BEAM, ET_PORTAL, ET_SPEAKER, + ET_GLOBALSPEAKER, ET_PUSH_TRIGGER, ET_TELEPORT_TRIGGER, ET_INVISIBLE, diff --git a/code/game/g_svcmds.c b/code/game/g_svcmds.c index 79634c1..5f3fbc9 100644 --- a/code/game/g_svcmds.c +++ b/code/game/g_svcmds.c @@ -692,6 +692,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; diff --git a/code/game/g_target.c b/code/game/g_target.c index 8372be2..a010a29 100644 --- a/code/game/g_target.c +++ b/code/game/g_target.c @@ -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_SPEAKER; + } else { + ent->s.eType = ET_GLOBALSPEAKER; + } ent->s.eventParm = ent->noise_index; ent->s.frame = (int)(ent->wait * 10); ent->s.clientNum = (int)(ent->random * 10);