CDAudio_Stop ();
// Try playing a fake track (sound file) first
- sfx = S_PrecacheSound (va ("cdtracks/track%02u.wav", track), false);
+ sfx = S_PrecacheSound (va ("cdtracks/track%02u.wav", track), false, true);
if (sfx != NULL)
{
faketrack = S_StartSound (-1, 0, sfx, vec3_origin, cdvolume, 0);
if (faketrack != -1)
{
if (looping)
- S_LoopChannel (faketrack, true);
+ S_LoopChannel (faketrack, true);
Con_DPrintf ("Fake CD track %u playing...\n", track);
}
}
for (i = 1;i < numsounds;i++)
{
CL_KeepaliveMessage();
- S_TouchSound(parse_sound_precache[i]);
+ S_TouchSound(parse_sound_precache[i], true);
}
S_PurgeUnused();
for (i=1 ; i<numsounds ; i++)
{
CL_KeepaliveMessage();
- cl.sound_precache[i] = S_PrecacheSound(parse_sound_precache[i], true);
+ cl.sound_precache[i] = S_PrecacheSound(parse_sound_precache[i], true, true);
}
// local state
*/
void CL_InitTEnts (void)
{
- cl_sfx_wizhit = S_PrecacheSound ("wizard/hit.wav", false);
- cl_sfx_knighthit = S_PrecacheSound ("hknight/hit.wav", false);
- cl_sfx_tink1 = S_PrecacheSound ("weapons/tink1.wav", false);
- cl_sfx_ric1 = S_PrecacheSound ("weapons/ric1.wav", false);
- cl_sfx_ric2 = S_PrecacheSound ("weapons/ric2.wav", false);
- cl_sfx_ric3 = S_PrecacheSound ("weapons/ric3.wav", false);
- cl_sfx_r_exp3 = S_PrecacheSound ("weapons/r_exp3.wav", false);
+ cl_sfx_wizhit = S_PrecacheSound ("wizard/hit.wav", false, true);
+ cl_sfx_knighthit = S_PrecacheSound ("hknight/hit.wav", false, true);
+ cl_sfx_tink1 = S_PrecacheSound ("weapons/tink1.wav", false, true);
+ cl_sfx_ric1 = S_PrecacheSound ("weapons/ric1.wav", false, true);
+ cl_sfx_ric2 = S_PrecacheSound ("weapons/ric2.wav", false, true);
+ cl_sfx_ric3 = S_PrecacheSound ("weapons/ric3.wav", false, true);
+ cl_sfx_r_exp3 = S_PrecacheSound ("weapons/r_exp3.wav", false, true);
}
void CL_ParseBeam (model_t *m, int lightning)
int cl_videoimagedata_bytesperpixel;
void *cl_videoimagedata;
-int cl_videosoundrate;
-int cl_videosoundlength;
-short *cl_videosounddata;
-int cl_videosoundresamplelength;
-short *cl_videosoundresampledata;
-
rtexture_t *cl_videotexture;
rtexturepool_t *cl_videotexturepool;
void CL_VideoFrame(void)
{
- int frames, framenum, samples, s;
+ int frames, framenum;
if (!cl_videoplaying)
return;
framenum = (realtime - cl_videostarttime) * cl_videoframerate;
R_UpdateTexture(cl_videotexture, cl_videoimagedata);
//Draw_NewPic("engine_videoframe", cl_videoimagewidth, cl_videoimageheight, false, cl_videoimagedata);
}
- if (cl_videosoundrate && (samples = S_RawSamples_QueueWantsMore()))
- {
- Con_DPrintf("%i = S_RawSamples_QueueWantsMore()\n", samples);
-
- // calculate how much source data we need to fill the output...
- s = samples * cl_videosoundrate / S_RawSamples_SampleRate();
-
- // reallocate processing buffer if needed
- if (cl_videosoundresamplelength < samples)
- {
- cl_videosoundresamplelength = samples + 100;
- if (cl_videosoundresampledata)
- Mem_Free(cl_videosoundresampledata);
- cl_videosoundresampledata = Mem_Alloc(clvideomempool, cl_videosoundresamplelength * sizeof(short[2]));
- }
-
- // reallocate loading buffer if needed
- if (cl_videosoundlength < s)
- {
- cl_videosoundlength = s + 100;
- if (cl_videosounddata)
- Mem_Free(cl_videosounddata);
- cl_videosounddata = Mem_Alloc(clvideomempool, cl_videosoundlength * sizeof(short[2]));
- }
-
- dpvsimpledecode_audio(cl_videostream, cl_videosounddata, s);
- S_ResampleBuffer16Stereo(cl_videosounddata, s, cl_videosoundresampledata, samples);
- S_RawSamples_Enqueue(cl_videosoundresampledata, samples);
- }
}
void CL_DrawVideo(void)
cl_videoimagedata = Mem_Alloc(clvideomempool, cl_videoimagewidth * cl_videoimageheight * cl_videoimagedata_bytesperpixel);
//memset(cl_videoimagedata, 97, cl_videoimagewidth * cl_videoimageheight * cl_videoimagedata_bytesperpixel);
- cl_videosoundrate = dpvsimpledecode_getsoundrate(cl_videostream);
- cl_videosoundlength = 0;
- cl_videosounddata = NULL;
- cl_videosoundresamplelength = 0;
- cl_videosoundresampledata = NULL;
-
cl_videotexturepool = R_AllocTexturePool();
cl_videotexture = R_LoadTexture2D(cl_videotexturepool, "videotexture", cl_videoimagewidth, cl_videoimageheight, NULL, TEXTYPE_RGBA, TEXF_FRAGMENT, NULL);
}
Mem_Free(cl_videoimagedata);
cl_videoimagedata = NULL;
- if (cl_videosounddata)
- Mem_Free(cl_videosounddata);
- cl_videosounddata = NULL;
-
- if (cl_videosoundresampledata)
- Mem_Free(cl_videosoundresampledata);
- cl_videosoundresampledata = NULL;
-
cl_videotexture = NULL;
R_FreeTexturePool(&cl_videotexturepool);
// Build the time stamp (ex: "Wed Jun 30 21:49:08 1993");
time (&crt_time);
crt_tm = localtime (&crt_time);
- strftime (timestring, sizeof (timestring), "%a %b %d %T %Y", crt_tm);
+ strftime (timestring, sizeof (timestring), "%a %b %d %H:%M:%S %Y", crt_tm);
if (desc != NULL)
snprintf (timestamp, sizeof (timestamp), "====== %s (%s) ======\n", desc, timestring);
if (txt[0] == 1)
{
mask = 128; // go to colored text
- S_LocalSound ("misc/talk.wav");
+ S_LocalSound ("misc/talk.wav", true);
// play talk wav
txt++;
}
[Project]
-FileName=darkplaces.dev
+FileName=DARKPL~1.DEV
Name=DarkPlaces
-UnitCount=160
+UnitCount=158
Type=0
Ver=1
ObjFiles=
BuildCmd=
[Unit71]
-FileName=wavefile.h
+FileName=winding.h
CompileCpp=0
Folder=Header Files
Compile=1
BuildCmd=
[Unit72]
-FileName=winding.h
+FileName=world.h
CompileCpp=0
Folder=Header Files
Compile=1
BuildCmd=
[Unit73]
-FileName=world.h
+FileName=zone.h
CompileCpp=0
Folder=Header Files
Compile=1
BuildCmd=
[Unit74]
-FileName=zone.h
+FileName=zone.c
CompileCpp=0
-Folder=Header Files
+Folder=Source Files
Compile=1
Link=1
Priority=1000
BuildCmd=
[Unit75]
-FileName=zone.c
+FileName=cd_shared.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit76]
-FileName=cd_shared.c
+FileName=cd_win.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit77]
-FileName=cd_win.c
+FileName=cgame.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit78]
-FileName=cgame.c
+FileName=cgamevm.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit79]
-FileName=cgamevm.c
+FileName=cl_collision.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit80]
-FileName=cl_collision.c
+FileName=cl_demo.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit81]
-FileName=cl_demo.c
+FileName=cl_input.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit82]
-FileName=cl_input.c
+FileName=cl_main.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit83]
-FileName=cl_main.c
+FileName=cl_parse.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit84]
-FileName=cl_parse.c
+FileName=cl_particles.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit85]
-FileName=cl_particles.c
+FileName=cl_screen.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit86]
-FileName=cl_screen.c
+FileName=cl_video.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit87]
-FileName=cl_video.c
+FileName=cmd.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit88]
-FileName=cmd.c
+FileName=collision.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit89]
-FileName=collision.c
+FileName=common.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit90]
-FileName=common.c
+FileName=conproc.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit91]
-FileName=conproc.c
+FileName=console.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit92]
-FileName=console.c
+FileName=crc.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit93]
-FileName=crc.c
+FileName=curves.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit94]
-FileName=curves.c
+FileName=cvar.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit95]
-FileName=cvar.c
+FileName=dpvsimpledecode.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit96]
-FileName=dpvsimpledecode.c
+FileName=filematch.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit97]
-FileName=filematch.c
+FileName=fractalnoise.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit98]
-FileName=fractalnoise.c
+FileName=fs.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit99]
-FileName=fs.c
+FileName=gl_backend.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit100]
-FileName=gl_backend.c
+FileName=gl_draw.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit101]
-FileName=gl_draw.c
+FileName=gl_models.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit102]
-FileName=gl_models.c
+FileName=gl_rmain.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit103]
-FileName=gl_rmain.c
+FileName=gl_rsurf.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit104]
-FileName=gl_rsurf.c
+FileName=gl_textures.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit105]
-FileName=gl_textures.c
+FileName=host.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit106]
-FileName=host.c
+FileName=host_cmd.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit107]
-FileName=host_cmd.c
+FileName=image.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit108]
-FileName=image.c
+FileName=jpeg.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit109]
-FileName=jpeg.c
+FileName=keys.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit110]
-FileName=keys.c
+FileName=lhnet.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit111]
-FileName=lhnet.c
+FileName=mathlib.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit112]
-FileName=mathlib.c
+FileName=matrixlib.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit113]
-FileName=matrixlib.c
+FileName=menu.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit114]
-FileName=menu.c
+FileName=meshqueue.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit115]
-FileName=meshqueue.c
+FileName=model_alias.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit116]
-FileName=model_alias.c
+FileName=model_brush.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit117]
-FileName=model_brush.c
+FileName=model_shared.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit118]
-FileName=model_shared.c
+FileName=model_sprite.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit119]
-FileName=model_sprite.c
+FileName=netconn.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit120]
-FileName=netconn.c
+FileName=palette.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit121]
-FileName=palette.c
+FileName=portals.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit122]
-FileName=portals.c
+FileName=pr_cmds.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit123]
-FileName=pr_cmds.c
+FileName=pr_edict.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit124]
-FileName=pr_edict.c
+FileName=pr_exec.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit125]
-FileName=pr_exec.c
+FileName=protocol.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit126]
-FileName=protocol.c
+FileName=prvm_cmds.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit127]
-FileName=prvm_cmds.c
+FileName=prvm_edict.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit128]
-FileName=prvm_edict.c
+FileName=prvm_exec.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit129]
-FileName=prvm_exec.c
+FileName=r_crosshairs.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit130]
-FileName=r_crosshairs.c
+FileName=r_explosion.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit131]
-FileName=r_explosion.c
+FileName=r_lerpanim.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit132]
-FileName=r_lerpanim.c
+FileName=r_light.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit133]
-FileName=r_light.c
+FileName=r_lightning.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit134]
-FileName=r_lightning.c
+FileName=r_modules.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit135]
-FileName=r_modules.c
+FileName=r_shadow.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit136]
-FileName=r_shadow.c
+FileName=r_sky.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit137]
-FileName=r_sky.c
+FileName=r_sprites.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit138]
-FileName=r_sprites.c
+FileName=sbar.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit139]
-FileName=sbar.c
+FileName=snd_dma.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit140]
-FileName=snd_dma.c
+FileName=snd_mem.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit141]
-FileName=snd_mem.c
+FileName=snd_mix.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit142]
-FileName=snd_mix.c
+FileName=snd_ogg.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit143]
-FileName=snd_ogg.c
+FileName=snd_wav.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit144]
-FileName=snd_wav.c
+FileName=snd_win.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit145]
-FileName=snd_win.c
+FileName=sv_main.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit146]
-FileName=sv_main.c
+FileName=sv_move.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit147]
-FileName=sv_move.c
+FileName=sv_phys.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit148]
-FileName=sv_phys.c
+FileName=sv_user.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit149]
-FileName=sv_user.c
+FileName=sys_shared.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit150]
-FileName=sys_shared.c
+FileName=sys_win.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit151]
-FileName=sys_win.c
+FileName=ui.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit152]
-FileName=ui.c
+FileName=vid_shared.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit153]
-FileName=vid_shared.c
+FileName=vid_wgl.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit154]
-FileName=vid_wgl.c
+FileName=view.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit155]
-FileName=view.c
+FileName=wad.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit156]
-FileName=wad.c
+FileName=winding.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit157]
-FileName=wavefile.c
+FileName=world.c
CompileCpp=0
Folder=Source Files
Compile=1
BuildCmd=
[Unit158]
-FileName=winding.c
+FileName=builddate.c
CompileCpp=0
Folder=Source Files
Compile=1
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\wavefile.c\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\winding.c\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
-SOURCE=.\wavefile.h\r
-# End Source File\r
-# Begin Source File\r
-\r
SOURCE=.\winding.h\r
# End Source File\r
# Begin Source File\r
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
+#include "quakedef.h"
#include "dpvsimpledecode.h"
-#include "wavefile.h"
-#define EMBEDDEDHZREAD 1
-
-#ifndef EMBEDDEDHZREAD
-#include "hz_read.h"
-#include "hz_read.c"
-#else
#define HZREADERROR_OK 0
#define HZREADERROR_EOF 1
#define HZREADERROR_MALLOCFAILED 2
while (size--)
*out++ = hz_bitstream_read_byte(blocks);
}
-#endif
#define BLOCKSIZE 8
// current video frame data (needed because of delta compression)
unsigned int *videopixels;
- // wav file the sound is being read from
- wavefile_t *wavefile;
+ // channel the sound file is being played on
+ int sndchan;
}
dpvsimpledecodestream_t;
wavename = malloc(strlen(filename) + 10);
if (wavename)
{
+ sfx_t* sfx;
+
StripExtension(filename, wavename);
strcat(wavename, ".wav");
- s->wavefile = waveopen(wavename, NULL);
+ sfx = S_PrecacheSound (wavename, false, false);
+ if (sfx != NULL)
+ s->sndchan = S_StartSound (-1, 0, sfx, vec3_origin, 1.0f, 0);
+ else
+ s->sndchan = -1;
free(wavename);
}
// all is well...
return;
if (s->videopixels)
free(s->videopixels);
- if (s->wavefile)
- waveclose(s->wavefile);
+ if (s->sndchan != -1)
+ S_StopChannel (s->sndchan);
if (s->framedatablocks)
hz_bitstream_read_blocks_free(s->framedatablocks);
if (s->bitstream)
return s->info_imageheight;
}
-// returns the sound sample rate of the stream
-unsigned int dpvsimpledecode_getsoundrate(void *stream)
-{
- dpvsimpledecodestream_t *s = stream;
- if (s->wavefile)
- return s->wavefile->info_rate;
- else
- return 0;
-}
-
// returns the framerate of the stream
double dpvsimpledecode_getframerate(void *stream)
{
dpvsimpledecode_convertpixels(s, imagedata, imagebytesperrow);
return s->error;
}
-
-// (note: sound is 16bit stereo native-endian, left channel first)
-int dpvsimpledecode_audio(void *stream, short *soundbuffer, int requestedlength)
-{
- int samples;
- dpvsimpledecodestream_t *s = stream;
- s->error = DPVSIMPLEDECODEERROR_NONE;
- if (requestedlength)
- {
- samples = 0;
- if (s->wavefile && requestedlength)
- samples = waveread16stereo(s->wavefile, soundbuffer, requestedlength);
- if (samples < requestedlength)
- memset(soundbuffer + samples * 2, 0, (requestedlength - samples) * sizeof(short[2]));
- }
- return s->error;
-}
// returns the height of the image data
unsigned int dpvsimpledecode_getheight(void *stream);
-// returns the sound sample rate of the stream
-unsigned int dpvsimpledecode_getsoundrate(void *stream);
-
// returns the framerate of the stream
double dpvsimpledecode_getframerate(void *stream);
// decodes a video frame to the supplied output pixels
int dpvsimpledecode_video(void *stream, void *imagedata, unsigned int Rmask, unsigned int Gmask, unsigned int Bmask, unsigned int bytesperpixel, int imagebytesperrow);
-// reads some sound
-// (note: sound is 16bit stereo native-endian, left channel first)
-int dpvsimpledecode_audio(void *stream, short *soundbuffer, int requestedlength);
#endif
#include "quakedef.h"
-#include <stdlib.h>
-#include <string.h>
#include <limits.h>
#include <fcntl.h>
vid_shared.o \
view.o \
wad.o \
- wavefile.o \
winding.o \
world.o \
zone.o
break;
case K_ENTER:
- S_LocalSound ("misc/menu2.wav");
+ S_LocalSound ("misc/menu2.wav", true);
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");
+ S_LocalSound ("misc/menu1.wav", true);
demo_cursor--;
if (demo_cursor < 0)
demo_cursor = NumberOfNehahraDemos-1;
case K_DOWNARROW:
case K_RIGHTARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
demo_cursor++;
if (demo_cursor >= NumberOfNehahraDemos)
demo_cursor = 0;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
if (++m_main_cursor >= MAIN_ITEMS)
m_main_cursor = 0;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
if (--m_main_cursor < 0)
m_main_cursor = MAIN_ITEMS - 1;
break;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
if (++m_singleplayer_cursor >= SINGLEPLAYER_ITEMS)
m_singleplayer_cursor = 0;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
if (--m_singleplayer_cursor < 0)
m_singleplayer_cursor = SINGLEPLAYER_ITEMS - 1;
break;
break;
case K_ENTER:
- S_LocalSound ("misc/menu2.wav");
+ S_LocalSound ("misc/menu2.wav", true);
if (!loadable[load_cursor])
return;
m_state = m_none;
case K_UPARROW:
case K_LEFTARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
load_cursor--;
if (load_cursor < 0)
load_cursor = MAX_SAVEGAMES-1;
case K_DOWNARROW:
case K_RIGHTARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
load_cursor++;
if (load_cursor >= MAX_SAVEGAMES)
load_cursor = 0;
case K_UPARROW:
case K_LEFTARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
load_cursor--;
if (load_cursor < 0)
load_cursor = MAX_SAVEGAMES-1;
case K_DOWNARROW:
case K_RIGHTARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
load_cursor++;
if (load_cursor >= MAX_SAVEGAMES)
load_cursor = 0;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
if (++m_multiplayer_cursor >= MULTIPLAYER_ITEMS)
m_multiplayer_cursor = 0;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
if (--m_multiplayer_cursor < 0)
m_multiplayer_cursor = MULTIPLAYER_ITEMS - 1;
break;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
setup_cursor--;
if (setup_cursor < 0)
setup_cursor = NUM_SETUP_CMDS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
setup_cursor++;
if (setup_cursor >= NUM_SETUP_CMDS)
setup_cursor = 0;
case K_LEFTARROW:
if (setup_cursor < 1)
return;
- S_LocalSound ("misc/menu3.wav");
+ S_LocalSound ("misc/menu3.wav", true);
if (setup_cursor == 1)
setup_top = setup_top - 1;
if (setup_cursor == 2)
if (setup_cursor < 1)
return;
forward:
- S_LocalSound ("misc/menu3.wav");
+ S_LocalSound ("misc/menu3.wav", true);
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");
+ S_LocalSound ("misc/menu3.wav", true);
optnum = 6;
if (options_cursor == optnum++)
return;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
options_cursor--;
if (options_cursor < 0)
options_cursor = OPTIONS_ITEMS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
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");
+ S_LocalSound ("misc/menu3.wav", true);
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");
+ S_LocalSound ("misc/menu1.wav", true);
options_effects_cursor--;
if (options_effects_cursor < 0)
options_effects_cursor = OPTIONS_EFFECTS_ITEMS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
options_effects_cursor++;
if (options_effects_cursor >= OPTIONS_EFFECTS_ITEMS)
options_effects_cursor = 0;
{
int optnum;
float f;
- S_LocalSound ("misc/menu3.wav");
+ S_LocalSound ("misc/menu3.wav", true);
optnum = 1;
if (options_colorcontrol_cursor == optnum++)
return;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
options_colorcontrol_cursor--;
if (options_colorcontrol_cursor < 0)
options_colorcontrol_cursor = OPTIONS_COLORCONTROL_ITEMS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
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");
+ S_LocalSound ("misc/menu1.wav", true);
if (k == K_ESCAPE)
{
bind_grab = false;
case K_LEFTARROW:
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
do
{
keys_cursor--;
case K_DOWNARROW:
case K_RIGHTARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
do
{
keys_cursor++;
case K_ENTER: // go into bind mode
M_FindKeysForCommand (bindnames[keys_cursor][0], keys);
- S_LocalSound ("misc/menu2.wav");
+ S_LocalSound ("misc/menu2.wav", true);
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");
+ S_LocalSound ("misc/menu2.wav", true);
M_UnbindCommand (bindnames[keys_cursor][0]);
break;
}
void M_Menu_Video_AdjustSliders (int dir)
{
- S_LocalSound ("misc/menu3.wav");
+ S_LocalSound ("misc/menu3.wav", true);
switch (video_cursor)
{
Cvar_SetValueQuick(&vid_height, current_vid_height);
Cvar_SetValueQuick(&vid_bitsperpixel, current_vid_bitsperpixel);
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
M_Menu_Options_f ();
break;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
video_cursor--;
if (video_cursor < 0)
video_cursor = VIDEO_ITEMS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
video_cursor++;
if (video_cursor >= VIDEO_ITEMS)
video_cursor = 0;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
lanConfig_cursor--;
if (lanConfig_cursor < 0)
lanConfig_cursor = NUM_LANCONFIG_CMDS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
lanConfig_cursor++;
if (lanConfig_cursor >= NUM_LANCONFIG_CMDS)
lanConfig_cursor = 0;
break;
case K_UPARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
gameoptions_cursor--;
if (gameoptions_cursor < 0)
gameoptions_cursor = NUM_GAMEOPTIONS-1;
break;
case K_DOWNARROW:
- S_LocalSound ("misc/menu1.wav");
+ S_LocalSound ("misc/menu1.wav", true);
gameoptions_cursor++;
if (gameoptions_cursor >= NUM_GAMEOPTIONS)
gameoptions_cursor = 0;
case K_LEFTARROW:
if (gameoptions_cursor == 0)
break;
- S_LocalSound ("misc/menu3.wav");
+ S_LocalSound ("misc/menu3.wav", true);
M_NetStart_Change (-1);
break;
case K_RIGHTARROW:
if (gameoptions_cursor == 0)
break;
- S_LocalSound ("misc/menu3.wav");
+ S_LocalSound ("misc/menu3.wav", true);
M_NetStart_Change (1);
break;
case K_ENTER:
- S_LocalSound ("misc/menu2.wav");
+ S_LocalSound ("misc/menu2.wav", true);
if (gameoptions_cursor == 0)
{
if (sv.active)
case K_UPARROW:
case K_LEFTARROW:
- S_LocalSound("misc/menu1.wav");
+ S_LocalSound("misc/menu1.wav", true);
slist_cursor--;
if (slist_cursor < 0)
slist_cursor = hostCacheCount - 1;
case K_DOWNARROW:
case K_RIGHTARROW:
- S_LocalSound("misc/menu1.wav");
+ S_LocalSound("misc/menu1.wav", true);
slist_cursor++;
if (slist_cursor >= hostCacheCount)
slist_cursor = 0;
break;
case K_ENTER:
- S_LocalSound("misc/menu2.wav");
+ S_LocalSound("misc/menu2.wav", true);
Cbuf_AddText(va("connect \"%s\"\n", hostcache[slist_cursor].cname));
break;
if (m_entersound)
{
- S_LocalSound ("misc/menu2.wav");
+ S_LocalSound ("misc/menu2.wav", true);
m_entersound = false;
}
s = PRVM_G_STRING(OFS_PARM0);
- if(!S_GetCached(s))
+ if(!S_GetCached(s, true))
{
Con_Printf("VM_localsound: %s : %s not cached !\n", PRVM_NAME, s);
PRVM_G_FLOAT(OFS_RETURN) = -4;
return;
}
- S_LocalSound(s);
+ S_LocalSound(s, true);
PRVM_G_FLOAT(OFS_RETURN) = 1;
}
PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
VM_CheckEmptyString (s);
- if(S_GetCached(s))
+ if(S_GetCached(s, true))
{
Con_Printf("VM_precache_sound: %s already cached (%s)\n", s, PRVM_NAME);
return;
}
- if(!S_PrecacheSound(s,true))
+ if(!S_PrecacheSound(s,true, true))
Con_Printf("VM_prache_sound: Failed to load %s for %s\n", s, PRVM_NAME);
}
SND_InitScaletable ();
- ambient_sfx[AMBIENT_WATER] = S_PrecacheSound ("ambience/water1.wav", false);
- ambient_sfx[AMBIENT_SKY] = S_PrecacheSound ("ambience/wind2.wav", false);
+ ambient_sfx[AMBIENT_WATER] = S_PrecacheSound ("ambience/water1.wav", false, true);
+ ambient_sfx[AMBIENT_SKY] = S_PrecacheSound ("ambience/wind2.wav", false, true);
total_channels = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS; // no statics
memset(channels, 0, MAX_CHANNELS * sizeof(channel_t));
=========
*/
-sfx_t *S_GetCached (const char *name)
+sfx_t *S_GetCached (const char *name, qboolean stdpath)
{
+ char namebuffer [MAX_QPATH];
+ size_t len;
int i;
if (!snd_initialized.integer)
return NULL;
if (!name)
- Host_Error("S_IsCached: NULL\n");
+ Host_Error("S_GetCached: NULL");
- if (strlen(name) >= MAX_QPATH)
- Host_Error("Sound name too long: %s", name);
+ // Add the default sound directory to the path
+ len = snprintf (namebuffer, sizeof (namebuffer), stdpath ? "sound/%s" : "%s", name);
+ if (len >= sizeof (namebuffer))
+ Host_Error ("S_GetCached: sound name too long (%s)", name);
for(i = 0;i < num_sfx;i++)
- if(!strcmp(known_sfx[i].name, name))
+ if(!strcmp(known_sfx[i].name, namebuffer))
return &known_sfx[i];
return NULL;
==================
*/
-sfx_t *S_FindName (char *name)
+sfx_t *S_FindName (const char *name, qboolean stdpath)
{
- int i;
sfx_t *sfx;
- if (!snd_initialized.integer)
- return NULL;
-
- if (!name)
- Host_Error("S_FindName: NULL\n");
-
- if (strlen(name) >= MAX_QPATH)
- Host_Error("Sound name too long: %s", name);
+ sfx = S_GetCached (name, stdpath);
-// see if already loaded
- for (i = 0;i < num_sfx;i++)
- if (!strcmp(known_sfx[i].name, name))
- return &known_sfx[i];
-
- if (num_sfx == MAX_SFX)
- Sys_Error("S_FindName: out of sfx_t");
+ // If we haven't allocated a sfx_t struct for it yet
+ if (sfx == NULL)
+ {
+ if (num_sfx == MAX_SFX)
+ Sys_Error ("S_FindName: out of sfx_t");
- sfx = &known_sfx[num_sfx++];
- memset(sfx, 0, sizeof(*sfx));
- strlcpy (sfx->name, name, sizeof (sfx->name));
+ sfx = &known_sfx[num_sfx++];
+ memset (sfx, 0, sizeof(*sfx));
+ snprintf (sfx->name, sizeof (sfx->name), stdpath ? "sound/%s" : "%s", name);
+ }
return sfx;
}
==================
*/
-void S_TouchSound (char *name)
+void S_TouchSound (const char *name, qboolean stdpath)
{
sfx_t *sfx;
- sfx = S_FindName (name);
+ sfx = S_FindName (name, stdpath);
// Set the "used" flag for this sound
if (sfx != NULL)
==================
*/
-sfx_t *S_PrecacheSound (char *name, int complain)
+sfx_t *S_PrecacheSound (const char *name, qboolean complain, qboolean stdpath)
{
sfx_t *sfx;
if (!snd_initialized.integer)
return NULL;
- sfx = S_FindName(name);
+ sfx = S_FindName (name, stdpath);
if (!nosound.integer && snd_precache.integer)
S_LoadSound(sfx, complain);
snprintf(name, sizeof(name), "%s.wav", Cmd_Argv(i));
else
strlcpy(name, Cmd_Argv(i), sizeof(name));
- sfx = S_PrecacheSound(name, true);
+ sfx = S_PrecacheSound(name, true, true);
// If we need to get the volume from the command line
if (fvol == -1.0f)
}
-void S_LocalSound (char *sound)
+void S_LocalSound (const char *sound, qboolean stdpath)
{
sfx_t *sfx;
int ch_ind;
if (!snd_initialized.integer || nosound.integer)
return;
- sfx = S_PrecacheSound (sound, true);
+ sfx = S_PrecacheSound (sound, true, stdpath);
if (!sfx)
{
Con_Printf("S_LocalSound: can't precache %s\n", sound);
S_LoadSound
==============
*/
-qboolean S_LoadSound (sfx_t *s, int complain)
+qboolean S_LoadSound (sfx_t *s, qboolean complain)
{
char namebuffer[MAX_QPATH];
size_t len;
return true;
}
- len = snprintf (namebuffer, sizeof (namebuffer), "sound/%s", s->name);
+ len = strlcpy (namebuffer, s->name, sizeof (namebuffer));
if (len >= sizeof (namebuffer))
return false;
{
}
-void S_TouchSound (char *sample)
+void S_TouchSound (const char *sample, qboolean stdpath)
{
}
{
}
-sfx_t *S_GetCached(const char *name)
+sfx_t *S_GetCached(const char *name, qboolean stdpath)
{
return NULL;
}
-sfx_t *S_PrecacheSound (char *sample, int complain)
+sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean stdpath)
{
return NULL;
}
{
}
-void S_LocalSound (char *s)
+void S_LocalSound (const char *s, qboolean stdpath)
{
}
void S_Update(vec3_t origin, vec3_t forward, vec3_t left, vec3_t up);
void S_ExtraUpdate (void);
-sfx_t *S_GetCached(const char *name);
-sfx_t *S_PrecacheSound (char *sample, int complain);
-void S_TouchSound (char *sample);
+sfx_t *S_GetCached(const char *name, qboolean stdpath);
+sfx_t *S_PrecacheSound (const char *sample, qboolean complain, qboolean stdpath);
+void S_TouchSound (const char *sample, qboolean stdpath);
void S_ClearUsed (void);
void S_PurgeUnused (void);
void S_PaintChannels(int endtime);
extern int snd_blocked;
-void S_LocalSound (char *s);
-qboolean S_LoadSound (sfx_t *s, int complain);
+void S_LocalSound (const char *s, qboolean stdpath);
+qboolean S_LoadSound (sfx_t *s, qboolean complain);
void S_UnloadSound(sfx_t *s);
void SND_InitScaletable (void);