48typedef struct music_s {
61#define MUSIC_MAX_ENTRIES 64
64static music_t music = {{}, {},
nullptr, 0,
nullptr,
false,
false,
true};
99 for (
linkedList_t* element = list; element !=
nullptr; element = element->
next) {
101 Com_Printf(
"M_ParseMusic: Too many music entries for category: '%s'!\n",
name);
117 if (
music.playingStream)
120 if (
music.data !=
nullptr) {
122 Mix_FreeMusic(
music.data);
128 music.data =
nullptr;
129 music.buffer =
nullptr;
140 if (!
s_env.initialized) {
150 const size_t len = strlen(
name);
161 if (
music.data && Mix_PlayingMusic()) {
162 if (!Mix_FadeOutMusic(1500))
175 Com_Printf(
"M_Start: Could not load '%s' background track!\n",
name);
179 SDL_RWops* rw = SDL_RWFromMem(musicBuf,
size);
186 music.data = Mix_LoadMUS_RW(rw, 1);
188 Com_Printf(
"M_Start: Could not load music: 'music/%s' (%s)!\n",
name, Mix_GetError());
195 music.buffer = musicBuf;
196 if (Mix_FadeInMusic(
music.data, 1, 1500) == -1)
197 Com_Printf(
"M_Start: Could not play music: 'music/%s' (%s)!\n",
name, Mix_GetError());
220 if (musicTrackCount) {
221 int randomID = rand() % musicTrackCount;
228 Com_Printf(
"..playing next music track: '%s'\n", musicTrack);
229 Cvar_Set(
"snd_music",
"%s", musicTrack);
246 music.category = category;
286 Com_Printf(
"M_Change_f: Could not find any %s themed music tracks!\n",
type);
308 if (
music.interruptStream) {
309 music.interruptStream =
false;
320 if (!
music.playing) {
321 if (Mix_PlayingMusic())
334 if (
music.playingStream) {
336 }
else if (!Mix_PlayingMusic()) {
340 music.nextTrack[0] =
'\0';
349 {
"music_play",
M_Play_f,
"Plays a music track."},
350 {
"music_change",
M_Change_f,
"Changes the music theme (valid values:battlescape/geoscape/main/aircombat)."},
351 {
"music_stop",
M_Stop,
"Stops currently playing music track."},
353 {
nullptr,
nullptr,
nullptr}
381 music.interruptStream =
true;
385 if (
length < availableBytes)
400 const int start =
length - end;
415 music.playingStream =
true;
430 if (!
s_env.initialized)
435 if (rate !=
s_env.rate) {
437 for (
int i = 0;;
i++) {
438 const int src =
i *
scale;
450 for (
int i = 0;
i < samples;
i++) {
464 if (userdata !=
nullptr)
466 music.playingStream =
false;
467 music.interruptStream =
false;
468 Mix_HookMusic(
nullptr,
nullptr);
bool CL_OnBattlescape(void)
Check whether we are in a tactical mission as server or as client. But this only means that we are ab...
memPool_t * cl_genericPool
Share stuff between the different cgame implementations.
bool Cmd_Exists(const char *cmdName)
Checks whether a function exists already.
const char * Cmd_Argv(int arg)
Returns a given argument.
void Cmd_AddParamCompleteFunction(const char *cmdName, int(*function)(const char *partial, const char **match))
void Cmd_TableAddList(const cmdList_t *cmdList)
void Cmd_RemoveCommand(const char *cmdName)
Removes a command from script interface.
bool Cmd_GenericCompleteFunction(char const *candidate, char const *partial, char const **match)
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
void Cmd_TableRemoveList(const cmdList_t *cmdList)
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
void Com_Error(int code, const char *fmt,...)
void Com_Printf(const char *const fmt,...)
definitions common between client and server, but not game lib
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
const char * Cvar_GetString(const char *varName)
Returns the value of cvar as string.
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
void FS_FreeFile(void *buffer)
const char * FS_NextFileFromFileList(const char *files)
Returns the next file that is found in the virtual filesystem identified by the given file pattern.
int FS_BuildFileList(const char *fileList)
Build a filelist.
void LIST_Delete(linkedList_t **list)
#define Mem_PoolStrDup(in, pool, tagNum)
Shared parsing functions.
QGL_EXTERN GLuint GLchar GLuint * len
QGL_EXTERN GLsizei const GLvoid * data
QGL_EXTERN GLuint GLsizei GLsizei * length
QGL_EXTERN GLint GLenum type
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
static void M_RandomTrack_f(void)
Sets the music cvar to a random track.
static void M_PlayMusicStream(musicStream_t *userdata)
static int M_CompleteMusic(const char *partial, const char **match)
static void M_MusicStreamCallback(musicStream_t *userdata, byte *stream, int length)
static char * musicArrays[MUSIC_MAX][MUSIC_MAX_ENTRIES]
void M_StopMusicStream(musicStream_t *userdata)
static cvar_t * snd_music_play
static const cmdList_t musicCmds[]
static cvar_t * snd_music
static void M_Change_f(void)
Changes the music if it suits the current situation.
static void M_Play_f(void)
Plays the music file given via commandline parameter.
void M_AddToSampleBuffer(musicStream_t *userdata, int rate, int samples, const byte *data)
Add stereo samples with a 16 byte width to the stream buffer.
void M_ParseMusic(const char *name, const char **text)
Parses music definitions for different situations.
static cvar_t * snd_music_volume
static int musicArrayLength[MUSIC_MAX]
#define MUSIC_MAX_ENTRIES
static void M_Start(const char *file)
static bool M_PlayRandomByCategory(int category)
static void M_MusicStreamUpdate(void)
bool Com_ParseList(const char **text, linkedList_t **list)
Header for script parsing functions.
#define Q_strvalid(string)
bool Q_strnull(const char *string)
void Com_StripExtension(const char *in, char *out, const size_t size)
Removes the file extension from a filename.
const char * Com_SkipPath(const char *pathname)
Returns just the filename from a given path.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
char nextTrack[MAX_QPATH]
char currentTrack[MAX_QPATH]
byte sampleBuf[MAX_RAW_SAMPLES]
void Sys_Sleep(int milliseconds)
Calls the win32 sleep function.
static const vec3_t scale