Hack to play allow playing named cd tracks

from the worldspawn sounds key
This commit is contained in:
Eric Wasylishen 2011-01-20 13:03:40 -07:00
parent 57f67bc798
commit 143fbe8ea8
3 changed files with 42 additions and 1 deletions

View File

@ -47,6 +47,45 @@ static qboolean CDAudio_IsNumberedTrack(const char *trackName)
return true;
}
void CDAudio_NewMap ()
{
// hack copied from gl_fog.c:Fog_ParseWorldspawn()
char key[128], value[4096];
const char *data;
data = COM_Parse(cl.worldmodel->entities);
if (!data)
return; // error
if (com_token[0] != '{')
return; // error
while (1)
{
data = COM_Parse(data);
if (!data)
return; // error
if (com_token[0] == '}')
break; // end of worldspawn
if (com_token[0] == '_')
strcpy(key, com_token + 1);
else
strcpy(key, com_token);
while (key[strlen(key)-1] == ' ') // remove trailing spaces
key[strlen(key)-1] = 0;
data = COM_Parse(data);
if (!data)
return; // error
strcpy(value, com_token);
if (!strcmp("sounds", key))
{
if (!CDAudio_IsNumberedTrack(value))
{
CDAudio_PlayNamed(value, true);
}
}
}
}
static void CDAudio_FinishedCallback(void *userdata)
{
CDAudio_Next();

View File

@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef __CDAUDIO_H
#define __CDAUDIO_H
void CDAudio_NewMap ();
int CDAudio_Init(void);
void CDAudio_PlayNamed(const char *name, qboolean looping);
void CDAudio_Play(byte track, qboolean looping);

View File

@ -373,7 +373,8 @@ void CL_ParseServerInfo (void)
cl_entities[0].model = cl.worldmodel = cl.model_precache[1];
R_NewMap ();
CDAudio_NewMap ();
//johnfitz -- clear out string; we don't consider identical
//messages to be duplicates if the map has changed in between
con_lastcenterstring[0] = 0;