shithub: qk3

Download patch

ref: a8a53b1228ec040b0b449150b7d62b06a8c7f4e1
parent: 761946b93cf45a3b9e47868a704fb165af760333
author: qwx <>
date: Fri Jan 11 17:11:45 EST 2019

dedicated build hackjob

--- a/code/cgame/tr_types.h
+++ b/code/cgame/tr_types.h
@@ -213,7 +213,7 @@
 #elif defined(_WIN32)
 */
 
-#if defined(Q3_VM) || defined(_WIN32)
+#ifdef Q3_VM
 
 #define _3DFX_DRIVER_NAME	"3dfxvgl"
 #define OPENGL_DRIVER_NAME	"opengl32"
--- a/code/client/client.h
+++ b/code/client/client.h
@@ -25,8 +25,8 @@
 #include "../qcommon/qcommon.h"
 #include "../renderer/tr_public.h"
 #include "../ui/ui_public.h"
-#include "keys.h"
-#include "snd_public.h"
+#include "../client/keys.h"
+#include "../client/snd_public.h"
 #include "../cgame/cg_public.h"
 #include "../game/bg_public.h"
 
--- a/code/game/bg_public.h
+++ b/code/game/bg_public.h
@@ -90,9 +90,9 @@
 
 #define CS_MAX					(CS_PARTICLES+MAX_LOCATIONS)
 
-#if (CS_MAX) > MAX_CONFIGSTRINGS
-#error overflow: (CS_MAX) > MAX_CONFIGSTRINGS
-#endif
+//#if (CS_MAX) > MAX_CONFIGSTRINGS
+//#error overflow: (CS_MAX) > MAX_CONFIGSTRINGS
+//#endif
 
 typedef enum {
 	GT_FFA,				// free for all
--- a/code/game/q_math.c
+++ b/code/game/q_math.c
@@ -545,7 +545,7 @@
 
 //============================================================================
 
-#if !idppc
+#ifndef idppc
 /*
 ** float q_rsqrt( float number )
 */
@@ -738,9 +738,11 @@
 ==================
 */
 
+/*
 #if !( (defined __linux__ || __FreeBSD__) && (defined __i386__) && (!defined C_ONLY)) // rb010123
 
 #if defined __LCC__ || defined C_ONLY || !id386 || defined __VECTORC
+*/
 
 int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p)
 {
@@ -805,6 +807,7 @@
 
 	return sides;
 }
+/*
 #else
 #pragma warning( disable: 4035 )
 
@@ -1041,6 +1044,7 @@
 
 #endif
 #endif
+*/
 
 /*
 =================
--- a/code/game/q_shared.c
+++ b/code/game/q_shared.c
@@ -488,61 +488,6 @@
 }
 
 
-#if 0
-// no longer used
-/*
-===============
-COM_ParseInfos
-===============
-*/
-int COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] ) {
-	char	*token;
-	int		count;
-	char	key[MAX_TOKEN_CHARS];
-
-	count = 0;
-
-	while ( 1 ) {
-		token = COM_Parse( &buf );
-		if ( !token[0] ) {
-			break;
-		}
-		if ( strcmp( token, "{" ) ) {
-			Com_Printf( "Missing { in info file\n" );
-			break;
-		}
-
-		if ( count == max ) {
-			Com_Printf( "Max infos exceeded\n" );
-			break;
-		}
-
-		infos[count][0] = 0;
-		while ( 1 ) {
-			token = COM_ParseExt( &buf, qtrue );
-			if ( !token[0] ) {
-				Com_Printf( "Unexpected end of info file\n" );
-				break;
-			}
-			if ( !strcmp( token, "}" ) ) {
-				break;
-			}
-			Q_strncpyz( key, token, sizeof( key ) );
-
-			token = COM_ParseExt( &buf, qfalse );
-			if ( !token[0] ) {
-				strcpy( token, "<NULL>" );
-			}
-			Info_SetValueForKey( infos[count], key, token );
-		}
-		count++;
-	}
-
-	return count;
-}
-#endif
-
-
 /*
 ==================
 COM_MatchToken
--- a/code/game/q_shared.h
+++ b/code/game/q_shared.h
@@ -80,16 +80,12 @@
 
 #else
 
-#include <assert.h>
-#include <math.h>
+#include <u.h>
+#include <libc.h>
 #include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdlib.h>
-#include <time.h>
-#include <ctype.h>
-#include <limits.h>
 
+typedef unsigned long size_t;
+
 #endif
 
 #ifdef _WIN32
@@ -98,26 +94,6 @@
 
 #endif
 
-
-// this is the define for determining if we have an asm version of a C function
-#if (defined _M_IX86 || defined __i386__) && !defined __sun__  && !defined __LCC__
-#define id386	1
-#else
-#define id386	0
-#endif
-
-#if (defined(powerc) || defined(powerpc) || defined(ppc) || defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY)
-#define idppc	1
-#if defined(__VEC__)
-#define idppc_altivec 1
-#else
-#define idppc_altivec 0
-#endif
-#else
-#define idppc	0
-#define idppc_altivec 0
-#endif
-
 // for windows fastcall option
 
 #define	QDECL
@@ -126,139 +102,18 @@
 int		LongSwap (int l);
 float	FloatSwap (const float *f);
 
-//======================= WIN32 DEFINES =================================
-
-#ifdef WIN32
-
-#define	MAC_STATIC
-
-#undef QDECL
-#define	QDECL	__cdecl
-
-// buildstring will be incorporated into the version string
-#ifdef NDEBUG
-#ifdef _M_IX86
-#define	CPUSTRING	"win-x86"
-#elif defined _M_ALPHA
-#define	CPUSTRING	"win-AXP"
-#endif
-#else
-#ifdef _M_IX86
-#define	CPUSTRING	"win-x86-debug"
-#elif defined _M_ALPHA
-#define	CPUSTRING	"win-AXP-debug"
-#endif
-#endif
-
-#define ID_INLINE __inline 
-
-static ID_INLINE short BigShort( short l) { return ShortSwap(l); }
-#define LittleShort
-static ID_INLINE int BigLong(int l) { LongSwap(l); }
-#define LittleLong
-static ID_INLINE float BigFloat(const float *l) { FloatSwap(l); }
-#define LittleFloat
-
-#define	PATH_SEP '\\'
-
-#endif
-
-//======================= MAC OS X DEFINES =====================
-
-#if defined(MACOS_X)
-
-#define MAC_STATIC
-#define __cdecl
-#define __declspec(x)
-#define stricmp strcasecmp
-#define ID_INLINE inline 
-
-#ifdef __ppc__
-#define CPUSTRING	"MacOSX-ppc"
-#elif defined __i386__
-#define CPUSTRING	"MacOSX-i386"
-#else
-#define CPUSTRING	"MacOSX-other"
-#endif
-
-#define	PATH_SEP	'/'
-
-#define __rlwimi(out, in, shift, maskBegin, maskEnd) asm("rlwimi %0,%1,%2,%3,%4" : "=r" (out) : "r" (in), "i" (shift), "i" (maskBegin), "i" (maskEnd))
-#define __dcbt(addr, offset) asm("dcbt %0,%1" : : "b" (addr), "r" (offset))
-
-static inline unsigned int __lwbrx(register void *addr, register int offset) {
-    register unsigned int word;
-    
-    asm("lwbrx %0,%2,%1" : "=r" (word) : "r" (addr), "b" (offset));
-    return word;
-}
-
-static inline unsigned short __lhbrx(register void *addr, register int offset) {
-    register unsigned short halfword;
-    
-    asm("lhbrx %0,%2,%1" : "=r" (halfword) : "r" (addr), "b" (offset));
-    return halfword;
-}
-
-static inline float __fctiw(register float f) {
-    register float fi;
-    
-    asm("fctiw %0,%1" : "=f" (fi) : "f" (f));
-
-    return fi;
-}
-
-#define BigShort
-static inline short LittleShort(short l) { return ShortSwap(l); }
-#define BigLong
-static inline int LittleLong (int l) { return LongSwap(l); }
-#define BigFloat
-static inline float LittleFloat (const float l) { return FloatSwap(&l); }
-
-#endif
-
-//======================= MAC DEFINES =================================
-
-#ifdef __MACOS__
-
-#include <MacTypes.h>
-#define	MAC_STATIC
-#define ID_INLINE inline 
-
-#define	CPUSTRING	"MacOS-PPC"
-
-#define	PATH_SEP ':'
-
-void Sys_PumpEvents( void );
-
-#define BigShort
-static inline short LittleShort(short l) { return ShortSwap(l); }
-#define BigLong
-static inline int LittleLong (int l) { return LongSwap(l); }
-#define BigFloat
-static inline float LittleFloat (const float l) { return FloatSwap(&l); }
-
-#endif
-
 //======================= LINUX DEFINES =================================
 
 // the mac compiler can't handle >32k of locals, so we
 // just waste space and make big arrays static...
-#ifdef __linux__
 
 // bk001205 - from Makefile
-#define stricmp strcasecmp
+#define stricmp cistrcmp
 
 #define	MAC_STATIC // bk: FIXME
-#define ID_INLINE inline 
+#define ID_INLINE 
 
-#ifdef __i386__
-#define	CPUSTRING	"linux-i386"
-#elif defined __axp__
-#define	CPUSTRING	"linux-alpha"
-#else
-#define	CPUSTRING	"linux-other"
-#endif
+#define	CPUSTRING	"plan9"
 
 #define	PATH_SEP '/'
 
@@ -270,7 +125,7 @@
 #define	BOTLIB_HARD_LINKED
 #endif
 
-#if !idppc
+#ifndef idppc
 inline static short BigShort( short l) { return ShortSwap(l); }
 #define LittleShort
 inline static int BigLong(int l) { return LongSwap(l); }
@@ -286,46 +141,6 @@
 inline static float LittleFloat (const float *l) { return FloatSwap(l); }
 #endif
 
-#endif
-
-//======================= FreeBSD DEFINES =====================
-#ifdef __FreeBSD__ // rb010123
-
-#define stricmp strcasecmp
-
-#define MAC_STATIC
-#define ID_INLINE inline 
-
-#ifdef __i386__
-#define CPUSTRING       "freebsd-i386"
-#elif defined __axp__
-#define CPUSTRING       "freebsd-alpha"
-#else
-#define CPUSTRING       "freebsd-other"
-#endif
-
-#define	PATH_SEP '/'
-
-// bk010116 - omitted Q3STATIC (see Linux above), broken target
-
-#if !idppc
-static short BigShort( short l) { return ShortSwap(l); }
-#define LittleShort
-static int BigLong(int l) { LongSwap(l); }
-#define LittleLong
-static float BigFloat(const float *l) { FloatSwap(l); }
-#define LittleFloat
-#else
-#define BigShort
-static short LittleShort(short l) { return ShortSwap(l); }
-#define BigLong
-static int LittleLong (int l) { return LongSwap(l); }
-#define BigFloat
-static float LittleFloat (const float *l) { return FloatSwap(l); }
-#endif
-
-#endif
-
 //=============================================================
 
 typedef unsigned char 		byte;
@@ -437,9 +252,11 @@
 #define UI_INVERSE		0x00002000
 #define UI_PULSE		0x00004000
 
-#if defined(_DEBUG) && !defined(BSPC)
+#ifdef _DEBUG
+#ifndef BSPC
 	#define HUNK_DEBUG
 #endif
+#endif
 
 typedef enum {
 	h_high,
@@ -462,7 +279,7 @@
 #define Snd_Memset Com_Memset
 #endif
 
-#if !( defined __VECTORC )
+#ifndef __VECTORC
 void Com_Memset (void* dest, const int val, const size_t count);
 void Com_Memcpy (void* dest, const void* src, const size_t count);
 #else
@@ -570,7 +387,7 @@
 
 #define	IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
 
-#if idppc
+#ifdef idppc
 
 static inline float Q_rsqrt( float number ) {
 		float x = 0.5f * number;
@@ -608,8 +425,6 @@
 int DirToByte( vec3_t dir );
 void ByteToDir( int b, vec3_t dir );
 
-#if	1
-
 #define DotProduct(x,y)			((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
 #define VectorSubtract(a,b,c)	((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])
 #define VectorAdd(a,b,c)		((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])
@@ -617,17 +432,6 @@
 #define	VectorScale(v, s, o)	((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))
 #define	VectorMA(v, s, b, o)	((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))
 
-#else
-
-#define DotProduct(x,y)			_DotProduct(x,y)
-#define VectorSubtract(a,b,c)	_VectorSubtract(a,b,c)
-#define VectorAdd(a,b,c)		_VectorAdd(a,b,c)
-#define VectorCopy(a,b)			_VectorCopy(a,b)
-#define	VectorScale(v, s, o)	_VectorScale(v,s,o)
-#define	VectorMA(v, s, b, o)	_VectorMA(v,s,b,o)
-
-#endif
-
 #ifdef __LCC__
 #ifdef VectorCopy
 #undef VectorCopy
@@ -989,7 +793,7 @@
 ==============================================================
 */
 
-#include "surfaceflags.h"			// shared with the q3map utility
+#include "../game/surfaceflags.h"			// shared with the q3map utility
 
 // plane types are used to speed some tests
 // 0-2 are axial planes
--- /dev/null
+++ b/code/mkfile
@@ -1,0 +1,86 @@
+</$objtype/mkfile
+BIN=$home/bin/$objtype
+TARG=q3ded
+
+OFILES=\
+	null/null_client.$O\
+	null/null_input.$O\
+	null/null_snddma.$O\
+	server/sv_bot.$O\
+	server/sv_ccmds.$O\
+	server/sv_client.$O\
+	server/sv_game.$O\
+	server/sv_init.$O\
+	server/sv_main.$O\
+	server/sv_net_chan.$O\
+	server/sv_snapshot.$O\
+	server/sv_world.$O\
+	qcommon/cm_load.$O\
+	qcommon/cm_patch.$O\
+	qcommon/cm_polylib.$O\
+	qcommon/cm_test.$O\
+	qcommon/cm_trace.$O\
+	qcommon/cmd.$O\
+	qcommon/common.$O\
+	qcommon/cvar.$O\
+	qcommon/files.$O\
+	qcommon/huffman.$O\
+	qcommon/md4.$O\
+	qcommon/msg.$O\
+	qcommon/net_chan.$O\
+	qcommon/unzip.$O\
+	qcommon/vm.$O\
+	qcommon/vm_interpreted.$O\
+	game/q_math.$O\
+	game/q_shared.$O\
+	unix/qk3ded.$O\
+	unix/linux_common.$O\
+	unix/unix_net.$O\
+	unix/unix_shared.$O\
+	unix/linux_signals.$O\
+
+HFILES=\
+	game/ai_chat.h\
+	game/ai_cmd.h\
+	game/ai_dmnet.h\
+	game/ai_dmq3.h\
+	game/ai_main.h\
+	game/ai_team.h\
+	game/ai_vcmd.h\
+	game/be_aas.h\
+	game/be_ai_char.h\
+	game/be_ai_chat.h\
+	game/be_ai_gen.h\
+	game/be_ai_goal.h\
+	game/be_ai_move.h\
+	game/be_ai_weap.h\
+	game/be_ea.h\
+	game/bg_lib.h\
+	game/bg_local.h\
+	game/bg_public.h\
+	game/botlib.h\
+	game/chars.h\
+	game/g_local.h\
+	game/g_public.h\
+	game/g_rankings.h\
+	game/g_team.h\
+	game/inv.h\
+	game/match.h\
+	game/q_shared.h\
+	game/surfaceflags.h\
+	game/syn.h\
+	qcommon/cm_local.h\
+	qcommon/cm_patch.h\
+	qcommon/cm_polylib.h\
+	qcommon/cm_public.h\
+	qcommon/qcommon.h\
+	qcommon/qfiles.h\
+	qcommon/unzip.h\
+	qcommon/vm_local.h\
+	server/server.h\
+	unix/linux_local.h\
+	unix/qasm.h\
+	unix/unix_glw.h\
+
+</sys/src/cmd/mkone
+CFLAGS=$CFLAGS -DDEDICATED -DC_ONLY
--- a/code/qcommon/cm_patch.c
+++ b/code/qcommon/cm_patch.c
@@ -1746,26 +1746,4 @@
 		VectorCopy( debugBlockPoints[0], v[2] );
 		drawPoly( 2, 3, v[0] );
 	}
-
-#if 0
-	vec3_t			v[4];
-
-	v[0][0] = pc->bounds[1][0];
-	v[0][1] = pc->bounds[1][1];
-	v[0][2] = pc->bounds[1][2];
-
-	v[1][0] = pc->bounds[1][0];
-	v[1][1] = pc->bounds[0][1];
-	v[1][2] = pc->bounds[1][2];
-
-	v[2][0] = pc->bounds[0][0];
-	v[2][1] = pc->bounds[0][1];
-	v[2][2] = pc->bounds[1][2];
-
-	v[3][0] = pc->bounds[0][0];
-	v[3][1] = pc->bounds[1][1];
-	v[3][2] = pc->bounds[1][2];
-
-	drawPoly( 4, v[0] );
-#endif
 }
--- a/code/qcommon/cm_public.h
+++ b/code/qcommon/cm_public.h
@@ -20,7 +20,7 @@
 ===========================================================================
 */
 
-#include "qfiles.h"
+#include "../qcommon/qfiles.h"
 
 
 void		CM_LoadMap( const char *name, qboolean clientload, int *checksum);
--- a/code/qcommon/cm_test.c
+++ b/code/qcommon/cm_test.c
@@ -119,15 +119,6 @@
 		}
 		((cbrush_t **)ll->list)[ ll->count++ ] = b;
 	}
-#if 0
-	// store patches?
-	for ( k = 0 ; k < leaf->numLeafSurfaces ; k++ ) {
-		patch = cm.surfaces[ cm.leafsurfaces[ leaf->firstleafsurface + k ] ];
-		if ( !patch ) {
-			continue;
-		}
-	}
-#endif
 }
 
 /*
--- a/code/qcommon/cm_trace.c
+++ b/code/qcommon/cm_trace.c
@@ -1060,17 +1060,6 @@
 		if ( tw->isPoint ) {
 			offset = 0;
 		} else {
-#if 0 // bk010201 - DEAD
-			// an axial brush right behind a slanted bsp plane
-			// will poke through when expanded, so adjust
-			// by sqrt(3)
-			offset = fabs(tw->extents[0]*plane->normal[0]) +
-				fabs(tw->extents[1]*plane->normal[1]) +
-				fabs(tw->extents[2]*plane->normal[2]);
-
-			offset *= 2;
-			offset = tw->maxOffset;
-#endif
 			// this is silly
 			offset = 2048;
 		}
--- a/code/qcommon/common.c
+++ b/code/qcommon/common.c
@@ -23,16 +23,6 @@
 
 #include "../game/q_shared.h"
 #include "qcommon.h"
-#include <setjmp.h>
-#ifdef __linux__
-#include <netinet/in.h>
-#else
-#if defined(MACOS_X)
-#include <netinet/in.h>
-#else
-#include <winsock.h>
-#endif
-#endif
 
 int demo_protocols[] =
 { 66, 67, 68, 0 };
@@ -81,9 +71,6 @@
 cvar_t	*cl_paused;
 cvar_t	*sv_paused;
 cvar_t	*com_cameraMode;
-#if defined(_WIN32) && defined(_DEBUG)
-cvar_t	*com_noErrorInterrupt;
-#endif
 
 // com_speeds times
 int		time_game;
@@ -174,13 +161,11 @@
     // TTimo: only open the qconsole.log if the filesystem is in an initialized state
     //   also, avoid recursing in the qconsole.log opening (i.e. if fs_debug is on)
 		if ( !logfile && FS_Initialized() && !opening_qconsole) {
-			struct tm *newtime;
-			time_t aclock;
+			Tm *newtime;
 
       opening_qconsole = qtrue;
 
-			time( &aclock );
-			newtime = localtime( &aclock );
+			newtime = localtime( time( nil ) );
 
 			logfile = FS_FOpenFileWrite( "qconsole.log" );
 			Com_Printf( "logfile opened on %s\n", asctime( newtime ) );
@@ -235,16 +220,6 @@
 	static int	errorCount;
 	int			currentTime;
 
-#if defined(_WIN32) && defined(_DEBUG)
-	if ( code != ERR_DISCONNECT && code != ERR_NEED_CD ) {
-		if (!com_noErrorInterrupt->integer) {
-			__asm {
-				int 0x03
-			}
-		}
-	}
-#endif
-
 	// when we are running automated scripts, make sure we
 	// know if anything failed
 	if ( com_buildScript && com_buildScript->integer ) {
@@ -682,23 +657,23 @@
 ================
 */
 int Com_RealTime(qtime_t *qtime) {
-	time_t t;
-	struct tm *tms;
+	long t;
+	Tm *tms;
 
-	t = time(NULL);
+	t = time(nil);
 	if (!qtime)
 		return t;
-	tms = localtime(&t);
+	tms = localtime(t);
 	if (tms) {
-		qtime->tm_sec = tms->tm_sec;
-		qtime->tm_min = tms->tm_min;
-		qtime->tm_hour = tms->tm_hour;
-		qtime->tm_mday = tms->tm_mday;
-		qtime->tm_mon = tms->tm_mon;
-		qtime->tm_year = tms->tm_year;
-		qtime->tm_wday = tms->tm_wday;
-		qtime->tm_yday = tms->tm_yday;
-		qtime->tm_isdst = tms->tm_isdst;
+		qtime->tm_sec = tms->sec;
+		qtime->tm_min = tms->min;
+		qtime->tm_hour = tms->hour;
+		qtime->tm_mday = tms->mday;
+		qtime->tm_mon = tms->mon;
+		qtime->tm_year = tms->year;
+		qtime->tm_wday = tms->wday;
+		qtime->tm_yday = tms->yday;
+		qtime->tm_isdst = 0;
 	}
 	return t;
 }
@@ -2351,7 +2326,7 @@
 void Com_Init( char *commandLine ) {
 	char	*s;
 
-	Com_Printf( "%s %s %s\n", Q3_VERSION, CPUSTRING, __DATE__ );
+	Com_Printf( "%s %s\n", Q3_VERSION, CPUSTRING);
 
 	if ( setjmp (abortframe) ) {
 		Sys_Error ("Error during initialization");
@@ -2439,10 +2414,6 @@
 
 	com_introPlayed = Cvar_Get( "com_introplayed", "0", CVAR_ARCHIVE);
 
-#if defined(_WIN32) && defined(_DEBUG)
-	com_noErrorInterrupt = Cvar_Get( "com_noErrorInterrupt", "0", 0 );
-#endif
-
 	if ( com_dedicated->integer ) {
 		if ( !com_viewlog->integer ) {
 			Cvar_Set( "viewlog", "1" );
@@ -2458,7 +2429,7 @@
 	Cmd_AddCommand ("changeVectors", MSG_ReportChangeVectors_f );
 	Cmd_AddCommand ("writeconfig", Com_WriteConfig_f );
 
-	s = va("%s %s %s", Q3_VERSION, CPUSTRING, __DATE__ );
+	s = va("%s %s", Q3_VERSION, CPUSTRING);
 	com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );
 
 	Sys_Init();
@@ -2815,10 +2786,6 @@
 
 }
 
-#if !( defined __VECTORC )
-#if !( defined __linux__ || defined __FreeBSD__ )  // r010123 - include FreeBSD 
-#if ((!id386) && (!defined __i386__)) // rcg010212 - for PPC
-
 void Com_Memcpy (void* dest, const void* src, const size_t count)
 {
 	memcpy(dest, src, count);
@@ -2829,307 +2796,6 @@
 	memset(dest, val, count);
 }
 
-#else
-
-typedef enum
-{
-	PRE_READ,									// prefetch assuming that buffer is used for reading only
-	PRE_WRITE,									// prefetch assuming that buffer is used for writing only
-	PRE_READ_WRITE								// prefetch assuming that buffer is used for both reading and writing
-} e_prefetch;
-
-void Com_Prefetch (const void *s, const unsigned int bytes, e_prefetch type);
-
-#define EMMS_INSTRUCTION	__asm emms
-
-void _copyDWord (unsigned int* dest, const unsigned int constant, const unsigned int count) {
-	__asm
-	{
-			mov		edx,dest
-			mov		eax,constant
-			mov		ecx,count
-			and		ecx,~7
-			jz		padding
-			sub		ecx,8
-			jmp		loopu
-			align	16
-loopu:		
-			test	[edx+ecx*4 + 28],ebx		// fetch next block destination to L1 cache
-			mov		[edx+ecx*4 + 0],eax
-			mov		[edx+ecx*4 + 4],eax
-			mov		[edx+ecx*4 + 8],eax
-			mov		[edx+ecx*4 + 12],eax
-			mov		[edx+ecx*4 + 16],eax
-			mov		[edx+ecx*4 + 20],eax
-			mov		[edx+ecx*4 + 24],eax
-			mov		[edx+ecx*4 + 28],eax
-			sub		ecx,8
-			jge		loopu
-padding:	mov		ecx,count
-			mov		ebx,ecx
-			and		ecx,7
-			jz		outta
-			and		ebx,~7
-			lea		edx,[edx+ebx*4]				// advance dest pointer
-			test	[edx+0],eax					// fetch destination to L1 cache
-			cmp		ecx,4
-			jl		skip4
-			mov		[edx+0],eax
-			mov		[edx+4],eax
-			mov		[edx+8],eax
-			mov		[edx+12],eax
-			add		edx,16
-			sub		ecx,4
-skip4:		cmp		ecx,2
-			jl		skip2
-			mov		[edx+0],eax
-			mov		[edx+4],eax
-			add		edx,8
-			sub		ecx,2
-skip2:		cmp		ecx,1
-			jl		outta
-			mov		[edx+0],eax
-outta:
-	}
-}
-
-// optimized memory copy routine that handles all alignment
-// cases and block sizes efficiently
-void Com_Memcpy (void* dest, const void* src, const size_t count) {
-	Com_Prefetch (src, count, PRE_READ);
-	__asm
-	{
-		push	edi
-		push	esi
-		mov		ecx,count
-		cmp		ecx,0						// count = 0 check (just to be on the safe side)
-		je		outta
-		mov		edx,dest
-		mov		ebx,src
-		cmp		ecx,32						// padding only?
-		jl		padding
-
-		mov		edi,ecx					
-		and		edi,~31					// edi = count&~31
-		sub		edi,32
-
-		align 16
-loopMisAligned:
-		mov		eax,[ebx + edi + 0 + 0*8]
-		mov		esi,[ebx + edi + 4 + 0*8]
-		mov		[edx+edi+0 + 0*8],eax
-		mov		[edx+edi+4 + 0*8],esi
-		mov		eax,[ebx + edi + 0 + 1*8]
-		mov		esi,[ebx + edi + 4 + 1*8]
-		mov		[edx+edi+0 + 1*8],eax
-		mov		[edx+edi+4 + 1*8],esi
-		mov		eax,[ebx + edi + 0 + 2*8]
-		mov		esi,[ebx + edi + 4 + 2*8]
-		mov		[edx+edi+0 + 2*8],eax
-		mov		[edx+edi+4 + 2*8],esi
-		mov		eax,[ebx + edi + 0 + 3*8]
-		mov		esi,[ebx + edi + 4 + 3*8]
-		mov		[edx+edi+0 + 3*8],eax
-		mov		[edx+edi+4 + 3*8],esi
-		sub		edi,32
-		jge		loopMisAligned
-		
-		mov		edi,ecx
-		and		edi,~31
-		add		ebx,edi					// increase src pointer
-		add		edx,edi					// increase dst pointer
-		and		ecx,31					// new count
-		jz		outta					// if count = 0, get outta here
-
-padding:
-		cmp		ecx,16
-		jl		skip16
-		mov		eax,dword ptr [ebx]
-		mov		dword ptr [edx],eax
-		mov		eax,dword ptr [ebx+4]
-		mov		dword ptr [edx+4],eax
-		mov		eax,dword ptr [ebx+8]
-		mov		dword ptr [edx+8],eax
-		mov		eax,dword ptr [ebx+12]
-		mov		dword ptr [edx+12],eax
-		sub		ecx,16
-		add		ebx,16
-		add		edx,16
-skip16:
-		cmp		ecx,8
-		jl		skip8
-		mov		eax,dword ptr [ebx]
-		mov		dword ptr [edx],eax
-		mov		eax,dword ptr [ebx+4]
-		sub		ecx,8
-		mov		dword ptr [edx+4],eax
-		add		ebx,8
-		add		edx,8
-skip8:
-		cmp		ecx,4
-		jl		skip4
-		mov		eax,dword ptr [ebx]	// here 4-7 bytes
-		add		ebx,4
-		sub		ecx,4
-		mov		dword ptr [edx],eax
-		add		edx,4
-skip4:							// 0-3 remaining bytes
-		cmp		ecx,2
-		jl		skip2
-		mov		ax,word ptr [ebx]	// two bytes
-		cmp		ecx,3				// less than 3?
-		mov		word ptr [edx],ax
-		jl		outta
-		mov		al,byte ptr [ebx+2]	// last byte
-		mov		byte ptr [edx+2],al
-		jmp		outta
-skip2:
-		cmp		ecx,1
-		jl		outta
-		mov		al,byte ptr [ebx]
-		mov		byte ptr [edx],al
-outta:
-		pop		esi
-		pop		edi
-	}
-}
-
-void Com_Memset (void* dest, const int val, const size_t count)
-{
-	unsigned int fillval;
-
-	if (count < 8)
-	{
-		__asm
-		{
-			mov		edx,dest
-			mov		eax, val
-			mov		ah,al
-			mov		ebx,eax
-			and		ebx, 0xffff
-			shl		eax,16
-			add		eax,ebx				// eax now contains pattern
-			mov		ecx,count
-			cmp		ecx,4
-			jl		skip4
-			mov		[edx],eax			// copy first dword
-			add		edx,4
-			sub		ecx,4
-	skip4:	cmp		ecx,2
-			jl		skip2
-			mov		word ptr [edx],ax	// copy 2 bytes
-			add		edx,2
-			sub		ecx,2
-	skip2:	cmp		ecx,0
-			je		skip1
-			mov		byte ptr [edx],al	// copy single byte
-	skip1:
-		}
-		return;
-	}
-
-	fillval = val;
-	
-	fillval = fillval|(fillval<<8);
-	fillval = fillval|(fillval<<16);		// fill dword with 8-bit pattern
-
-	_copyDWord ((unsigned int*)(dest),fillval, count/4);
-	
-	__asm									// padding of 0-3 bytes
-	{
-		mov		ecx,count
-		mov		eax,ecx
-		and		ecx,3
-		jz		skipA
-		and		eax,~3
-		mov		ebx,dest
-		add		ebx,eax
-		mov		eax,fillval
-		cmp		ecx,2
-		jl		skipB
-		mov		word ptr [ebx],ax
-		cmp		ecx,2
-		je		skipA					
-		mov		byte ptr [ebx+2],al		
-		jmp		skipA
-skipB:		
-		cmp		ecx,0
-		je		skipA
-		mov		byte ptr [ebx],al
-skipA:
-	}
-}
-
-qboolean Com_Memcmp (const void *src0, const void *src1, const unsigned int count)
-{
-	unsigned int i;
-	// MMX version anyone?
-
-	if (count >= 16)
-	{
-		unsigned int *dw = (unsigned int*)(src0);
-		unsigned int *sw = (unsigned int*)(src1);
-
-		unsigned int nm2 = count/16;
-		for (i = 0; i < nm2; i+=4)
-		{
-			unsigned int tmp = (dw[i+0]-sw[i+0])|(dw[i+1]-sw[i+1])|
-						  (dw[i+2]-sw[i+2])|(dw[i+3]-sw[i+3]);
-			if (tmp)
-				return qfalse;
-		}
-	}
-	if (count & 15)
-	{
-		byte *d = (byte*)src0;
-		byte *s = (byte*)src1;
-		for (i = count & 0xfffffff0; i < count; i++)
-		if (d[i]!=s[i])
-			return qfalse;
-	}
-
-	return qtrue;
-}
-
-void Com_Prefetch (const void *s, const unsigned int bytes, e_prefetch type)
-{
-	// write buffer prefetching is performed only if
-	// the processor benefits from it. Read and read/write
-	// prefetching is always performed.
-
-	switch (type)
-	{
-		case PRE_WRITE : break;
-		case PRE_READ:
-		case PRE_READ_WRITE:
-
-		__asm
-		{
-			mov		ebx,s
-			mov		ecx,bytes
-			cmp		ecx,4096				// clamp to 4kB
-			jle		skipClamp
-			mov		ecx,4096
-skipClamp:
-			add		ecx,0x1f
-			shr		ecx,5					// number of cache lines
-			jz		skip
-			jmp		loopie
-
-			align 16
-	loopie:	test	byte ptr [ebx],al
-			add		ebx,32
-			dec		ecx
-			jnz		loopie
-	skip:
-		}
-
-		break;
-	}
-}
-#endif
-#endif 
-#endif // bk001208 - memset/memcpy assembly, Q_acos needed (RC4)
 //------------------------------------------------------------------------
 
 
--- a/code/qcommon/cvar.c
+++ b/code/qcommon/cvar.c
@@ -197,12 +197,6 @@
 		var_name = "BADNAME";
 	}
 
-#if 0		// FIXME: values with backslash happen
-	if ( !Cvar_ValidateString( var_value ) ) {
-		Com_Printf("invalid cvar value string: %s\n", var_value );
-		var_value = "BADVALUE";
-	}
-#endif
 
 	var = Cvar_FindVar (var_name);
 	if ( var ) {
@@ -238,14 +232,6 @@
 			Cvar_Set2( var_name, s, qtrue );
 			Z_Free( s );
 		}
-
-// use a CVAR_SET for rom sets, get won't override
-#if 0
-		// CVAR_ROM always overrides
-		if ( flags & CVAR_ROM ) {
-			Cvar_Set2( var_name, var_value, qtrue );
-		}
-#endif
 		return var;
 	}
 
@@ -292,13 +278,6 @@
 		Com_Printf("invalid cvar name string: %s\n", var_name );
 		var_name = "BADNAME";
 	}
-
-#if 0	// FIXME
-	if ( value && !Cvar_ValidateString( value ) ) {
-		Com_Printf("invalid cvar value string: %s\n", value );
-		var_value = "BADVALUE";
-	}
-#endif
 
 	var = Cvar_FindVar (var_name);
 	if (!var) {
--- a/code/qcommon/files.c
+++ b/code/qcommon/files.c
@@ -321,7 +321,7 @@
 ==============
 */
 
-qboolean FS_Initialized() {
+qboolean FS_Initialized(void) {
 	return (fs_searchpaths != NULL);
 }
 
@@ -354,7 +354,7 @@
 return load stack
 =================
 */
-int FS_LoadStack()
+int FS_LoadStack(void)
 {
 	return fs_loadStack;
 }
@@ -741,7 +741,21 @@
 	return 0;
 }
 
+static int
+rename(char *old, char *new)
+{
+	char *p;
+	Dir d;
 
+	if((p = strrchr(new, '/')) == nil)
+		p = new;
+	else
+		p++;
+	nulldir(&d);
+	d.name = p;
+	return dirwstat(old, &d) < 0;
+}
+
 /*
 ===========
 FS_SV_Rename
@@ -2699,7 +2713,7 @@
   this can lead to misleading situations, see https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=540
 ================
 */
-static void FS_ReorderPurePaks()
+static void FS_ReorderPurePaks(void)
 {
 	searchpath_t *s;
 	int i;
--- a/code/qcommon/md4.c
+++ b/code/qcommon/md4.c
@@ -1,9 +1,8 @@
 /* GLOBAL.H - RSAREF types and constants */
 
-#include <string.h>
-#if defined(_WIN32)
-#pragma warning(disable : 4711)		// selected for automatic inline expansion
-#endif
+#include <u.h>
+#include <libc.h>
+typedef unsigned long size_t;
 
 /* POINTER defines a generic pointer type */
 typedef unsigned char *POINTER;
@@ -21,9 +20,9 @@
 
 All rights reserved.
   
-License to copy and use this software is granted provided that it is identified as the �RSA Data Security, Inc. MD4 Message-Digest Algorithm� in all material mentioning or referencing this software or this function.
-License is also granted to make and use derivative works provided that such works are identified as �derived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm� in all material mentioning or referencing the derived work.
-RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided �as is� without express or implied warranty of any kind.
+License to copy and use this software is granted provided that it is identified as the �RSA Data Security, Inc. MD4 Message-Digest Algorithm� in all material mentioning or referencing this software or this function.
+License is also granted to make and use derivative works provided that such works are identified as �derived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm� in all material mentioning or referencing the derived work.
+RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided �as is� without express or implied warranty of any kind.
   
 These notices must be retained in any copies of any part of this documentation and/or software. */
 
--- a/code/qcommon/msg.c
+++ b/code/qcommon/msg.c
@@ -39,7 +39,7 @@
 
 int oldsize = 0;
 
-void MSG_initHuffman();
+void MSG_initHuffman(void);
 
 void MSG_Init( msg_t *buf, byte *data, int length ) {
 	if (!msgInit) {
@@ -785,57 +785,57 @@
 
 netField_t	entityStateFields[] = 
 {
-{ NETF(pos.trTime), 32 },
-{ NETF(pos.trBase[0]), 0 },
-{ NETF(pos.trBase[1]), 0 },
-{ NETF(pos.trDelta[0]), 0 },
-{ NETF(pos.trDelta[1]), 0 },
-{ NETF(pos.trBase[2]), 0 },
-{ NETF(apos.trBase[1]), 0 },
-{ NETF(pos.trDelta[2]), 0 },
-{ NETF(apos.trBase[0]), 0 },
-{ NETF(event), 10 },
-{ NETF(angles2[1]), 0 },
-{ NETF(eType), 8 },
-{ NETF(torsoAnim), 8 },
-{ NETF(eventParm), 8 },
-{ NETF(legsAnim), 8 },
-{ NETF(groundEntityNum), GENTITYNUM_BITS },
-{ NETF(pos.trType), 8 },
-{ NETF(eFlags), 19 },
-{ NETF(otherEntityNum), GENTITYNUM_BITS },
-{ NETF(weapon), 8 },
-{ NETF(clientNum), 8 },
-{ NETF(angles[1]), 0 },
-{ NETF(pos.trDuration), 32 },
-{ NETF(apos.trType), 8 },
-{ NETF(origin[0]), 0 },
-{ NETF(origin[1]), 0 },
-{ NETF(origin[2]), 0 },
-{ NETF(solid), 24 },
-{ NETF(powerups), 16 },
-{ NETF(modelindex), 8 },
-{ NETF(otherEntityNum2), GENTITYNUM_BITS },
-{ NETF(loopSound), 8 },
-{ NETF(generic1), 8 },
-{ NETF(origin2[2]), 0 },
-{ NETF(origin2[0]), 0 },
-{ NETF(origin2[1]), 0 },
-{ NETF(modelindex2), 8 },
-{ NETF(angles[0]), 0 },
-{ NETF(time), 32 },
-{ NETF(apos.trTime), 32 },
-{ NETF(apos.trDuration), 32 },
-{ NETF(apos.trBase[2]), 0 },
-{ NETF(apos.trDelta[0]), 0 },
-{ NETF(apos.trDelta[1]), 0 },
-{ NETF(apos.trDelta[2]), 0 },
-{ NETF(time2), 32 },
-{ NETF(angles[2]), 0 },
-{ NETF(angles2[0]), 0 },
-{ NETF(angles2[2]), 0 },
-{ NETF(constantLight), 32 },
-{ NETF(frame), 16 }
+{ "pos.trTime",(int)&((entityState_t*)0)->pos.trTime, 32 },
+{ "pos.trBase[0]",(int)&((entityState_t*)0)->pos.trBase[0], 0 },
+{ "pos.trBase[1]",(int)&((entityState_t*)0)->pos.trBase[1], 0 },
+{ "pos.trDelta[0]",(int)&((entityState_t*)0)->pos.trDelta[0], 0 },
+{ "pos.trDelta[1]",(int)&((entityState_t*)0)->pos.trDelta[1], 0 },
+{ "pos.trBase[2]",(int)&((entityState_t*)0)->pos.trBase[2], 0 },
+{ "apos.trBase[1]",(int)&((entityState_t*)0)->apos.trBase[1], 0 },
+{ "pos.trDelta[2]",(int)&((entityState_t*)0)->pos.trDelta[2], 0 },
+{ "apos.trBase[0]",(int)&((entityState_t*)0)->apos.trBase[0], 0 },
+{ "event",(int)&((entityState_t*)0)->event, 10 },
+{ "angles2[1]",(int)&((entityState_t*)0)->angles2[1], 0 },
+{ "eType",(int)&((entityState_t*)0)->eType, 8 },
+{ "torsoAnim",(int)&((entityState_t*)0)->torsoAnim, 8 },
+{ "eventParm",(int)&((entityState_t*)0)->eventParm, 8 },
+{ "legsAnim",(int)&((entityState_t*)0)->legsAnim, 8 },
+{ "groundEntityNum",(int)&((entityState_t*)0)->groundEntityNum, GENTITYNUM_BITS },
+{ "pos.trType",(int)&((entityState_t*)0)->pos.trType, 8 },
+{ "eFlags",(int)&((entityState_t*)0)->eFlags, 19 },
+{ "otherEntityNum",(int)&((entityState_t*)0)->otherEntityNum, GENTITYNUM_BITS },
+{ "weapon",(int)&((entityState_t*)0)->weapon, 8 },
+{ "clientNum",(int)&((entityState_t*)0)->clientNum, 8 },
+{ "angles[1]",(int)&((entityState_t*)0)->angles[1], 0 },
+{ "pos.trDuration",(int)&((entityState_t*)0)->pos.trDuration, 32 },
+{ "apos.trType",(int)&((entityState_t*)0)->apos.trType, 8 },
+{ "origin[0]",(int)&((entityState_t*)0)->origin[0], 0 },
+{ "origin[1]",(int)&((entityState_t*)0)->origin[1], 0 },
+{ "origin[2]",(int)&((entityState_t*)0)->origin[2], 0 },
+{ "solid",(int)&((entityState_t*)0)->solid, 24 },
+{ "powerups",(int)&((entityState_t*)0)->powerups, 16 },
+{ "modelindex",(int)&((entityState_t*)0)->modelindex, 8 },
+{ "otherEntityNum2",(int)&((entityState_t*)0)->otherEntityNum2, GENTITYNUM_BITS },
+{ "loopSound",(int)&((entityState_t*)0)->loopSound, 8 },
+{ "generic1",(int)&((entityState_t*)0)->generic1, 8 },
+{ "origin2[2]",(int)&((entityState_t*)0)->origin2[2], 0 },
+{ "origin2[0]",(int)&((entityState_t*)0)->origin2[0], 0 },
+{ "origin2[1]",(int)&((entityState_t*)0)->origin2[1], 0 },
+{ "modelindex2",(int)&((entityState_t*)0)->modelindex2, 8 },
+{ "angles[0]",(int)&((entityState_t*)0)->angles[0], 0 },
+{ "time",(int)&((entityState_t*)0)->time, 32 },
+{ "apos.trTime",(int)&((entityState_t*)0)->apos.trTime, 32 },
+{ "apos.trDuration",(int)&((entityState_t*)0)->apos.trDuration, 32 },
+{ "apos.trBase[2]",(int)&((entityState_t*)0)->apos.trBase[2], 0 },
+{ "apos.trDelta[0]",(int)&((entityState_t*)0)->apos.trDelta[0], 0 },
+{ "apos.trDelta[1]",(int)&((entityState_t*)0)->apos.trDelta[1], 0 },
+{ "apos.trDelta[2]",(int)&((entityState_t*)0)->apos.trDelta[2], 0 },
+{ "time2",(int)&((entityState_t*)0)->time2, 32 },
+{ "angles[2]",(int)&((entityState_t*)0)->angles[2], 0 },
+{ "angles2[0]",(int)&((entityState_t*)0)->angles2[0], 0 },
+{ "angles2[2]",(int)&((entityState_t*)0)->angles2[2], 0 },
+{ "constantLight",(int)&((entityState_t*)0)->constantLight, 32 },
+{ "frame",(int)&((entityState_t*)0)->frame, 16 }
 };
 
 
@@ -1100,54 +1100,54 @@
 
 netField_t	playerStateFields[] = 
 {
-{ PSF(commandTime), 32 },				
-{ PSF(origin[0]), 0 },
-{ PSF(origin[1]), 0 },
-{ PSF(bobCycle), 8 },
-{ PSF(velocity[0]), 0 },
-{ PSF(velocity[1]), 0 },
-{ PSF(viewangles[1]), 0 },
-{ PSF(viewangles[0]), 0 },
-{ PSF(weaponTime), -16 },
-{ PSF(origin[2]), 0 },
-{ PSF(velocity[2]), 0 },
-{ PSF(legsTimer), 8 },
-{ PSF(pm_time), -16 },
-{ PSF(eventSequence), 16 },
-{ PSF(torsoAnim), 8 },
-{ PSF(movementDir), 4 },
-{ PSF(events[0]), 8 },
-{ PSF(legsAnim), 8 },
-{ PSF(events[1]), 8 },
-{ PSF(pm_flags), 16 },
-{ PSF(groundEntityNum), GENTITYNUM_BITS },
-{ PSF(weaponstate), 4 },
-{ PSF(eFlags), 16 },
-{ PSF(externalEvent), 10 },
-{ PSF(gravity), 16 },
-{ PSF(speed), 16 },
-{ PSF(delta_angles[1]), 16 },
-{ PSF(externalEventParm), 8 },
-{ PSF(viewheight), -8 },
-{ PSF(damageEvent), 8 },
-{ PSF(damageYaw), 8 },
-{ PSF(damagePitch), 8 },
-{ PSF(damageCount), 8 },
-{ PSF(generic1), 8 },
-{ PSF(pm_type), 8 },					
-{ PSF(delta_angles[0]), 16 },
-{ PSF(delta_angles[2]), 16 },
-{ PSF(torsoTimer), 12 },
-{ PSF(eventParms[0]), 8 },
-{ PSF(eventParms[1]), 8 },
-{ PSF(clientNum), 8 },
-{ PSF(weapon), 5 },
-{ PSF(viewangles[2]), 0 },
-{ PSF(grapplePoint[0]), 0 },
-{ PSF(grapplePoint[1]), 0 },
-{ PSF(grapplePoint[2]), 0 },
-{ PSF(jumppad_ent), 10 },
-{ PSF(loopSound), 16 }
+{ "commandTime",(int)&((playerState_t*)0)->commandTime, 32 },				
+{ "origin[0]",(int)&((playerState_t*)0)->origin[0], 0 },
+{ "origin[1]",(int)&((playerState_t*)0)->origin[1], 0 },
+{ "bobCycle",(int)&((playerState_t*)0)->bobCycle, 8 },
+{ "velocity[0]",(int)&((playerState_t*)0)->velocity[0], 0 },
+{ "velocity[1]",(int)&((playerState_t*)0)->velocity[1], 0 },
+{ "viewangles[1]",(int)&((playerState_t*)0)->viewangles[1], 0 },
+{ "viewangles[0]",(int)&((playerState_t*)0)->viewangles[0], 0 },
+{ "weaponTime",(int)&((playerState_t*)0)->weaponTime, -16 },
+{ "origin[2]",(int)&((playerState_t*)0)->origin[2], 0 },
+{ "velocity[2]",(int)&((playerState_t*)0)->velocity[2], 0 },
+{ "legsTimer",(int)&((playerState_t*)0)->legsTimer, 8 },
+{ "pm_time",(int)&((playerState_t*)0)->pm_time, -16 },
+{ "eventSequence",(int)&((playerState_t*)0)->eventSequence, 16 },
+{ "torsoAnim",(int)&((playerState_t*)0)->torsoAnim, 8 },
+{ "movementDir",(int)&((playerState_t*)0)->movementDir, 4 },
+{ "events[0]",(int)&((playerState_t*)0)->events[0], 8 },
+{ "legsAnim",(int)&((playerState_t*)0)->legsAnim, 8 },
+{ "events[1]",(int)&((playerState_t*)0)->events[1], 8 },
+{ "pm_flags",(int)&((playerState_t*)0)->pm_flags, 16 },
+{ "groundEntityNum",(int)&((playerState_t*)0)->groundEntityNum, GENTITYNUM_BITS },
+{ "weaponstate",(int)&((playerState_t*)0)->weaponstate, 4 },
+{ "eFlags",(int)&((playerState_t*)0)->eFlags, 16 },
+{ "externalEvent",(int)&((playerState_t*)0)->externalEvent, 10 },
+{ "gravity",(int)&((playerState_t*)0)->gravity, 16 },
+{ "speed",(int)&((playerState_t*)0)->speed, 16 },
+{ "delta_angles[1]",(int)&((playerState_t*)0)->delta_angles[1], 16 },
+{ "externalEventParm",(int)&((playerState_t*)0)->externalEventParm, 8 },
+{ "viewheight",(int)&((playerState_t*)0)->viewheight, -8 },
+{ "damageEvent",(int)&((playerState_t*)0)->damageEvent, 8 },
+{ "damageYaw",(int)&((playerState_t*)0)->damageYaw, 8 },
+{ "damagePitch",(int)&((playerState_t*)0)->damagePitch, 8 },
+{ "damageCount",(int)&((playerState_t*)0)->damageCount, 8 },
+{ "generic1",(int)&((playerState_t*)0)->generic1, 8 },
+{ "pm_type",(int)&((playerState_t*)0)->pm_type, 8 },					
+{ "delta_angles[0]",(int)&((playerState_t*)0)->delta_angles[0], 16 },
+{ "delta_angles[2]",(int)&((playerState_t*)0)->delta_angles[2], 16 },
+{ "torsoTimer",(int)&((playerState_t*)0)->torsoTimer, 12 },
+{ "eventParms[0]",(int)&((playerState_t*)0)->eventParms[0], 8 },
+{ "eventParms[1]",(int)&((playerState_t*)0)->eventParms[1], 8 },
+{ "clientNum",(int)&((playerState_t*)0)->clientNum, 8 },
+{ "weapon",(int)&((playerState_t*)0)->weapon, 5 },
+{ "viewangles[2]",(int)&((playerState_t*)0)->viewangles[2], 0 },
+{ "grapplePoint[0]",(int)&((playerState_t*)0)->grapplePoint[0], 0 },
+{ "grapplePoint[1]",(int)&((playerState_t*)0)->grapplePoint[1], 0 },
+{ "grapplePoint[2]",(int)&((playerState_t*)0)->grapplePoint[2], 0 },
+{ "jumppad_ent",(int)&((playerState_t*)0)->jumppad_ent, 10 },
+{ "loopSound",(int)&((playerState_t*)0)->loopSound, 16 }
 };
 
 /*
@@ -1706,7 +1706,7 @@
 13504,			// 255
 };
 
-void MSG_initHuffman() {
+void MSG_initHuffman(void) {
 	int i,j;
 
 	msgInit = qtrue;
--- a/code/qcommon/net_chan.c
+++ b/code/qcommon/net_chan.c
@@ -93,92 +93,6 @@
 	chan->outgoingSequence = 1;
 }
 
-// TTimo: unused, commenting out to make gcc happy
-#if 0
-/*
-==============
-Netchan_ScramblePacket
-
-A probably futile attempt to make proxy hacking somewhat
-more difficult.
-==============
-*/
-#define	SCRAMBLE_START	6
-static void Netchan_ScramblePacket( msg_t *buf ) {
-	unsigned	seed;
-	int			i, j, c, mask, temp;
-	int			seq[MAX_PACKETLEN];
-
-	seed = ( LittleLong( *(unsigned *)buf->data ) * 3 ) ^ ( buf->cursize * 123 );
-	c = buf->cursize;
-	if ( c <= SCRAMBLE_START ) {
-		return;
-	}
-	if ( c > MAX_PACKETLEN ) {
-		Com_Error( ERR_DROP, "MAX_PACKETLEN" );
-	}
-
-	// generate a sequence of "random" numbers
-	for (i = 0 ; i < c ; i++) {
-		seed = (119 * seed + 1);
-		seq[i] = seed;
-	}
-
-	// transpose each character
-	for ( mask = 1 ; mask < c-SCRAMBLE_START ; mask = ( mask << 1 ) + 1 ) {
-	}
-	mask >>= 1;
-	for (i = SCRAMBLE_START ; i < c ; i++) {
-		j = SCRAMBLE_START + ( seq[i] & mask );
-		temp = buf->data[j];
-		buf->data[j] = buf->data[i];
-		buf->data[i] = temp;
-	}
-
-	// byte xor the data after the header
-	for (i = SCRAMBLE_START ; i < c ; i++) {
-		buf->data[i] ^= seq[i];
-	}
-}
-
-static void Netchan_UnScramblePacket( msg_t *buf ) {
-	unsigned	seed;
-	int			i, j, c, mask, temp;
-	int			seq[MAX_PACKETLEN];
-
-	seed = ( LittleLong( *(unsigned *)buf->data ) * 3 ) ^ ( buf->cursize * 123 );
-	c = buf->cursize;
-	if ( c <= SCRAMBLE_START ) {
-		return;
-	}
-	if ( c > MAX_PACKETLEN ) {
-		Com_Error( ERR_DROP, "MAX_PACKETLEN" );
-	}
-
-	// generate a sequence of "random" numbers
-	for (i = 0 ; i < c ; i++) {
-		seed = (119 * seed + 1);
-		seq[i] = seed;
-	}
-
-	// byte xor the data after the header
-	for (i = SCRAMBLE_START ; i < c ; i++) {
-		buf->data[i] ^= seq[i];
-	}
-
-	// transpose each character in reverse order
-	for ( mask = 1 ; mask < c-SCRAMBLE_START ; mask = ( mask << 1 ) + 1 ) {
-	}
-	mask >>= 1;
-	for (i = c-1 ; i >= SCRAMBLE_START ; i--) {
-		j = SCRAMBLE_START + ( seq[i] & mask );
-		temp = buf->data[j];
-		buf->data[j] = buf->data[i];
-		buf->data[i] = temp;
-	}
-}
-#endif
-
 /*
 =================
 Netchan_TransmitNextFragment
--- a/code/qcommon/qcommon.h
+++ b/code/qcommon/qcommon.h
@@ -516,7 +516,7 @@
 
 #define BASEGAME "baseq3"
 
-qboolean FS_Initialized();
+qboolean FS_Initialized(void);
 
 void	FS_InitFilesystem (void);
 void	FS_Shutdown( qboolean closemfp );
@@ -534,7 +534,7 @@
 
 qboolean FS_FileExists( const char *file );
 
-int		FS_LoadStack();
+int		FS_LoadStack(void);
 
 int		FS_GetFileList(  const char *path, const char *extension, char *listbuf, int bufsize );
 int		FS_GetModList(  char *listbuf, int bufsize );
@@ -772,8 +772,10 @@
 
 */
 
-#if defined(_DEBUG) && !defined(BSPC)
+#ifdef _DEBUG
+#ifndef BSPC
 	#define ZONE_DEBUG
+#endif
 #endif
 
 #ifdef ZONE_DEBUG
--- a/code/qcommon/qfiles.h
+++ b/code/qcommon/qfiles.h
@@ -33,7 +33,7 @@
 
 
 // the maximum size of game relative pathnames
-#define	MAX_QPATH		64
+//#define	MAX_QPATH		64
 
 /*
 ========================================================================
--- a/code/qcommon/unzip.c
+++ b/code/qcommon/unzip.c
@@ -976,11 +976,7 @@
 #endif
 /* default windowBits for decompression. MAX_WBITS is for compression only */
 
-#if MAX_MEM_LEVEL >= 8
 #  define DEF_MEM_LEVEL 8
-#else
-#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
-#endif
 /* default memLevel */
 
 #define STORED_BLOCK 0
@@ -1049,12 +1045,6 @@
 #define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
 
 
-#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \
-                      !defined(CASESENSITIVITYDEFAULT_NO)
-#define CASESENSITIVITYDEFAULT_NO
-#endif
-
-
 #ifndef UNZ_BUFSIZE
 #define UNZ_BUFSIZE (65536)
 #endif
@@ -2280,16 +2270,7 @@
     inflate_blocks_statef *,
     z_streamp));
 
-#if 0
-static void inflate_set_dictionary OF((
-    inflate_blocks_statef *s,
-    const Byte *d,  /* dictionary */
-    uInt  n));       /* dictionary length */
 
-static int inflate_blocks_sync_point OF((
-    inflate_blocks_statef *s));
-#endif
-
 /* simplify the use of the inflate_huft type with some defines */
 #define exop word.what.Exop
 #define bits word.what.Bits
@@ -2551,8 +2532,7 @@
 {
   inflate_blocks_statef *s;
 
-  if ((s = (inflate_blocks_statef *)ZALLOC
-       (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
+  if ((s = (inflate_blocks_statef *)ZALLOC(z,1,sizeof(struct inflate_blocks_state))) == Z_NULL)
     return s;
   if ((s->hufts =
        (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL)
@@ -2830,24 +2810,6 @@
   return Z_OK;
 }
 
-#if 0
-void inflate_set_dictionary(inflate_blocks_statef *s, const Byte *d, uInt n)
-{
-  zmemcpy(s->window, d, n);
-  s->read = s->write = s->window + n;
-}
-
-/* Returns true if inflate is currently at the end of a block generated
- * by Z_SYNC_FLUSH or Z_FULL_FLUSH. 
- * IN assertion: s != Z_NULL
- */
-int inflate_blocks_sync_point(inflate_blocks_statef *s)
-{
-  return s->mode == LENS;
-}
-#endif
-
-
 /* And'ing with mask[n] masks the lower n bits */
 static uInt inflate_mask[17] = {
     0x0000,
@@ -2934,11 +2896,7 @@
   copyright string in the executable of your product.
  */
 
-/* simplify the use of the inflate_huft type with some defines */
-#define exop word.what.Exop
-#define bits word.what.Bits
 
-
 static int huft_build OF((
     uInt *,				/* code lengths in bits */
     uInt,               /* number of codes */
@@ -3461,10 +3419,6 @@
   return Z_OK;
 }
 
-/* simplify the use of the inflate_huft type with some defines */
-#define exop word.what.Exop
-#define bits word.what.Bits
-
 /* macros for bit input with no checking and for returning unused bytes */
 #define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
 #define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}
@@ -3618,10 +3572,6 @@
  * For conditions of distribution and use, see copyright notice in zlib.h 
  */
 
-/* simplify the use of the inflate_huft type with some defines */
-#define exop word.what.Exop
-#define bits word.what.Bits
-
 typedef enum {        /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
       START,    /* x: set up for LEN */
       LEN,      /* i: get length/literal/eob next */
@@ -3932,16 +3882,6 @@
     inflate_blocks_statef *,
     z_streamp));
 
-#if 0
-static void inflate_set_dictionary OF((
-    inflate_blocks_statef *s,
-    const Byte *d,  /* dictionary */
-    uInt  n));       /* dictionary length */
-
-static int inflate_blocks_sync_point OF((
-    inflate_blocks_statef *s));
-#endif
-
 typedef enum {
       imMETHOD,   /* waiting for method byte */
       imFLAG,     /* waiting for flag byte */
@@ -4063,13 +4003,6 @@
   return Z_OK;
 }
 
-#if 0
-int inflateInit_(z_streamp z, const char *version, int stream_size)
-{
-  return inflateInit2_(z, DEF_WBITS, version, stream_size);
-}
-#endif
-
 #define iNEEDBYTE {if(z->avail_in==0)return r;r=f;}
 #define iNEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++)
 
@@ -4197,92 +4130,6 @@
   return Z_STREAM_ERROR;  /* Some dumb compilers complain without this */
 #endif
 }
-
-// defined but not used
-#if 0
-int inflateSetDictionary(z_streamp z, const Byte *dictionary, uInt dictLength)
-{
-  uInt length = dictLength;
-
-  if (z == Z_NULL || z->state == Z_NULL || z->state->mode != imDICT0)
-    return Z_STREAM_ERROR;
-
-  if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR;
-  z->adler = 1L;
-
-  if (length >= ((uInt)1<<z->state->wbits))
-  {
-    length = (1<<z->state->wbits)-1;
-    dictionary += dictLength - length;
-  }
-  inflate_set_dictionary(z->state->blocks, dictionary, length);
-  z->state->mode = imBLOCKS;
-  return Z_OK;
-}
-
-int inflateSync(z_streamp z)
-{
-  uInt n;       /* number of bytes to look at */
-  Byte *p;     /* pointer to bytes */
-  uInt m;       /* number of marker bytes found in a row */
-  uLong r, w;   /* temporaries to save total_in and total_out */
-
-  /* set up */
-  if (z == Z_NULL || z->state == Z_NULL)
-    return Z_STREAM_ERROR;
-  if (z->state->mode != imBAD)
-  {
-    z->state->mode = imBAD;
-    z->state->sub.marker = 0;
-  }
-  if ((n = z->avail_in) == 0)
-    return Z_BUF_ERROR;
-  p = z->next_in;
-  m = z->state->sub.marker;
-
-  /* search */
-  while (n && m < 4)
-  {
-    static const Byte mark[4] = {0, 0, 0xff, 0xff};
-    if (*p == mark[m])
-      m++;
-    else if (*p)
-      m = 0;
-    else
-      m = 4 - m;
-    p++, n--;
-  }
-
-  /* restore */
-  z->total_in += p - z->next_in;
-  z->next_in = p;
-  z->avail_in = n;
-  z->state->sub.marker = m;
-
-  /* return no joy or set up to restart on a new block */
-  if (m != 4)
-    return Z_DATA_ERROR;
-  r = z->total_in;  w = z->total_out;
-  inflateReset(z);
-  z->total_in = r;  z->total_out = w;
-  z->state->mode = imBLOCKS;
-  return Z_OK;
-}
-
-/* Returns true if inflate is currently at the end of a block generated
- * by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
- * implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
- * but removes the length bytes of the resulting empty stored block. When
- * decompressing, PPP checks that at the end of input packet, inflate is
- * waiting for these length bytes.
- */
-int inflateSyncPoint(z_streamp z)
-{
-  if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL)
-    return Z_STREAM_ERROR;
-  return inflate_blocks_sync_point(z->state->blocks);
-}
-#endif
 
 voidp zcalloc (voidp opaque, unsigned items, unsigned size)
 {
--- a/code/qcommon/unzip.h
+++ b/code/qcommon/unzip.h
@@ -20,14 +20,7 @@
 ===========================================================================
 */
 
-#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
-/* like the STRICT of WIN32, we define a pointer that cannot be converted
-    from (void*) without cast */
-typedef struct TagunzFile__ { int unused; } unzFile__; 
-typedef unzFile__ *unzFile;
-#else
 typedef void* unzFile;
-#endif
 
 /* tm_unz contain date/time info */
 typedef struct tm_unz_s 
--- a/code/qcommon/vm.c
+++ b/code/qcommon/vm.c
@@ -325,7 +325,7 @@
 ============
 */
 int QDECL VM_DllSyscall( int arg, ... ) {
-#if ((defined __linux__) && (defined __powerpc__))
+/*
   // rcg010206 - see commentary above
   int args[16];
   int i;
@@ -339,9 +339,8 @@
   va_end(ap);
   
   return currentVM->systemCall( args );
-#else // original id code
+*/
 	return currentVM->systemCall( &arg );
-#endif
 }
 
 /*
@@ -575,17 +574,6 @@
 		Sys_UnloadDll( vm->dllHandle );
 		Com_Memset( vm, 0, sizeof( *vm ) );
 	}
-#if 0	// now automatically freed by hunk
-	if ( vm->codeBase ) {
-		Z_Free( vm->codeBase );
-	}
-	if ( vm->dataBase ) {
-		Z_Free( vm->dataBase );
-	}
-	if ( vm->instructionPointers ) {
-		Z_Free( vm->instructionPointers );
-	}
-#endif
 	Com_Memset( vm, 0, sizeof( *vm ) );
 
 	currentVM = NULL;
--- a/code/qcommon/vm_interpreted.c
+++ b/code/qcommon/vm_interpreted.c
@@ -111,17 +111,8 @@
 };
 #endif
 
-#if idppc
-    #if defined(__GNUC__)
-        static inline unsigned int loadWord(void *addr) {
-            unsigned int word;
-            
-            asm("lwbrx %0,0,%1" : "=r" (word) : "r" (addr));
-            return word;
-        }
-    #else
+#ifdef idppc
 	#define loadWord(addr) __lwbrx(addr,0)
-    #endif
 #else
 	#define	loadWord(addr) *((int *)addr)
 #endif
--- a/code/server/sv_bot.c
+++ b/code/server/sv_bot.c
@@ -594,28 +594,6 @@
 	return qtrue;
 }
 
-#if 0
-/*
-==================
-EntityInPVS
-==================
-*/
-int EntityInPVS( int client, int entityNum ) {
-	client_t			*cl;
-	clientSnapshot_t	*frame;
-	int					i;
-
-	cl = &svs.clients[client];
-	frame = &cl->frames[cl->netchan.outgoingSequence & PACKET_MASK];
-	for ( i = 0; i < frame->num_entities; i++ )	{
-		if ( svs.snapshotEntities[(frame->first_entity + i) % svs.numSnapshotEntities].number == entityNum ) {
-			return qtrue;
-		}
-	}
-	return qfalse;
-}
-#endif
-
 /*
 ==================
 SV_BotGetSnapshotEntity
--- a/code/server/sv_ccmds.c
+++ b/code/server/sv_ccmds.c
@@ -744,19 +744,5 @@
 ==================
 */
 void SV_RemoveOperatorCommands( void ) {
-#if 0
-	// removing these won't let the server start again
-	Cmd_RemoveCommand ("heartbeat");
-	Cmd_RemoveCommand ("kick");
-	Cmd_RemoveCommand ("banUser");
-	Cmd_RemoveCommand ("banClient");
-	Cmd_RemoveCommand ("status");
-	Cmd_RemoveCommand ("serverinfo");
-	Cmd_RemoveCommand ("systeminfo");
-	Cmd_RemoveCommand ("dumpuser");
-	Cmd_RemoveCommand ("map_restart");
-	Cmd_RemoveCommand ("sectorlist");
-	Cmd_RemoveCommand ("say");
-#endif
 }
 
--- a/code/server/sv_game.c
+++ b/code/server/sv_game.c
@@ -306,11 +306,7 @@
 ====================
 */
 //rcg010207 - see my comments in VM_DllSyscall(), in qcommon/vm.c ...
-#if ((defined __linux__) && (defined __powerpc__))
-#define VMA(x) ((void *) args[x])
-#else
 #define	VMA(x) VM_ArgPtr(args[x])
-#endif
 
 #define	VMF(x)	((float *)args)[x]
 
--- a/code/server/sv_main.c
+++ b/code/server/sv_main.c
@@ -506,7 +506,7 @@
 	MSG_BeginReadingOOB( msg );
 	MSG_ReadLong( msg );		// skip the -1 marker
 
-	if (!Q_strncmp("connect", &msg->data[4], 7)) {
+	if (!Q_strncmp("connect", (char*)&msg->data[4], 7)) {
 		Huff_Decompress(msg, 12);
 	}
 
--- a/code/unix/linux_common.c
+++ b/code/unix/linux_common.c
@@ -30,11 +30,8 @@
  *	AH - Created on 08 Dec 2000
  */
 
-#include <unistd.h>   // AH - for size_t
-#include <string.h>
+#include "../game/q_shared.h"
 
-// bk001207 - we need something under Linux, too. Mac?
-#if 1 // defined(C_ONLY) // bk010102 - dedicated?
 void Com_Memcpy (void* dest, const void* src, const size_t count) {
   memcpy(dest, src, count);
 }
@@ -42,303 +39,3 @@
 void Com_Memset (void* dest, const int val, const size_t count) {
   memset(dest, val, count);
 }
-
-#else
-
-typedef enum {
-  PRE_READ,         // prefetch assuming that buffer is used for reading only
-  PRE_WRITE,        // prefetch assuming that buffer is used for writing only
-  PRE_READ_WRITE    // prefetch assuming that buffer is used for both reading and writing
-} e_prefetch;
-
-void Com_Prefetch (const void *s, const unsigned int bytes, e_prefetch type);
-
-void _copyDWord (unsigned int* dest, const unsigned int constant, const unsigned int count) {
-	// MMX version not used on standard Pentium MMX
-	// because the dword version is faster (with
-	// proper destination prefetching)
-		__asm__ __volatile__ (" \
-			//mov			eax,constant		// eax = val \
-			//mov			edx,dest			// dest \
-			//mov			ecx,count \
-			movd		%%eax, %%mm0 \
-			punpckldq	%%mm0, %%mm0 \
-\
-			// ensure that destination is qword aligned \
-\
-			testl		$7, %%edx				// qword padding?\
-			jz		0f	\
-			movl		%%eax, (%%edx) \
-			decl		%%ecx \
-			addl		$4, %%edx \
-\
-0:			movl		%%ecx, %%ebx				\
-			andl		$0xfffffff0, %%ecx	\
-			jz		2f \
-			jmp		1f \
-			.align 		16 \
-\
-			// funny ordering here to avoid commands \
-			// that cross 32-byte boundaries (the \
-			// [edx+0] version has a special 3-byte opcode... \
-1:			movq		%%mm0, 8(%%edx) \
-			movq		%%mm0, 16(%%edx) \
-			movq		%%mm0, 24(%%edx) \
-			movq		%%mm0, 32(%%edx) \
-			movq		%%mm0, 40(%%edx) \
-			movq		%%mm0, 48(%%edx) \
-			movq		%%mm0, 56(%%edx) \
-			movq		%%mm0, (%%edx)\
-			addl		$64, %%edx \
-			subl		$16, %%ecx \
-			jnz		1b \
-2:	\
-			movl		%%ebx, %%ecx				// ebx = cnt \
-			andl		$0xfffffff0, %%ecx				// ecx = cnt&~15 \
-			subl		%%ecx, %%ebx \
-			jz		6f \
-			cmpl		$8, %%ebx \
-			jl		3f \
-\
-			movq		%%mm0, (%%edx) \
-			movq		%%mm0, 8(%%edx) \
-			movq		%%mm0, 16(%%edx) \
-			movq		%%mm0, 24(%%edx) \
-			addl		$32, %%edx \
-			subl		$8, %%ebx \
-			jz		6f \
-\
-3:			cmpl		$4, %%ebx \
-			jl		4f \
-			\
-			movq		%%mm0, (%%edx) \
-			movq		%%mm0, 8(%%edx) \
-			addl		$16, %%edx \
-			subl		$4, %%ebx \
-\
-4:			cmpl		$2, %%ebx \
-			jl		5f \
-			movq		%%mm0, (%%edx) \
-			addl		$8, %%edx \
-			subl		$2, %%ebx \
-\
-5:			cmpl		$1, %%ebx \
-			jl		6f \
-			movl		%%eax, (%%edx) \
-6: \
-			emms \
-	"
-	: : "a" (constant), "c" (count), "d" (dest)
-	: "%ebx", "%edi", "%esi", "cc", "memory");
-}
-
-// optimized memory copy routine that handles all alignment
-// cases and block sizes efficiently
-void Com_Memcpy (void* dest, const void* src, const size_t count) {
-	Com_Prefetch (src, count, PRE_READ);
-	__asm__ __volatile__ (" \
-		pushl		%%edi \
-		pushl		%%esi \
-		//mov		ecx,count \
-		cmpl		$0, %%ecx						// count = 0 check (just to be on the safe side) \
-		je		6f \
-		//mov		edx,dest \
-		movl		%0, %%ebx \
-		cmpl		$32, %%ecx						// padding only? \
-		jl		1f \
-\
-		movl		%%ecx, %%edi					\
-		andl		$0xfffffe00, %%edi					// edi = count&~31 \
-		subl		$32, %%edi \
-\
-		.align 16 \
-0: \
-		movl		(%%ebx, %%edi, 1), %%eax \
-		movl		4(%%ebx, %%edi, 1), %%esi \
-		movl		%%eax, (%%edx, %%edi, 1) \
-		movl		%%esi, 4(%%edx, %%edi, 1) \
-		movl		8(%%ebx, %%edi, 1), %%eax \
-		movl		12(%%ebx, %%edi, 1), %%esi \
-		movl		%%eax, 8(%%edx, %%edi, 1) \
-		movl		%%esi, 12(%%edx, %%edi, 1) \
-		movl		16(%%ebx, %%edi, 1), %%eax \
-		movl		20(%%ebx, %%edi, 1), %%esi \
-		movl		%%eax, 16(%%edx, %%edi, 1) \
-		movl		%%esi, 20(%%edx, %%edi, 1) \
-		movl		24(%%ebx, %%edi, 1), %%eax \
-		movl		28(%%ebx, %%edi, 1), %%esi \
-		movl		%%eax, 24(%%edx, %%edi, 1) \
-		movl		%%esi, 28(%%edx, %%edi, 1) \
-		subl		$32, %%edi \
-		jge		0b \
-		\
-		movl		%%ecx, %%edi \
-		andl		$0xfffffe00, %%edi \
-		addl		%%edi, %%ebx					// increase src pointer \
-		addl		%%edi, %%edx					// increase dst pointer \
-		andl		$31, %%ecx					// new count \
-		jz		6f					// if count = 0, get outta here \
-\
-1: \
-		cmpl		$16, %%ecx \
-		jl		2f \
-		movl		(%%ebx), %%eax \
-		movl		%%eax, (%%edx) \
-		movl		4(%%ebx), %%eax \
-		movl		%%eax, 4(%%edx) \
-		movl		8(%%ebx), %%eax \
-		movl		%%eax, 8(%%edx) \
-		movl		12(%%ebx), %%eax \
-		movl		%%eax, 12(%%edx) \
-		subl		$16, %%ecx \
-		addl		$16, %%ebx \
-		addl		$16, %%edx \
-2: \
-		cmpl		$8, %%ecx \
-		jl		3f \
-		movl		(%%ebx), %%eax \
-		movl		%%eax, (%%edx) \
-		movl		4(%%ebx), %%eax \
-		subl		$8, %%ecx \
-		movl		%%eax, 4(%%edx) \
-		addl		$8, %%ebx \
-		addl		$8, %%edx \
-3: \
-		cmpl		$4, %%ecx \
-		jl		4f \
-		movl		(%%ebx), %%eax	// here 4-7 bytes \
-		addl		$4, %%ebx \
-		subl		$4, %%ecx \
-		movl		%%eax, (%%edx) \
-		addl		$4, %%edx \
-4:							// 0-3 remaining bytes \
-		cmpl		$2, %%ecx \
-		jl		5f \
-		movw		(%%ebx), %%ax	// two bytes \
-		cmpl		$3, %%ecx				// less than 3? \
-		movw		%%ax, (%%edx) \
-		jl		6f \
-		movb		2(%%ebx), %%al	// last byte \
-		movb		%%al, 2(%%edx) \
-		jmp		6f \
-5: \
-		cmpl		$1, %%ecx \
-		jl		6f \
-		movb		(%%ebx), %%al \
-		movb		%%al, (%%edx) \
-6: \
-		popl		%%esi \
-		popl		%%edi \
-	"
-	: : "m" (src), "d" (dest), "c" (count)
-	: "%eax", "%ebx", "%edi", "%esi", "cc", "memory");
-}
-
-void Com_Memset (void* dest, const int val, const size_t count)
-{
-	unsigned int fillval;
-
-	if (count < 8)
-	{
-		__asm__ __volatile__ (" \
-			//mov		edx,dest \
-			//mov		eax, val \
-			movb		%%al, %%ah \
-			movl		%%eax, %%ebx \
-			andl		$0xffff, %%ebx \
-			shll		$16, %%eax \
-			addl		%%ebx, %%eax	// eax now contains pattern \
-			//mov		ecx,count \
-			cmpl		$4, %%ecx \
-			jl		0f \
-			movl		%%eax, (%%edx)	// copy first dword \
-			addl		$4, %%edx \
-			subl		$4, %%ecx \
-	0:		cmpl		$2, %%ecx \
-			jl		1f \
-			movw		%%ax, (%%edx)	// copy 2 bytes \
-			addl		$2, %%edx \
-			subl		$2, %%ecx \
-	1:		cmpl		$0, %%ecx \
-			je		2f \
-			movb		%%al, (%%edx)	// copy single byte \
-	2:		 \
-		"
-		: : "d" (dest), "a" (val), "c" (count)
-		: "%ebx", "%edi", "%esi", "cc", "memory");
-		
-		return;
-	}
-
-	fillval = val;
-	
-	fillval = fillval|(fillval<<8);
-	fillval = fillval|(fillval<<16);		// fill dword with 8-bit pattern
-
-	_copyDWord ((unsigned int*)(dest),fillval, count/4);
-	
-	__asm__ __volatile__ ("     		// padding of 0-3 bytes \
-		//mov		ecx,count \
-		movl		%%ecx, %%eax \
-		andl		$3, %%ecx \
-		jz		1f \
-		andl		$0xffffff00, %%eax \
-		//mov		ebx,dest \
-		addl		%%eax, %%edx \
-		movl		%0, %%eax \
-		cmpl		$2, %%ecx \
-		jl		0f \
-		movw		%%ax, (%%edx) \
-		cmpl		$2, %%ecx \
-		je		1f					\
-		movb		%%al, 2(%%edx)		\
-		jmp		1f \
-0:		\
-		cmpl		$0, %%ecx\
-		je		1f\
-		movb		%%al, (%%edx)\
-1:	\
-	"
-	: : "m" (fillval), "c" (count), "d" (dest)
-	: "%eax", "%ebx", "%edi", "%esi", "cc", "memory");	
-}
-
-void Com_Prefetch (const void *s, const unsigned int bytes, e_prefetch type)
-{
-	// write buffer prefetching is performed only if
-	// the processor benefits from it. Read and read/write
-	// prefetching is always performed.
-
-	switch (type)
-	{
-		case PRE_WRITE : break;
-		case PRE_READ:
-		case PRE_READ_WRITE:
-
-		__asm__ __volatile__ ("\
-			//mov		ebx,s\
-			//mov		ecx,bytes\
-			cmpl		$4096, %%ecx				// clamp to 4kB\
-			jle		0f\
-			movl		$4096, %%ecx\
-	0:\
-			addl		$0x1f, %%ecx\
-			shrl		$5, %%ecx					// number of cache lines\
-			jz		2f\
-			jmp		1f\
-\
-			.align 16\
-	1:		testb		%%al, (%%edx)\
-			addl		$32, %%edx\
-			decl		%%ecx\
-			jnz		1b\
-	2:\
-		"
-		: : "d" (s), "c" (bytes)
-		: "%eax", "%ebx", "%edi", "%esi", "memory", "cc");
-		
-		break;
-	}
-}
-
-#endif
--- /dev/null
+++ b/code/unix/qk3ded.c
@@ -1,0 +1,47 @@
+#include "../game/q_shared.h"
+#include "../qcommon/qcommon.h"
+#include "../renderer/tr_public.h"
+#include "../client/client.h"
+
+#include <thread.h>
+
+void *
+emalloc(ulong n)
+{
+	void *p;
+
+	if((p = mallocz(n, 1)) == nil)
+		sysfatal("emalloc %r");
+	setmalloctag(p, getcallerpc(&n));
+	return p;
+}
+
+static void
+Sys_ConsoleInputInit(void)
+{
+	/* FIXME: on exit: Sys_Exit(0) */
+}
+
+void
+threadmain(int argc, char **argv)
+{
+	int i, len;
+	char *args;
+
+	Sys_SetDefaultCDPath(argv[0]);
+	/* FIXME: no. */
+	for(len=1, i=1; i<argc; i++)
+		len += strlen(argv[i]) + 1;
+	args = emalloc(len);
+	for(i=1; i<argc; i++){
+		if(i > 1)
+			strcat(args, " ");
+		strcat(args, argv[i]);
+	}
+	Com_Init(args);
+	NET_Init();
+	Sys_ConsoleInputInit();
+	setfcr(getfcr() & ~(FPINVAL|FPZDIV));
+	for(;;)
+		Com_Frame();
+}
--- a/code/unix/unix_main.c
+++ b/code/unix/unix_main.c
@@ -19,36 +19,7 @@
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 ===========================================================================
 */
-#include <unistd.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/wait.h>
-#include <sys/mman.h>
-#include <errno.h>
-#ifdef __linux__ // rb010123
-  #include <mntent.h>
-#endif
-#include <dlfcn.h>
 
-#ifdef __linux__
-  #include <fpu_control.h> // bk001213 - force dumps on divide by zero
-#endif
-
-// FIXME TTimo should we gard this? most *nix system should comply?
-#include <termios.h>
-
 #include "../game/q_shared.h"
 #include "../qcommon/qcommon.h"
 #include "../renderer/tr_public.h"
@@ -60,7 +31,6 @@
 
 unsigned  sys_frame_time;
 
-uid_t saved_euid;
 qboolean stdin_active = qtrue;
 
 // =============================================================
@@ -494,7 +464,7 @@
               characters  EOF,  EOL,  EOL2, ERASE, KILL, REPRINT,
               STATUS, and WERASE, and buffers by lines.
      ISIG: when any of the characters  INTR,  QUIT,  SUSP,  or
-              DSUSP are received, generate the corresponding sig�
+              DSUSP are received, generate the corresponding sig�
               nal
     */              
     tc.c_lflag &= ~(ECHO | ICANON);
@@ -1226,10 +1196,6 @@
   int   len, i;
   char  *cmdline;
   void Sys_SetDefaultCDPath(const char *path);
-
-  // go back to real user for config loads
-  saved_euid = geteuid();
-  seteuid(getuid());
 
   Sys_ParseArgs( argc, argv );  // bk010104 - added this for support
 
--- a/code/unix/unix_net.c
+++ b/code/unix/unix_net.c
@@ -24,31 +24,8 @@
 #include "../game/q_shared.h"
 #include "../qcommon/qcommon.h"
 
-#include <unistd.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <arpa/inet.h> // bk001204
-
-#include <sys/param.h>
-#include <sys/ioctl.h>
-#include <sys/uio.h>
-#include <errno.h>
-
-#ifdef MACOS_X
-#import <sys/sockio.h>
-#import <net/if.h>
-#import <net/if_types.h>
-
-#import <arpa/inet.h>         // for inet_ntoa()
-#import <net/if_dl.h>         // for 'struct sockaddr_dl'
-#endif
-
 static cvar_t	*noudp;
 
-netadr_t	net_local_adr;
-
 int			ip_socket;
 int			ipx_socket;
 
@@ -332,100 +309,7 @@
 NET_GetLocalAddress
 =====================
 */
-#ifdef MACOS_X
-// Don't do a forward mapping from the hostname of the machine to the IP.  The reason is that we might have obtained an IP address from DHCP and there might not be any name registered for the machine.  On Mac OS X, the machine name defaults to 'localhost' and NetInfo has 127.0.0.1 listed for this name.  Instead, we want to get a list of all the IP network interfaces on the machine.
-// This code adapted from OmniNetworking.
-
-#define IFR_NEXT(ifr)	\
-    ((struct ifreq *) ((char *) (ifr) + sizeof(*(ifr)) + \
-      MAX(0, (int) (ifr)->ifr_addr.sa_len - (int) sizeof((ifr)->ifr_addr))))
-
 void NET_GetLocalAddress( void ) {
-        struct ifreq requestBuffer[MAX_IPS], *linkInterface, *inetInterface;
-        struct ifconf ifc;
-        struct ifreq ifr;
-        struct sockaddr_dl *sdl;
-        int interfaceSocket;
-        int family;
-        
-        //Com_Printf("NET_GetLocalAddress: Querying for network interfaces\n");
-        
-        // Set this early so we can just return if there is an error
-	numIP = 0;
-        
-        ifc.ifc_len = sizeof(requestBuffer);
-        ifc.ifc_buf = (caddr_t)requestBuffer;
-
-        // Since we get at this info via an ioctl, we need a temporary little socket.  This will only get AF_INET interfaces, but we probably don't care about anything else.  If we do end up caring later, we should add a ONAddressFamily and at a -interfaces method to it.
-        family = AF_INET;
-        if ((interfaceSocket = socket(family, SOCK_DGRAM, 0)) < 0) {
-            Com_Printf("NET_GetLocalAddress: Unable to create temporary socket, errno = %d\n", errno);
-            return;
-        }
-
-        if (ioctl(interfaceSocket, SIOCGIFCONF, &ifc) != 0) {
-            Com_Printf("NET_GetLocalAddress: Unable to get list of network interfaces, errno = %d\n", errno);
-            return;
-        }
-
-
-        linkInterface = (struct ifreq *) ifc.ifc_buf;
-        while ((char *) linkInterface < &ifc.ifc_buf[ifc.ifc_len]) {
-            unsigned int nameLength;
-
-            // The ioctl returns both the entries having the address (AF_INET) and the link layer entries (AF_LINK).  The AF_LINK entry has the link layer address which contains the interface type.  This is the only way I can see to get this information.  We cannot assume that we will get bot an AF_LINK and AF_INET entry since the interface may not be configured.  For example, if you have a 10Mb port on the motherboard and a 100Mb card, you may not configure the motherboard port.
-
-            // For each AF_LINK entry...
-            if (linkInterface->ifr_addr.sa_family == AF_LINK) {
-                // if there is a matching AF_INET entry
-                inetInterface = (struct ifreq *) ifc.ifc_buf;
-                while ((char *) inetInterface < &ifc.ifc_buf[ifc.ifc_len]) {
-                    if (inetInterface->ifr_addr.sa_family == AF_INET &&
-                        !strncmp(inetInterface->ifr_name, linkInterface->ifr_name, sizeof(linkInterface->ifr_name))) {
-
-                        for (nameLength = 0; nameLength < IFNAMSIZ; nameLength++)
-                            if (!linkInterface->ifr_name[nameLength])
-                                break;
-
-                        sdl = (struct sockaddr_dl *)&linkInterface->ifr_addr;
-                        // Skip loopback interfaces
-                        if (sdl->sdl_type != IFT_LOOP) {
-                            // Get the local interface address
-                            strncpy(ifr.ifr_name, inetInterface->ifr_name, sizeof(ifr.ifr_name));
-                            if (ioctl(interfaceSocket, OSIOCGIFADDR, (caddr_t)&ifr) < 0) {
-                                Com_Printf("NET_GetLocalAddress: Unable to get local address for interface '%s', errno = %d\n", inetInterface->ifr_name, errno);
-                            } else {
-                                struct sockaddr_in *sin;
-                                int ip;
-            
-                                sin = (struct sockaddr_in *)&ifr.ifr_addr;
-            
-                                ip = ntohl(sin->sin_addr.s_addr);
-                                localIP[ numIP ][0] = (ip >> 24) & 0xff;
-                                localIP[ numIP ][1] = (ip >> 16) & 0xff;
-                                localIP[ numIP ][2] = (ip >>  8) & 0xff;
-                                localIP[ numIP ][3] = (ip >>  0) & 0xff;
-                                Com_Printf( "IP: %i.%i.%i.%i (%s)\n", localIP[ numIP ][0], localIP[ numIP ][1], localIP[ numIP ][2], localIP[ numIP ][3], inetInterface->ifr_name);
-                                numIP++;
-                            }
-                        }
-
-                        // We will assume that there is only one AF_INET entry per AF_LINK entry.
-                        // What happens when we have an interface that has multiple IP addresses, or
-                        // can that even happen?
-                        // break;
-                    }
-                    inetInterface = IFR_NEXT(inetInterface);
-                }
-            }
-            linkInterface = IFR_NEXT(linkInterface);
-        }
-
-        close(interfaceSocket);
-}
-
-#else
-void NET_GetLocalAddress( void ) {
 	char				hostname[256];
 	struct hostent		*hostInfo;
 	// int					error; // bk001204 - unused
@@ -462,7 +346,6 @@
 		Com_Printf( "IP: %i.%i.%i.%i\n", ( ip >> 24 ) & 0xff, ( ip >> 16 ) & 0xff, ( ip >> 8 ) & 0xff, ip & 0xff );
 	}
 }
-#endif
 
 /*
 ====================