From 59c621e0cfade50eff94c40b719ceae9f0cd1172 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 25 Dec 2011 16:23:02 +0900 Subject: [PATCH 01/15] Move qfprogs from tools to qfcc (packaging). --- tools/build_scripts/qf-win32.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build_scripts/qf-win32.py b/tools/build_scripts/qf-win32.py index fa160b9e8..640942762 100755 --- a/tools/build_scripts/qf-win32.py +++ b/tools/build_scripts/qf-win32.py @@ -74,7 +74,6 @@ tools = [ dir + "bin/qfbsp.exe", dir + "bin/qflight.exe", dir + "bin/qfmodelgen.exe", - dir + "bin/qfprogs.exe", dir + "bin/qfvis.exe", dir + "bin/qfwavinfo.exe", dir + "bin/wad.exe", @@ -85,6 +84,7 @@ qfcc = [ dir, dir + "bin", dir + "bin/qfcc.exe", + dir + "bin/qfprogs.exe", dir + "bin/qfpreqcc", dir + "qfcc.1", dir + "qfcc.pc", From 8ee13ef8c21206d6b64e2fdcf9712c8f37c32106 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 28 Dec 2011 19:17:15 +0900 Subject: [PATCH 02/15] Do some clipping in the draw routines. After fixing Maraakate's crash, I thought it would be a good idea to put the fixes into QF, too. --- libs/video/renderer/sw/draw.c | 55 ++++++++++++++++++++++++++++++--- libs/video/renderer/sw32/draw.c | 55 ++++++++++++++++++++++++++++++--- 2 files changed, 100 insertions(+), 10 deletions(-) diff --git a/libs/video/renderer/sw/draw.c b/libs/video/renderer/sw/draw.c index 26ce2e545..44c52d15a 100644 --- a/libs/video/renderer/sw/draw.c +++ b/libs/video/renderer/sw/draw.c @@ -73,6 +73,26 @@ typedef struct cachepic_s { cachepic_t cachepics[MAX_CACHED_PICS]; int numcachepics; +#define CLIP(x,y,w,h,mw,mh) \ + do { \ + if (y < 0) { \ + h += y; \ + y = 0; \ + } \ + if (y + h > mh) \ + h = mh - y; \ + if (h <= 0) \ + return; \ + if (x < 0) { \ + w += x; \ + x = 0; \ + } \ + if (x + w > mw) \ + w = mw - x; \ + if (w <= 0) \ + return; \ + } while (0) + VISIBLE qpic_t * Draw_PicFromWad (const char *name) @@ -362,7 +382,9 @@ Draw_Pic (int x, int y, qpic_t *pic) if (x < 0 || (unsigned int) (x + pic->width) > vid.conwidth || y < 0 || (unsigned int) (y + pic->height) > vid.conheight) { - Sys_Error ("Draw_Pic: bad coordinates"); + Sys_MaskPrintf (SYS_VID, "Draw_Pic: bad coordinates"); + Draw_SubPic (x, y, pic, 0, 0, pic->width, pic->height); + return; } source = pic->data; @@ -414,8 +436,29 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, if ((x < 0) || (x + width > (int) vid.conwidth) || (y < 0) || (y + height > (int) vid.conheight)) { - Sys_Error ("Draw_SubPic: bad coordinates"); + Sys_MaskPrintf (SYS_VID, "Draw_SubPic: bad coordinates"); } + // first, clip to screen + if (x < 0) { + srcx += x; + width += x; + x = 0; + } + if (x + width > (int) vid.width) + width = vid.width - x; + if (width <= 0) + return; + if (y < 0) { + srcy += y; + height += y; + y = 0; + } + if (y + height > (int) vid.height) + height = vid.height - y; + if (height <= 0) + return; + // next, clip to pic + CLIP (srcx, srcy, width, height, pic->width, pic->height); source = pic->data + srcy * pic->width + srcx; @@ -531,7 +574,6 @@ R_DrawRect (vrect_t *prect, int rowbytes, byte * psrc, int transparent) } } - /* Draw_TileClear @@ -545,6 +587,8 @@ Draw_TileClear (int x, int y, int w, int h) byte *psrc; vrect_t vr; + CLIP (x, y, w, h, (int) vid.width, (int) vid.height); + r_rectdesc.rect.x = x; r_rectdesc.rect.y = y; r_rectdesc.rect.width = w; @@ -608,9 +652,10 @@ Draw_Fill (int x, int y, int w, int h, int c) if (x < 0 || x + w > (int) vid.conwidth || y < 0 || y + h > (int) vid.conheight) { - Sys_Printf ("Bad Draw_Fill(%d, %d, %d, %d, %c)\n", x, y, w, h, c); - return; + Sys_MaskPrintf (SYS_VID, "Bad Draw_Fill(%d, %d, %d, %d, %c)\n", + x, y, w, h, c); } + CLIP (x, y, w, h, (int) vid.width, (int) vid.height); dest = ((byte*)vid.buffer) + y * vid.rowbytes + x; for (v = 0; v < h; v++, dest += vid.rowbytes) diff --git a/libs/video/renderer/sw32/draw.c b/libs/video/renderer/sw32/draw.c index ce84861cb..14fb260a2 100644 --- a/libs/video/renderer/sw32/draw.c +++ b/libs/video/renderer/sw32/draw.c @@ -73,6 +73,26 @@ typedef struct cachepic_s { cachepic_t cachepics[MAX_CACHED_PICS]; int numcachepics; +#define CLIP(x,y,w,h,mw,mh) \ + do { \ + if (y < 0) { \ + h += y; \ + y = 0; \ + } \ + if (y + h > mh) \ + h = mh - y; \ + if (h <= 0) \ + return; \ + if (x < 0) { \ + w += x; \ + x = 0; \ + } \ + if (x + w > mw) \ + w = mw - x; \ + if (w <= 0) \ + return; \ + } while (0) + VISIBLE qpic_t * Draw_PicFromWad (const char *name) @@ -435,7 +455,9 @@ Draw_Pic (int x, int y, qpic_t *pic) if (x < 0 || (unsigned int) (x + pic->width) > vid.conwidth || y < 0 || (unsigned int) (y + pic->height) > vid.conheight) { - Sys_Error ("Draw_Pic: bad coordinates"); + Sys_MaskPrintf (SYS_VID, "Draw_Pic: bad coordinates"); + Draw_SubPic (x, y, pic, 0, 0, pic->width, pic->height); + return; } source = pic->data; @@ -527,8 +549,29 @@ Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, if ((x < 0) || (x + width > (int) vid.conwidth) || (y < 0) || (y + height > (int) vid.conheight)) { - Sys_Error ("Draw_SubPic: bad coordinates"); + Sys_MaskPrintf (SYS_VID, "Draw_SubPic: bad coordinates"); } + // first, clip to screen + if (x < 0) { + srcx += x; + width += x; + x = 0; + } + if (x + width > (int) vid.width) + width = vid.width - x; + if (width <= 0) + return; + if (y < 0) { + srcy += y; + height += y; + y = 0; + } + if (y + height > (int) vid.height) + height = vid.height - y; + if (height <= 0) + return; + // next, clip to pic + CLIP (srcx, srcy, width, height, pic->width, pic->height); source = pic->data + srcy * pic->width + srcx; @@ -944,7 +987,6 @@ R_DrawRect (vrect_t *prect, int rowbytes, byte * psrc, int transparent) } } - /* Draw_TileClear @@ -958,6 +1000,8 @@ Draw_TileClear (int x, int y, int w, int h) byte *psrc; vrect_t vr; + CLIP (x, y, w, h, (int) vid.width, (int) vid.height); + r_rectdesc.rect.x = x; r_rectdesc.rect.y = y; r_rectdesc.rect.width = w; @@ -1020,9 +1064,10 @@ Draw_Fill (int x, int y, int w, int h, int c) if (x < 0 || x + w > (int) vid.conwidth || y < 0 || y + h > (int) vid.conheight) { - Sys_Printf ("Bad Draw_Fill(%d, %d, %d, %d, %c)\n", x, y, w, h, c); - return; + Sys_MaskPrintf (SYS_VID, "Bad Draw_Fill(%d, %d, %d, %d, %c)\n", + x, y, w, h, c); } + CLIP (x, y, w, h, (int) vid.width, (int) vid.height); switch (r_pixbytes) { case 1: From 0e521a7779b0a214c4cd9bcb751844deafbfce21 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 29 Dec 2011 11:27:54 +0900 Subject: [PATCH 03/15] Correctly detect going past the end of the pcx data. palette is just that, the palette, and often won't point to the end of the pcx data. Use the right end :). --- libs/image/pcx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/image/pcx.c b/libs/image/pcx.c index a29306223..55a3ec8d8 100644 --- a/libs/image/pcx.c +++ b/libs/image/pcx.c @@ -55,6 +55,7 @@ LoadPCX (QFile *f, qboolean convert, byte *pal) pcx_t *pcx; int pcx_mark; byte *palette; + byte *end; byte *pix; byte *dataByte; int runLength = 1; @@ -85,7 +86,7 @@ LoadPCX (QFile *f, qboolean convert, byte *pal) return 0; } - palette = ((byte *) pcx) + fsize - 768; + end = palette = ((byte *) pcx) + fsize - 768; dataByte = (byte *) &pcx[1]; count = (pcx->xmax + 1) * (pcx->ymax + 1); @@ -106,12 +107,12 @@ LoadPCX (QFile *f, qboolean convert, byte *pal) pix = tex->data; while (count) { - if (dataByte >= palette) + if (dataByte >= end) break; if ((*dataByte & 0xC0) == 0xC0) { runLength = *dataByte++ & 0x3F; - if (dataByte >= palette) + if (dataByte >= end) break; } else { runLength = 1; From ffc9680653cfacd56cc884db9dafcf61fc08dcae Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 4 Jan 2012 13:17:57 +0900 Subject: [PATCH 04/15] Add an option to prevent the use of default paths. Despair has things locked down such that running qfcc during a build fails due to lack of read access to /usr/local/lib. This is actually a good thing as accidentally hitting old includes/libs (when a file gets deleted in the tree) hides bugs. Thus, --no-default-paths to turn off default search paths. --- ruamoko/cl_menu/Makefile.am | 2 +- ruamoko/game/Makefile.am | 2 +- ruamoko/gui/Makefile.am | 2 +- ruamoko/lib/Makefile.am | 2 +- ruamoko/scheme/Makefile.am | 2 +- tools/qfcc/doc/man/qfcc.1 | 3 +++ tools/qfcc/include/options.h | 1 + tools/qfcc/source/options.c | 11 +++++++++-- tools/qwaq/Makefile.am | 2 +- 9 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ruamoko/cl_menu/Makefile.am b/ruamoko/cl_menu/Makefile.am index be09a6ace..0a84ec944 100644 --- a/ruamoko/cl_menu/Makefile.am +++ b/ruamoko/cl_menu/Makefile.am @@ -5,7 +5,7 @@ pkgdatadir=@sharepath@/QF QFCC_DEP=$(top_builddir)/tools/qfcc/source/qfcc$(EXEEXT) QFCC=$(QFCC_DEP) -QCFLAGS=-qq -g -Wall -Werror -Wno-integer-divide +QCFLAGS=-qq -g -Wall -Werror -Wno-integer-divide --no-default-paths QCPPFLAGS=-I. -I$(srcdir) -I$(top_builddir)/ruamoko/include -I$(top_srcdir)/ruamoko/include -I$(top_builddir)/include -I$(top_srcdir)/include GZIP=if echo $@ | grep -q .gz; then gzip -f `basename $@ .gz`; if test -f `basename $@ .dat.gz`.sym; then gzip -f `basename $@ .dat.gz`.sym; fi; fi if HAVE_ZLIB diff --git a/ruamoko/game/Makefile.am b/ruamoko/game/Makefile.am index e955caa1c..1f3fece7b 100644 --- a/ruamoko/game/Makefile.am +++ b/ruamoko/game/Makefile.am @@ -7,7 +7,7 @@ pkgdatadir=@sharepath@/id1 QFCC_DEP=$(top_builddir)/tools/qfcc/source/qfcc$(EXEEXT) QFCC=$(QFCC_DEP) -QCFLAGS=-qq -g -Werror -Wall -Wno-integer-divide +QCFLAGS=-qq -g -Werror -Wall -Wno-integer-divide --no-default-paths QCPPFLAGS=-I. -I$(srcdir) -I$(top_builddir)/ruamoko/include -I$(top_srcdir)/ruamoko/include GZIP=if echo $@ | grep -q .gz; then gzip -f `basename $@ .gz`; if test -f `basename $@ .dat.gz`.sym; then gzip -f `basename $@ .dat.gz`.sym; fi; fi if HAVE_ZLIB diff --git a/ruamoko/gui/Makefile.am b/ruamoko/gui/Makefile.am index 2debef885..3848270e1 100644 --- a/ruamoko/gui/Makefile.am +++ b/ruamoko/gui/Makefile.am @@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS= foreign pkglibdir=$(libdir)/qfcc/lib QFCC=$(top_builddir)/tools/qfcc/source/qfcc$(EXEEXT) -QCFLAGS=-qq -g -Werror -Wall -Wno-integer-divide +QCFLAGS=-qq -g -Werror -Wall -Wno-integer-divide --no-default-paths QCPPFLAGS=$(INCLUDES) PAK=$(top_builddir)/tools/pak/pak$(EXEEXT) RANLIB=touch diff --git a/ruamoko/lib/Makefile.am b/ruamoko/lib/Makefile.am index 92ede7a79..ed21e5b57 100644 --- a/ruamoko/lib/Makefile.am +++ b/ruamoko/lib/Makefile.am @@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS= foreign pkglibdir=$(libdir)/qfcc/lib QFCC=$(top_builddir)/tools/qfcc/source/qfcc$(EXEEXT) -QCFLAGS=-qq -g -Wall -Wno-integer-divide -Werror +QCFLAGS=-qq -g -Wall -Wno-integer-divide -Werror --no-default-paths QCPPFLAGS=$(INCLUDES) PAK=$(top_builddir)/tools/pak/pak$(EXEEXT) RANLIB=touch diff --git a/ruamoko/scheme/Makefile.am b/ruamoko/scheme/Makefile.am index ad9f40894..258c741e5 100644 --- a/ruamoko/scheme/Makefile.am +++ b/ruamoko/scheme/Makefile.am @@ -4,7 +4,7 @@ pkglibdir=$(libdir)/qfcc/lib QFCC_DEP=$(top_builddir)/tools/qfcc/source/qfcc$(EXEEXT) QFCC=$(QFCC_DEP) -QCFLAGS=-qq -g -Werror -Wall -Wno-integer-divide +QCFLAGS=-qq -g -Werror -Wall -Wno-integer-divide --no-default-paths QCPPFLAGS=$(INCLUDES) PAK=$(top_builddir)/tools/pak/pak$(EXEEXT) GZIP=if echo $@ | grep -q .gz; then gzip -f `basename $@ .gz`; if test -f `basename $@ .dat.gz`.sym; then gzip -f `basename $@ .dat.gz`.sym; fi; fi diff --git a/tools/qfcc/doc/man/qfcc.1 b/tools/qfcc/doc/man/qfcc.1 index 0e24df0cc..fba7fab7f 100644 --- a/tools/qfcc/doc/man/qfcc.1 +++ b/tools/qfcc/doc/man/qfcc.1 @@ -101,6 +101,9 @@ object files built using the \fBpak\fP utility. Generate dependency info. Dependent on \*[cpp] version, so check \*[cpp]'s documentation. .TP +.B \-\-no\-default\-paths +Do not use default paths for include files or libraries. +.TP .B \-N, \-\-notice OPTION,... Set notice options. See \fBNOTICE OPTIONS\fP for details. diff --git a/tools/qfcc/include/options.h b/tools/qfcc/include/options.h index 96e249021..eb0714139 100644 --- a/tools/qfcc/include/options.h +++ b/tools/qfcc/include/options.h @@ -76,6 +76,7 @@ typedef struct { qboolean single_cpp; // process progs.src into a series of // #include directives and then compile // that + qboolean no_default_paths; // no default -I or -L qboolean save_temps; // save temporary files qboolean files_dat; // generate files.dat qboolean progdefs_h; // generate progdefs.h diff --git a/tools/qfcc/source/options.c b/tools/qfcc/source/options.c index c7cb912e9..8f55dceac 100644 --- a/tools/qfcc/source/options.c +++ b/tools/qfcc/source/options.c @@ -65,6 +65,7 @@ enum { OPT_ADVANCED, OPT_CPP, OPT_INCLUDE, + OPT_NO_DEFAULT_PATHS, OPT_PROGDEFS, OPT_QCCX_ESCAPES, OPT_TRADITIONAL, @@ -78,6 +79,7 @@ static struct option const long_options[] = { {"files", no_argument, 0, 'F'}, {"help", no_argument, 0, 'h'}, {"include", required_argument, 0, OPT_INCLUDE}, + {"no-default-paths", no_argument, 0, OPT_NO_DEFAULT_PATHS}, {"notice", required_argument, 0, 'N'}, {"output-file", required_argument, 0, 'o'}, {"progdefs", no_argument, 0, OPT_PROGDEFS}, @@ -537,6 +539,9 @@ DecodeArgs (int argc, char **argv) add_cpp_def (nva ("-M")); } break; + case OPT_NO_DEFAULT_PATHS: + options.no_default_paths = 1; + break; default: usage (1); } @@ -579,8 +584,10 @@ DecodeArgs (int argc, char **argv) add_cpp_def ("-D__VERSION6__=1"); // add the default paths - add_cpp_def (nva ("-I%s", QFCC_INCLUDE_PATH)); - linker_add_path (QFCC_LIB_PATH); + if (!options.no_default_paths) { + add_cpp_def (nva ("-I%s", QFCC_INCLUDE_PATH)); + linker_add_path (QFCC_LIB_PATH); + } if (options.verbosity >= 3) yydebug = 1; diff --git a/tools/qwaq/Makefile.am b/tools/qwaq/Makefile.am index edffc3302..b440ccab7 100644 --- a/tools/qwaq/Makefile.am +++ b/tools/qwaq/Makefile.am @@ -6,7 +6,7 @@ INCLUDES= -I$(top_srcdir)/include $(QWAQ_INCS) QFCC_DEP=$(top_builddir)/tools/qfcc/source/qfcc$(EXEEXT) QFCC=$(top_builddir)/tools/qfcc/source/qfcc -QCFLAGS=-qq -g -Werror --advanced +QCFLAGS=-qq -g -Werror --advanced --no-default-paths if BUILD_QWAQ qwaq=qwaq From 03bcfb9483e3c92af840d19cc0f951e22888d799 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 5 Jan 2012 14:00:57 +0900 Subject: [PATCH 05/15] Set the default hudtype. Yay, Deek for finding another bug in qf :). He had an old dirconf that didn't specify HudType and thus caused the status bar code to blow up. Set the default to "id" if none is found. --- libs/util/quakefs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index 4206eebc6..232a23a9c 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -539,6 +539,8 @@ qfs_build_gamedir (const char **list) ; gamedir->dir.def = nva ("%.*s", (int) (dir - gamedir->path), gamedir->path); + if (!gamedir->hudtype) + gamedir->hudtype = strdup ("id"); if (!gamedir->dir.skins) gamedir->dir.skins = nva ("%s/skins", gamedir->dir.def); if (!gamedir->dir.models) From a988c192abb17d35e948e1e9ee3f8eb35c495170 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 6 Jan 2012 21:21:45 +0900 Subject: [PATCH 06/15] Fix OSS sound. YAY!!! Much thanks to Spirit from quaddicted for his patient help in testing, and Spike for his heckling ;) --- libs/audio/targets/snd_oss.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/audio/targets/snd_oss.c b/libs/audio/targets/snd_oss.c index 5e5ad5320..b1281cddd 100644 --- a/libs/audio/targets/snd_oss.c +++ b/libs/audio/targets/snd_oss.c @@ -250,7 +250,8 @@ try_open (int rw) return 0; } - sn.frames = info.fragstotal; + sn.frames = info.fragstotal * info.fragsize; + sn.frames /= sn.channels * sn.samplebits / 8; sn.submission_chunk = 1; if (mmaped_io) { // memory map the dma buffer @@ -260,7 +261,8 @@ try_open (int rw) len = (len + sz - 1) & ~(sz - 1); sn.buffer = (byte *) mmap (NULL, len, mmmode, mmflags, audio_fd, 0); if (sn.buffer == MAP_FAILED) { - Sys_Printf ("Could not mmap %s: %s\n", snd_dev, strerror (errno)); + Sys_MaskPrintf (SYS_SND, "Could not mmap %s: %s\n", snd_dev, + strerror (errno)); close (audio_fd); return 0; } @@ -326,7 +328,7 @@ SNDDMA_GetDMAPos (void) } // sn.samplepos = (count.bytes / (sn.samplebits / 8)) & (sn.samples-1); // fprintf(stderr, "%d \r", count.ptr); - sn.framepos = count.ptr / (sn.samplebits / 8); + sn.framepos = count.ptr / (sn.channels * sn.samplebits / 8); return sn.framepos; From 58cb0845494e5bf74af4a2c3b7b331d150fa9fcc Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 7 Jan 2012 09:39:35 +0900 Subject: [PATCH 07/15] Update NEWS for 0.6.1. --- NEWS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/NEWS b/NEWS index d830691eb..b89905da5 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,14 @@ NEWS for the QuakeForge project ------------------------------- +Changes from 0.6.0 + o qfprogs has been moved from tools to qfcc (windows packages). + o The software renderer can now cope with pics being off-screen. + o A potential issue with reading past the end of PCX files has been fixed. + o qfcc now accepts --no-default-paths. Mainly for building Ruamoko code in + the main source tree, but useful for those that want to avoid libr. + o A segfault involving old dirconfs has been fixed. + o OSS sound should be working now. + Changes from 0.5.99 Beta 4.1 o Many more keys supported in X11 (-glx, -x11) clients: most of the keys on a Microsoft Natural Ergonomic Keyboard 4000 v1.0 are supported (not From 05bf637466aa885bf3e70a5918b7ee9449f7086e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 17 Jan 2012 19:14:42 +0900 Subject: [PATCH 08/15] SDL sound patches from SVD. Thanks to "Sander van Dijk" , we now have much better SDL sound support. Here's the promised cleaned up version of the "double buffer" approach patch for "snd_sdl.c". I've taken some more time to re-read and test it this time, and it seems to behave well. All memory that is used by both the main thread and the SDL audio thread is prefixed with "shm_", and locking is used to ensure that only one thread accesses it at the same time. --- libs/audio/targets/snd_sdl.c | 108 ++++++++++++++++++++++++----------- 1 file changed, 75 insertions(+), 33 deletions(-) diff --git a/libs/audio/targets/snd_sdl.c b/libs/audio/targets/snd_sdl.c index 211471068..c2ee47a34 100644 --- a/libs/audio/targets/snd_sdl.c +++ b/libs/audio/targets/snd_sdl.c @@ -53,7 +53,13 @@ static __attribute__ ((used)) const char rcsid[] = static dma_t sn; static int snd_inited; -static int snd_blocked = 0; +static int snd_blocked; + +static unsigned shm_buflen; +static unsigned char *shm_buf; +static unsigned shm_rpos; + +static unsigned wpos; static cvar_t *snd_bits; static cvar_t *snd_rate; @@ -71,25 +77,16 @@ static snd_output_funcs_t plugin_info_snd_output_funcs; static void paint_audio (void *unused, Uint8 * stream, int len) { - int frameposbytes, framesbytes, frames; - - frames = len / (sn.channels * (sn.samplebits / 8)); - frameposbytes = sn.framepos * sn.channels * (sn.samplebits / 8); - framesbytes = sn.frames * sn.channels * (sn.samplebits / 8); - - sn.framepos += frames; - while (sn.framepos >= sn.frames) - sn.framepos -= sn.frames; - - if (sn.framepos + frames <= sn.frames) - memcpy (stream, sn.buffer + frameposbytes, len); - else { - memcpy (stream, sn.buffer + frameposbytes, framesbytes - - frameposbytes); - memcpy (stream + framesbytes - frameposbytes, sn.buffer, len - - (framesbytes - frameposbytes)); + while (shm_rpos + len > shm_buflen) { + memcpy (stream, shm_buf + shm_rpos, shm_buflen - shm_rpos); + stream += shm_buflen - shm_rpos; + len -= shm_buflen - shm_rpos; + shm_rpos = 0; + } + if (len) { + memcpy (stream, shm_buf + shm_rpos, len); + shm_rpos += len; } - *plugin_info_snd_output_data.soundtime += frames; } static void @@ -101,7 +98,6 @@ SNDDMA_Init_Cvars (void) "sound playback rate. 0 is system default"); snd_bits = Cvar_Get ("snd_bits", "0", CVAR_ROM, NULL, "sound sample depth. 0 is system default"); - } static volatile dma_t * @@ -109,7 +105,8 @@ SNDDMA_Init (void) { SDL_AudioSpec desired, obtained; - snd_inited = 0; + if (snd_inited) + return &sn; if (SDL_Init (SDL_INIT_AUDIO) < 0) { Sys_Printf ("Couldn't initialize SDL AUDIO: %s\n", SDL_GetError ()); @@ -179,20 +176,37 @@ SNDDMA_Init (void) sn.frames = obtained.samples * 8; // 8 chunks in the buffer sn.framepos = 0; sn.submission_chunk = 1; - sn.buffer = calloc(sn.frames * sn.channels * (sn.samplebits / 8), 1); + + shm_buflen = sn.frames * sn.channels * (sn.samplebits / 8); + + sn.buffer = calloc (shm_buflen, 1); if (!sn.buffer) Sys_Error ("Failed to allocate buffer for sound!"); - SDL_LockAudio(); - SDL_PauseAudio (0); + shm_buf = calloc (shm_buflen, 1); + if (!shm_buf) + Sys_Error ("Failed to allocate buffer for sound!"); + + shm_rpos = wpos = 0; + + if (!snd_blocked) + SDL_PauseAudio (0); snd_inited = 1; + return &sn; } static int SNDDMA_GetDMAPos (void) { + if (!snd_inited) + return 0; + + SDL_LockAudio (); + sn.framepos = shm_rpos / (sn.channels * (sn.samplebits / 8)); + SDL_UnlockAudio (); + return sn.framepos; } @@ -200,9 +214,9 @@ static void SNDDMA_Shutdown (void) { if (snd_inited) { - SDL_PauseAudio (1); - SDL_UnlockAudio (); SDL_CloseAudio (); + free (sn.buffer); + free (shm_buf); snd_inited = 0; } } @@ -215,25 +229,53 @@ SNDDMA_Shutdown (void) static void SNDDMA_Submit (void) { - if (snd_blocked) + static unsigned old_paintedtime; + unsigned len; + + if (!snd_inited || snd_blocked) return; - SDL_UnlockAudio(); - SDL_LockAudio(); + SDL_LockAudio (); + + if (*plugin_info_snd_output_data.paintedtime < old_paintedtime) + old_paintedtime = 0; + + len = (*plugin_info_snd_output_data.paintedtime - old_paintedtime) * + sn.channels * (sn.samplebits / 8); + + old_paintedtime = *plugin_info_snd_output_data.paintedtime; + + while (wpos + len > shm_buflen) { + memcpy (shm_buf + wpos, sn.buffer + wpos, shm_buflen - wpos); + len -= shm_buflen - wpos; + wpos = 0; + } + if (len) { + memcpy (shm_buf + wpos, sn.buffer + wpos, len); + wpos += len; + } + + SDL_UnlockAudio (); } static void SNDDMA_BlockSound (void) { - ++snd_blocked; + if (!snd_inited) + return; + + if (++snd_blocked == 1) + SDL_PauseAudio (1); } static void SNDDMA_UnblockSound (void) { - if (!snd_blocked) + if (!snd_inited || !snd_blocked) return; - --snd_blocked; + + if (!--snd_blocked) + SDL_PauseAudio (0); } PLUGIN_INFO(snd_output, sdl) @@ -243,7 +285,7 @@ PLUGIN_INFO(snd_output, sdl) plugin_info.plugin_version = "0.1"; plugin_info.description = "SDL digital output"; plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n" - "Copyright (C) 1999,2000,2001 contributors of the QuakeForge " + "Copyright (C) 1999,2000,2001,2012 contributors of the QuakeForge " "project\n" "Please see the file \"AUTHORS\" for a list of contributors"; plugin_info.functions = &plugin_info_funcs; From d8432e78bbe9ff5c1c52ee1ccf5762c590156710 Mon Sep 17 00:00:00 2001 From: Sander van Dijk Date: Tue, 17 Jan 2012 14:12:48 +0100 Subject: [PATCH 09/15] Fix a wrongly negated condition in snd_win.c:SNDDMA_UnblockSound(). --- libs/audio/targets/snd_win.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/audio/targets/snd_win.c b/libs/audio/targets/snd_win.c index 1c319f8f8..299dbfdf4 100644 --- a/libs/audio/targets/snd_win.c +++ b/libs/audio/targets/snd_win.c @@ -109,7 +109,7 @@ SNDDMA_BlockSound (void) static void SNDDMA_UnblockSound (void) { - if (!snd_blocked) + if (snd_blocked) --snd_blocked; } From 8e6c3f7bf8d8cf75583abd2e5a019f1868916c19 Mon Sep 17 00:00:00 2001 From: Sander van Dijk Date: Thu, 19 Jan 2012 20:44:26 +0100 Subject: [PATCH 10/15] Make gl_rsurf.c compile without warnings with "gcc (GCC) 4.4.5 20101112 (Red Hat 4.4.5-2)". --- libs/video/renderer/gl/gl_rsurf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/video/renderer/gl/gl_rsurf.c b/libs/video/renderer/gl/gl_rsurf.c index 103a97b76..b7e0fceae 100644 --- a/libs/video/renderer/gl/gl_rsurf.c +++ b/libs/video/renderer/gl/gl_rsurf.c @@ -68,7 +68,8 @@ instsurf_t **sky_chain_tail; #define CHAIN_SURF_F2B(surf,chain) \ do { \ instsurf_t *inst = (surf)->instsurf; \ - if (!inst) (surf)->tinst = inst = get_instsurf (); \ + if (__builtin_expect(!inst, 1)) \ + (surf)->tinst = inst = get_instsurf (); \ inst->surface = (surf); \ *(chain##_tail) = inst; \ (chain##_tail) = &inst->tex_chain; \ @@ -78,7 +79,8 @@ instsurf_t **sky_chain_tail; #define CHAIN_SURF_B2F(surf,chain) \ do { \ instsurf_t *inst = (surf)->instsurf; \ - if (!inst) (surf)->tinst = inst = get_instsurf (); \ + if (__builtin_expect(!inst, 1)) \ + (surf)->tinst = inst = get_instsurf (); \ inst->surface = (surf); \ inst->tex_chain = (chain); \ (chain) = inst; \ @@ -387,7 +389,7 @@ R_DrawWaterSurfaces (void) } } -static inline void +static void DrawTextureChains (int disable_blend, int do_bind) { int i; From 25ffe6bc3e805b9adcb104c159f96887b2e5fd52 Mon Sep 17 00:00:00 2001 From: Sander van Dijk Date: Fri, 20 Jan 2012 20:58:19 +0100 Subject: [PATCH 11/15] cd_sdl.c: fix typo. --- libs/audio/cd_sdl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/audio/cd_sdl.c b/libs/audio/cd_sdl.c index cd420d944..616a4e1d7 100644 --- a/libs/audio/cd_sdl.c +++ b/libs/audio/cd_sdl.c @@ -151,7 +151,7 @@ I_CDAudio_Resume (void) return; if (SDL_CDResume (cd_id)) - Sys_MaskPrintf (SYS_SND, "CDAudio_Resume: Failed tp resume track.\n"); + Sys_MaskPrintf (SYS_SND, "CDAudio_Resume: Failed to resume track.\n"); } static void From 197481bdbbe413e84254a52abc26febd73efc82c Mon Sep 17 00:00:00 2001 From: Sander van Dijk Date: Fri, 20 Jan 2012 21:01:05 +0100 Subject: [PATCH 12/15] in_sdl.c: default to "have_focus" to "1". --- libs/video/targets/in_sdl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/video/targets/in_sdl.c b/libs/video/targets/in_sdl.c index 08b72a470..117c5110b 100644 --- a/libs/video/targets/in_sdl.c +++ b/libs/video/targets/in_sdl.c @@ -49,7 +49,7 @@ static __attribute__ ((used)) const char rcsid[] = cvar_t *in_snd_block; static keydest_t old_key_dest = key_none; -static int have_focus; +static int have_focus = 1; static void From 3c3a9d0a33b543a00d47f08f7410889b29825298 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 21 Jan 2012 16:18:20 +0900 Subject: [PATCH 13/15] Ensure the beam entitys' angles get set. This fixes the incorrectly oriented beam entities. --- nq/source/cl_tent.c | 2 ++ qw/source/cl_tent.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/nq/source/cl_tent.c b/nq/source/cl_tent.c index f508994ce..f5cced8c0 100644 --- a/nq/source/cl_tent.c +++ b/nq/source/cl_tent.c @@ -278,6 +278,7 @@ beam_setup (beam_t *b, qboolean transform) seed = b->seed + ((int) (cl.time * BEAM_SEED_INTERVAL) % BEAM_SEED_INTERVAL); + ang[ROLL] = 0; while (ent_count--) { tent = new_temp_entity (); tent->next = b->tents; @@ -293,6 +294,7 @@ beam_setup (beam_t *b, qboolean transform) ang[ROLL] = seed % 360; CL_TransformEntity (&tent->ent, ang, true); } + VectorCopy (ang, tent->ent.angles); R_AddEfrags (&tent->ent); } } diff --git a/qw/source/cl_tent.c b/qw/source/cl_tent.c index 8d7f06da7..dbd7093fe 100644 --- a/qw/source/cl_tent.c +++ b/qw/source/cl_tent.c @@ -284,6 +284,7 @@ beam_setup (beam_t *b, qboolean transform) seed = b->seed + ((int) (cl.time * BEAM_SEED_INTERVAL) % BEAM_SEED_INTERVAL); + ang[ROLL] = 0; while (ent_count--) { tent = new_temp_entity (); tent->next = b->tents; @@ -299,6 +300,7 @@ beam_setup (beam_t *b, qboolean transform) ang[ROLL] = seed % 360; CL_TransformEntity (&tent->ent, ang, true); } + VectorCopy (ang, tent->ent.angles); R_AddEfrags (&tent->ent); } } From 86a401b02522d5186f2d932c2e87dc0d27c06e48 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 22 Jan 2012 19:23:02 +0900 Subject: [PATCH 14/15] Fix the importer for blender 2.61. The use_image field of faces disappeared somewhere between 2.59 and 2.61. --- tools/io_mesh_qfmdl/import_mdl.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/io_mesh_qfmdl/import_mdl.py b/tools/io_mesh_qfmdl/import_mdl.py index 53d4379c2..bda8062da 100644 --- a/tools/io_mesh_qfmdl/import_mdl.py +++ b/tools/io_mesh_qfmdl/import_mdl.py @@ -108,7 +108,8 @@ def setup_skins (mdl, uvs): for j, uv in enumerate(f.uv): uv[0], uv[1] = mdl_uv[j] f.image = img - f.use_image = True + if hasattr(f, "use_image"): # for older blender + f.use_image = True mat = bpy.data.materials.new(mdl.name) mat.diffuse_color = (1,1,1) mat.use_raytrace = False From 6104db50e1b67d7f0d6ad54bcecacccadf23f78f Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 24 Jan 2012 12:08:12 +0900 Subject: [PATCH 15/15] Fix a gl matrix stack overflow. I'd missed a couple of places for glPopMatrix (worse, one was push!). --- libs/video/renderer/gl/gl_sky_clip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/video/renderer/gl/gl_sky_clip.c b/libs/video/renderer/gl/gl_sky_clip.c index e99f0f390..37154014d 100644 --- a/libs/video/renderer/gl/gl_sky_clip.c +++ b/libs/video/renderer/gl/gl_sky_clip.c @@ -703,7 +703,7 @@ draw_black_sky_polys (const instsurf_t *sky_chain) p = p->next; } if (sc->transform) - qfglPushMatrix (); + qfglPopMatrix (); sc = sc->tex_chain; } qfglEnable (GL_TEXTURE_2D); @@ -845,6 +845,8 @@ R_DrawSkyChain (const instsurf_t *sky_chain) qfglEnd (); p = p->next; } + if (sc->transform) + qfglPopMatrix (); sc = sc->tex_chain; } }