CDAudio_Stop ();
// Try playing a fake track (sound file) first
- sfx = S_PrecacheSound (va ("cdtracks/track%02u.wav", track), false, true, false);
+ sfx = S_PrecacheSound (va ("cdtracks/track%02u.wav", track), false, false);
// FIXME: perhaps force it to be always %03u (but for compatibility?):
if (!sfx)
- sfx = S_PrecacheSound (va ("cdtracks/track%03u.wav", track), false, true, false);
+ sfx = S_PrecacheSound (va ("cdtracks/track%03u.wav", track), false, false);
if (sfx != NULL)
{
faketrack = S_StartSound (-1, 0, sfx, vec3_origin, cdvolume, 0);
CL_KeepaliveMessage();
// Don't lock the sfx here, S_ServerSounds already did that
- cl.sound_precache[i] = S_PrecacheSound(parse_sound_precache[i], true, true, false);
+ cl.sound_precache[i] = S_PrecacheSound (parse_sound_precache[i], true, false);
}
// local state
*/
void CL_InitTEnts (void)
{
- cl_sfx_wizhit = S_PrecacheSound ("wizard/hit.wav", false, true, true);
- cl_sfx_knighthit = S_PrecacheSound ("hknight/hit.wav", false, true, true);
- cl_sfx_tink1 = S_PrecacheSound ("weapons/tink1.wav", false, true, true);
- cl_sfx_ric1 = S_PrecacheSound ("weapons/ric1.wav", false, true, true);
- cl_sfx_ric2 = S_PrecacheSound ("weapons/ric2.wav", false, true, true);
- cl_sfx_ric3 = S_PrecacheSound ("weapons/ric3.wav", false, true, true);
- cl_sfx_r_exp3 = S_PrecacheSound ("weapons/r_exp3.wav", false, true, true);
+ cl_sfx_wizhit = S_PrecacheSound ("sound/wizard/hit.wav", false, true);
+ cl_sfx_knighthit = S_PrecacheSound ("sound/hknight/hit.wav", false, true);
+ cl_sfx_tink1 = S_PrecacheSound ("sound/weapons/tink1.wav", false, true);
+ cl_sfx_ric1 = S_PrecacheSound ("sound/weapons/ric1.wav", false, true);
+ cl_sfx_ric2 = S_PrecacheSound ("sound/weapons/ric2.wav", false, true);
+ cl_sfx_ric3 = S_PrecacheSound ("sound/weapons/ric3.wav", false, true);
+ cl_sfx_r_exp3 = S_PrecacheSound ("sound/weapons/r_exp3.wav", false, true);
}
void CL_ParseBeam (model_t *m, int lightning)
if (txt[0] == 1)
{
mask = 128; // go to colored text
- S_LocalSound ("misc/talk.wav", true);
+ S_LocalSound ("sound/misc/talk.wav");
// play talk wav
txt++;
}
StripExtension(filename, wavename);
strcat(wavename, ".wav");
- sfx = S_PrecacheSound (wavename, false, false, false);
+ sfx = S_PrecacheSound (wavename, false, false);
if (sfx != NULL)
s->sndchan = S_StartSound (-1, 0, sfx, vec3_origin, 1.0f, 0);
else
break;
case K_ENTER:
- S_LocalSound ("misc/menu2.wav", true);
+ S_LocalSound ("sound/misc/menu2.wav");
m_state = m_none;
key_dest = key_game;
Cbuf_AddText (va ("playdemo %s\n", NehahraDemos[demo_cursor].name));
case K_UPARROW:
case K_LEFTARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
demo_cursor--;
if (demo_cursor < 0)
demo_cursor = NumberOfNehahraDemos-1;
case K_DOWNARROW:
case K_RIGHTARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
demo_cursor++;
if (demo_cursor >= NumberOfNehahraDemos)
demo_cursor = 0;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
if (++m_main_cursor >= MAIN_ITEMS)
m_main_cursor = 0;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
if (--m_main_cursor < 0)
m_main_cursor = MAIN_ITEMS - 1;
break;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
if (++m_singleplayer_cursor >= SINGLEPLAYER_ITEMS)
m_singleplayer_cursor = 0;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
if (--m_singleplayer_cursor < 0)
m_singleplayer_cursor = SINGLEPLAYER_ITEMS - 1;
break;
break;
case K_ENTER:
- S_LocalSound ("misc/menu2.wav", true);
+ S_LocalSound ("sound/misc/menu2.wav");
if (!loadable[load_cursor])
return;
m_state = m_none;
case K_UPARROW:
case K_LEFTARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
load_cursor--;
if (load_cursor < 0)
load_cursor = MAX_SAVEGAMES-1;
case K_DOWNARROW:
case K_RIGHTARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
load_cursor++;
if (load_cursor >= MAX_SAVEGAMES)
load_cursor = 0;
case K_UPARROW:
case K_LEFTARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
load_cursor--;
if (load_cursor < 0)
load_cursor = MAX_SAVEGAMES-1;
case K_DOWNARROW:
case K_RIGHTARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
load_cursor++;
if (load_cursor >= MAX_SAVEGAMES)
load_cursor = 0;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
if (++m_multiplayer_cursor >= MULTIPLAYER_ITEMS)
m_multiplayer_cursor = 0;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
if (--m_multiplayer_cursor < 0)
m_multiplayer_cursor = MULTIPLAYER_ITEMS - 1;
break;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
setup_cursor--;
if (setup_cursor < 0)
setup_cursor = NUM_SETUP_CMDS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
setup_cursor++;
if (setup_cursor >= NUM_SETUP_CMDS)
setup_cursor = 0;
case K_LEFTARROW:
if (setup_cursor < 1)
return;
- S_LocalSound ("misc/menu3.wav", true);
+ S_LocalSound ("sound/misc/menu3.wav");
if (setup_cursor == 1)
setup_top = setup_top - 1;
if (setup_cursor == 2)
if (setup_cursor < 1)
return;
forward:
- S_LocalSound ("misc/menu3.wav", true);
+ S_LocalSound ("sound/misc/menu3.wav");
if (setup_cursor == 1)
setup_top = setup_top + 1;
if (setup_cursor == 2)
void M_Menu_Options_AdjustSliders (int dir)
{
int optnum;
- S_LocalSound ("misc/menu3.wav", true);
+ S_LocalSound ("sound/misc/menu3.wav");
optnum = 7;
if (options_cursor == optnum++)
return;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
options_cursor--;
if (options_cursor < 0)
options_cursor = OPTIONS_ITEMS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
options_cursor++;
if (options_cursor >= OPTIONS_ITEMS)
options_cursor = 0;
void M_Menu_Options_Effects_AdjustSliders (int dir)
{
int optnum;
- S_LocalSound ("misc/menu3.wav", true);
+ S_LocalSound ("sound/misc/menu3.wav");
optnum = 0;
if (options_effects_cursor == optnum++) Cvar_SetValueQuick (&r_modellights, bound(0, r_modellights.value + dir, 8));
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
options_effects_cursor--;
if (options_effects_cursor < 0)
options_effects_cursor = OPTIONS_EFFECTS_ITEMS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
options_effects_cursor++;
if (options_effects_cursor >= OPTIONS_EFFECTS_ITEMS)
options_effects_cursor = 0;
void M_Menu_Options_Graphics_AdjustSliders (int dir)
{
int optnum;
- S_LocalSound ("misc/menu3.wav", true);
+ S_LocalSound ("sound/misc/menu3.wav");
optnum = 0;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
options_graphics_cursor--;
if (options_graphics_cursor < 0)
options_graphics_cursor = OPTIONS_GRAPHICS_ITEMS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
options_graphics_cursor++;
if (options_graphics_cursor >= OPTIONS_GRAPHICS_ITEMS)
options_graphics_cursor = 0;
{
int optnum;
float f;
- S_LocalSound ("misc/menu3.wav", true);
+ S_LocalSound ("sound/misc/menu3.wav");
optnum = 1;
if (options_colorcontrol_cursor == optnum++)
return;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
options_colorcontrol_cursor--;
if (options_colorcontrol_cursor < 0)
options_colorcontrol_cursor = OPTIONS_COLORCONTROL_ITEMS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
options_colorcontrol_cursor++;
if (options_colorcontrol_cursor >= OPTIONS_COLORCONTROL_ITEMS)
options_colorcontrol_cursor = 0;
if (bind_grab)
{ // defining a key
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
if (k == K_ESCAPE)
{
bind_grab = false;
case K_LEFTARROW:
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
do
{
keys_cursor--;
case K_DOWNARROW:
case K_RIGHTARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
do
{
keys_cursor++;
case K_ENTER: // go into bind mode
M_FindKeysForCommand (bindnames[keys_cursor][0], keys);
- S_LocalSound ("misc/menu2.wav", true);
+ S_LocalSound ("sound/misc/menu2.wav");
if (keys[NUMKEYS - 1] != -1)
M_UnbindCommand (bindnames[keys_cursor][0]);
bind_grab = true;
case K_BACKSPACE: // delete bindings
case K_DEL: // delete bindings
- S_LocalSound ("misc/menu2.wav", true);
+ S_LocalSound ("sound/misc/menu2.wav");
M_UnbindCommand (bindnames[keys_cursor][0]);
break;
}
void M_Menu_Video_AdjustSliders (int dir)
{
- S_LocalSound ("misc/menu3.wav", true);
+ S_LocalSound ("sound/misc/menu3.wav");
switch (video_cursor)
{
Cvar_SetValueQuick(&vid_height, current_vid_height);
Cvar_SetValueQuick(&vid_bitsperpixel, current_vid_bitsperpixel);
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
M_Menu_Options_f ();
break;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
video_cursor--;
if (video_cursor < 0)
video_cursor = VIDEO_ITEMS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
video_cursor++;
if (video_cursor >= VIDEO_ITEMS)
video_cursor = 0;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
lanConfig_cursor--;
if (lanConfig_cursor < 0)
lanConfig_cursor = NUM_LANCONFIG_CMDS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
lanConfig_cursor++;
if (lanConfig_cursor >= NUM_LANCONFIG_CMDS)
lanConfig_cursor = 0;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
gameoptions_cursor--;
if (gameoptions_cursor < 0)
gameoptions_cursor = NUM_GAMEOPTIONS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
gameoptions_cursor++;
if (gameoptions_cursor >= NUM_GAMEOPTIONS)
gameoptions_cursor = 0;
case K_LEFTARROW:
if (gameoptions_cursor == 0)
break;
- S_LocalSound ("misc/menu3.wav", true);
+ S_LocalSound ("sound/misc/menu3.wav");
M_NetStart_Change (-1);
break;
case K_RIGHTARROW:
if (gameoptions_cursor == 0)
break;
- S_LocalSound ("misc/menu3.wav", true);
+ S_LocalSound ("sound/misc/menu3.wav");
M_NetStart_Change (1);
break;
case K_ENTER:
- S_LocalSound ("misc/menu2.wav", true);
+ S_LocalSound ("sound/misc/menu2.wav");
if (gameoptions_cursor == 0)
{
if (sv.active)
case K_UPARROW:
case K_LEFTARROW:
- S_LocalSound("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
slist_cursor--;
if (slist_cursor < 0)
slist_cursor = hostCacheCount - 1;
case K_DOWNARROW:
case K_RIGHTARROW:
- S_LocalSound("misc/menu1.wav", true);
+ S_LocalSound ("sound/misc/menu1.wav");
slist_cursor++;
if (slist_cursor >= hostCacheCount)
slist_cursor = 0;
break;
case K_ENTER:
- S_LocalSound("misc/menu2.wav", true);
+ S_LocalSound ("sound/misc/menu2.wav");
Cbuf_AddText(va("connect \"%s\"\n", hostcache[slist_cursor].cname));
break;
if (m_entersound)
{
- S_LocalSound ("misc/menu2.wav", true);
+ S_LocalSound ("sound/misc/menu2.wav");
m_entersound = false;
}
s = PRVM_G_STRING(OFS_PARM0);
- if(!S_LocalSound(s, true))
+ if(!S_LocalSound (s))
{
Con_Printf("VM_localsound: Failed to play %s for %s !\n", s, PRVM_NAME);
PRVM_G_FLOAT(OFS_RETURN) = -4;
PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
VM_CheckEmptyString (s);
- if(!S_PrecacheSound(s,true, true, true))
+ if(!S_PrecacheSound (s,true, true))
Con_Printf("VM_precache_sound: Failed to load %s for %s\n", s, PRVM_NAME);
}
==================
*/
-sfx_t *S_FindName (const char *name, qboolean stdpath)
+sfx_t *S_FindName (const char *name)
{
sfx_t *sfx;
- size_t len;
- char namebuffer [MAX_QPATH];
if (!snd_initialized.integer)
return NULL;
// Add the default sound directory to the path
- len = snprintf (namebuffer, sizeof (namebuffer), stdpath ? "sound/%s" : "%s", name);
- if (len >= sizeof (namebuffer))
+ if (strlen (name) >= sizeof (sfx->name))
Host_Error ("S_FindName: sound name too long (%s)", name);
// Look for this sound in the list of known sfx
for (sfx = known_sfx; sfx != NULL; sfx = sfx->next)
- if(!strcmp (sfx->name, namebuffer))
+ if(!strcmp (sfx->name, name))
return sfx;
// Add a sfx_t struct for this sound
sfx = Mem_Alloc (snd_mempool, sizeof (*sfx));
memset (sfx, 0, sizeof(*sfx));
- strlcpy (sfx->name, namebuffer, sizeof (sfx->name));
+ strlcpy (sfx->name, name, sizeof (sfx->name));
sfx->next = known_sfx;
known_sfx = sfx;
unsigned int i;
// Start the ambient sounds and make them loop
- channels[AMBIENT_WATER].sfx = S_PrecacheSound ("ambience/water1.wav", false, true, true);
- channels[AMBIENT_SKY].sfx = S_PrecacheSound ("ambience/wind2.wav", false, true, true);
+ channels[AMBIENT_WATER].sfx = S_PrecacheSound ("sound/ambience/water1.wav", false, true);
+ channels[AMBIENT_SKY].sfx = S_PrecacheSound ("sound/ambience/wind2.wav", false, true);
for (i = 0; i < NUM_AMBIENTS; i++)
channels[i].flags |= CHANNELFLAG_FORCELOOP;
// Add 1 lock and the SFXFLAG_SERVERSOUND flag to each sfx in "serversound"
for (i = 1; i < numsounds; i++)
{
- sfx = S_FindName (serversound[i], true);
+ sfx = S_FindName (serversound[i]);
if (sfx != NULL)
{
sfx->locks++;
==================
*/
-sfx_t *S_PrecacheSound (const char *name, qboolean complain, qboolean stdpath, qboolean lock)
+sfx_t *S_PrecacheSound (const char *name, qboolean complain, qboolean lock)
{
sfx_t *sfx;
if (!snd_initialized.integer)
return NULL;
- sfx = S_FindName (name, stdpath);
+ sfx = S_FindName (name);
if (sfx == NULL)
return NULL;
snprintf(name, sizeof(name), "%s.wav", Cmd_Argv(i));
else
strlcpy(name, Cmd_Argv(i), sizeof(name));
- sfx = S_PrecacheSound(name, true, true, false);
+ sfx = S_PrecacheSound (name, true, false);
// If we need to get the volume from the command line
if (fvol == -1.0f)
}
-qboolean S_LocalSound (const char *sound, qboolean stdpath)
+qboolean S_LocalSound (const char *sound)
{
sfx_t *sfx;
int ch_ind;
if (!snd_initialized.integer || nosound.integer)
return true;
- sfx = S_PrecacheSound (sound, true, stdpath, false);
+ sfx = S_PrecacheSound (sound, true, false);
if (!sfx)
{
Con_Printf("S_LocalSound: can't precache %s\n", sound);
*/
qboolean S_LoadSound (sfx_t *s, qboolean complain)
{
- char namebuffer[MAX_QPATH];
+ char namebuffer[MAX_QPATH + 16];
size_t len;
- qboolean modified_name = false;
if (!shm || !shm->format.speed)
return false;
return true;
}
- len = strlcpy (namebuffer, s->name, sizeof (namebuffer));
+ // LordHavoc: if the sound filename does not begin with sound/, try adding it
+ if (strncasecmp(s->name, "sound/", 6))
+ {
+ len = snprintf (namebuffer, sizeof(namebuffer), "sound/%s", s->name);
+ if (len >= sizeof (namebuffer))
+ {
+ // name too long
+ Con_DPrintf("S_LoadSound: name \"%s\" is too long\n", s->name);
+ return false;
+ }
+ if (S_LoadWavFile (namebuffer, s))
+ return true;
+ if (len >= 4 && !strcasecmp (namebuffer + len - 4, ".wav"))
+ strcpy (namebuffer + len - 3, "ogg");
+ if (OGG_LoadVorbisFile (namebuffer, s))
+ return true;
+ }
+
+ // LordHavoc: then try without the added sound/ as wav and ogg
+ len = snprintf (namebuffer, sizeof(namebuffer), "%s", s->name);
if (len >= sizeof (namebuffer))
+ {
+ // name too long
+ Con_DPrintf("S_LoadSound: name \"%s\" is too long\n", s->name);
return false;
-
- // Try to load it as a WAV file
+ }
if (S_LoadWavFile (namebuffer, s))
return true;
-
- // Else, try to load it as an Ogg Vorbis file
- if (!strcasecmp (namebuffer + len - 4, ".wav"))
- {
+ if (len >= 4 && !strcasecmp (namebuffer + len - 4, ".wav"))
strcpy (namebuffer + len - 3, "ogg");
- modified_name = true;
- }
if (OGG_LoadVorbisFile (namebuffer, s))
return true;
// Can't load the sound!
s->flags |= SFXFLAG_FILEMISSING;
if (complain)
- {
- if (modified_name)
- strcpy (namebuffer + len - 3, "wav");
- Con_Printf("Couldn't load %s\n", namebuffer);
- }
+ Con_Printf("S_LoadSound: Couldn't load \"%s\"\n", s->name);
return false;
}
{
}
-sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean stdpath, qboolean lock)
+sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean lock)
{
return NULL;
}
{
}
-qboolean S_LocalSound (const char *s, qboolean stdpath)
+qboolean S_LocalSound (const char *s)
{
return false;
}
void S_Update(const matrix4x4_t *listenermatrix);
void S_ExtraUpdate (void);
-sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean stdpath, qboolean lock);
+sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean lock);
void S_ServerSounds (char serversound [][MAX_QPATH], unsigned int numsounds);
void S_UnlockSfx (sfx_t *sfx);
// S_StartSound returns the channel index, or -1 if an error occurred
int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
-qboolean S_LocalSound (const char *s, qboolean stdpath);
+qboolean S_LocalSound (const char *s);
void S_StaticSound (sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void S_StopSound (int entnum, int entchannel);