}
if (FS_FileExists(filename) && (sfx = S_PrecacheSound (filename, false, true)))
{
- faketrack = S_StartSound_StartPosition (-1, 0, sfx, vec3_origin, cdvolume, 0, startposition);
+ faketrack = S_StartSound_StartPosition_Flags (-1, 0, sfx, vec3_origin, cdvolume, 0, startposition, (looping ? CHANNELFLAG_FORCELOOP : 0) | CHANNELFLAG_FULLVOLUME | CHANNELFLAG_LOCALSOUND);
if (faketrack != -1)
{
- if (looping)
- S_SetChannelFlag (faketrack, CHANNELFLAG_FORCELOOP, true);
- S_SetChannelFlag (faketrack, CHANNELFLAG_FULLVOLUME, true);
- S_SetChannelFlag (faketrack, CHANNELFLAG_LOCALSOUND, true); // not pausable
if(track >= 1)
{
if(cdaudio.integer != 0) // we don't need these messages if only fake tracks can be played anyway
static cvar_t snd_width = {CVAR_SAVE, "snd_width", "2", "sound output precision, in bytes (1 and 2 supported)"};
static cvar_t snd_channels = {CVAR_SAVE, "snd_channels", "2", "number of channels for the sound output (2 for stereo; up to 8 supported for 3D sound)"};
+static cvar_t snd_startloopingsounds = {0, "snd_startloopingsounds", "1", "whether to start sounds that would loop (you want this to be 1); existing sounds are not affected"};
+static cvar_t snd_startnonloopingsounds = {0, "snd_startnonloopingsounds", "1", "whether to start sounds that would not loop (you want this to be 1); existing sounds are not affected"};
+
// Ambient sounds
static sfx_t* ambient_sfxs [2] = { NULL, NULL };
static const char* ambient_names [2] = { "sound/ambience/water1.wav", "sound/ambience/wind2.wav" };
Cvar_RegisterVariable(&snd_channels);
Cvar_RegisterVariable(&snd_mutewhenidle);
+ Cvar_RegisterVariable(&snd_startloopingsounds);
+ Cvar_RegisterVariable(&snd_startnonloopingsounds);
+
// COMMANDLINEOPTION: Sound: -nosound disables sound (including CD audio)
if (COM_CheckParm("-nosound"))
{
Con_Printf("S_PlaySfxOnChannel called with NULL??\n");
return;
}
+
+ if ((sfx->loopstart < sfx->total_length) || (flags & CHANNELFLAG_FORCELOOP))
+ {
+ if(!snd_startloopingsounds.integer)
+ return;
+ }
+ else
+ {
+ if(!snd_startnonloopingsounds.integer)
+ return;
+ }
+
// Initialize the channel
// a crash was reported on an in-use channel, so check here...
if (target_chan->sfx)
}
-int S_StartSound_StartPosition (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition)
+int S_StartSound_StartPosition_Flags (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition, int flags)
{
channel_t *target_chan, *check, *ch;
int ch_idx, startpos;
}
}
- S_PlaySfxOnChannel (sfx, target_chan, CHANNELFLAG_NONE, origin, fvol, attenuation, false, entnum, entchannel, startpos);
+ S_PlaySfxOnChannel (sfx, target_chan, flags, origin, fvol, attenuation, false, entnum, entchannel, startpos);
return (target_chan - channels);
}
+int S_StartSound_StartPosition (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition)
+{
+ return S_StartSound_StartPosition_Flags(entnum, entchannel, sfx, origin, fvol, attenuation, startposition, CHANNELFLAG_NONE);
+}
+
int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation)
{
return S_StartSound_StartPosition(entnum, entchannel, sfx, origin, fvol, attenuation, 0);
// S_StartSound returns the channel index, or -1 if an error occurred
int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
int S_StartSound_StartPosition (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition);
+int S_StartSound_StartPosition_Flags (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float startposition, int flags);
qboolean S_LocalSound (const char *s);
void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation);