27 #include "../cl_shared.h" 28 #include "../../shared/parse.h" 29 #include "../../ports/system.h" 30 #include "../../common/filesys.h" 31 #include "../../common/common.h" 32 #include "../../common/scripts.h" 33 #include "../cl_renderer.h" 34 #include "../cl_video.h" 35 #include "../battlescape/cl_camera.h" 36 #include "../battlescape/cl_localentity.h" 37 #include "../battlescape/cl_battlescape.h" 48 typedef struct music_s {
61 #define MUSIC_MAX_ENTRIES 64 64 static 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);
150 const size_t len = strlen(
name);
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);
185 #if SDL_VERSION_ATLEAST(2,0,0) 191 Com_Printf(
"M_Start: Could not load music: 'music/%s' (%s)!\n",
name, Mix_GetError());
199 if (Mix_FadeInMusic(
music.
data, 1, 1500) == -1)
200 Com_Printf(
"M_Start: Could not play music: 'music/%s' (%s)!\n",
name, Mix_GetError());
223 if (musicTrackCount) {
224 int randomID = rand() % musicTrackCount;
231 Com_Printf(
"..playing next music track: '%s'\n", musicTrack);
232 Cvar_Set(
"snd_music",
"%s", musicTrack);
289 Com_Printf(
"M_Change_f: Could not find any %s themed music tracks!\n",
type);
324 if (Mix_PlayingMusic())
339 }
else if (!Mix_PlayingMusic()) {
352 {
"music_play",
M_Play_f,
"Plays a music track."},
353 {
"music_change",
M_Change_f,
"Changes the music theme (valid values:battlescape/geoscape/main/aircombat)."},
354 {
"music_stop",
M_Stop,
"Stops currently playing music track."},
356 {
nullptr,
nullptr,
nullptr}
388 if (
length < availableBytes)
403 const int start =
length - end;
440 for (
int i = 0;;
i++) {
441 const int src =
i *
scale;
453 for (
int i = 0;
i < samples;
i++) {
467 if (userdata !=
nullptr)
471 Mix_HookMusic(
nullptr,
nullptr);
bool Q_strnull(const char *string)
const char * Cmd_Argv(int arg)
Returns a given argument.
static void M_MusicStreamCallback(musicStream_t *userdata, byte *stream, int length)
const char * FS_NextFileFromFileList(const char *files)
Returns the next file that is found in the virtual filesystem identified by the given file pattern...
char nextTrack[MAX_QPATH]
void Cmd_RemoveCommand(const char *cmdName)
Removes a command from script interface.
static void M_RandomTrack_f(void)
Sets the music cvar to a random track.
QGL_EXTERN GLint GLenum type
static void M_PlayMusicStream(musicStream_t *userdata)
const char * Com_SkipPath(const char *pathname)
Returns just the filename from a given path.
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...
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...
void M_ParseMusic(const char *name, const char **text)
Parses music definitions for different situations.
static const vec3_t scale
static bool M_PlayRandomByCategory(int category)
void Com_StripExtension(const char *in, char *out, const size_t size)
Removes the file extension from a filename.
byte sampleBuf[MAX_RAW_SAMPLES]
static char * musicArrays[MUSIC_MAX][MUSIC_MAX_ENTRIES]
char currentTrack[MAX_QPATH]
QGL_EXTERN GLsizei const GLvoid * data
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
void Com_Printf(const char *const fmt,...)
static void M_Change_f(void)
Changes the music if it suits the current situation.
bool Cmd_GenericCompleteFunction(char const *candidate, char const *partial, char const **match)
#define MUSIC_MAX_ENTRIES
int FS_BuildFileList(const char *fileList)
Build a filelist.
void LIST_Delete(linkedList_t **list)
static int M_CompleteMusic(const char *partial, const char **match)
void Cmd_TableRemoveList(const cmdList_t *cmdList)
static cvar_t * snd_music
memPool_t * cl_genericPool
#define Q_strvalid(string)
static cvar_t * snd_music_volume
void Com_Error(int code, const char *fmt,...)
static int musicArrayLength[MUSIC_MAX]
void Sys_Sleep(int milliseconds)
Calls the win32 sleep function.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
QGL_EXTERN GLuint GLsizei GLsizei * length
static void M_Start(const char *file)
bool Cmd_Exists(const char *cmdName)
Checks whether a function exists already.
static void M_Play_f(void)
Plays the music file given via commandline parameter.
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
static void M_MusicStreamUpdate(void)
void M_StopMusicStream(musicStream_t *userdata)
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
bool Com_ParseList(const char **text, linkedList_t **list)
QGL_EXTERN GLuint GLchar GLuint * len
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.
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
static cvar_t * snd_music_play
void Cmd_AddParamCompleteFunction(const char *cmdName, int(*function)(const char *partial, const char **match))
static const cmdList_t musicCmds[]
cvar_t * Cvar_Set(const char *varName, const char *value,...)
Sets a cvar value.
const char * Cvar_GetString(const char *varName)
Returns the value of cvar as string.
#define Mem_PoolStrDup(in, pool, tagNum)
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
void Cmd_TableAddList(const cmdList_t *cmdList)
void FS_FreeFile(void *buffer)