From a8fa60f5e8370fded3d26994136a924903d9508e Mon Sep 17 00:00:00 2001 From: divverent Date: Sun, 15 Nov 2009 19:31:15 +0000 Subject: [PATCH] first preliminary version of DP_SND_SETPARAMS: let sound() calls with sample set to "" modify an existing sound on the given entity and channel git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9499 d7cf8633-e32d-0410-b094-e92efae38249 --- prvm_cmds.c | 2 +- snd_main.c | 25 +++++++++++++++++++++++-- svvm_cmds.c | 1 + 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/prvm_cmds.c b/prvm_cmds.c index 755c0802..ad060cbd 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -1088,7 +1088,7 @@ void VM_precache_sound (void) s = PRVM_G_STRING(OFS_PARM0); PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0); - VM_CheckEmptyString(s); + //VM_CheckEmptyString(s); if(snd_initialized.integer && !S_PrecacheSound(s, true, true)) { diff --git a/snd_main.c b/snd_main.c index 5f60089a..4d4bf704 100644 --- a/snd_main.c +++ b/snd_main.c @@ -921,6 +921,7 @@ void S_UnloadAllSounds_f (void) S_FindName ================== */ +sfx_t changevolume_sfx = {""}; sfx_t *S_FindName (const char *name) { sfx_t *sfx; @@ -928,6 +929,9 @@ sfx_t *S_FindName (const char *name) if (!snd_initialized.integer) return NULL; + if(!strcmp(name, changevolume_sfx.name)) + return &changevolume_sfx; + if (strlen (name) >= sizeof (sfx->name)) { Con_Printf ("S_FindName: sound name too long (%s)\n", name); @@ -1100,7 +1104,7 @@ S_IsSoundPrecached */ qboolean S_IsSoundPrecached (const sfx_t *sfx) { - return (sfx != NULL && sfx->fetcher != NULL); + return (sfx != NULL && sfx->fetcher != NULL) || (sfx == &changevolume_sfx); } /* @@ -1443,12 +1447,29 @@ void S_PlaySfxOnChannel (sfx_t *sfx, channel_t *target_chan, unsigned int flags, int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation) { - channel_t *target_chan, *check; + channel_t *target_chan, *check, *ch; int ch_idx; if (snd_renderbuffer == NULL || sfx == NULL || nosound.integer) return -1; + if(sfx == &changevolume_sfx) + { + if(entchannel == 0) + return -1; + for (ch_idx=NUM_AMBIENTS ; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS ; ch_idx++) + { + ch = &channels[ch_idx]; + if (ch->entnum == entnum && (ch->entchannel == entchannel || entchannel == -1) ) + { + S_SetChannelVolume(ch_idx, fvol); + ch->dist_mult = attenuation / (64.0f * snd_soundradius.value); + return ch_idx; + } + } + return -1; + } + if (sfx->fetcher == NULL) return -1; diff --git a/svvm_cmds.c b/svvm_cmds.c index c23aefb5..fe837a00 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -120,6 +120,7 @@ char *vm_sv_extensions = "DP_SND_DIRECTIONLESSATTNNONE " "DP_SND_FAKETRACKS " "DP_SND_OGGVORBIS " +"DP_SND_SETPARAMS " "DP_SND_STEREOWAV " "DP_SOLIDCORPSE " "DP_SPRITE32 " -- 2.39.2