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"
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);
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 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
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,...)
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)
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)
#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