]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
sound7(): properly support channel flags on client; reassign sound flags so FORCELOOP...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 28 Feb 2013 11:39:47 +0000 (11:39 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 28 Feb 2013 11:39:47 +0000 (11:39 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11919 d7cf8633-e32d-0410-b094-e92efae38249

clvm_cmds.c
snd_main.c
sound.h
svvm_cmds.c

index e1c6ff0d2a104bea4abea5e3b87bc29883c507d1..7cde1d918105e872bd7d34773e1fb507dfd9d063 100644 (file)
@@ -225,10 +225,6 @@ static void VM_CL_sound (prvm_prog_t *prog)
                return;
        }
 
-       // TODO currently the only flag defined in the interface is
-       // SOUNDFLAG_RELIABLE. This one makes no sense at all from CSQC.
-       // We want to, in a later extension, expose more flags.
-
        CL_VM_GetEntitySoundOrigin(MAX_EDICTS + PRVM_NUM_FOR_EDICT(entity), org);
        S_StartSound_StartPosition_Flags(MAX_EDICTS + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), org, volume, attenuation, startposition, flags, pitchchange > 0.0f ? pitchchange * 0.01f : 1.0f);
 }
index 1fb7cd54d8e7433d84c8645feba33dcdbeb99664..7788a774a4138fb24e1cbbe8e8ae3d05b37b93fd 100644 (file)
@@ -1677,7 +1677,7 @@ static void S_PlaySfxOnChannel (sfx_t *sfx, channel_t *target_chan, unsigned int
 int S_StartSound_StartPosition_Flags (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition, int flags, float fspeed)
 {
        channel_t *target_chan, *check, *ch;
-       int             ch_idx, startpos;
+       int             ch_idx, startpos, i;
 
        if (snd_renderbuffer == NULL || sfx == NULL || nosound.integer)
                return -1;
@@ -1693,6 +1693,9 @@ int S_StartSound_StartPosition_Flags (int entnum, int entchannel, sfx_t *sfx, ve
                        {
                                S_SetChannelVolume(ch_idx, fvol);
                                S_SetChannelSpeed(ch_idx, fspeed);
+                               for(i = 1; i > 0 && (i <= flags || i <= (int) channels[ch_idx].flags); i <<= 1)
+                                       if((flags ^ channels[ch_idx].flags) & i)
+                                               S_SetChannelFlag(ch_idx, i, flags & i);
                                ch->distfade = attenuation / snd_soundradius.value;
                                SND_Spatialize(ch, false);
                                return ch_idx;
diff --git a/sound.h b/sound.h
index 28b0f0a01fcfc3aaae455a3dad1959e28b995aa9..512ae9cf24036062d2b07e946d60a6fea04a1623 100644 (file)
--- a/sound.h
+++ b/sound.h
@@ -32,12 +32,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #define DEFAULT_SOUND_PACKET_ATTENUATION 1.0
 
 // Channel flags
-#define CHANNELFLAG_NONE               0
-#define CHANNELFLAG_FORCELOOP  (1 << 0) // force looping even if the sound is not looped
-#define CHANNELFLAG_LOCALSOUND (1 << 1) // INTERNAL USE. Not settable by S_SetChannelFlag
-#define CHANNELFLAG_PAUSED             (1 << 2)
-#define CHANNELFLAG_FULLVOLUME (1 << 3) // isn't affected by the general volume
-
+// These channel flags can be used for sound() builtins, with SOUNDFLAG_* names
+#define CHANNELFLAG_NONE       0
+#define CHANNELFLAG_RELIABLE   (1 << 0) // send as reliable message (only used on server)
+#define CHANNELFLAG_FORCELOOP  (1 << 1) // force looping even if the sound is not looped
+#define CHANNELFLAG_LOCALSOUND (1 << 2) // INTERNAL USE. Not settable by S_SetChannelFlag
+#define CHANNELFLAG_PAUSED     (1 << 3) // pause status
+#define CHANNELFLAG_FULLVOLUME (1 << 4) // isn't affected by the general volume
 
 // ====================================================================
 // Types and variables
@@ -74,9 +75,6 @@ void S_PurgeUnused (void);
 qboolean S_IsSoundPrecached (const sfx_t *sfx);
 sfx_t *S_FindName(const char *name);
 
-// for sound() builtins
-#define SOUNDFLAG_RELIABLE 1
-
 // these define the "engine" channel namespace
 #define CHAN_MIN_AUTO       -128
 #define CHAN_MAX_AUTO          0
index 053ae44aefbb2f23e50af87d9bf580f2ed037a21..ec7eac412094cd79b96a98ed89445599b20021b9 100644 (file)
@@ -549,7 +549,7 @@ static void VM_SV_sound(prvm_prog_t *prog)
                flags = 0;
                if(channel >= 8 && channel <= 15) // weird QW feature
                {
-                       flags |= SOUNDFLAG_RELIABLE;
+                       flags |= CHANNELFLAG_RELIABLE;
                        channel -= 8;
                }
        }
@@ -576,7 +576,7 @@ static void VM_SV_sound(prvm_prog_t *prog)
                return;
        }
 
-       SV_StartSound (entity, channel, sample, volume, attenuation, flags & SOUNDFLAG_RELIABLE, pitchchange);
+       SV_StartSound (entity, channel, sample, volume, attenuation, flags & CHANNELFLAG_RELIABLE, pitchchange);
 }
 
 /*