Index: code/win32/win_main.c
===================================================================
--- code/win32/win_main.c	(revision 7)
+++ code/win32/win_main.c	(revision 27)
@@ -1191,6 +1191,10 @@
         return 0;
 	}
 
+	// Cgg - max number of open files at the crt level
+	_setmaxstdio(2048);
+	// !Cgg
+
 	g_wv.hInstance = hInstance;
 	Q_strncpyz( sys_cmdline, lpCmdLine, sizeof( sys_cmdline ) );
 
Index: code/server/sv_init.c
===================================================================
--- code/server/sv_init.c	(revision 7)
+++ code/server/sv_init.c	(revision 27)
@@ -520,12 +520,17 @@
 		Cvar_Set( "sv_paks", "" );
 		Cvar_Set( "sv_pakNames", "" );
 	}
+// Cgg - this fails with the large number of defrag pk3s
+// Removing this prevents packs from being auto-downloaded, but so does repacking.
+/*
 	// the server sends these to the clients so they can figure
 	// out which pk3s should be auto-downloaded
 	p = FS_ReferencedPakChecksums();
 	Cvar_Set( "sv_referencedPaks", p );
 	p = FS_ReferencedPakNames();
 	Cvar_Set( "sv_referencedPakNames", p );
+*/
+// !Cgg
 
 	// save systeminfo and serverinfo strings
 	Q_strncpyz( systemInfo, Cvar_InfoString_Big( CVAR_SYSTEMINFO ), sizeof( systemInfo ) );
Index: code/qcommon/files.c
===================================================================
--- code/qcommon/files.c	(revision 7)
+++ code/qcommon/files.c	(revision 27)
@@ -1705,6 +1705,10 @@
 	{
 		err = unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);
 		if (err != UNZ_OK) {
+			// Cgg - it's better to fail and have the user notified than to have a half-loaded pk3,
+			// or worse a failed pack referenced that results in further failures (yes it does happen)
+			Com_Error(ERR_FATAL, "Corrupted pk3 file \'%s\'", basename);
+			// !Cgg
 			break;
 		}
 		len += strlen(filename_inzip) + 1;
@@ -1746,6 +1750,9 @@
 	{
 		err = unzGetCurrentFileInfo(uf, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);
 		if (err != UNZ_OK) {
+			// Cgg - see above
+			Com_Error(ERR_FATAL, "Corrupted pk3 file \'%s\'", basename);
+			// !Cgg
 			break;
 		}
 		if (file_info.uncompressed_size > 0) {
@@ -2436,6 +2443,99 @@
 	}
 }
 
+// Cgg - autocompletion on map & demo names
+void Maps_CommandCompletion(void (*callback) (const char *s)) {
+	char **matches;
+	char m[MAX_QPATH];
+	char *c;
+	int i, n;
+
+	matches = FS_ListFilteredFiles("maps", ".bsp", NULL, &n);
+	FS_SortFileList(matches, n);
+	for (i=0; i<n; i++) {
+		Q_strncpyz(m, matches[i], sizeof(m));
+		for (c=m+strlen(m)-1; c>m; c--) {
+			if (*c != '.') {
+				continue;
+			}
+			*c = 0;
+			break;
+		}
+		callback(m);
+	}
+	FS_FreeFileList(matches);
+}
+const char *Field_GetCompletionString();	// prototype from common.c
+void Demos_CommandCompletion(void (*callback) (const char *s)) {
+	char searchpath[MAX_QPATH];
+	char path[MAX_QPATH];
+	char m[MAX_QPATH];
+	char **matches;
+	char **list;
+	const char *completionString, *c;
+	int i, n, nlist;
+
+	// set up searchpath
+	Q_strncpyz(path, "", sizeof(path));
+	Q_strncpyz(searchpath, "demos", sizeof(searchpath));
+	completionString = Field_GetCompletionString();
+	for (c=completionString+strlen(completionString)-1; c>completionString; c--) {
+		if (*c == '/') {
+			Q_strncpyz(path, completionString, c-completionString+1);	// destsize accounts for the trailing \0
+			Com_sprintf(searchpath, sizeof(searchpath), "demos/%s", path);
+			break;
+		}
+	}
+
+	// set up the list
+	list = Z_Malloc(MAX_FOUND_FILES * sizeof(*list));
+	nlist = 0;
+
+	// directories
+	matches = FS_ListFilteredFiles(searchpath, "/", NULL, &n);
+	for (i=0; i<n; i++) {
+		// filter out . .. and hidden files that follow the unix convention
+		if (matches[i][0] == '.') {
+			continue;
+		}
+		// FS_ListFilteredFiles() on directories returns one empty string
+		if (matches[i][0] == 0) {
+			continue;
+		}
+		if (strlen(path)) {
+			Com_sprintf(m, sizeof(m), "%s/%s/", path, matches[i]);
+		} else {
+			Com_sprintf(m, sizeof(m), "%s/", matches[i]);
+		}
+		nlist = FS_AddFileToList(m, list, nlist);
+	}
+	FS_FreeFileList(matches);
+
+	// demos
+	matches = FS_ListFilteredFiles(searchpath, ".dm_6?", NULL, &n);
+	for (i=0; i<n; i++) {
+		// filter hidden files out
+		if (matches[i][0] == '.') {
+			continue;
+		}
+		if (strlen(path)) {
+			Com_sprintf(m, sizeof(m), "%s/%s", path, matches[i]);
+			nlist = FS_AddFileToList(m, list, nlist);
+			continue;
+		}
+		nlist = FS_AddFileToList(matches[i], list, nlist);
+	}
+	FS_FreeFileList(matches);
+
+	// sort list and callback
+	FS_SortFileList(list, nlist);
+	for (i=0; i<nlist; i++) {
+		callback(list[i]);
+	}
+	FS_FreeFileList(list);
+}
+// !Cgg
+
 //===========================================================================
 
 
Index: code/qcommon/cmd.c
===================================================================
--- code/qcommon/cmd.c	(revision 7)
+++ code/qcommon/cmd.c	(revision 27)
@@ -240,6 +240,7 @@
 	char	*f;
 	int		len;
 	char	filename[MAX_QPATH];
+	char	*c, *lf, *s;	// Cgg
 
 	if (Cmd_Argc () != 2) {
 		Com_Printf ("exec <filename> : execute a script file\n");
@@ -254,9 +255,25 @@
 		return;
 	}
 	Com_Printf ("execing %s\n",Cmd_Argv(1));
-	
-	Cbuf_InsertText (f);
 
+	// Cgg - execute the file buffer incrementally
+	Cbuf_Execute();
+	for (c=f,s=f,lf=f; *c; c++) {
+		if (*c == '\n') {
+			lf = c;
+		}
+		if (c - s >= 0x4000 -1) {
+			*lf = 0;
+			Cbuf_InsertText(s);
+			Cbuf_Execute();
+			s = lf+1;
+		}
+	}
+	Cbuf_InsertText(s);
+	Cbuf_Execute();
+	//was: Cbuf_InsertText (f);
+	// !Cgg
+
 	FS_FreeFile (f);
 }
 
Index: code/qcommon/qcommon.h
===================================================================
--- code/qcommon/qcommon.h	(revision 7)
+++ code/qcommon/qcommon.h	(revision 27)
@@ -632,6 +632,11 @@
 
 void FS_Rename( const char *from, const char *to );
 
+// Cgg - autocompletion on map & demo names
+void Maps_CommandCompletion(void (*callback) (const char *s));
+void Demos_CommandCompletion(void (*callback) (const char *s));
+// !Cgg
+
 /*
 ==============================================================
 
Index: code/qcommon/common.c
===================================================================
--- code/qcommon/common.c	(revision 7)
+++ code/qcommon/common.c	(revision 27)
@@ -3184,6 +3184,12 @@
 // field we are working on, passed to Field_CompleteCommand (&g_consoleCommand for instance)
 static field_t *completionField;
 
+// Cgg
+const char *Field_GetCompletionString() {
+	return completionString;
+}
+// !Cgg
+
 /*
 ===============
 FindMatches
@@ -3293,6 +3299,51 @@
 		return;
 	}
 
+	// Cgg - autocompletion on map names
+	if (!Q_stricmp(completionString, "map")
+		|| !Q_stricmp(completionString, "devmap")
+		|| !Q_stricmp(completionString, "vq3")
+		|| !Q_stricmp(completionString, "devvq3")
+		|| !Q_stricmp(completionString, "cpm")
+		|| !Q_stricmp(completionString, "devcpm")) {
+		const char *cmd;
+		cmd = Q_strlwr(Cmd_Argv(0));
+		completionString = Cmd_Argv(1);
+		if ( cmd[0] == '\\' || cmd[0] == '/' ) {
+			cmd++;
+		}
+		Maps_CommandCompletion(FindMatches);
+		Com_sprintf(completionField->buffer, sizeof(completionField->buffer), "\\%s %s", cmd, (shortestMatch[0]) ? shortestMatch : Cmd_Argv(1));
+		completionField->cursor = strlen(completionField->buffer);
+		if (matchCount < 2) {
+			return;
+		}
+		Com_Printf( "]%s\n", completionField->buffer );
+		Maps_CommandCompletion(PrintMatches);
+		return;
+	}
+	// !Cgg
+
+	// Cgg - autocompletion on demo names
+	if (!Q_stricmp(completionString, "demo")) {
+		const char *cmd;
+		cmd = Q_strlwr(Cmd_Argv(0));
+		completionString = Cmd_Argv(1);
+		if ( cmd[0] == '\\' || cmd[0] == '/' ) {
+			cmd++;
+		}
+		Demos_CommandCompletion(FindMatches);
+		Com_sprintf(completionField->buffer, sizeof(completionField->buffer), "\\%s %s", cmd, (shortestMatch[0]) ? shortestMatch : Cmd_Argv(1));
+		completionField->cursor = strlen(completionField->buffer);
+		if (matchCount < 2) {
+			return;
+		}
+		Com_Printf( "]%s\n", completionField->buffer );
+		Demos_CommandCompletion(PrintMatches);
+		return;
+	}
+	// !Cgg
+
 	Cmd_CommandCompletion( FindMatches );
 	Cvar_CommandCompletion( FindMatches );
 
Index: code/client/cl_main.c
===================================================================
--- code/client/cl_main.c	(revision 7)
+++ code/client/cl_main.c	(revision 27)
@@ -279,11 +279,11 @@
 		Com_Printf ("You must be in a level to record.\n");
 		return;
 	}
-
-  // sync 0 doesn't prevent recording, so not forcing it off .. everyone does g_sync 1 ; record ; g_sync 0 ..
+/* Cgg
+// sync 0 doesn't prevent recording, so not forcing it off .. everyone does g_sync 1 ; record ; g_sync 0 ..
 	if ( !Cvar_VariableValue( "g_synchronousClients" ) ) {
 		Com_Printf (S_COLOR_YELLOW "WARNING: You should set 'g_synchronousClients 1' for smoother demo recording\n");
-	}
+	}*/
 
 	if ( Cmd_Argc() == 2 ) {
 		s = Cmd_Argv(1);
Index: code/client/cl_scrn.c
===================================================================
--- code/client/cl_scrn.c	(revision 7)
+++ code/client/cl_scrn.c	(revision 27)
@@ -30,6 +30,7 @@
 cvar_t		*cl_graphheight;
 cvar_t		*cl_graphscale;
 cvar_t		*cl_graphshift;
+cvar_t		*cl_showRecording;	// Cgg
 
 /*
 ================
@@ -329,6 +330,12 @@
 	char	string[1024];
 	int		pos;
 
+	// Cgg - off by default
+	if (!cl_showRecording->integer) {
+		return;
+	}
+	// !Cgg
+
 	if ( !clc.demorecording ) {
 		return;
 	}
@@ -421,6 +428,7 @@
 	cl_graphheight = Cvar_Get ("graphheight", "32", CVAR_CHEAT);
 	cl_graphscale = Cvar_Get ("graphscale", "1", CVAR_CHEAT);
 	cl_graphshift = Cvar_Get ("graphshift", "0", CVAR_CHEAT);
+	cl_showRecording = Cvar_Get ("cl_showRecording", "0", CVAR_ARCHIVE);	// Cgg
 
 	scr_initialized = qtrue;
 }
