From: havoc Date: Sat, 20 Nov 2004 18:05:23 +0000 (+0000) Subject: fixed bug with engine sounds (for TE_ effects) and local sounds (menu, etc) being... X-Git-Tag: xonotic-v0.1.0preview~5359 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=90a6130a618f72bef104521840169b03d1cc7794 fixed bug with engine sounds (for TE_ effects) and local sounds (menu, etc) being unloaded on level change (they are supposed to stay indefinitely) keep play/play2/playvol sounds around until level change (so they're not being constantly unloaded and reloaded when used repeatedly) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4777 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/snd_main.c b/snd_main.c index 3672c680..7f01b52e 100644 --- a/snd_main.c +++ b/snd_main.c @@ -320,7 +320,7 @@ void S_ServerSounds (char serversound [][MAX_QPATH], unsigned int numsounds) 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; @@ -359,8 +359,11 @@ sfx_t *S_PrecacheSound (const char *name, qboolean complain, qboolean lock) 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); @@ -934,20 +937,26 @@ static void S_Play_Common(float fvol, float attenuation) i = 1; while (iflags & 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); @@ -1008,7 +1017,7 @@ qboolean S_LocalSound (const char *sound) 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); diff --git a/snd_main.h b/snd_main.h index d9ecb0c6..aa36d015 100644 --- a/snd_main.h +++ b/snd_main.h @@ -43,6 +43,7 @@ typedef struct #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