28 #include "../../common/filesys.h"
29 #include "../../common/common.h"
31 #define SAMPLE_HASH_SIZE 64
35 #define SAMPLE_MAX_COUNT 1000
52 if (
Q_streq(name, sample->name))
62 const char** extension = soundExtensions;
64 if (!sound || sound[0] ==
'*')
67 size_t len = strlen(sound);
69 Com_Printf(
"S_LoadSound: MAX_QPATH exceeded for: '%s'\n", sound);
74 if ((len =
FS_LoadFile(
va(
"sound/%s.%s", sound, *extension++), &buf)) == -1)
77 SDL_RWops* rw = SDL_RWFromMem(buf, len);
83 Mix_Chunk* chunk = Mix_LoadWAV_RW(rw,
false);
85 Com_Printf(
"S_LoadSound: %s.\n", Mix_GetError());
95 Com_Printf(
"S_LoadSound: Could not find sound file: '%s'\n", sound);
114 return sample->index;
124 sample->
chunk = chunk;
126 sampleHash[
hash] = sample;
129 return sample->
index;
135 return sampleIndex[soundIdx];
143 Mix_FreeChunk(sample->chunk);
149 for (
s_sample_t* sample = sampleHash[
i]; sample; sample = next) {
int S_LoadSampleIdx(const char *soundFile)
Loads and registers a sound file for later use.
this is a fire definition for our weapons/ammo
s_sample_t * S_LoadSample(const char *soundFile)
Loads and registers a sound file for later use.
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...
static s_sample_t * sampleIndex[SAMPLE_MAX_COUNT]
void Com_StripExtension(const char *in, char *out, const size_t size)
Removes the file extension from a filename.
fireDef_t fd[MAX_WEAPONS_PER_OBJDEF][MAX_FIREDEFS_PER_WEAPON]
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
void Com_Printf(const char *const fmt,...)
const char * hitBodySound
Defines all attributes of objects used in the inventory.
void S_PrecacheSamples(void)
static s_sample_t * sampleHash[SAMPLE_HASH_SIZE]
fireDefIndex_t numFiredefs[MAX_WEAPONS_PER_OBJDEF]
s_sample_t * stdSoundPool[MAX_SOUNDIDS]
static wrapCache_t * hash[MAX_WRAP_HASH]
static Mix_Chunk * S_LoadSampleChunk(const char *sound)
static int sampleIndexLast
s_sample_t * S_GetSample(const int soundIdx)
#define SAMPLE_TYPES
Supported sound file extensions.
QGL_EXTERN GLuint GLchar GLuint * len
memPool_t * cl_soundSysPool
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
unsigned int Com_HashKey(const char *name, int hashsize)
returns hash key for a string
static s_sample_t * S_FindByName(const char *name)
Searches the hash for a given sound file.
const objDef_t * INVSH_GetItemByIDX(int index)
Returns the item that belongs to the given index or nullptr if the index is invalid.
#define Mem_PoolStrDup(in, pool, tagNum)
#define Mem_PoolAllocType(type, pool)
void FS_FreeFile(void *buffer)
struct s_sample_s * hashNext