Fix sounds not downloading when precached only in csqc.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3775 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2011-04-20 21:32:43 +00:00
parent b59935e30f
commit 84717bc230
3 changed files with 39 additions and 32 deletions

View file

@ -1081,6 +1081,42 @@ int CL_LoadSounds(int stage, qboolean dontactuallyload)
return stage;
}
void Sound_CheckDownload(char *s)
{
char mangled[512];
if (*s == '*') //q2 sexed sound
return;
if (!S_HaveOutput())
return;
//check without the sound/ prefix
if (CL_CheckFile(s))
return; //we have it already
//the things I do for nexuiz... *sigh*
COM_StripExtension(s, mangled, sizeof(mangled));
COM_DefaultExtension(mangled, ".ogg", sizeof(mangled));
if (CL_CheckFile(mangled))
return;
//check with the sound/ prefix
s = va("sound/%s",s);
if (CL_CheckFile(s))
return; //we have it already
//the things I do for nexuiz... *sigh*
COM_StripExtension(s, mangled, sizeof(mangled));
COM_DefaultExtension(mangled, ".ogg", sizeof(mangled));
if (CL_CheckFile(mangled))
return;
//download the one the server said.
CL_CheckOrEnqueDownloadFile(s, NULL, 0);
}
/*
=================
Sound_NextDownload
@ -1088,7 +1124,6 @@ Sound_NextDownload
*/
void Sound_CheckDownloads (void)
{
char mangled[512];
char *s;
int i;
@ -1122,37 +1157,7 @@ void Sound_CheckDownloads (void)
for (i = 1; cl.sound_name[i][0]
; i++)
{
s = cl.sound_name[i];
if (*s == '*') //q2 sexed sound
continue;
if (!S_HaveOutput())
continue;
//check without the sound/ prefix
if (CL_CheckFile(s))
continue; //we have it already
//the things I do for nexuiz... *sigh*
COM_StripExtension(s, mangled, sizeof(mangled));
COM_DefaultExtension(mangled, ".ogg", sizeof(mangled));
if (CL_CheckFile(mangled))
continue;
//check with the sound/ prefix
s = va("sound/%s",s);
if (CL_CheckFile(s))
continue; //we have it already
//the things I do for nexuiz... *sigh*
COM_StripExtension(s, mangled, sizeof(mangled));
COM_DefaultExtension(mangled, ".ogg", sizeof(mangled));
if (CL_CheckFile(mangled))
continue;
//download the one the server said.
CL_CheckOrEnqueDownloadFile(s, NULL, 0);
Sound_CheckDownload(cl.sound_name[i]);
}
}

View file

@ -935,6 +935,7 @@ qboolean CL_ParseOOBDownload(void);
void CL_DownloadFinished(void);
void CL_RequestNextDownload (void);
void CL_SendDownloadReq(sizebuf_t *msg);
void Sound_CheckDownload(char *s); /*checkorenqueue a sound file*/
qboolean CL_IsUploading(void);
void CL_NextUpload(void);

View file

@ -1724,6 +1724,7 @@ static void QCBUILTIN PF_cs_PrecacheModel(progfuncs_t *prinst, struct globalvars
static void QCBUILTIN PF_cs_PrecacheSound(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *soundname = PR_GetStringOfs(prinst, OFS_PARM0);
Sound_CheckDownload(soundname);
S_PrecacheSound(soundname);
}