for (i = 1; i < numsounds; i++)
{
sfx = S_FindName (serversound[i]);
- if (sfx != NULL)
+ if (sfx != NULL && !(sfx->flags & SFXFLAG_SERVERSOUND))
{
sfx->locks++;
sfx->flags |= SFXFLAG_SERVERSOUND;
if (sfx == NULL)
return NULL;
- if (lock)
+ if (lock && !(sfx->flags & SFXFLAG_PERMANENT))
+ {
+ sfx->flags |= SFXFLAG_PERMANENT;
sfx->locks++;
+ }
if (!nosound.integer && snd_precache.integer)
S_LoadSound(sfx, complain);
i = 1;
while (i<Cmd_Argc())
{
- if (!strrchr(Cmd_Argv(i), '.'))
- snprintf(name, sizeof(name), "%s.wav", Cmd_Argv(i));
- else
- strlcpy(name, Cmd_Argv(i), sizeof(name));
+ strlcpy(name, Cmd_Argv(i), sizeof(name));
+ if (!strrchr(name, '.'))
+ strlcat(name, ".wav", sizeof(name));
+ i++;
sfx = S_PrecacheSound (name, true, false);
+ // add a lock and the serversound flag to the sfx so it will be kept
+ // until level change
+ if (sfx && !(sfx->flags & SFXFLAG_SERVERSOUND))
+ {
+ sfx->flags |= SFXFLAG_SERVERSOUND;
+ sfx->locks++;
+ }
+
// If we need to get the volume from the command line
if (fvol == -1.0f)
{
- fvol = atof(Cmd_Argv(i+1));
- i += 2;
- }
- else
+ fvol = atof(Cmd_Argv(i));
i++;
+ }
ch_ind = S_StartSound(-1, 0, sfx, listener_origin, fvol, attenuation);
if (!snd_initialized.integer || nosound.integer)
return true;
- sfx = S_PrecacheSound (sound, true, false);
+ sfx = S_PrecacheSound (sound, true, true);
if (!sfx)
{
Con_Printf("S_LocalSound: can't precache %s\n", sound);
#define SFXFLAG_FILEMISSING (1 << 0) // wasn't able to load the associated sound file
#define SFXFLAG_SERVERSOUND (1 << 1) // the sfx is part of the server precache list
#define SFXFLAG_STREAMED (1 << 2) // informative only. You shouldn't need to know that
+#define SFXFLAG_PERMANENT (1 << 3) // the sfx is used by the client code and should not be purged (even if it is also in the server precache list)
typedef struct snd_fetcher_s snd_fetcher_t;
struct sfx_s