summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2006-06-17 23:13:57 +0000
committerTim Angus <tim@ngus.net>2006-06-17 23:13:57 +0000
commit579672760092292b7a9752899010ffa4ac6faf6f (patch)
treea59ed488de023b76032ad8f0bdad5dc40cf51bc4 /src/client
parentda11bfa115f0670861cb18e05ec45ba515b7c3b7 (diff)
* Merged ioq3-r810
Diffstat (limited to 'src/client')
-rw-r--r--src/client/cl_main.c2
-rw-r--r--src/client/cl_parse.c28
-rw-r--r--src/client/snd_codec.c15
-rw-r--r--src/client/snd_codec_ogg.c9
-rw-r--r--src/client/snd_openal.c1
5 files changed, 40 insertions, 15 deletions
diff --git a/src/client/cl_main.c b/src/client/cl_main.c
index 6e0cdaff..3390ead5 100644
--- a/src/client/cl_main.c
+++ b/src/client/cl_main.c
@@ -1403,7 +1403,7 @@ void CL_NextDownload(void) {
*s++ = 0;
else
s = localName + strlen(localName); // point at the nul byte
-
+
CL_BeginDownload( localName, remoteName );
clc.downloadRestart = qtrue;
diff --git a/src/client/cl_parse.c b/src/client/cl_parse.c
index 7f219b32..dc14cd66 100644
--- a/src/client/cl_parse.c
+++ b/src/client/cl_parse.c
@@ -256,6 +256,13 @@ void CL_ParseSnapshot( msg_t *msg ) {
// read areamask
len = MSG_ReadByte( msg );
+
+ if(len > sizeof(newSnap.areamask))
+ {
+ Com_Error (ERR_DROP,"CL_ParseSnapshot: Invalid size %d for areamask.", len);
+ return;
+ }
+
MSG_ReadData( msg, &newSnap.areamask, len);
// read playerinfo
@@ -476,6 +483,12 @@ void CL_ParseDownload ( msg_t *msg ) {
unsigned char data[MAX_MSGLEN];
int block;
+ if (!*clc.downloadTempName) {
+ Com_Printf("Server sending download, but no download was requested\n");
+ CL_AddReliableCommand( "stopdl" );
+ return;
+ }
+
// read the data
block = MSG_ReadShort ( msg );
@@ -494,8 +507,13 @@ void CL_ParseDownload ( msg_t *msg ) {
}
size = MSG_ReadShort ( msg );
- if (size > 0)
- MSG_ReadData( msg, data, size );
+ if (size < 0 || size > sizeof(data))
+ {
+ Com_Error(ERR_DROP, "CL_ParseDownload: Invalid size %d for download chunk.", size);
+ return;
+ }
+
+ MSG_ReadData(msg, data, size);
if (clc.downloadBlock != block) {
Com_DPrintf( "CL_ParseDownload: Expected block %d, got %d\n", clc.downloadBlock, block);
@@ -505,12 +523,6 @@ void CL_ParseDownload ( msg_t *msg ) {
// open the file if not opened yet
if (!clc.download)
{
- if (!*clc.downloadTempName) {
- Com_Printf("Server sending download, but no download was requested\n");
- CL_AddReliableCommand( "stopdl" );
- return;
- }
-
clc.download = FS_SV_FOpenFileWrite( clc.downloadTempName );
if (!clc.download) {
diff --git a/src/client/snd_codec.c b/src/client/snd_codec.c
index 98fae65f..088236a4 100644
--- a/src/client/snd_codec.c
+++ b/src/client/snd_codec.c
@@ -34,13 +34,16 @@ S_FileExtension
*/
static char *S_FileExtension(const char *fni)
{
- char *fn = (char *)fni;
+ // we should search from the ending to the last '/'
+
+ char *fn = (char *) fni + strlen(fni) - 1;
char *eptr = NULL;
- while(*fn)
+
+ while(*fn != '/' && fn != fni)
{
if(*fn == '.')
eptr = fn;
- fn++;
+ fn--;
}
return eptr;
@@ -64,8 +67,10 @@ static snd_codec_t *S_FindCodecForFile(const char *filename)
while(codec)
{
char fn[MAX_QPATH];
- Q_strncpyz(fn, filename, sizeof(fn) - 4);
- COM_DefaultExtension(fn, sizeof(fn), codec->ext);
+
+ // there is no extension so we do not need to subtract 4 chars
+ Q_strncpyz(fn, filename, MAX_QPATH);
+ COM_DefaultExtension(fn, MAX_QPATH, codec->ext);
// Check it exists
if(FS_ReadFile(fn, NULL) != -1)
diff --git a/src/client/snd_codec_ogg.c b/src/client/snd_codec_ogg.c
index 9c17c0b9..72ece944 100644
--- a/src/client/snd_codec_ogg.c
+++ b/src/client/snd_codec_ogg.c
@@ -360,6 +360,13 @@ int S_OGG_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
// Bitstream for the decoder
int BS = 0;
+ // big endian machines want their samples in big endian order
+ int IsBigEndian = 0;
+
+# ifdef Q3_BIG_ENDIAN
+ IsBigEndian = 1;
+# endif // Q3_BIG_ENDIAN
+
// check if input is valid
if(!(stream && buffer))
{
@@ -379,7 +386,7 @@ int S_OGG_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
while(-1)
{
// read some bytes from the OGG codec
- c = ov_read((OggVorbis_File *) stream->ptr, bufPtr, bytesLeft, 0, OGG_SAMPLEWIDTH, 1, &BS);
+ c = ov_read((OggVorbis_File *) stream->ptr, bufPtr, bytesLeft, IsBigEndian, OGG_SAMPLEWIDTH, 1, &BS);
// no more bytes are left
if(c <= 0)
diff --git a/src/client/snd_openal.c b/src/client/snd_openal.c
index c44f1e0a..c71a58ee 100644
--- a/src/client/snd_openal.c
+++ b/src/client/snd_openal.c
@@ -1539,6 +1539,7 @@ void S_AL_StopAllSounds( void )
{
S_AL_SrcShutup();
S_AL_StopBackgroundTrack();
+ S_AL_StreamDie();
}
/*