]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
first preliminary version of DP_SND_SETPARAMS: let sound() calls with sample set...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 15 Nov 2009 19:31:15 +0000 (19:31 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 15 Nov 2009 19:31:15 +0000 (19:31 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9499 d7cf8633-e32d-0410-b094-e92efae38249

prvm_cmds.c
snd_main.c
svvm_cmds.c

index 755c0802c0449cde47a23dd0d650e7b0f2e6a927..ad060cbde18eb81c6cab7e7663e6fd6079ab8d5d 100644 (file)
@@ -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))
        {
index 5f60089af00a4af2db292a7a17675c4800483c43..4d4bf704db54132541787447f283430737558d13 100644 (file)
@@ -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;
 
index c23aefb5d494c9e2eddfb08c5718ff3e239afbc9..fe837a009b7579276110713a0caf913d28945631 100644 (file)
@@ -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 "