mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
Hack to play allow playing named cd tracks
from the worldspawn sounds key
This commit is contained in:
parent
57f67bc798
commit
143fbe8ea8
3 changed files with 42 additions and 1 deletions
|
@ -47,6 +47,45 @@ static qboolean CDAudio_IsNumberedTrack(const char *trackName)
|
||||||
return true;
|
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)
|
static void CDAudio_FinishedCallback(void *userdata)
|
||||||
{
|
{
|
||||||
CDAudio_Next();
|
CDAudio_Next();
|
||||||
|
|
|
@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#ifndef __CDAUDIO_H
|
#ifndef __CDAUDIO_H
|
||||||
#define __CDAUDIO_H
|
#define __CDAUDIO_H
|
||||||
|
|
||||||
|
void CDAudio_NewMap ();
|
||||||
int CDAudio_Init(void);
|
int CDAudio_Init(void);
|
||||||
void CDAudio_PlayNamed(const char *name, qboolean looping);
|
void CDAudio_PlayNamed(const char *name, qboolean looping);
|
||||||
void CDAudio_Play(byte track, qboolean looping);
|
void CDAudio_Play(byte track, qboolean looping);
|
||||||
|
|
|
@ -373,7 +373,8 @@ void CL_ParseServerInfo (void)
|
||||||
cl_entities[0].model = cl.worldmodel = cl.model_precache[1];
|
cl_entities[0].model = cl.worldmodel = cl.model_precache[1];
|
||||||
|
|
||||||
R_NewMap ();
|
R_NewMap ();
|
||||||
|
CDAudio_NewMap ();
|
||||||
|
|
||||||
//johnfitz -- clear out string; we don't consider identical
|
//johnfitz -- clear out string; we don't consider identical
|
||||||
//messages to be duplicates if the map has changed in between
|
//messages to be duplicates if the map has changed in between
|
||||||
con_lastcenterstring[0] = 0;
|
con_lastcenterstring[0] = 0;
|
||||||
|
|
Loading…
Reference in a new issue